aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPeter Grehan <grehan@FreeBSD.org>2012-04-26 07:52:28 +0000
committerPeter Grehan <grehan@FreeBSD.org>2012-04-26 07:52:28 +0000
commit38f1b189cd839bd8aa122ae06cc084810ca1e395 (patch)
tree66e8b09d104ddfb3e858eb44c5eb480e59c57a35 /lib
parent2a5bbbe3805c1e83265149c9d84307e051966a74 (diff)
parent8df7248cf34b3e46f257f55c3a901d612a101d67 (diff)
downloadsrc-38f1b189cd839bd8aa122ae06cc084810ca1e395.tar.gz
src-38f1b189cd839bd8aa122ae06cc084810ca1e395.zip
IFC @ r234692
sys/amd64/include/cpufunc.h sys/amd64/include/fpu.h sys/amd64/amd64/fpu.c sys/amd64/vmm/vmm.c - Add API to allow vmm FPU state init/save/restore. FP stuff discussed with: kib
Notes
Notes: svn path=/projects/bhyve/; revision=234695
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile10
-rw-r--r--lib/bind/config.h5
-rw-r--r--lib/bind/dns/code.h2
-rw-r--r--lib/bind/dns/dns/enumclass.h2
-rw-r--r--lib/bind/dns/dns/enumtype.h2
-rw-r--r--lib/bind/dns/dns/rdatastruct.h124
-rw-r--r--lib/bind/lwres/lwres/netdb.h2
-rw-r--r--lib/bind/lwres/lwres/platform.h2
-rw-r--r--lib/clang/Makefile21
-rw-r--r--lib/clang/clang.build.mk19
-rw-r--r--lib/clang/include/Makefile5
-rw-r--r--lib/clang/include/MipsGenMCCodeEmitter.inc2
-rw-r--r--lib/clang/include/clang/Basic/DiagnosticSerializationKinds.inc2
-rw-r--r--lib/clang/include/clang/Basic/Version.inc8
-rw-r--r--lib/clang/include/clang/Config/config.h20
-rw-r--r--lib/clang/include/clang/Sema/AttrParsedAttrKinds.inc2
-rw-r--r--lib/clang/include/clang/Sema/AttrParsedAttrList.inc2
-rw-r--r--lib/clang/include/clang/Sema/AttrTemplateInstantiate.inc2
-rw-r--r--lib/clang/include/llvm/Config/config.h63
-rw-r--r--lib/clang/include/llvm/Config/llvm-config.h18
-rw-r--r--lib/clang/libclanganalysis/Makefile5
-rw-r--r--lib/clang/libclangarcmigrate/Makefile4
-rw-r--r--lib/clang/libclangast/Makefile2
-rw-r--r--lib/clang/libclangbasic/Makefile2
-rw-r--r--lib/clang/libclangcodegen/Makefile1
-rw-r--r--lib/clang/libclangdriver/Makefile4
-rw-r--r--lib/clang/libclangedit/Makefile16
-rw-r--r--lib/clang/libclangfrontend/Makefile8
-rw-r--r--lib/clang/libclangindex/Makefile1
-rw-r--r--lib/clang/libclanglex/Makefile2
-rw-r--r--lib/clang/libclangparse/Makefile1
-rw-r--r--lib/clang/libclangrewrite/Makefile2
-rw-r--r--lib/clang/libclangsema/Makefile9
-rw-r--r--lib/clang/libclangserialization/Makefile3
-rw-r--r--lib/clang/libclangstaticanalyzercheckers/Makefile12
-rw-r--r--lib/clang/libclangstaticanalyzercore/Makefile5
-rw-r--r--lib/clang/libllvmanalysis/Makefile19
-rw-r--r--lib/clang/libllvmarchive/Makefile10
-rw-r--r--lib/clang/libllvmarmcodegen/Makefile2
-rw-r--r--lib/clang/libllvmarmdesc/Makefile1
-rw-r--r--lib/clang/libllvmasmprinter/Makefile1
-rw-r--r--lib/clang/libllvmcodegen/Makefile20
-rw-r--r--lib/clang/libllvmcore/Makefile1
-rw-r--r--lib/clang/libllvmdebuginfo/Makefile17
-rw-r--r--lib/clang/libllvmexecutionengine/Makefile10
-rw-r--r--lib/clang/libllvminstrumentation/Makefile7
-rw-r--r--lib/clang/libllvminterpreter/Makefile12
-rw-r--r--lib/clang/libllvmipa/Makefile6
-rw-r--r--lib/clang/libllvmipo/Makefile6
-rw-r--r--lib/clang/libllvmjit/Makefile11
-rw-r--r--lib/clang/libllvmlinker/Makefile11
-rw-r--r--lib/clang/libllvmmc/Makefile7
-rw-r--r--lib/clang/libllvmmcdisassembler/Makefile12
-rw-r--r--lib/clang/libllvmmcjit/Makefile14
-rw-r--r--lib/clang/libllvmmipsasmparser/Makefile13
-rw-r--r--lib/clang/libllvmmipscodegen/Makefile5
-rw-r--r--lib/clang/libllvmmipsdesc/Makefile2
-rw-r--r--lib/clang/libllvmobject/Makefile16
-rw-r--r--lib/clang/libllvmpowerpccodegen/Makefile1
-rw-r--r--lib/clang/libllvmpowerpcdesc/Makefile3
-rw-r--r--lib/clang/libllvmruntimedyld/Makefile10
-rw-r--r--lib/clang/libllvmscalaropts/Makefile12
-rw-r--r--lib/clang/libllvmselectiondag/Makefile4
-rw-r--r--lib/clang/libllvmsupport/Makefile19
-rw-r--r--lib/clang/libllvmtablegen/Makefile1
-rw-r--r--lib/clang/libllvmtarget/Makefile3
-rw-r--r--lib/clang/libllvmtransformutils/Makefile12
-rw-r--r--lib/clang/libllvmvectorize/Makefile11
-rw-r--r--lib/clang/libllvmx86codegen/Makefile1
-rw-r--r--lib/clang/libllvmx86desc/Makefile4
-rw-r--r--lib/clang/libllvmx86disassembler/Makefile6
-rw-r--r--lib/csu/Makefile.inc2
-rw-r--r--lib/csu/amd64/Makefile12
-rw-r--r--lib/csu/amd64/crt1.c28
-rw-r--r--lib/csu/arm/Makefile12
-rw-r--r--lib/csu/arm/crt1.c25
-rw-r--r--lib/csu/common/crtbrand.c27
-rw-r--r--lib/csu/common/ignore_init.c114
-rw-r--r--lib/csu/common/notes.h38
-rw-r--r--lib/csu/i386-elf/Makefile12
-rw-r--r--lib/csu/i386-elf/crt1_c.c27
-rw-r--r--lib/csu/ia64/Makefile6
-rw-r--r--lib/csu/mips/Makefile12
-rw-r--r--lib/csu/mips/crt1.c37
-rw-r--r--lib/csu/powerpc/Makefile12
-rw-r--r--lib/csu/powerpc/crt1.c27
-rw-r--r--lib/csu/powerpc64/Makefile15
-rw-r--r--lib/csu/powerpc64/crt1.c26
-rw-r--r--lib/csu/sparc64/crt1.c27
-rw-r--r--lib/libarchive/Makefile414
-rw-r--r--lib/libarchive/config_freebsd.h332
-rw-r--r--lib/libarchive/test/Makefile67
-rw-r--r--lib/libbluetooth/bluetooth.34
-rw-r--r--lib/libc++/Makefile3
-rw-r--r--lib/libc/Makefile1
-rw-r--r--lib/libc/amd64/gen/Makefile.inc2
-rw-r--r--lib/libc/amd64/gen/getcontextx.c101
-rw-r--r--lib/libc/arm/Symbol.map1
-rw-r--r--lib/libc/arm/_fpmath.h3
-rw-r--r--lib/libc/arm/gen/Makefile.inc4
-rw-r--r--lib/libc/arm/gen/__aeabi_read_tp.S40
-rw-r--r--lib/libc/arm/gen/_set_tp.c6
-rw-r--r--lib/libc/arm/gen/flt_rounds.c65
-rw-r--r--lib/libc/arm/gen/getcontextx.c69
-rw-r--r--lib/libc/arm/softfloat/softfloat.h28
-rw-r--r--lib/libc/compat-43/killpg.25
-rw-r--r--lib/libc/db/man/hash.32
-rw-r--r--lib/libc/gen/Makefile.inc6
-rw-r--r--lib/libc/gen/Symbol.map4
-rw-r--r--lib/libc/gen/arc4random.36
-rw-r--r--lib/libc/gen/aux.c31
-rw-r--r--lib/libc/gen/closedir.c4
-rw-r--r--lib/libc/gen/directory.39
-rw-r--r--lib/libc/gen/dl_iterate_phdr.3115
-rw-r--r--lib/libc/gen/dlfcn.c60
-rw-r--r--lib/libc/gen/dlopen.336
-rw-r--r--lib/libc/gen/fmtmsg.c14
-rw-r--r--lib/libc/gen/fstab.c2
-rw-r--r--lib/libc/gen/fts.319
-rw-r--r--lib/libc/gen/fts.c55
-rw-r--r--lib/libc/gen/getcontext.331
-rw-r--r--lib/libc/gen/getgrouplist.34
-rw-r--r--lib/libc/gen/getpagesizes.32
-rw-r--r--lib/libc/gen/getutxent.33
-rw-r--r--lib/libc/gen/getutxent.c24
-rw-r--r--lib/libc/gen/opendir.c38
-rw-r--r--lib/libc/gen/psignal.32
-rw-r--r--lib/libc/gen/sem.c28
-rw-r--r--lib/libc/gen/sem_new.c64
-rw-r--r--lib/libc/gen/sysconf.32
-rw-r--r--lib/libc/gen/sysctl.316
-rw-r--r--lib/libc/gen/tls.c36
-rw-r--r--lib/libc/gen/ucontext.34
-rw-r--r--lib/libc/gen/utxdb.c4
-rw-r--r--lib/libc/i386/gen/Makefile.inc2
-rw-r--r--lib/libc/i386/gen/getcontextx.c133
-rw-r--r--lib/libc/i386/string/strchr.S2
-rw-r--r--lib/libc/i386/string/strrchr.S2
-rw-r--r--lib/libc/i386/sys/i386_get_ioperm.22
-rw-r--r--lib/libc/i386/sys/i386_set_watch.32
-rw-r--r--lib/libc/i386/sys/i386_vm86.22
-rw-r--r--lib/libc/ia64/gen/Makefile.inc2
-rw-r--r--lib/libc/ia64/gen/getcontextx.c69
-rw-r--r--lib/libc/iconv/iconv.32
-rw-r--r--lib/libc/iconv/iconvctl.34
-rw-r--r--lib/libc/iconv/iconvlist.32
-rw-r--r--lib/libc/include/libc_private.h23
-rw-r--r--lib/libc/locale/Makefile.inc1
-rw-r--r--lib/libc/locale/Symbol.map5
-rw-r--r--lib/libc/locale/btowc.313
-rw-r--r--lib/libc/locale/collate.c5
-rw-r--r--lib/libc/locale/ctype.32
-rw-r--r--lib/libc/locale/ctype_l.3138
-rw-r--r--lib/libc/locale/digittoint.311
-rw-r--r--lib/libc/locale/duplocale.319
-rw-r--r--lib/libc/locale/isalnum.339
-rw-r--r--lib/libc/locale/isalpha.335
-rw-r--r--lib/libc/locale/isblank.313
-rw-r--r--lib/libc/locale/iscntrl.328
-rw-r--r--lib/libc/locale/isdigit.317
-rw-r--r--lib/libc/locale/isgraph.339
-rw-r--r--lib/libc/locale/islower.313
-rw-r--r--lib/libc/locale/isprint.339
-rw-r--r--lib/libc/locale/ispunct.315
-rw-r--r--lib/libc/locale/isspace.33
-rw-r--r--lib/libc/locale/isupper.313
-rw-r--r--lib/libc/locale/isxdigit.311
-rw-r--r--lib/libc/locale/newlocale.36
-rw-r--r--lib/libc/locale/nomacros.c6
-rw-r--r--lib/libc/locale/setrunelocale.c31
-rw-r--r--lib/libc/locale/table.c2
-rw-r--r--lib/libc/locale/xlocale.331
-rw-r--r--lib/libc/locale/xlocale.c64
-rw-r--r--lib/libc/locale/xlocale_private.h46
-rw-r--r--lib/libc/mips/gen/Makefile.inc3
-rw-r--r--lib/libc/mips/gen/_set_tp.c4
-rw-r--r--lib/libc/mips/gen/getcontextx.c69
-rw-r--r--lib/libc/mips/softfloat/softfloat.h28
-rw-r--r--lib/libc/mips/string/strchr.S2
-rw-r--r--lib/libc/mips/string/strrchr.S2
-rw-r--r--lib/libc/net/eui64.37
-rw-r--r--lib/libc/net/getaddrinfo.c5
-rw-r--r--lib/libc/net/getifaddrs.c169
-rw-r--r--lib/libc/net/getipnodebyname.312
-rw-r--r--lib/libc/net/getnameinfo.32
-rw-r--r--lib/libc/net/if_nametoindex.c3
-rw-r--r--lib/libc/net/inet_net.31
-rw-r--r--lib/libc/net/name6.c2
-rw-r--r--lib/libc/net/nsdispatch.311
-rw-r--r--lib/libc/net/sctp_bindx.34
-rw-r--r--lib/libc/net/sctp_connectx.38
-rw-r--r--lib/libc/net/sctp_freepaddrs.34
-rw-r--r--lib/libc/net/sctp_getaddrlen.32
-rw-r--r--lib/libc/net/sctp_getassocid.33
-rw-r--r--lib/libc/net/sctp_getpaddrs.32
-rw-r--r--lib/libc/net/sctp_opt_info.34
-rw-r--r--lib/libc/net/sctp_recvmsg.334
-rw-r--r--lib/libc/net/sctp_send.338
-rw-r--r--lib/libc/net/sctp_sendmsg.334
-rw-r--r--lib/libc/net/sourcefilter.32
-rw-r--r--lib/libc/posix1e/acl_add_flag_np.310
-rw-r--r--lib/libc/posix1e/acl_add_perm.332
-rw-r--r--lib/libc/posix1e/acl_create_entry.32
-rw-r--r--lib/libc/posix1e/acl_set_entry_type_np.34
-rw-r--r--lib/libc/posix1e/acl_set_tag_type.316
-rw-r--r--lib/libc/posix1e/acl_to_text.37
-rw-r--r--lib/libc/powerpc/SYS.h37
-rw-r--r--lib/libc/powerpc/gen/Makefile.inc2
-rw-r--r--lib/libc/powerpc/gen/_setjmp.S1
-rw-r--r--lib/libc/powerpc/gen/getcontextx.c69
-rw-r--r--lib/libc/powerpc/gen/setjmp.S4
-rw-r--r--lib/libc/powerpc/gen/sigsetjmp.S1
-rw-r--r--lib/libc/powerpc64/SYS.h37
-rw-r--r--lib/libc/powerpc64/gen/Makefile.inc2
-rw-r--r--lib/libc/powerpc64/gen/_setjmp.S1
-rw-r--r--lib/libc/powerpc64/gen/getcontextx.c69
-rw-r--r--lib/libc/powerpc64/gen/makecontext.c2
-rw-r--r--lib/libc/powerpc64/gen/setjmp.S6
-rw-r--r--lib/libc/powerpc64/gen/sigsetjmp.S1
-rw-r--r--lib/libc/powerpc64/sys/cerror.S2
-rw-r--r--lib/libc/regex/regcomp.c5
-rw-r--r--lib/libc/rpc/Makefile.inc2
-rw-r--r--lib/libc/rpc/rpc.312
-rw-r--r--lib/libc/rpc/rpc_clnt_create.38
-rw-r--r--lib/libc/rpc/rpc_soc.317
-rw-r--r--lib/libc/softfloat/Makefile.inc12
-rw-r--r--lib/libc/softfloat/Symbol.map14
-rw-r--r--lib/libc/softfloat/bits32/softfloat-macros4
-rw-r--r--lib/libc/softfloat/bits32/softfloat.c4
-rw-r--r--lib/libc/softfloat/bits64/softfloat-macros6
-rw-r--r--lib/libc/softfloat/bits64/softfloat.c107
-rw-r--r--lib/libc/softfloat/eqtf2.c24
-rw-r--r--lib/libc/softfloat/getf2.c26
-rw-r--r--lib/libc/softfloat/gexf2.c25
-rw-r--r--lib/libc/softfloat/gttf2.c26
-rw-r--r--lib/libc/softfloat/gtxf2.c25
-rw-r--r--lib/libc/softfloat/letf2.c26
-rw-r--r--lib/libc/softfloat/lttf2.c26
-rw-r--r--lib/libc/softfloat/negtf2.c27
-rw-r--r--lib/libc/softfloat/negxf2.c25
-rw-r--r--lib/libc/softfloat/netf2.c26
-rw-r--r--lib/libc/softfloat/nexf2.c25
-rw-r--r--lib/libc/softfloat/softfloat-for-gcc.h148
-rw-r--r--lib/libc/softfloat/softfloat-source.txt4
-rw-r--r--lib/libc/softfloat/softfloat-specialize37
-rw-r--r--lib/libc/softfloat/softfloat.txt4
-rw-r--r--lib/libc/sparc64/fpu/fpu_emu.h3
-rw-r--r--lib/libc/sparc64/fpu/fpu_mul.c4
-rw-r--r--lib/libc/sparc64/gen/Makefile.inc2
-rw-r--r--lib/libc/sparc64/gen/getcontextx.c69
-rw-r--r--lib/libc/stdio/fclose.c14
-rw-r--r--lib/libc/stdio/findfp.c16
-rw-r--r--lib/libc/stdio/fputws.c4
-rw-r--r--lib/libc/stdio/getline.32
-rw-r--r--lib/libc/stdio/mktemp.315
-rw-r--r--lib/libc/stdio/printf.346
-rw-r--r--lib/libc/stdio/snprintf.c15
-rw-r--r--lib/libc/stdio/vfprintf.c3
-rw-r--r--lib/libc/stdio/vfscanf.c815
-rw-r--r--lib/libc/stdio/vfwprintf.c3
-rw-r--r--lib/libc/stdio/vfwscanf.c697
-rw-r--r--lib/libc/stdio/vsnprintf.c8
-rw-r--r--lib/libc/stdio/vswprintf.c9
-rw-r--r--lib/libc/stdlib/Makefile.inc17
-rw-r--r--lib/libc/stdlib/Symbol.map17
-rw-r--r--lib/libc/stdlib/at_quick_exit.312
-rw-r--r--lib/libc/stdlib/getenv.32
-rw-r--r--lib/libc/stdlib/jemalloc/Makefile.inc46
-rw-r--r--lib/libc/stdlib/jemalloc/Symbol.map35
-rw-r--r--lib/libc/stdlib/malloc.3591
-rw-r--r--lib/libc/stdlib/posix_memalign.396
-rw-r--r--lib/libc/stdlib/ql.h122
-rw-r--r--lib/libc/stdlib/qr.h106
-rw-r--r--lib/libc/stdlib/rb.h1002
-rw-r--r--lib/libc/stdlib/reallocf.382
-rw-r--r--lib/libc/string/memchr.32
-rw-r--r--lib/libc/string/strchr.c2
-rw-r--r--lib/libc/string/strerror.31
-rw-r--r--lib/libc/string/strerror.c2
-rw-r--r--lib/libc/string/strrchr.c2
-rw-r--r--lib/libc/string/swab.35
-rw-r--r--lib/libc/string/swab.c2
-rw-r--r--lib/libc/sys/Makefile.inc2
-rw-r--r--lib/libc/sys/cap_enter.24
-rw-r--r--lib/libc/sys/cap_new.210
-rw-r--r--lib/libc/sys/chflags.223
-rw-r--r--lib/libc/sys/chroot.220
-rw-r--r--lib/libc/sys/close.26
-rw-r--r--lib/libc/sys/cpuset.28
-rw-r--r--lib/libc/sys/cpuset_getaffinity.23
-rw-r--r--lib/libc/sys/dup.217
-rw-r--r--lib/libc/sys/fcntl.236
-rw-r--r--lib/libc/sys/getdirentries.28
-rw-r--r--lib/libc/sys/getsockopt.215
-rw-r--r--lib/libc/sys/jail.210
-rw-r--r--lib/libc/sys/kill.28
-rw-r--r--lib/libc/sys/kldstat.24
-rw-r--r--lib/libc/sys/kqueue.213
-rw-r--r--lib/libc/sys/kse.22
-rw-r--r--lib/libc/sys/ktrace.234
-rw-r--r--lib/libc/sys/mmap.27
-rw-r--r--lib/libc/sys/msync.27
-rw-r--r--lib/libc/sys/nfssvc.24
-rw-r--r--lib/libc/sys/pathconf.23
-rw-r--r--lib/libc/sys/pdfork.27
-rw-r--r--lib/libc/sys/posix_fadvise.25
-rw-r--r--lib/libc/sys/posix_fallocate.25
-rw-r--r--lib/libc/sys/ptrace.29
-rw-r--r--lib/libc/sys/quotactl.24
-rw-r--r--lib/libc/sys/read.24
-rw-r--r--lib/libc/sys/sctp_generic_sendmsg.24
-rw-r--r--lib/libc/sys/sctp_peeloff.23
-rw-r--r--lib/libc/sys/select.22
-rw-r--r--lib/libc/sys/sendfile.22
-rw-r--r--lib/libc/sys/setfib.227
-rw-r--r--lib/libc/sys/setuid.22
-rw-r--r--lib/libc/sys/shm_open.21
-rw-r--r--lib/libc/sys/sigqueue.23
-rw-r--r--lib/libc/sys/write.24
-rw-r--r--lib/libc/uuid/uuid.313
-rw-r--r--lib/libc/yp/Makefile.inc2
-rw-r--r--lib/libcam/cam.320
-rw-r--r--lib/libcam/cam_cdbparse.318
-rw-r--r--lib/libcam/camlib.c102
-rw-r--r--lib/libcom_err/Makefile3
-rw-r--r--lib/libcrypt/crypt.36
-rw-r--r--lib/libcxxrt/Makefile1
-rw-r--r--lib/libcxxrt/Version.map323
-rw-r--r--lib/libdevstat/devstat.318
-rw-r--r--lib/libdevstat/devstat.c40
-rw-r--r--lib/libdisk/libdisk.h2
-rw-r--r--lib/libedit/edit/readline/Makefile3
-rw-r--r--lib/libedit/edit/readline/tilde.h32
-rw-r--r--lib/libelf/elf.32
-rw-r--r--lib/libelf/elf_getdata.32
-rw-r--r--lib/libelf/elf_getphdrnum.33
-rw-r--r--lib/libelf/elf_getphnum.31
-rw-r--r--lib/libelf/elf_getshdrnum.33
-rw-r--r--lib/libelf/elf_getshdrstrndx.33
-rw-r--r--lib/libelf/elf_getshnum.31
-rw-r--r--lib/libelf/elf_getshstrndx.31
-rw-r--r--lib/libelf/libelf_data.c4
-rw-r--r--lib/libfetch/common.c57
-rw-r--r--lib/libfetch/common.h7
-rw-r--r--lib/libfetch/fetch.32
-rw-r--r--lib/libfetch/fetch.c51
-rw-r--r--lib/libfetch/http.c17
-rw-r--r--lib/libgpib/gpib.31
-rw-r--r--lib/libgssapi/Symbol.map1
-rw-r--r--lib/libgssapi/gss_accept_sec_context.32
-rw-r--r--lib/libgssapi/gss_display_status.c16
-rw-r--r--lib/libgssapi/gss_pseudo_random.c4
-rw-r--r--lib/libgssapi/gss_release_buffer.32
-rw-r--r--lib/libgssapi/gss_release_oid.c2
-rw-r--r--lib/libgssapi/gss_release_oid_set.32
-rw-r--r--lib/libgssapi/mech.54
-rw-r--r--lib/libgssapi/mech_switch.h1
-rw-r--r--lib/libipsec/pfkey.c14
-rw-r--r--lib/libjail/jail.c53
-rw-r--r--lib/libkse/Makefile2
-rw-r--r--lib/libkvm/kvm_proc.c59
-rw-r--r--lib/libmagic/Makefile2
-rw-r--r--lib/libmagic/config.h78
-rw-r--r--lib/libmemstat/libmemstat.34
-rw-r--r--lib/libopie/config.h2
-rw-r--r--lib/libpam/modules/pam_exec/pam_exec.884
-rw-r--r--lib/libpam/modules/pam_exec/pam_exec.c362
-rw-r--r--lib/libpam/modules/pam_krb5/pam_krb5.c169
-rw-r--r--lib/libpam/modules/pam_ksu/pam_ksu.c38
-rw-r--r--lib/libpam/modules/pam_nologin/pam_nologin.82
-rw-r--r--lib/libpam/modules/pam_unix/Makefile4
-rw-r--r--lib/libpmc/Makefile6
-rw-r--r--lib/libpmc/libpmc.c190
-rw-r--r--lib/libpmc/pmc.326
-rw-r--r--lib/libpmc/pmc.atom.323
-rw-r--r--lib/libpmc/pmc.core.327
-rw-r--r--lib/libpmc/pmc.core2.323
-rw-r--r--lib/libpmc/pmc.corei7.340
-rw-r--r--lib/libpmc/pmc.corei7uc.323
-rw-r--r--lib/libpmc/pmc.h2
-rw-r--r--lib/libpmc/pmc.iaf.323
-rw-r--r--lib/libpmc/pmc.k7.324
-rw-r--r--lib/libpmc/pmc.k8.324
-rw-r--r--lib/libpmc/pmc.mips24k.3 (renamed from lib/libpmc/pmc.mips.3)72
-rw-r--r--lib/libpmc/pmc.octeon.3253
-rw-r--r--lib/libpmc/pmc.p4.324
-rw-r--r--lib/libpmc/pmc.p5.323
-rw-r--r--lib/libpmc/pmc.p6.323
-rw-r--r--lib/libpmc/pmc.sandybridge.3932
-rw-r--r--lib/libpmc/pmc.sandybridgeuc.3233
-rw-r--r--lib/libpmc/pmc.soft.3104
-rw-r--r--lib/libpmc/pmc.tsc.323
-rw-r--r--lib/libpmc/pmc.ucf.323
-rw-r--r--lib/libpmc/pmc.westmere.3398
-rw-r--r--lib/libpmc/pmc.westmereuc.323
-rw-r--r--lib/libpmc/pmc.xscale.339
-rw-r--r--lib/libpmc/pmc_allocate.322
-rw-r--r--lib/libpmc/pmc_attach.322
-rw-r--r--lib/libpmc/pmc_capabilities.324
-rw-r--r--lib/libpmc/pmc_configure_logfile.322
-rw-r--r--lib/libpmc/pmc_disable.322
-rw-r--r--lib/libpmc/pmc_event_names_of_class.322
-rw-r--r--lib/libpmc/pmc_get_driver_stats.322
-rw-r--r--lib/libpmc/pmc_get_msr.322
-rw-r--r--lib/libpmc/pmc_init.322
-rw-r--r--lib/libpmc/pmc_name_of_capability.322
-rw-r--r--lib/libpmc/pmc_read.322
-rw-r--r--lib/libpmc/pmc_set.322
-rw-r--r--lib/libpmc/pmc_start.322
-rw-r--r--lib/libpmc/pmclog.322
-rw-r--r--lib/libpmc/pmclog.c6
-rw-r--r--lib/libpmc/pmclog.h8
-rw-r--r--lib/libproc/proc_bkpt.c3
-rw-r--r--lib/libproc/proc_regs.c8
-rw-r--r--lib/libprocstat/Symbol.map4
-rw-r--r--lib/libprocstat/Versions.def5
-rw-r--r--lib/libprocstat/common_kvm.c2
-rw-r--r--lib/libprocstat/libprocstat.315
-rw-r--r--lib/libprocstat/libprocstat.c72
-rw-r--r--lib/libprocstat/libprocstat.h6
-rw-r--r--lib/libradius/libradius.38
-rw-r--r--lib/librpcsec_gss/rpc_gss_seccreate.32
-rw-r--r--lib/librpcsvc/Makefile2
-rw-r--r--lib/librt/sigev_thread.c10
-rw-r--r--lib/librt/sigev_thread.h2
-rw-r--r--lib/libsm/Makefile4
-rw-r--r--lib/libstdthreads/thrd_create.34
-rw-r--r--lib/libtacplus/libtacplus.33
-rw-r--r--lib/libthr/arch/arm/arm/pthread_md.c7
-rw-r--r--lib/libthr/arch/arm/include/pthread_md.h2
-rw-r--r--lib/libthr/arch/mips/include/pthread_md.h12
-rw-r--r--lib/libthr/arch/mips/mips/pthread_md.c13
-rw-r--r--lib/libthr/thread/thr_barrier.c27
-rw-r--r--lib/libthr/thread/thr_list.c20
-rw-r--r--lib/libthr/thread/thr_private.h27
-rw-r--r--lib/libthr/thread/thr_rwlock.c26
-rw-r--r--lib/libthr/thread/thr_sig.c23
-rw-r--r--lib/libthr/thread/thr_umtx.c99
-rw-r--r--lib/libthr/thread/thr_umtx.h27
-rw-r--r--lib/libthread_db/Makefile4
-rw-r--r--lib/libulog/ulog_login.c2
-rw-r--r--lib/libulog/utempter_add_record.32
-rw-r--r--lib/libusb/Makefile5
-rw-r--r--lib/libusb/libusb.324
-rw-r--r--lib/libusb/libusb.h4
-rw-r--r--lib/libusb/libusb10.c44
-rw-r--r--lib/libusb/libusb10_desc.c8
-rw-r--r--lib/libusb/libusb10_io.c20
-rw-r--r--lib/libusb/libusb20.35
-rw-r--r--lib/libusb/libusb20.c5
-rw-r--r--lib/libusb/libusb20_desc.c14
-rw-r--r--lib/libusb/libusb20_ugen20.c2
-rw-r--r--lib/libutil/Makefile75
-rw-r--r--lib/libutil/flopen.32
-rw-r--r--lib/libutil/kinfo_getallproc.32
-rw-r--r--lib/libutil/kinfo_getproc.36
-rw-r--r--lib/libutil/kld.32
-rw-r--r--lib/libutil/libutil.h222
-rw-r--r--lib/libutil/login.conf.5148
-rw-r--r--lib/libutil/login_cap.34
-rw-r--r--lib/libutil/login_class.c9
-rw-r--r--lib/libutil/pidfile.346
-rw-r--r--lib/libutil/pidfile.c23
-rw-r--r--lib/libutil/property.31
-rw-r--r--lib/libutil/pw_util.c19
-rw-r--r--lib/libutil/quotafile.34
-rw-r--r--lib/libutil/realhostname.32
-rw-r--r--lib/libvgl/bitmap.c2
-rw-r--r--lib/libvgl/keyboard.c2
-rw-r--r--lib/libvgl/main.c2
-rw-r--r--lib/libvgl/mouse.c2
-rw-r--r--lib/libvgl/simple.c6
-rw-r--r--lib/libvgl/text.c2
-rw-r--r--lib/libvgl/vgl.37
-rw-r--r--lib/libvgl/vgl.h2
-rw-r--r--lib/libypclnt/Makefile2
-rw-r--r--lib/libz/Makefile8
-rw-r--r--lib/msun/Makefile2
-rw-r--r--lib/msun/arm/Symbol.map5
-rw-r--r--lib/msun/arm/fenv.c14
-rw-r--r--lib/msun/arm/fenv.h23
-rw-r--r--lib/msun/man/csqrt.314
-rw-r--r--lib/msun/man/ieee.31
-rw-r--r--lib/msun/src/fenv-softfloat.h184
-rw-r--r--lib/msun/src/k_expf.c2
-rw-r--r--lib/msun/src/s_fabsl.c2
-rw-r--r--lib/msun/src/s_remquo.c7
-rw-r--r--lib/msun/src/s_remquof.c3
-rw-r--r--lib/msun/src/s_remquol.c3
489 files changed, 9813 insertions, 5606 deletions
diff --git a/lib/Makefile b/lib/Makefile
index cac8e44c395d..0c47d087d87b 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -33,7 +33,6 @@ SUBDIR_ORDERED= ${_csu} \
libc \
libbsm \
libauditd \
- libcom_err \
libcompiler_rt \
libcrypt \
libelf \
@@ -52,6 +51,10 @@ SUBDIR_ORDERED= ${_csu} \
${_libcxxrt} \
${_libcplusplus}
+.if ${MK_KERBEROS_SUPPORT} != "no"
+SUBDIR_ORDERED+= libcom_err
+.endif
+
SUBDIR= ${SUBDIR_ORDERED} \
libalias \
libarchive \
@@ -199,6 +202,11 @@ _libefi= libefi
_libsmb= libsmb
.endif
+.if ${MACHINE_CPUARCH} == "mips"
+_libproc= libproc
+_librtld_db= librtld_db
+.endif
+
.if ${MACHINE_CPUARCH} == "powerpc"
_libsmb= libsmb
.endif
diff --git a/lib/bind/config.h b/lib/bind/config.h
index ca364b5233bb..22d76bc60494 100644
--- a/lib/bind/config.h
+++ b/lib/bind/config.h
@@ -19,7 +19,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: acconfig.h,v 1.53 2008-12-01 23:47:44 tbox Exp $ */
+/* $Id: acconfig.h,v 1.53 2008/12/01 23:47:44 tbox Exp $ */
/*! \file */
@@ -397,6 +397,9 @@ int sigwait(const unsigned int *set, int *sig);
(O_NDELAY/O_NONBLOCK). */
#define PORT_NONBLOCK O_NONBLOCK
+/* The size of `void *', as computed by sizeof. */
+#define SIZEOF_VOID_P 8
+
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
diff --git a/lib/bind/dns/code.h b/lib/bind/dns/code.h
index bfc5330316ec..ad9e11e54f9a 100644
--- a/lib/bind/dns/code.h
+++ b/lib/bind/dns/code.h
@@ -1,7 +1,7 @@
/* $FreeBSD$ */
/*
- * Copyright (C) 2004-2011 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2012 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1998-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
diff --git a/lib/bind/dns/dns/enumclass.h b/lib/bind/dns/dns/enumclass.h
index 4c8d6c912bc3..7ee27fedd8bf 100644
--- a/lib/bind/dns/dns/enumclass.h
+++ b/lib/bind/dns/dns/enumclass.h
@@ -1,7 +1,7 @@
/* $FreeBSD$ */
/*
- * Copyright (C) 2004-2011 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2012 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1998-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
diff --git a/lib/bind/dns/dns/enumtype.h b/lib/bind/dns/dns/enumtype.h
index ef8179182450..bc64f69a3bdc 100644
--- a/lib/bind/dns/dns/enumtype.h
+++ b/lib/bind/dns/dns/enumtype.h
@@ -1,7 +1,7 @@
/* $FreeBSD$ */
/*
- * Copyright (C) 2004-2011 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2012 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1998-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
diff --git a/lib/bind/dns/dns/rdatastruct.h b/lib/bind/dns/dns/rdatastruct.h
index 880beeebd020..4b50b575e335 100644
--- a/lib/bind/dns/dns/rdatastruct.h
+++ b/lib/bind/dns/dns/rdatastruct.h
@@ -1,7 +1,7 @@
/* $FreeBSD$ */
/*
- * Copyright (C) 2004-2011 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2012 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1998-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
@@ -43,7 +43,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: rdatastructpre.h,v 1.16 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: rdatastructpre.h,v 1.16 2007/06/19 23:47:17 tbox Exp $ */
#ifndef DNS_RDATASTRUCT_H
#define DNS_RDATASTRUCT_H 1
@@ -89,7 +89,7 @@ typedef struct dns_rdatacommon {
#ifndef IN_1_A_1_H
#define IN_1_A_1_H 1
-/* $Id: a_1.h,v 1.28 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: a_1.h,v 1.28 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_in_a {
dns_rdatacommon_t common;
@@ -113,7 +113,7 @@ typedef struct dns_rdata_in_a {
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: a_1.h,v 1.5 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: a_1.h,v 1.5 2007/06/19 23:47:17 tbox Exp $ */
/* by Bjorn.Victor@it.uu.se, 2005-05-07 */
/* Based on generic/mx_15.h */
@@ -152,7 +152,7 @@ typedef struct dns_rdata_ch_a {
#ifndef HS_4_A_1_H
#define HS_4_A_1_H 1
-/* $Id: a_1.h,v 1.12 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: a_1.h,v 1.12 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_hs_a {
dns_rdatacommon_t common;
@@ -181,7 +181,7 @@ typedef struct dns_rdata_hs_a {
#ifndef GENERIC_NS_2_H
#define GENERIC_NS_2_H 1
-/* $Id: ns_2.h,v 1.27 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: ns_2.h,v 1.27 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_ns {
dns_rdatacommon_t common;
@@ -212,7 +212,7 @@ typedef struct dns_rdata_ns {
#ifndef GENERIC_MD_3_H
#define GENERIC_MD_3_H 1
-/* $Id: md_3.h,v 1.28 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: md_3.h,v 1.28 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_md {
dns_rdatacommon_t common;
@@ -243,7 +243,7 @@ typedef struct dns_rdata_md {
#ifndef GENERIC_MF_4_H
#define GENERIC_MF_4_H 1
-/* $Id: mf_4.h,v 1.26 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: mf_4.h,v 1.26 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_mf {
dns_rdatacommon_t common;
@@ -269,7 +269,7 @@ typedef struct dns_rdata_mf {
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: cname_5.h,v 1.26 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: cname_5.h,v 1.26 2007/06/19 23:47:17 tbox Exp $ */
#ifndef GENERIC_CNAME_5_H
#define GENERIC_CNAME_5_H 1
@@ -302,7 +302,7 @@ typedef struct dns_rdata_cname {
#ifndef GENERIC_SOA_6_H
#define GENERIC_SOA_6_H 1
-/* $Id: soa_6.h,v 1.32 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: soa_6.h,v 1.32 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_soa {
dns_rdatacommon_t common;
@@ -339,7 +339,7 @@ typedef struct dns_rdata_soa {
#ifndef GENERIC_MB_7_H
#define GENERIC_MB_7_H 1
-/* $Id: mb_7.h,v 1.27 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: mb_7.h,v 1.27 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_mb {
dns_rdatacommon_t common;
@@ -369,7 +369,7 @@ typedef struct dns_rdata_mb {
#ifndef GENERIC_MG_8_H
#define GENERIC_MG_8_H 1
-/* $Id: mg_8.h,v 1.26 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: mg_8.h,v 1.26 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_mg {
dns_rdatacommon_t common;
@@ -399,7 +399,7 @@ typedef struct dns_rdata_mg {
#ifndef GENERIC_MR_9_H
#define GENERIC_MR_9_H 1
-/* $Id: mr_9.h,v 1.26 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: mr_9.h,v 1.26 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_mr {
dns_rdatacommon_t common;
@@ -429,7 +429,7 @@ typedef struct dns_rdata_mr {
#ifndef GENERIC_NULL_10_H
#define GENERIC_NULL_10_H 1
-/* $Id: null_10.h,v 1.25 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: null_10.h,v 1.25 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_null {
dns_rdatacommon_t common;
@@ -460,7 +460,7 @@ typedef struct dns_rdata_null {
#ifndef IN_1_WKS_11_H
#define IN_1_WKS_11_H 1
-/* $Id: wks_11.h,v 1.22 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: wks_11.h,v 1.22 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_in_wks {
dns_rdatacommon_t common;
@@ -493,7 +493,7 @@ typedef struct dns_rdata_in_wks {
#ifndef GENERIC_PTR_12_H
#define GENERIC_PTR_12_H 1
-/* $Id: ptr_12.h,v 1.27 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: ptr_12.h,v 1.27 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_ptr {
dns_rdatacommon_t common;
@@ -522,7 +522,7 @@ typedef struct dns_rdata_ptr {
#ifndef GENERIC_HINFO_13_H
#define GENERIC_HINFO_13_H 1
-/* $Id: hinfo_13.h,v 1.25 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: hinfo_13.h,v 1.25 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_hinfo {
dns_rdatacommon_t common;
@@ -555,7 +555,7 @@ typedef struct dns_rdata_hinfo {
#ifndef GENERIC_MINFO_14_H
#define GENERIC_MINFO_14_H 1
-/* $Id: minfo_14.h,v 1.27 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: minfo_14.h,v 1.27 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_minfo {
dns_rdatacommon_t common;
@@ -586,7 +586,7 @@ typedef struct dns_rdata_minfo {
#ifndef GENERIC_MX_15_H
#define GENERIC_MX_15_H 1
-/* $Id: mx_15.h,v 1.29 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: mx_15.h,v 1.29 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_mx {
dns_rdatacommon_t common;
@@ -617,7 +617,7 @@ typedef struct dns_rdata_mx {
#ifndef GENERIC_TXT_16_H
#define GENERIC_TXT_16_H 1
-/* $Id: txt_16.h,v 1.28 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: txt_16.h,v 1.28 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_txt_string {
isc_uint8_t length;
@@ -668,7 +668,7 @@ dns_rdata_txt_current(dns_rdata_txt_t *, dns_rdata_txt_string_t *);
#ifndef GENERIC_RP_17_H
#define GENERIC_RP_17_H 1
-/* $Id: rp_17.h,v 1.21 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: rp_17.h,v 1.21 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC1183 */
@@ -702,7 +702,7 @@ typedef struct dns_rdata_rp {
#ifndef GENERIC_AFSDB_18_H
#define GENERIC_AFSDB_18_H 1
-/* $Id: afsdb_18.h,v 1.20 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: afsdb_18.h,v 1.20 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC1183 */
@@ -736,7 +736,7 @@ typedef struct dns_rdata_afsdb {
#ifndef GENERIC_X25_19_H
#define GENERIC_X25_19_H 1
-/* $Id: x25_19.h,v 1.18 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: x25_19.h,v 1.18 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC1183 */
@@ -769,7 +769,7 @@ typedef struct dns_rdata_x25 {
#ifndef GENERIC_ISDN_20_H
#define GENERIC_ISDN_20_H 1
-/* $Id: isdn_20.h,v 1.18 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: isdn_20.h,v 1.18 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC1183 */
@@ -804,7 +804,7 @@ typedef struct dns_rdata_isdn {
#ifndef GENERIC_RT_21_H
#define GENERIC_RT_21_H 1
-/* $Id: rt_21.h,v 1.21 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: rt_21.h,v 1.21 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC1183 */
@@ -837,7 +837,7 @@ typedef struct dns_rdata_rt {
#ifndef IN_1_NSAP_22_H
#define IN_1_NSAP_22_H 1
-/* $Id: nsap_22.h,v 1.18 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: nsap_22.h,v 1.18 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC1706 */
@@ -870,7 +870,7 @@ typedef struct dns_rdata_in_nsap {
#ifndef IN_1_NSAP_PTR_23_H
#define IN_1_NSAP_PTR_23_H 1
-/* $Id: nsap-ptr_23.h,v 1.19 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: nsap-ptr_23.h,v 1.19 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC1348. Obsoleted in RFC 1706 - use PTR instead. */
@@ -902,7 +902,7 @@ typedef struct dns_rdata_in_nsap_ptr {
#ifndef GENERIC_SIG_24_H
#define GENERIC_SIG_24_H 1
-/* $Id: sig_24.h,v 1.26 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: sig_24.h,v 1.26 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC2535 */
@@ -944,7 +944,7 @@ typedef struct dns_rdata_sig_t {
#ifndef GENERIC_KEY_25_H
#define GENERIC_KEY_25_H 1
-/* $Id: key_25.h,v 1.19 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: key_25.h,v 1.19 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC2535 */
@@ -981,7 +981,7 @@ typedef struct dns_rdata_key_t {
#ifndef IN_1_PX_26_H
#define IN_1_PX_26_H 1
-/* $Id: px_26.h,v 1.19 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: px_26.h,v 1.19 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC2163 */
@@ -1015,7 +1015,7 @@ typedef struct dns_rdata_in_px {
#ifndef GENERIC_GPOS_27_H
#define GENERIC_GPOS_27_H 1
-/* $Id: gpos_27.h,v 1.17 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: gpos_27.h,v 1.17 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief per RFC1712 */
@@ -1052,7 +1052,7 @@ typedef struct dns_rdata_gpos {
#ifndef IN_1_AAAA_28_H
#define IN_1_AAAA_28_H 1
-/* $Id: aaaa_28.h,v 1.21 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: aaaa_28.h,v 1.21 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC1886 */
@@ -1083,7 +1083,7 @@ typedef struct dns_rdata_in_aaaa {
#ifndef GENERIC_LOC_29_H
#define GENERIC_LOC_29_H 1
-/* $Id: loc_29.h,v 1.19 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: loc_29.h,v 1.19 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC1876 */
@@ -1126,7 +1126,7 @@ typedef struct dns_rdata_loc {
#ifndef GENERIC_NXT_30_H
#define GENERIC_NXT_30_H 1
-/* $Id: nxt_30.h,v 1.25 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: nxt_30.h,v 1.25 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief RFC2535 */
@@ -1160,7 +1160,7 @@ typedef struct dns_rdata_nxt {
#ifndef IN_1_SRV_33_H
#define IN_1_SRV_33_H 1
-/* $Id: srv_33.h,v 1.19 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: srv_33.h,v 1.19 2007/06/19 23:47:17 tbox Exp $ */
/* Reviewed: Fri Mar 17 13:01:00 PST 2000 by bwelling */
@@ -1178,7 +1178,7 @@ typedef struct dns_rdata_in_srv {
#endif /* IN_1_SRV_33_H */
/*
- * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004, 2005, 2007, 2012 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2001 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -1197,9 +1197,9 @@ typedef struct dns_rdata_in_srv {
#ifndef IN_1_NAPTR_35_H
#define IN_1_NAPTR_35_H 1
-/* $Id: naptr_35.h,v 1.23 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id$ */
-/*!
+/*!
* \brief Per RFC2915 */
typedef struct dns_rdata_in_naptr {
@@ -1237,7 +1237,7 @@ typedef struct dns_rdata_in_naptr {
#ifndef IN_1_KX_36_H
#define IN_1_KX_36_H 1
-/* $Id: kx_36.h,v 1.20 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: kx_36.h,v 1.20 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC2230 */
@@ -1267,7 +1267,7 @@ typedef struct dns_rdata_in_kx {
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: cert_37.h,v 1.20 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: cert_37.h,v 1.20 2007/06/19 23:47:17 tbox Exp $ */
#ifndef GENERIC_CERT_37_H
#define GENERIC_CERT_37_H 1
@@ -1304,7 +1304,7 @@ typedef struct dns_rdata_cert {
#ifndef IN_1_A6_38_H
#define IN_1_A6_38_H 1
-/* $Id: a6_38.h,v 1.24 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: a6_38.h,v 1.24 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC2874 */
@@ -1338,7 +1338,7 @@ typedef struct dns_rdata_in_a6 {
#ifndef GENERIC_DNAME_39_H
#define GENERIC_DNAME_39_H 1
-/* $Id: dname_39.h,v 1.21 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: dname_39.h,v 1.21 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief per RFC2672 */
@@ -1370,7 +1370,7 @@ typedef struct dns_rdata_dname {
#ifndef GENERIC_OPT_41_H
#define GENERIC_OPT_41_H 1
-/* $Id: opt_41.h,v 1.18 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: opt_41.h,v 1.18 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC2671 */
@@ -1426,7 +1426,7 @@ dns_rdata_opt_current(dns_rdata_opt_t *, dns_rdata_opt_opcode_t *);
#ifndef IN_1_APL_42_H
#define IN_1_APL_42_H 1
-/* $Id: apl_42.h,v 1.6 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: apl_42.h,v 1.6 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_apl_ent {
isc_boolean_t negative;
@@ -1478,7 +1478,7 @@ dns_rdata_apl_current(dns_rdata_in_apl_t *, dns_rdata_apl_ent_t *);
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: ds_43.h,v 1.7 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: ds_43.h,v 1.7 2007/06/19 23:47:17 tbox Exp $ */
#ifndef GENERIC_DS_43_H
#define GENERIC_DS_43_H 1
@@ -1513,7 +1513,7 @@ typedef struct dns_rdata_ds {
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: sshfp_44.h,v 1.8 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: sshfp_44.h,v 1.8 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC 4255 */
@@ -1547,7 +1547,7 @@ typedef struct dns_rdata_sshfp {
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: ipseckey_45.h,v 1.4 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: ipseckey_45.h,v 1.4 2007/06/19 23:47:17 tbox Exp $ */
#ifndef GENERIC_IPSECKEY_45_H
#define GENERIC_IPSECKEY_45_H 1
@@ -1586,7 +1586,7 @@ typedef struct dns_rdata_ipseckey {
#ifndef GENERIC_DNSSIG_46_H
#define GENERIC_DNSSIG_46_H 1
-/* $Id: rrsig_46.h,v 1.7 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: rrsig_46.h,v 1.7 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per RFC2535 */
@@ -1627,7 +1627,7 @@ typedef struct dns_rdata_rrsig {
#ifndef GENERIC_NSEC_47_H
#define GENERIC_NSEC_47_H 1
-/* $Id: nsec_47.h,v 1.10 2008-07-15 23:47:21 tbox Exp $ */
+/* $Id: nsec_47.h,v 1.10 2008/07/15 23:47:21 tbox Exp $ */
/*!
* \brief Per RFC 3845 */
@@ -1661,7 +1661,7 @@ typedef struct dns_rdata_nsec {
#ifndef GENERIC_DNSKEY_48_H
#define GENERIC_DNSKEY_48_H 1
-/* $Id: dnskey_48.h,v 1.7 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: dnskey_48.h,v 1.7 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief per RFC2535 */
@@ -1698,7 +1698,7 @@ typedef struct dns_rdata_dnskey {
#ifndef IN_1_DHCID_49_H
#define IN_1_DHCID_49_H 1
-/* $Id: dhcid_49.h,v 1.5 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: dhcid_49.h,v 1.5 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_in_dhcid {
dns_rdatacommon_t common;
@@ -1709,7 +1709,7 @@ typedef struct dns_rdata_in_dhcid {
#endif /* IN_1_DHCID_49_H */
/*
- * Copyright (C) 2008 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2008, 2012 Internet Systems Consortium, Inc. ("ISC")
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -1728,7 +1728,7 @@ typedef struct dns_rdata_in_dhcid {
#ifndef GENERIC_NSEC3_50_H
#define GENERIC_NSEC3_50_H 1
-/* $Id: nsec3_50.h,v 1.4 2008-09-25 04:02:39 tbox Exp $ */
+/* $Id$ */
/*!
* \brief Per RFC 5155 */
@@ -1821,7 +1821,7 @@ typedef struct dns_rdata_nsec3 {
#ifndef GENERIC_NSEC3PARAM_51_H
#define GENERIC_NSEC3PARAM_51_H 1
-/* $Id: nsec3param_51.h,v 1.4 2008-09-25 04:02:39 tbox Exp $ */
+/* $Id: nsec3param_51.h,v 1.4 2008/09/25 04:02:39 tbox Exp $ */
/*!
* \brief Per RFC 5155 */
@@ -1855,7 +1855,7 @@ typedef struct dns_rdata_nsec3param {
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: hip_55.h,v 1.2 2009-02-26 06:09:19 marka Exp $ */
+/* $Id: hip_55.h,v 1.2 2009/02/26 06:09:19 marka Exp $ */
#ifndef GENERIC_HIP_5_H
#define GENERIC_HIP_5_H 1
@@ -1906,7 +1906,7 @@ dns_rdata_hip_current(dns_rdata_hip_t *, dns_name_t *);
#ifndef GENERIC_SPF_99_H
#define GENERIC_SPF_99_H 1
-/* $Id: spf_99.h,v 1.4 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: spf_99.h,v 1.4 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_spf_string {
isc_uint8_t length;
@@ -1958,7 +1958,7 @@ dns_rdata_spf_current(dns_rdata_spf_t *, dns_rdata_spf_string_t *);
#ifndef GENERIC_UNSPEC_103_H
#define GENERIC_UNSPEC_103_H 1
-/* $Id: unspec_103.h,v 1.17 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: unspec_103.h,v 1.17 2007/06/19 23:47:17 tbox Exp $ */
typedef struct dns_rdata_unspec_t {
dns_rdatacommon_t common;
@@ -1988,7 +1988,7 @@ typedef struct dns_rdata_unspec_t {
#ifndef GENERIC_TKEY_249_H
#define GENERIC_TKEY_249_H 1
-/* $Id: tkey_249.h,v 1.24 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: tkey_249.h,v 1.24 2007/06/19 23:47:17 tbox Exp $ */
/*!
* \brief Per draft-ietf-dnsind-tkey-00.txt */
@@ -2026,7 +2026,7 @@ typedef struct dns_rdata_tkey {
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: tsig_250.h,v 1.25 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: tsig_250.h,v 1.25 2007/06/19 23:47:17 tbox Exp $ */
#ifndef ANY_255_TSIG_250_H
#define ANY_255_TSIG_250_H 1
@@ -2063,7 +2063,7 @@ typedef struct dns_rdata_any_tsig {
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: dlv_32769.h,v 1.5 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: dlv_32769.h,v 1.5 2007/06/19 23:47:17 tbox Exp $ */
/* draft-ietf-dnsext-delegation-signer-05.txt */
#ifndef GENERIC_DLV_32769_H
@@ -2099,7 +2099,7 @@ typedef struct dns_rdata_dlv {
#ifndef GENERIC_KEYDATA_65533_H
#define GENERIC_KEYDATA_65533_H 1
-/* $Id: keydata_65533.h,v 1.2 2009-06-30 02:52:32 each Exp $ */
+/* $Id: keydata_65533.h,v 1.2 2009/06/30 02:52:32 each Exp $ */
typedef struct dns_rdata_keydata {
dns_rdatacommon_t common;
@@ -2132,7 +2132,7 @@ typedef struct dns_rdata_keydata {
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: rdatastructsuf.h,v 1.10 2007-06-19 23:47:17 tbox Exp $ */
+/* $Id: rdatastructsuf.h,v 1.10 2007/06/19 23:47:17 tbox Exp $ */
ISC_LANG_ENDDECLS
diff --git a/lib/bind/lwres/lwres/netdb.h b/lib/bind/lwres/lwres/netdb.h
index 59ad93a7a931..55dc7a15c14a 100644
--- a/lib/bind/lwres/lwres/netdb.h
+++ b/lib/bind/lwres/lwres/netdb.h
@@ -17,7 +17,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: netdb.h.in,v 1.41 2009-01-18 23:48:14 tbox Exp $ */
+/* $Id: netdb.h.in,v 1.41 2009/01/18 23:48:14 tbox Exp $ */
/*! \file */
diff --git a/lib/bind/lwres/lwres/platform.h b/lib/bind/lwres/lwres/platform.h
index 9f207dbc1143..608bb721772b 100644
--- a/lib/bind/lwres/lwres/platform.h
+++ b/lib/bind/lwres/lwres/platform.h
@@ -17,7 +17,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: platform.h.in,v 1.21 2007-06-19 23:47:23 tbox Exp $ */
+/* $Id: platform.h.in,v 1.21 2007/06/19 23:47:23 tbox Exp $ */
/*! \file */
diff --git a/lib/clang/Makefile b/lib/clang/Makefile
index 8f7d18a31213..d6e9457895b7 100644
--- a/lib/clang/Makefile
+++ b/lib/clang/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+.include <bsd.own.mk>
+
.if !make(install)
SUBDIR= libclanganalysis \
libclangarcmigrate \
@@ -7,6 +9,7 @@ SUBDIR= libclanganalysis \
libclangbasic \
libclangcodegen \
libclangdriver \
+ libclangedit \
libclangfrontend \
libclangfrontendtool \
libclangindex \
@@ -20,6 +23,7 @@ SUBDIR= libclanganalysis \
libclangstaticanalyzerfrontend \
\
libllvmanalysis \
+ libllvmarchive \
libllvmasmparser \
libllvmasmprinter \
libllvmbitreader \
@@ -30,14 +34,17 @@ SUBDIR= libclanganalysis \
libllvminstrumentation \
libllvmipa \
libllvmipo \
+ libllvmlinker \
libllvmmc \
libllvmmcparser \
+ libllvmobject \
libllvmscalaropts \
libllvmselectiondag \
libllvmsupport \
libllvmtablegen \
libllvmtarget \
libllvmtransformutils \
+ libllvmvectorize \
\
libllvmarmasmparser \
libllvmarmcodegen \
@@ -45,6 +52,7 @@ SUBDIR= libclanganalysis \
libllvmarmdisassembler \
libllvmarminfo \
libllvmarminstprinter \
+ libllvmmipsasmparser \
libllvmmipscodegen \
libllvmmipsdesc \
libllvmmipsinfo \
@@ -60,6 +68,19 @@ SUBDIR= libclanganalysis \
libllvmx86info \
libllvmx86instprinter \
libllvmx86utils
+
+.if ${MK_CLANG_EXTRAS} != "no"
+SUBDIR+=libllvmarchive \
+ libllvmdebuginfo \
+ libllvmexecutionengine \
+ libllvminterpreter \
+ libllvmjit \
+ libllvmlinker \
+ libllvmmcdisassembler \
+ libllvmmcjit \
+ libllvmobject \
+ libllvmruntimedyld
+.endif
.endif
SUBDIR+= include
diff --git a/lib/clang/clang.build.mk b/lib/clang/clang.build.mk
index 2c059f517764..a14918dc5e6a 100644
--- a/lib/clang/clang.build.mk
+++ b/lib/clang/clang.build.mk
@@ -12,7 +12,7 @@ CFLAGS+=-I${LLVM_SRCS}/include -I${CLANG_SRCS}/include \
CFLAGS+= -fno-strict-aliasing
TARGET_ARCH?= ${MACHINE_ARCH}
-CFLAGS+=-DLLVM_HOSTTRIPLE=\"${TARGET_ARCH:C/amd64/x86_64/}-unknown-freebsd10.0\"
+CFLAGS+=-DLLVM_DEFAULT_TARGET_TRIPLE=\"${TARGET_ARCH:C/amd64/x86_64/}-unknown-freebsd10.0\"
.ifndef LLVM_REQUIRES_EH
CXXFLAGS+=-fno-exceptions
@@ -82,6 +82,16 @@ AttrList.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
-gen-clang-attr-list -o ${.TARGET} \
-I ${CLANG_SRCS}/include ${.ALLSRC}
+AttrParsedAttrKinds.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
+ -gen-clang-attr-parsed-attr-kinds -o ${.TARGET} \
+ -I ${CLANG_SRCS}/include ${.ALLSRC}
+
+AttrParsedAttrList.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
+ -gen-clang-attr-parsed-attr-list -o ${.TARGET} \
+ -I ${CLANG_SRCS}/include ${.ALLSRC}
+
AttrPCHRead.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Serialization \
${TBLINC} -gen-clang-attr-pch-read -o ${.TARGET} \
@@ -97,6 +107,11 @@ AttrSpellings.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
-gen-clang-attr-spelling-list -o ${.TARGET} \
-I ${CLANG_SRCS}/include ${.ALLSRC}
+AttrTemplateInstantiate.inc.h: ${CLANG_SRCS}/include/clang/Basic/Attr.td
+ ${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
+ -gen-clang-attr-template-instantiate -o ${.TARGET} \
+ -I ${CLANG_SRCS}/include ${.ALLSRC}
+
DeclNodes.inc.h: ${CLANG_SRCS}/include/clang/Basic/DeclNodes.td
${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/AST ${TBLINC} \
-gen-clang-decl-nodes -o ${.TARGET} ${.ALLSRC}
@@ -117,7 +132,7 @@ DiagnosticIndexName.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
-gen-clang-diags-index-name -o ${.TARGET} ${.ALLSRC}
-.for hdr in AST Analysis Common Driver Frontend Lex Parse Sema
+.for hdr in AST Analysis Common Driver Frontend Lex Parse Sema Serialization
Diagnostic${hdr}Kinds.inc.h: ${CLANG_SRCS}/include/clang/Basic/Diagnostic.td
${CLANG_TBLGEN} -I ${CLANG_SRCS}/include/clang/Basic ${TBLINC} \
-gen-clang-diags-defs -clang-component=${hdr} \
diff --git a/lib/clang/include/Makefile b/lib/clang/include/Makefile
index 6f46e2842fa5..73a6120c2cdc 100644
--- a/lib/clang/include/Makefile
+++ b/lib/clang/include/Makefile
@@ -2,10 +2,11 @@
.PATH: ${.CURDIR}/../../../contrib/llvm/tools/clang/lib/Headers
-INCSDIR=${INCLUDEDIR}/clang/3.0
+INCSDIR=${INCLUDEDIR}/clang/3.1
INCS= altivec.h \
avxintrin.h \
+ cpuid.h \
emmintrin.h \
immintrin.h \
mm3dnow.h \
@@ -14,7 +15,9 @@ INCS= altivec.h \
nmmintrin.h \
pmmintrin.h \
smmintrin.h \
+ stdalign.h \
tmmintrin.h \
+ unwind.h \
wmmintrin.h \
x86intrin.h \
xmmintrin.h
diff --git a/lib/clang/include/MipsGenMCCodeEmitter.inc b/lib/clang/include/MipsGenMCCodeEmitter.inc
new file mode 100644
index 000000000000..82cd41835e69
--- /dev/null
+++ b/lib/clang/include/MipsGenMCCodeEmitter.inc
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+#include "MipsGenMCCodeEmitter.inc.h"
diff --git a/lib/clang/include/clang/Basic/DiagnosticSerializationKinds.inc b/lib/clang/include/clang/Basic/DiagnosticSerializationKinds.inc
new file mode 100644
index 000000000000..f0d84f1ed3aa
--- /dev/null
+++ b/lib/clang/include/clang/Basic/DiagnosticSerializationKinds.inc
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+#include "DiagnosticSerializationKinds.inc.h"
diff --git a/lib/clang/include/clang/Basic/Version.inc b/lib/clang/include/clang/Basic/Version.inc
index 98425840a9c3..55d4ea6cfd9d 100644
--- a/lib/clang/include/clang/Basic/Version.inc
+++ b/lib/clang/include/clang/Basic/Version.inc
@@ -1,10 +1,10 @@
/* $FreeBSD$ */
-#define CLANG_VERSION 3.0
+#define CLANG_VERSION 3.1
#define CLANG_VERSION_MAJOR 3
-#define CLANG_VERSION_MINOR 0
+#define CLANG_VERSION_MINOR 1
#define CLANG_VENDOR "FreeBSD "
-#define CLANG_VENDOR_SUFFIX " 20111210"
+#define CLANG_VENDOR_SUFFIX " 20120413"
-#define SVN_REVISION "145349"
+#define SVN_REVISION "154661"
diff --git a/lib/clang/include/clang/Config/config.h b/lib/clang/include/clang/Config/config.h
new file mode 100644
index 000000000000..7348308e3a59
--- /dev/null
+++ b/lib/clang/include/clang/Config/config.h
@@ -0,0 +1,20 @@
+/* $FreeBSD$ */
+/* tools/clang/include/clang/Config/config.h. Generated from config.h.in by configure. */
+/* include/clang/Config/config.h.in. */
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+/* Bug report URL. */
+#define BUG_REPORT_URL "http://llvm.org/bugs/"
+
+/* Relative directory for resource files */
+#define CLANG_RESOURCE_DIR ""
+
+/* Directory where gcc is installed. */
+#define GCC_INSTALL_PREFIX ""
+
+/* Directories clang will search for headers */
+#define C_INCLUDE_DIRS ""
+
+#endif
diff --git a/lib/clang/include/clang/Sema/AttrParsedAttrKinds.inc b/lib/clang/include/clang/Sema/AttrParsedAttrKinds.inc
new file mode 100644
index 000000000000..77d009288a5d
--- /dev/null
+++ b/lib/clang/include/clang/Sema/AttrParsedAttrKinds.inc
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+#include "AttrParsedAttrKinds.inc.h"
diff --git a/lib/clang/include/clang/Sema/AttrParsedAttrList.inc b/lib/clang/include/clang/Sema/AttrParsedAttrList.inc
new file mode 100644
index 000000000000..b5aeac3af3e5
--- /dev/null
+++ b/lib/clang/include/clang/Sema/AttrParsedAttrList.inc
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+#include "AttrParsedAttrList.inc.h"
diff --git a/lib/clang/include/clang/Sema/AttrTemplateInstantiate.inc b/lib/clang/include/clang/Sema/AttrTemplateInstantiate.inc
new file mode 100644
index 000000000000..88c3c1128625
--- /dev/null
+++ b/lib/clang/include/clang/Sema/AttrTemplateInstantiate.inc
@@ -0,0 +1,2 @@
+/* $FreeBSD$ */
+#include "AttrTemplateInstantiate.inc.h"
diff --git a/lib/clang/include/llvm/Config/config.h b/lib/clang/include/llvm/Config/config.h
index 92c960bc2844..f6001e9be806 100644
--- a/lib/clang/include/llvm/Config/config.h
+++ b/lib/clang/include/llvm/Config/config.h
@@ -11,33 +11,18 @@
/* Relative directory for resource files */
#define CLANG_RESOURCE_DIR ""
-/* 32 bit multilib directory. */
-#define CXX_INCLUDE_32BIT_DIR ""
-
-/* 64 bit multilib directory. */
-#define CXX_INCLUDE_64BIT_DIR ""
-
-/* Arch the libstdc++ headers. */
-#define CXX_INCLUDE_ARCH ""
-
-/* Directory with the libstdc++ headers. */
-#define CXX_INCLUDE_ROOT ""
-
/* Directories clang will search for headers */
#define C_INCLUDE_DIRS ""
-/* Define if CBE is enabled for printf %a output */
-#define ENABLE_CBE_PRINTF_A 1
-
/* Define if position independent code is enabled */
#define ENABLE_PIC 0
-/* Define if threads enabled */
-#define ENABLE_THREADS 0
-
/* Define if timestamp information (e.g., __DATE___) is allowed */
#define ENABLE_TIMESTAMPS 0
+/* Directory where gcc is installed. */
+#define GCC_INSTALL_PREFIX ""
+
/* Define to 1 if you have the `argz_append' function. */
/* #undef HAVE_ARGZ_APPEND */
@@ -297,6 +282,9 @@
/* Define to 1 if you have the `powf' function. */
#define HAVE_POWF 1
+/* Define to 1 if you have the `pread' function. */
+#define HAVE_PREAD 1
+
/* Define if libtool can extract symbol lists from object files. */
#define HAVE_PRELOADED_SYMBOLS 1
@@ -373,7 +361,7 @@
#define HAVE_STDLIB_H 1
/* Set to 1 if the std::isinf function is found in <cmath> */
-/* #undef HAVE_STD_ISINF_IN_CMATH */
+#define HAVE_STD_ISINF_IN_CMATH 1
/* Set to 1 if the std::isnan function is found in <cmath> */
#define HAVE_STD_ISNAN_IN_CMATH 1
@@ -545,18 +533,21 @@
/* Installation directory for data files */
/* #undef LLVM_DATADIR */
+/* Target triple LLVM will generate code for by default */
+/* #undef LLVM_DEFAULT_TARGET_TRIPLE */
+
/* Installation directory for documentation */
/* #undef LLVM_DOCSDIR */
+/* Define if threads enabled */
+#define LLVM_ENABLE_THREADS 0
+
/* Installation directory for config files */
/* #undef LLVM_ETCDIR */
/* Has gcc/MSVC atomic intrinsics */
#define LLVM_HAS_ATOMICS 0
-/* Host triple we were built on */
-/* #undef LLVM_HOSTTRIPLE */
-
/* Installation directory for include files */
/* #undef LLVM_INCLUDEDIR */
@@ -578,6 +569,9 @@
/* LLVM name for the native AsmPrinter init function, if available */
#define LLVM_NATIVE_ASMPRINTER LLVMInitializeX86AsmPrinter
+/* LLVM name for the native Disassembler init function, if available */
+#define LLVM_NATIVE_DISASSEMBLER LLVMInitializeX86Disassembler
+
/* LLVM name for the native Target init function, if available */
#define LLVM_NATIVE_TARGET LLVMInitializeX86Target
@@ -623,6 +617,18 @@
/* Installation prefix directory */
/* #undef LLVM_PREFIX */
+/* Define if we have the Intel JIT API runtime support library */
+#define LLVM_USE_INTEL_JITEVENTS 0
+
+/* Define if we have the oprofile JIT-support library */
+#define LLVM_USE_OPROFILE 0
+
+/* Major version of the LLVM API */
+#define LLVM_VERSION_MAJOR 3
+
+/* Minor version of the LLVM API */
+#define LLVM_VERSION_MINOR 1
+
/* Define if the OS needs help to load dependent libraries for dlopen(). */
#define LTDL_DLOPEN_DEPLIBS 1
@@ -648,19 +654,19 @@
/* #undef NEED_USCORE */
/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT "llvmbugs@cs.uiuc.edu"
+#define PACKAGE_BUGREPORT "http://llvm.org/bugs/"
/* Define to the full name of this package. */
-#define PACKAGE_NAME "llvm"
+#define PACKAGE_NAME "LLVM"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "llvm 3.0"
+#define PACKAGE_STRING "LLVM 3.1svn"
/* Define to the one symbol short name of this package. */
-#define PACKAGE_TARNAME "-llvm-"
+#define PACKAGE_TARNAME "llvm"
/* Define to the version of this package. */
-#define PACKAGE_VERSION "3.0"
+#define PACKAGE_VERSION "3.1svn"
/* Define as the return type of signal handlers (`int' or `void'). */
#define RETSIGTYPE void
@@ -677,9 +683,6 @@
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
/* #undef TM_IN_SYS_TIME */
-/* Define if we have the oprofile JIT-support library */
-#define USE_OPROFILE 0
-
/* Define if use udis86 library */
#define USE_UDIS86 0
diff --git a/lib/clang/include/llvm/Config/llvm-config.h b/lib/clang/include/llvm/Config/llvm-config.h
index 1b50ab879902..4a8d46060331 100644
--- a/lib/clang/include/llvm/Config/llvm-config.h
+++ b/lib/clang/include/llvm/Config/llvm-config.h
@@ -27,18 +27,21 @@
/* Installation directory for data files */
/* #undef LLVM_DATADIR */
+/* Target triple LLVM will generate code for by default */
+/* #undef LLVM_DEFAULT_TARGET_TRIPLE */
+
/* Installation directory for documentation */
/* #undef LLVM_DOCSDIR */
+/* Define if threads enabled */
+#define LLVM_ENABLE_THREADS 0
+
/* Installation directory for config files */
/* #undef LLVM_ETCDIR */
/* Has gcc/MSVC atomic intrinsics */
#define LLVM_HAS_ATOMICS 0
-/* Host triple we were built on */
-/* #undef LLVM_HOSTTRIPLE */
-
/* Installation directory for include files */
/* #undef LLVM_INCLUDEDIR */
@@ -60,6 +63,9 @@
/* LLVM name for the native AsmPrinter init function, if available */
#define LLVM_NATIVE_ASMPRINTER LLVMInitializeX86AsmPrinter
+/* LLVM name for the native Disassembler init function, if available */
+#define LLVM_NATIVE_DISASSEMBLER LLVMInitializeX86Disassembler
+
/* LLVM name for the native Target init function, if available */
#define LLVM_NATIVE_TARGET LLVMInitializeX86Target
@@ -105,4 +111,10 @@
/* Installation prefix directory */
/* #undef LLVM_PREFIX */
+/* Major version of the LLVM API */
+#define LLVM_VERSION_MAJOR 3
+
+/* Minor version of the LLVM API */
+#define LLVM_VERSION_MINOR 1
+
#endif
diff --git a/lib/clang/libclanganalysis/Makefile b/lib/clang/libclanganalysis/Makefile
index f5fbc6270d3a..f45ec59f01ba 100644
--- a/lib/clang/libclanganalysis/Makefile
+++ b/lib/clang/libclanganalysis/Makefile
@@ -3,13 +3,16 @@
LIB= clanganalysis
SRCDIR= tools/clang/lib/Analysis
-SRCS= AnalysisContext.cpp \
+SRCS= AnalysisDeclContext.cpp \
+ CallGraph.cpp \
CFG.cpp \
CFGReachabilityAnalysis.cpp \
CFGStmtMap.cpp \
CocoaConventions.cpp \
+ Dominators.cpp \
FormatString.cpp \
LiveVariables.cpp \
+ PostOrderCFGView.cpp \
PrintfFormatString.cpp \
ProgramPoint.cpp \
PseudoConstantAnalysis.cpp \
diff --git a/lib/clang/libclangarcmigrate/Makefile b/lib/clang/libclangarcmigrate/Makefile
index 957c3bade6a0..d097ec485276 100644
--- a/lib/clang/libclangarcmigrate/Makefile
+++ b/lib/clang/libclangarcmigrate/Makefile
@@ -6,6 +6,7 @@ SRCDIR= tools/clang/lib/ARCMigrate
SRCS= ARCMT.cpp \
ARCMTActions.cpp \
FileRemapper.cpp \
+ ObjCMT.cpp \
PlistReporter.cpp \
TransAPIUses.cpp \
TransARCAssign.cpp \
@@ -14,6 +15,8 @@ SRCS= ARCMT.cpp \
TransEmptyStatementsAndDealloc.cpp \
TransformActions.cpp \
Transforms.cpp \
+ TransGCAttrs.cpp \
+ TransGCCalls.cpp \
TransProperties.cpp \
TransRetainReleaseDealloc.cpp \
TransUnbridgedCasts.cpp \
@@ -21,6 +24,7 @@ SRCS= ARCMT.cpp \
TransZeroOutPropsInDealloc.cpp
TGHDRS= AttrList \
+ AttrParsedAttrList \
Attrs \
DeclNodes \
DiagnosticCommonKinds \
diff --git a/lib/clang/libclangast/Makefile b/lib/clang/libclangast/Makefile
index 61f68811c5cb..81812dc6bf82 100644
--- a/lib/clang/libclangast/Makefile
+++ b/lib/clang/libclangast/Makefile
@@ -28,10 +28,12 @@ SRCS= APValue.cpp \
InheritViz.cpp \
ItaniumCXXABI.cpp \
ItaniumMangle.cpp \
+ LambdaMangleContext.cpp \
Mangle.cpp \
MicrosoftCXXABI.cpp \
MicrosoftMangle.cpp \
NestedNameSpecifier.cpp \
+ NSAPI.cpp \
ParentMap.cpp \
RecordLayout.cpp \
RecordLayoutBuilder.cpp \
diff --git a/lib/clang/libclangbasic/Makefile b/lib/clang/libclangbasic/Makefile
index dec03c585abd..742cc24368d5 100644
--- a/lib/clang/libclangbasic/Makefile
+++ b/lib/clang/libclangbasic/Makefile
@@ -11,6 +11,7 @@ SRCS= Builtins.cpp \
FileSystemStatCache.cpp \
IdentifierTable.cpp \
LangOptions.cpp \
+ Module.cpp \
SourceLocation.cpp \
SourceManager.cpp \
TargetInfo.cpp \
@@ -29,6 +30,7 @@ TGHDRS= DiagnosticAnalysisKinds \
DiagnosticLexKinds \
DiagnosticParseKinds \
DiagnosticSemaKinds \
+ DiagnosticSerializationKinds \
arm_neon
.include "../clang.lib.mk"
diff --git a/lib/clang/libclangcodegen/Makefile b/lib/clang/libclangcodegen/Makefile
index 467b2d27ff0e..bd7b1713e53b 100644
--- a/lib/clang/libclangcodegen/Makefile
+++ b/lib/clang/libclangcodegen/Makefile
@@ -31,7 +31,6 @@ SRCS= BackendUtil.cpp \
CGRTTI.cpp \
CGRecordLayoutBuilder.cpp \
CGStmt.cpp \
- CGTemporaries.cpp \
CGVTT.cpp \
CGVTables.cpp \
CodeGenAction.cpp \
diff --git a/lib/clang/libclangdriver/Makefile b/lib/clang/libclangdriver/Makefile
index ce9d25170aca..53d49d15a854 100644
--- a/lib/clang/libclangdriver/Makefile
+++ b/lib/clang/libclangdriver/Makefile
@@ -11,7 +11,6 @@ SRCS= Action.cpp \
Compilation.cpp \
Driver.cpp \
DriverOptions.cpp \
- HostInfo.cpp \
Job.cpp \
OptTable.cpp \
Option.cpp \
@@ -20,7 +19,8 @@ SRCS= Action.cpp \
ToolChain.cpp \
ToolChains.cpp \
Tools.cpp \
- Types.cpp
+ Types.cpp \
+ WindowsToolChain.cpp
TGHDRS= CC1AsOptions \
CC1Options \
diff --git a/lib/clang/libclangedit/Makefile b/lib/clang/libclangedit/Makefile
new file mode 100644
index 000000000000..147d13373356
--- /dev/null
+++ b/lib/clang/libclangedit/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+LIB= clangedit
+
+SRCDIR= tools/clang/lib/Edit
+SRCS= Commit.cpp \
+ EditedSource.cpp \
+ RewriteObjCFoundationAPI.cpp
+
+TGHDRS= AttrList \
+ Attrs \
+ DeclNodes \
+ StmtNodes \
+ DiagnosticCommonKinds
+
+.include "../clang.lib.mk"
diff --git a/lib/clang/libclangfrontend/Makefile b/lib/clang/libclangfrontend/Makefile
index d8495a290fb8..0ef026b07b5e 100644
--- a/lib/clang/libclangfrontend/Makefile
+++ b/lib/clang/libclangfrontend/Makefile
@@ -7,10 +7,14 @@ SRCS= ASTConsumers.cpp \
ASTMerge.cpp \
ASTUnit.cpp \
CacheTokens.cpp \
+ ChainedDiagnosticConsumer.cpp \
+ ChainedIncludesSource.cpp \
CompilerInstance.cpp \
CompilerInvocation.cpp \
CreateInvocationFromCommandLine.cpp \
DependencyFile.cpp \
+ DependencyGraph.cpp \
+ DiagnosticRenderer.cpp \
FrontendAction.cpp \
FrontendActions.cpp \
FrontendOptions.cpp \
@@ -18,15 +22,19 @@ SRCS= ASTConsumers.cpp \
InitHeaderSearch.cpp \
InitPreprocessor.cpp \
LangStandards.cpp \
+ LayoutOverrideSource.cpp \
LogDiagnosticPrinter.cpp \
MultiplexConsumer.cpp \
PrintPreprocessedOutput.cpp \
+ SerializedDiagnosticPrinter.cpp \
+ TextDiagnostic.cpp \
TextDiagnosticBuffer.cpp \
TextDiagnosticPrinter.cpp \
VerifyDiagnosticConsumer.cpp \
Warnings.cpp
TGHDRS= AttrList \
+ AttrParsedAttrList \
Attrs \
CC1Options \
DeclNodes \
diff --git a/lib/clang/libclangindex/Makefile b/lib/clang/libclangindex/Makefile
index 0980da0fb0c8..63b532c83ba5 100644
--- a/lib/clang/libclangindex/Makefile
+++ b/lib/clang/libclangindex/Makefile
@@ -5,7 +5,6 @@ LIB= clangindex
SRCDIR= tools/clang/lib/Index
SRCS= ASTLocation.cpp \
Analyzer.cpp \
- CallGraph.cpp \
DeclReferenceMap.cpp \
Entity.cpp \
GlobalSelector.cpp \
diff --git a/lib/clang/libclanglex/Makefile b/lib/clang/libclanglex/Makefile
index 7e659c66beeb..3ad0e3f78c23 100644
--- a/lib/clang/libclanglex/Makefile
+++ b/lib/clang/libclanglex/Makefile
@@ -9,7 +9,9 @@ SRCS= HeaderMap.cpp \
LiteralSupport.cpp \
MacroArgs.cpp \
MacroInfo.cpp \
+ ModuleMap.cpp \
PPCaching.cpp \
+ PPCallbacks.cpp \
PPDirectives.cpp \
PPExpressions.cpp \
PPLexerChange.cpp \
diff --git a/lib/clang/libclangparse/Makefile b/lib/clang/libclangparse/Makefile
index 6bd0b5bf2508..1bf46a8ba2c3 100644
--- a/lib/clang/libclangparse/Makefile
+++ b/lib/clang/libclangparse/Makefile
@@ -19,6 +19,7 @@ SRCS= ParseAST.cpp \
TGHDRS= AttrLateParsed \
AttrList \
+ AttrParsedAttrList \
Attrs \
DeclNodes \
DiagnosticCommonKinds \
diff --git a/lib/clang/libclangrewrite/Makefile b/lib/clang/libclangrewrite/Makefile
index 496c699d64ea..3150b56aa85f 100644
--- a/lib/clang/libclangrewrite/Makefile
+++ b/lib/clang/libclangrewrite/Makefile
@@ -9,6 +9,7 @@ SRCS= DeltaTree.cpp \
HTMLPrint.cpp \
HTMLRewrite.cpp \
RewriteMacros.cpp \
+ RewriteModernObjC.cpp \
RewriteObjC.cpp \
RewriteRope.cpp \
RewriteTest.cpp \
@@ -16,6 +17,7 @@ SRCS= DeltaTree.cpp \
TokenRewriter.cpp
TGHDRS= AttrList \
+ AttrParsedAttrList \
Attrs \
DeclNodes \
DiagnosticCommonKinds \
diff --git a/lib/clang/libclangsema/Makefile b/lib/clang/libclangsema/Makefile
index 57f5ccb8d2c2..e40a756f33fb 100644
--- a/lib/clang/libclangsema/Makefile
+++ b/lib/clang/libclangsema/Makefile
@@ -10,7 +10,6 @@ SRCS= AnalysisBasedWarnings.cpp \
DelayedDiagnostic.cpp \
IdentifierResolver.cpp \
JumpDiagnostics.cpp \
- MultiInitializer.cpp \
Scope.cpp \
Sema.cpp \
SemaAccess.cpp \
@@ -19,20 +18,23 @@ SRCS= AnalysisBasedWarnings.cpp \
SemaCast.cpp \
SemaChecking.cpp \
SemaCodeComplete.cpp \
+ SemaConsumer.cpp \
SemaDecl.cpp \
SemaDeclAttr.cpp \
SemaDeclCXX.cpp \
- SemaExprMember.cpp \
SemaDeclObjC.cpp \
SemaExceptionSpec.cpp \
SemaExpr.cpp \
SemaExprCXX.cpp \
+ SemaExprMember.cpp \
SemaExprObjC.cpp \
SemaFixItUtils.cpp \
SemaInit.cpp \
+ SemaLambda.cpp \
SemaLookup.cpp \
SemaObjCProperty.cpp \
SemaOverload.cpp \
+ SemaPseudoObject.cpp \
SemaStmt.cpp \
SemaTemplate.cpp \
SemaTemplateDeduction.cpp \
@@ -43,6 +45,9 @@ SRCS= AnalysisBasedWarnings.cpp \
TargetAttributesSema.cpp
TGHDRS= AttrList \
+ AttrParsedAttrKinds \
+ AttrParsedAttrList \
+ AttrTemplateInstantiate \
Attrs \
DeclNodes \
DiagnosticASTKinds \
diff --git a/lib/clang/libclangserialization/Makefile b/lib/clang/libclangserialization/Makefile
index a4e0f36532a6..acd97aec5cfc 100644
--- a/lib/clang/libclangserialization/Makefile
+++ b/lib/clang/libclangserialization/Makefile
@@ -10,7 +10,6 @@ SRCS= ASTCommon.cpp \
ASTWriter.cpp \
ASTWriterDecl.cpp \
ASTWriterStmt.cpp \
- ChainedIncludesSource.cpp \
GeneratePCH.cpp \
Module.cpp \
ModuleManager.cpp
@@ -18,11 +17,13 @@ SRCS= ASTCommon.cpp \
TGHDRS= AttrList \
AttrPCHRead \
AttrPCHWrite \
+ AttrParsedAttrList \
Attrs \
DeclNodes \
DiagnosticCommonKinds \
DiagnosticFrontendKinds \
DiagnosticSemaKinds \
+ DiagnosticSerializationKinds \
StmtNodes
.include "../clang.lib.mk"
diff --git a/lib/clang/libclangstaticanalyzercheckers/Makefile b/lib/clang/libclangstaticanalyzercheckers/Makefile
index 44f7d58ca7b1..d4eb771b4fc9 100644
--- a/lib/clang/libclangstaticanalyzercheckers/Makefile
+++ b/lib/clang/libclangstaticanalyzercheckers/Makefile
@@ -9,8 +9,10 @@ SRCS= AdjustedReturnValueChecker.cpp \
ArrayBoundCheckerV2.cpp \
AttrNonNullChecker.cpp \
BasicObjCFoundationChecks.cpp \
+ BoolAssignmentChecker.cpp \
BuiltinFunctionChecker.cpp \
CStringChecker.cpp \
+ CStringSyntaxChecker.cpp \
CallAndMessageChecker.cpp \
CastSizeChecker.cpp \
CastToStructChecker.cpp \
@@ -18,13 +20,16 @@ SRCS= AdjustedReturnValueChecker.cpp \
CheckObjCInstMethSignature.cpp \
CheckSecuritySyntaxOnly.cpp \
CheckSizeofPointer.cpp \
+ CheckerDocumentation.cpp \
ChrootChecker.cpp \
ClangCheckers.cpp \
+ CommonBugCategories.cpp \
DeadStoresChecker.cpp \
DebugCheckers.cpp \
DereferenceChecker.cpp \
DivZeroChecker.cpp \
FixedAddressChecker.cpp \
+ GenericTaintChecker.cpp \
IdempotentOperationChecker.cpp \
IteratorsChecker.cpp \
LLVMConventionsChecker.cpp \
@@ -32,11 +37,14 @@ SRCS= AdjustedReturnValueChecker.cpp \
MacOSXAPIChecker.cpp \
MallocChecker.cpp \
MallocOverflowSecurityChecker.cpp \
+ MallocSizeofChecker.cpp \
NSAutoreleasePoolChecker.cpp \
NSErrorChecker.cpp \
NoReturnFunctionChecker.cpp \
OSAtomicChecker.cpp \
ObjCAtSyncChecker.cpp \
+ ObjCContainersASTChecker.cpp \
+ ObjCContainersChecker.cpp \
ObjCSelfInitChecker.cpp \
ObjCUnusedIVarsChecker.cpp \
PointerArithChecker.cpp \
@@ -47,6 +55,7 @@ SRCS= AdjustedReturnValueChecker.cpp \
ReturnUndefChecker.cpp \
StackAddrEscapeChecker.cpp \
StreamChecker.cpp \
+ TaintTesterChecker.cpp \
UndefBranchChecker.cpp \
UndefCapturedBlockVarChecker.cpp \
UndefResultChecker.cpp \
@@ -54,7 +63,8 @@ SRCS= AdjustedReturnValueChecker.cpp \
UndefinedAssignmentChecker.cpp \
UnixAPIChecker.cpp \
UnreachableCodeChecker.cpp \
- VLASizeChecker.cpp
+ VLASizeChecker.cpp \
+ VirtualCallChecker.cpp
TGHDRS= AttrList \
Attrs \
diff --git a/lib/clang/libclangstaticanalyzercore/Makefile b/lib/clang/libclangstaticanalyzercore/Makefile
index 9a33751e244d..27cdcc6529a1 100644
--- a/lib/clang/libclangstaticanalyzercore/Makefile
+++ b/lib/clang/libclangstaticanalyzercore/Makefile
@@ -3,8 +3,7 @@
LIB= clangstaticanalyzercore
SRCDIR= tools/clang/lib/StaticAnalyzer/Core
-SRCS= AggExprVisitor.cpp \
- AnalysisManager.cpp \
+SRCS= AnalysisManager.cpp \
BasicConstraintManager.cpp \
BasicValueFactory.cpp \
BlockCounter.cpp \
@@ -23,6 +22,7 @@ SRCS= AggExprVisitor.cpp \
ExprEngineCXX.cpp \
ExprEngineCallAndReturn.cpp \
ExprEngineObjC.cpp \
+ FunctionSummary.cpp \
HTMLDiagnostics.cpp \
MemRegion.cpp \
ObjCMessage.cpp \
@@ -36,6 +36,7 @@ SRCS= AggExprVisitor.cpp \
SimpleConstraintManager.cpp \
SimpleSValBuilder.cpp \
Store.cpp \
+ SubEngine.cpp \
SymbolManager.cpp \
TextPathDiagnostics.cpp
diff --git a/lib/clang/libllvmanalysis/Makefile b/lib/clang/libllvmanalysis/Makefile
index 2b0bccff976a..a05dac57a8c5 100644
--- a/lib/clang/libllvmanalysis/Makefile
+++ b/lib/clang/libllvmanalysis/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+.include <bsd.own.mk>
+
LIB= llvmanalysis
SRCDIR= lib/Analysis
@@ -10,13 +12,15 @@ SRCS= AliasAnalysis.cpp \
AliasSetTracker.cpp \
Analysis.cpp \
BasicAliasAnalysis.cpp \
+ BlockFrequencyInfo.cpp \
BranchProbabilityInfo.cpp \
CFGPrinter.cpp \
CaptureTracking.cpp \
+ CodeMetrics.cpp \
ConstantFolding.cpp \
+ DIBuilder.cpp \
DbgInfoPrinter.cpp \
DebugInfo.cpp \
- DIBuilder.cpp \
DomPrinter.cpp \
DominanceFrontier.cpp \
IVUsers.cpp \
@@ -27,6 +31,7 @@ SRCS= AliasAnalysis.cpp \
IntervalPartition.cpp \
LazyValueInfo.cpp \
LibCallAliasAnalysis.cpp \
+ LibCallSemantics.cpp \
Lint.cpp \
Loads.cpp \
LoopDependenceAnalysis.cpp \
@@ -38,6 +43,9 @@ SRCS= AliasAnalysis.cpp \
ModuleDebugInfoPrinter.cpp \
NoAliasAnalysis.cpp \
PHITransAddr.cpp \
+ PathNumbering.cpp \
+ PathProfileInfo.cpp \
+ PathProfileVerifier.cpp \
PostDominators.cpp \
ProfileEstimatorPass.cpp \
ProfileInfo.cpp \
@@ -52,9 +60,18 @@ SRCS= AliasAnalysis.cpp \
ScalarEvolutionExpander.cpp \
ScalarEvolutionNormalization.cpp \
SparsePropagation.cpp \
+ Trace.cpp \
TypeBasedAliasAnalysis.cpp \
ValueTracking.cpp
+.if ${MK_CLANG_EXTRAS} != "no"
+SRCS+= BlockFrequencyInfo.cpp \
+ LibCallSemantics.cpp \
+ PathNumbering.cpp \
+ PathProfileInfo.cpp \
+ PathProfileVerifier.cpp
+.endif
+
TGHDRS= Intrinsics
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmarchive/Makefile b/lib/clang/libllvmarchive/Makefile
new file mode 100644
index 000000000000..a28f2f510a69
--- /dev/null
+++ b/lib/clang/libllvmarchive/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+LIB= llvmarchive
+
+SRCDIR= lib/Archive
+SRCS= Archive.cpp \
+ ArchiveReader.cpp \
+ ArchiveWriter.cpp
+
+.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmarmcodegen/Makefile b/lib/clang/libllvmarmcodegen/Makefile
index 29579bc32ab5..b18f12c8fcd9 100644
--- a/lib/clang/libllvmarmcodegen/Makefile
+++ b/lib/clang/libllvmarmcodegen/Makefile
@@ -13,7 +13,6 @@ SRCS= ARMAsmPrinter.cpp \
ARMExpandPseudoInsts.cpp \
ARMFastISel.cpp \
ARMFrameLowering.cpp \
- ARMGlobalMerge.cpp \
ARMHazardRecognizer.cpp \
ARMISelDAGToDAG.cpp \
ARMISelLowering.cpp \
@@ -21,6 +20,7 @@ SRCS= ARMAsmPrinter.cpp \
ARMJITInfo.cpp \
ARMLoadStoreOptimizer.cpp \
ARMMCInstLower.cpp \
+ ARMMachineFunctionInfo.cpp \
ARMRegisterInfo.cpp \
ARMSelectionDAGInfo.cpp \
ARMSubtarget.cpp \
diff --git a/lib/clang/libllvmarmdesc/Makefile b/lib/clang/libllvmarmdesc/Makefile
index e732074ddeab..bd2e0cb96b7d 100644
--- a/lib/clang/libllvmarmdesc/Makefile
+++ b/lib/clang/libllvmarmdesc/Makefile
@@ -4,6 +4,7 @@ LIB= llvmarmdesc
SRCDIR= lib/Target/ARM/MCTargetDesc
SRCS= ARMAsmBackend.cpp \
+ ARMELFObjectWriter.cpp \
ARMMachObjectWriter.cpp \
ARMMCAsmInfo.cpp \
ARMMCCodeEmitter.cpp \
diff --git a/lib/clang/libllvmasmprinter/Makefile b/lib/clang/libllvmasmprinter/Makefile
index 26f113f63d77..36e626fc3427 100644
--- a/lib/clang/libllvmasmprinter/Makefile
+++ b/lib/clang/libllvmasmprinter/Makefile
@@ -8,6 +8,7 @@ SRCS= ARMException.cpp \
AsmPrinterDwarf.cpp \
AsmPrinterInlineAsm.cpp \
DIE.cpp \
+ DwarfAccelTable.cpp \
DwarfCFIException.cpp \
DwarfCompileUnit.cpp \
DwarfDebug.cpp \
diff --git a/lib/clang/libllvmcodegen/Makefile b/lib/clang/libllvmcodegen/Makefile
index 0d593b662a48..70da7daab2a0 100644
--- a/lib/clang/libllvmcodegen/Makefile
+++ b/lib/clang/libllvmcodegen/Makefile
@@ -13,9 +13,8 @@ SRCS= AggressiveAntiDepBreaker.cpp \
CodePlacementOpt.cpp \
CriticalAntiDepBreaker.cpp \
DeadMachineInstructionElim.cpp \
+ DFAPacketizer.cpp \
DwarfEHPrepare.cpp \
- ELFCodeEmitter.cpp \
- ELFWriter.cpp \
EdgeBundles.cpp \
ExecutionDepsFix.cpp \
ExpandISelPseudos.cpp \
@@ -27,6 +26,7 @@ SRCS= AggressiveAntiDepBreaker.cpp \
InlineSpiller.cpp \
InterferenceCache.cpp \
IntrinsicLowering.cpp \
+ JITCodeEmitter.cpp \
LLVMTargetMachine.cpp \
LatencyPriorityQueue.cpp \
LexicalScopes.cpp \
@@ -40,7 +40,11 @@ SRCS= AggressiveAntiDepBreaker.cpp \
LiveRangeEdit.cpp \
LocalStackSlotAllocation.cpp \
MachineBasicBlock.cpp \
+ MachineBlockFrequencyInfo.cpp \
+ MachineBlockPlacement.cpp \
MachineBranchProbabilityInfo.cpp \
+ MachineCodeEmitter.cpp \
+ MachineCopyPropagation.cpp \
MachineCSE.cpp \
MachineDominators.cpp \
MachineFunction.cpp \
@@ -48,6 +52,7 @@ SRCS= AggressiveAntiDepBreaker.cpp \
MachineFunctionPass.cpp \
MachineFunctionPrinterPass.cpp \
MachineInstr.cpp \
+ MachineInstrBundle.cpp \
MachineLICM.cpp \
MachineLoopInfo.cpp \
MachineLoopRanges.cpp \
@@ -56,9 +61,9 @@ SRCS= AggressiveAntiDepBreaker.cpp \
MachinePassRegistry.cpp \
MachineRegisterInfo.cpp \
MachineSSAUpdater.cpp \
+ MachineScheduler.cpp \
MachineSink.cpp \
MachineVerifier.cpp \
- ObjectCodeEmitter.cpp \
OcamlGC.cpp \
OptimizePHIs.cpp \
PHIElimination.cpp \
@@ -69,17 +74,16 @@ SRCS= AggressiveAntiDepBreaker.cpp \
ProcessImplicitDefs.cpp \
PrologEpilogInserter.cpp \
PseudoSourceValue.cpp \
+ RegAllocBase.cpp \
RegAllocBasic.cpp \
RegAllocFast.cpp \
RegAllocGreedy.cpp \
- RegAllocLinearScan.cpp \
RegAllocPBQP.cpp \
RegisterClassInfo.cpp \
RegisterCoalescer.cpp \
RegisterScavenging.cpp \
RenderMachineFunction.cpp \
ScheduleDAG.cpp \
- ScheduleDAGEmit.cpp \
ScheduleDAGInstrs.cpp \
ScheduleDAGPrinter.cpp \
ScoreboardHazardRecognizer.cpp \
@@ -90,17 +94,17 @@ SRCS= AggressiveAntiDepBreaker.cpp \
Spiller.cpp \
SpillPlacement.cpp \
SplitKit.cpp \
- Splitter.cpp \
StackProtector.cpp \
StackSlotColoring.cpp \
StrongPHIElimination.cpp \
TailDuplication.cpp \
+ TargetFrameLoweringImpl.cpp \
TargetInstrInfoImpl.cpp \
TargetLoweringObjectFileImpl.cpp \
+ TargetOptionsImpl.cpp \
TwoAddressInstructionPass.cpp \
UnreachableBlockElim.cpp \
- VirtRegMap.cpp \
- VirtRegRewriter.cpp
+ VirtRegMap.cpp
TGHDRS= Intrinsics
diff --git a/lib/clang/libllvmcore/Makefile b/lib/clang/libllvmcore/Makefile
index c37d45a26642..2702b66a3812 100644
--- a/lib/clang/libllvmcore/Makefile
+++ b/lib/clang/libllvmcore/Makefile
@@ -10,7 +10,6 @@ SRCS= AsmWriter.cpp \
ConstantFold.cpp \
Constants.cpp \
Core.cpp \
- DebugInfoProbe.cpp \
DebugLoc.cpp \
Dominators.cpp \
Function.cpp \
diff --git a/lib/clang/libllvmdebuginfo/Makefile b/lib/clang/libllvmdebuginfo/Makefile
new file mode 100644
index 000000000000..b7241573c123
--- /dev/null
+++ b/lib/clang/libllvmdebuginfo/Makefile
@@ -0,0 +1,17 @@
+# $FreeBSD$
+
+LIB= llvmdebuginfo
+
+SRCDIR= lib/DebugInfo
+SRCS= DIContext.cpp \
+ DWARFAbbreviationDeclaration.cpp \
+ DWARFCompileUnit.cpp \
+ DWARFContext.cpp \
+ DWARFDebugAbbrev.cpp \
+ DWARFDebugArangeSet.cpp \
+ DWARFDebugAranges.cpp \
+ DWARFDebugInfoEntry.cpp \
+ DWARFDebugLine.cpp \
+ DWARFFormValue.cpp
+
+.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmexecutionengine/Makefile b/lib/clang/libllvmexecutionengine/Makefile
new file mode 100644
index 000000000000..c0dde71debb4
--- /dev/null
+++ b/lib/clang/libllvmexecutionengine/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+LIB= llvmexecutionengine
+
+SRCDIR= lib/ExecutionEngine
+SRCS= ExecutionEngine.cpp \
+ ExecutionEngineBindings.cpp \
+ TargetSelect.cpp
+
+.include "../clang.lib.mk"
diff --git a/lib/clang/libllvminstrumentation/Makefile b/lib/clang/libllvminstrumentation/Makefile
index 62d9f979687c..fbfa1983d188 100644
--- a/lib/clang/libllvminstrumentation/Makefile
+++ b/lib/clang/libllvminstrumentation/Makefile
@@ -3,13 +3,16 @@
LIB= llvminstrumentation
SRCDIR= lib/Transforms/Instrumentation
-SRCS= EdgeProfiling.cpp \
+SRCS= AddressSanitizer.cpp \
+ EdgeProfiling.cpp \
+ FunctionBlackList.cpp \
GCOVProfiling.cpp \
Instrumentation.cpp \
OptimalEdgeProfiling.cpp \
PathProfiling.cpp \
ProfilingUtils.cpp \
+ ThreadSanitizer.cpp
-#TGHDRS= Intrinsics
+TGHDRS= Intrinsics
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvminterpreter/Makefile b/lib/clang/libllvminterpreter/Makefile
new file mode 100644
index 000000000000..6a1b453459b2
--- /dev/null
+++ b/lib/clang/libllvminterpreter/Makefile
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+LIB= llvminterpreter
+
+SRCDIR= lib/ExecutionEngine/Interpreter
+SRCS= Execution.cpp \
+ ExternalFunctions.cpp \
+ Interpreter.cpp \
+
+TGHDRS= Intrinsics
+
+.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmipa/Makefile b/lib/clang/libllvmipa/Makefile
index fc241dfc241e..4caa0e5dec84 100644
--- a/lib/clang/libllvmipa/Makefile
+++ b/lib/clang/libllvmipa/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+.include <bsd.own.mk>
+
LIB= llvmipa
SRCDIR= lib/Analysis/IPA
@@ -8,6 +10,10 @@ SRCS= CallGraph.cpp \
FindUsedTypes.cpp \
GlobalsModRef.cpp
+.if ${MK_CLANG_EXTRAS} != "no"
+SRCS+= IPA.cpp
+.endif
+
TGHDRS= Intrinsics
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmipo/Makefile b/lib/clang/libllvmipo/Makefile
index 42cc2fa93252..a493532d6504 100644
--- a/lib/clang/libllvmipo/Makefile
+++ b/lib/clang/libllvmipo/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+.include <bsd.own.mk>
+
LIB= llvmipo
SRCDIR= lib/Transforms/IPO
@@ -23,6 +25,10 @@ SRCS= ArgumentPromotion.cpp \
StripDeadPrototypes.cpp \
StripSymbols.cpp
+.if ${MK_CLANG_EXTRAS} != "no"
+SRCS+= IPO.cpp
+.endif
+
TGHDRS= Intrinsics
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmjit/Makefile b/lib/clang/libllvmjit/Makefile
new file mode 100644
index 000000000000..ff852d5047b7
--- /dev/null
+++ b/lib/clang/libllvmjit/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+LIB= llvmjit
+
+SRCDIR= lib/ExecutionEngine/JIT
+SRCS= JIT.cpp \
+ JITDwarfEmitter.cpp \
+ JITEmitter.cpp \
+ JITMemoryManager.cpp
+
+.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmlinker/Makefile b/lib/clang/libllvmlinker/Makefile
new file mode 100644
index 000000000000..73f153b378fb
--- /dev/null
+++ b/lib/clang/libllvmlinker/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+LIB= llvmlinker
+
+SRCDIR= lib/Linker
+SRCS= LinkArchives.cpp \
+ LinkItems.cpp \
+ LinkModules.cpp \
+ Linker.cpp
+
+.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmmc/Makefile b/lib/clang/libllvmmc/Makefile
index 5fef440114b9..9309e9725bec 100644
--- a/lib/clang/libllvmmc/Makefile
+++ b/lib/clang/libllvmmc/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+.include <bsd.own.mk>
+
LIB= llvmmc
SRCDIR= lib/MC
@@ -21,7 +23,6 @@ SRCS= ELFObjectWriter.cpp \
MCInst.cpp \
MCInstPrinter.cpp \
MCInstrAnalysis.cpp \
- MCLoggingStreamer.cpp \
MCMachOStreamer.cpp \
MCMachObjectTargetWriter.cpp \
MCNullStreamer.cpp \
@@ -43,4 +44,8 @@ SRCS= ELFObjectWriter.cpp \
WinCOFFObjectWriter.cpp \
WinCOFFStreamer.cpp
+.if ${MK_CLANG_EXTRAS} != "no"
+SRCS+= MCDisassembler.cpp
+.endif
+
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmmcdisassembler/Makefile b/lib/clang/libllvmmcdisassembler/Makefile
new file mode 100644
index 000000000000..dc5f29437e0c
--- /dev/null
+++ b/lib/clang/libllvmmcdisassembler/Makefile
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+LIB= llvmmcdisassembler
+
+SRCDIR= lib/MC/MCDisassembler
+SRCS= Disassembler.cpp \
+ EDDisassembler.cpp \
+ EDInst.cpp \
+ EDOperand.cpp \
+ EDToken.cpp
+
+.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmmcjit/Makefile b/lib/clang/libllvmmcjit/Makefile
new file mode 100644
index 000000000000..553186f70712
--- /dev/null
+++ b/lib/clang/libllvmmcjit/Makefile
@@ -0,0 +1,14 @@
+# $FreeBSD$
+
+.include <bsd.own.mk>
+
+LIB= llvmmcjit
+
+SRCDIR= lib/ExecutionEngine/MCJIT
+SRCS= MCJIT.cpp
+
+.if ${MK_CLANG_EXTRAS} != "no"
+SRCS+= MCJITMemoryManager.cpp
+.endif
+
+.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmmipsasmparser/Makefile b/lib/clang/libllvmmipsasmparser/Makefile
new file mode 100644
index 000000000000..dd9539488763
--- /dev/null
+++ b/lib/clang/libllvmmipsasmparser/Makefile
@@ -0,0 +1,13 @@
+# $FreeBSD$
+
+LIB= llvmmipsasmparser
+
+SRCDIR= lib/Target/Mips/AsmParser
+INCDIR= lib/Target/Mips
+SRCS= MipsAsmParser.cpp
+
+TGHDRS= MipsGenInstrInfo \
+ MipsGenRegisterInfo \
+ MipsGenSubtargetInfo
+
+.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmmipscodegen/Makefile b/lib/clang/libllvmmipscodegen/Makefile
index f0b01808576d..d550006fba34 100644
--- a/lib/clang/libllvmmipscodegen/Makefile
+++ b/lib/clang/libllvmmipscodegen/Makefile
@@ -3,7 +3,8 @@
LIB= llvmmipscodegen
SRCDIR= lib/Target/Mips
-SRCS= MipsAsmPrinter.cpp \
+SRCS= MipsAnalyzeImmediate.cpp \
+ MipsAsmPrinter.cpp \
MipsCodeEmitter.cpp \
MipsDelaySlotFiller.cpp \
MipsEmitGPRestore.cpp \
@@ -14,7 +15,7 @@ SRCS= MipsAsmPrinter.cpp \
MipsInstrInfo.cpp \
MipsJITInfo.cpp \
MipsMCInstLower.cpp \
- MipsMCSymbolRefExpr.cpp \
+ MipsMachineFunction.cpp \
MipsRegisterInfo.cpp \
MipsSelectionDAGInfo.cpp \
MipsSubtarget.cpp \
diff --git a/lib/clang/libllvmmipsdesc/Makefile b/lib/clang/libllvmmipsdesc/Makefile
index 23136030f434..5c17588cfa89 100644
--- a/lib/clang/libllvmmipsdesc/Makefile
+++ b/lib/clang/libllvmmipsdesc/Makefile
@@ -4,12 +4,14 @@ LIB= llvmmipsdesc
SRCDIR= lib/Target/Mips/MCTargetDesc
SRCS= MipsAsmBackend.cpp \
+ MipsELFObjectWriter.cpp \
MipsMCAsmInfo.cpp \
MipsMCCodeEmitter.cpp \
MipsMCTargetDesc.cpp
CFLAGS+= -I${LLVM_SRCS}/${SRCDIR}/..
TGHDRS= MipsGenInstrInfo \
+ MipsGenMCCodeEmitter \
MipsGenRegisterInfo \
MipsGenSubtargetInfo
diff --git a/lib/clang/libllvmobject/Makefile b/lib/clang/libllvmobject/Makefile
new file mode 100644
index 000000000000..d056dc7c15d3
--- /dev/null
+++ b/lib/clang/libllvmobject/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+LIB= llvmobject
+
+SRCDIR= lib/Object
+SRCS= Archive.cpp \
+ Binary.cpp \
+ COFFObjectFile.cpp \
+ ELFObjectFile.cpp \
+ Error.cpp \
+ MachOObject.cpp \
+ MachOObjectFile.cpp \
+ Object.cpp \
+ ObjectFile.cpp
+
+.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmpowerpccodegen/Makefile b/lib/clang/libllvmpowerpccodegen/Makefile
index aec0e1eaf625..18740954dc1d 100644
--- a/lib/clang/libllvmpowerpccodegen/Makefile
+++ b/lib/clang/libllvmpowerpccodegen/Makefile
@@ -13,6 +13,7 @@ SRCS= PPCAsmPrinter.cpp \
PPCInstrInfo.cpp \
PPCJITInfo.cpp \
PPCMCInstLower.cpp \
+ PPCMachineFunctionInfo.cpp \
PPCRegisterInfo.cpp \
PPCSelectionDAGInfo.cpp \
PPCSubtarget.cpp \
diff --git a/lib/clang/libllvmpowerpcdesc/Makefile b/lib/clang/libllvmpowerpcdesc/Makefile
index c45abecf076a..2a5ef6eabf66 100644
--- a/lib/clang/libllvmpowerpcdesc/Makefile
+++ b/lib/clang/libllvmpowerpcdesc/Makefile
@@ -7,7 +7,8 @@ SRCS= PPCAsmBackend.cpp \
PPCMCAsmInfo.cpp \
PPCMCCodeEmitter.cpp \
PPCMCTargetDesc.cpp \
- PPCPredicates.cpp
+ PPCPredicates.cpp \
+ PPCELFObjectWriter.cpp
CFLAGS+= -I${LLVM_SRCS}/${SRCDIR}/..
TGHDRS= PPCGenInstrInfo \
diff --git a/lib/clang/libllvmruntimedyld/Makefile b/lib/clang/libllvmruntimedyld/Makefile
new file mode 100644
index 000000000000..7280e1d34137
--- /dev/null
+++ b/lib/clang/libllvmruntimedyld/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+LIB= llvmruntimedyld
+
+SRCDIR= lib/ExecutionEngine/RuntimeDyld
+SRCS= RuntimeDyld.cpp \
+ RuntimeDyldELF.cpp \
+ RuntimeDyldMachO.cpp
+
+.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmscalaropts/Makefile b/lib/clang/libllvmscalaropts/Makefile
index c376b685d591..f89b0a2cdc99 100644
--- a/lib/clang/libllvmscalaropts/Makefile
+++ b/lib/clang/libllvmscalaropts/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+.include <bsd.own.mk>
+
LIB= llvmscalaropts
SRCDIR= lib/Transforms/Scalar
@@ -11,6 +13,7 @@ SRCS= ADCE.cpp \
DCE.cpp \
DeadStoreElimination.cpp \
EarlyCSE.cpp \
+ GlobalMerge.cpp \
GVN.cpp \
IndVarSimplify.cpp \
JumpThreading.cpp \
@@ -21,9 +24,11 @@ SRCS= ADCE.cpp \
LoopStrengthReduce.cpp \
LoopUnrollPass.cpp \
LoopUnswitch.cpp \
+ LowerAtomic.cpp \
MemCpyOptimizer.cpp \
ObjCARC.cpp \
Reassociate.cpp \
+ Reg2Mem.cpp \
SCCP.cpp \
ScalarReplAggregates.cpp \
SimplifyCFGPass.cpp \
@@ -31,6 +36,13 @@ SRCS= ADCE.cpp \
Sink.cpp \
TailRecursionElimination.cpp
+.if ${MK_CLANG_EXTRAS} != "no"
+SRCS+= LoopInstSimplify.cpp \
+ LowerAtomic.cpp \
+ Reg2Mem.cpp \
+ Scalar.cpp
+.endif
+
TGHDRS= Intrinsics
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmselectiondag/Makefile b/lib/clang/libllvmselectiondag/Makefile
index 6c508c1017a4..e69501273443 100644
--- a/lib/clang/libllvmselectiondag/Makefile
+++ b/lib/clang/libllvmselectiondag/Makefile
@@ -14,12 +14,14 @@ SRCS= DAGCombiner.cpp \
LegalizeTypesGeneric.cpp \
LegalizeVectorOps.cpp \
LegalizeVectorTypes.cpp \
+ ResourcePriorityQueue.cpp \
ScheduleDAGFast.cpp \
- ScheduleDAGList.cpp \
ScheduleDAGRRList.cpp \
ScheduleDAGSDNodes.cpp \
+ ScheduleDAGVLIW.cpp \
SelectionDAG.cpp \
SelectionDAGBuilder.cpp \
+ SelectionDAGDumper.cpp \
SelectionDAGISel.cpp \
SelectionDAGPrinter.cpp \
TargetLowering.cpp \
diff --git a/lib/clang/libllvmsupport/Makefile b/lib/clang/libllvmsupport/Makefile
index e1a16c46260e..19afb44d92d2 100644
--- a/lib/clang/libllvmsupport/Makefile
+++ b/lib/clang/libllvmsupport/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+.include <bsd.own.mk>
+
LIB= llvmsupport
SRCDIR= lib/Support
@@ -8,6 +10,7 @@ SRCS= APFloat.cpp \
APSInt.cpp \
Allocator.cpp \
Atomic.cpp \
+ BlockFrequency.cpp \
BranchProbability.cpp \
CommandLine.cpp \
ConstantRange.cpp \
@@ -22,12 +25,16 @@ SRCS= APFloat.cpp \
FoldingSet.cpp \
FormattedStream.cpp \
GraphWriter.cpp \
+ Hashing.cpp \
Host.cpp \
IntervalMap.cpp \
IntEqClasses.cpp \
+ IntrusiveRefCntPtr.cpp \
+ LockFileManager.cpp \
ManagedStatic.cpp \
Memory.cpp \
MemoryBuffer.cpp \
+ MemoryObject.cpp \
Mutex.cpp \
Path.cpp \
PathV2.cpp \
@@ -43,6 +50,7 @@ SRCS= APFloat.cpp \
SmallVector.cpp \
SourceMgr.cpp \
Statistic.cpp \
+ StreamableMemoryObject.cpp \
StringExtras.cpp \
StringMap.cpp \
StringPool.cpp \
@@ -67,4 +75,15 @@ SRCS= APFloat.cpp \
system_error.cpp
LLVM_REQUIRES_RTTI=
+.if ${MK_CLANG_EXTRAS} != "no"
+SRCS+= BlockFrequency.cpp \
+ BranchProbability.cpp \
+ DataExtractor.cpp \
+ DataStream.cpp \
+ Disassembler.cpp \
+ FileUtilities.cpp \
+ MemoryObject.cpp \
+ SystemUtils.cpp
+.endif
+
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmtablegen/Makefile b/lib/clang/libllvmtablegen/Makefile
index 272aa883e7ab..0832498ffeaf 100644
--- a/lib/clang/libllvmtablegen/Makefile
+++ b/lib/clang/libllvmtablegen/Makefile
@@ -6,6 +6,7 @@ SRCDIR= lib/TableGen
SRCS= Error.cpp \
Main.cpp \
Record.cpp \
+ TableGenAction.cpp \
TableGenBackend.cpp \
TGLexer.cpp \
TGParser.cpp
diff --git a/lib/clang/libllvmtarget/Makefile b/lib/clang/libllvmtarget/Makefile
index 8c16f84e4dbb..eaad17e55992 100644
--- a/lib/clang/libllvmtarget/Makefile
+++ b/lib/clang/libllvmtarget/Makefile
@@ -7,8 +7,9 @@ SRCS= Mangler.cpp \
Target.cpp \
TargetData.cpp \
TargetELFWriterInfo.cpp \
- TargetFrameLowering.cpp \
TargetInstrInfo.cpp \
+ TargetIntrinsicInfo.cpp \
+ TargetJITInfo.cpp \
TargetLibraryInfo.cpp \
TargetLoweringObjectFile.cpp \
TargetMachine.cpp \
diff --git a/lib/clang/libllvmtransformutils/Makefile b/lib/clang/libllvmtransformutils/Makefile
index 18eecda5d62c..f8afaec711f6 100644
--- a/lib/clang/libllvmtransformutils/Makefile
+++ b/lib/clang/libllvmtransformutils/Makefile
@@ -1,15 +1,17 @@
# $FreeBSD$
+.include <bsd.own.mk>
+
LIB= llvmtransformutils
SRCDIR= lib/Transforms/Utils
SRCS= AddrModeMatcher.cpp \
BasicBlockUtils.cpp \
- BasicInliner.cpp \
BreakCriticalEdges.cpp \
BuildLibCalls.cpp \
CloneFunction.cpp \
CloneModule.cpp \
+ CmpInstAnalysis.cpp \
CodeExtractor.cpp \
DemoteRegToStack.cpp \
InlineFunction.cpp \
@@ -18,17 +20,25 @@ SRCS= AddrModeMatcher.cpp \
Local.cpp \
LoopSimplify.cpp \
LoopUnroll.cpp \
+ LoopUnrollRuntime.cpp \
LowerExpectIntrinsic.cpp \
LowerInvoke.cpp \
LowerSwitch.cpp \
Mem2Reg.cpp \
+ ModuleUtils.cpp \
PromoteMemoryToRegister.cpp \
SSAUpdater.cpp \
SimplifyCFG.cpp \
SimplifyIndVar.cpp \
+ SimplifyInstructions.cpp \
UnifyFunctionExitNodes.cpp \
ValueMapper.cpp
+.if ${MK_CLANG_EXTRAS} != "no"
+SRCS+= SimplifyInstructions.cpp \
+ Utils.cpp
+.endif
+
TGHDRS= Intrinsics
.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmvectorize/Makefile b/lib/clang/libllvmvectorize/Makefile
new file mode 100644
index 000000000000..61a37b56eae6
--- /dev/null
+++ b/lib/clang/libllvmvectorize/Makefile
@@ -0,0 +1,11 @@
+# $FreeBSD$
+
+LIB= llvmvectorize
+
+SRCDIR= lib/Transforms/Vectorize
+SRCS= BBVectorize.cpp \
+ Vectorize.cpp
+
+TGHDRS= Intrinsics
+
+.include "../clang.lib.mk"
diff --git a/lib/clang/libllvmx86codegen/Makefile b/lib/clang/libllvmx86codegen/Makefile
index 5dc45ef58c61..a61cad9db041 100644
--- a/lib/clang/libllvmx86codegen/Makefile
+++ b/lib/clang/libllvmx86codegen/Makefile
@@ -15,6 +15,7 @@ SRCS= X86AsmPrinter.cpp \
X86InstrInfo.cpp \
X86JITInfo.cpp \
X86MCInstLower.cpp \
+ X86MachineFunctionInfo.cpp \
X86RegisterInfo.cpp \
X86SelectionDAGInfo.cpp \
X86Subtarget.cpp \
diff --git a/lib/clang/libllvmx86desc/Makefile b/lib/clang/libllvmx86desc/Makefile
index badb0f2a78b2..3d2a9dd9bfd7 100644
--- a/lib/clang/libllvmx86desc/Makefile
+++ b/lib/clang/libllvmx86desc/Makefile
@@ -4,10 +4,12 @@ LIB= llvmx86desc
SRCDIR= lib/Target/X86/MCTargetDesc
SRCS= X86AsmBackend.cpp \
+ X86ELFObjectWriter.cpp \
X86MachObjectWriter.cpp \
X86MCAsmInfo.cpp \
X86MCCodeEmitter.cpp \
- X86MCTargetDesc.cpp
+ X86MCTargetDesc.cpp \
+ X86WinCOFFObjectWriter.cpp
CFLAGS+= -I${LLVM_SRCS}/${SRCDIR}/..
TGHDRS= X86GenInstrInfo \
diff --git a/lib/clang/libllvmx86disassembler/Makefile b/lib/clang/libllvmx86disassembler/Makefile
index 1d1b3b651620..9b738007c72a 100644
--- a/lib/clang/libllvmx86disassembler/Makefile
+++ b/lib/clang/libllvmx86disassembler/Makefile
@@ -1,11 +1,17 @@
# $FreeBSD$
+.include <bsd.own.mk>
+
LIB= llvmx86disassembler
SRCDIR= lib/Target/X86/Disassembler
INCDIR= lib/Target/X86
SRCS= X86Disassembler.cpp
+.if ${MK_CLANG_EXTRAS} != "no"
+SRCS+= X86DisassemblerDecoder.c
+.endif
+
TGHDRS= X86GenDisassemblerTables \
X86GenEDInfo \
X86GenInstrInfo \
diff --git a/lib/csu/Makefile.inc b/lib/csu/Makefile.inc
index 078cb9f08432..11ddc664c55b 100644
--- a/lib/csu/Makefile.inc
+++ b/lib/csu/Makefile.inc
@@ -2,4 +2,6 @@
SSP_CFLAGS=
+SED_FIX_NOTE = -i "" -e '/\.note\.tag/s/progbits/note/'
+
.include "../Makefile.inc"
diff --git a/lib/csu/amd64/Makefile b/lib/csu/amd64/Makefile
index aac0c64b51a4..80d14a7ae7af 100644
--- a/lib/csu/amd64/Makefile
+++ b/lib/csu/amd64/Makefile
@@ -19,24 +19,24 @@ CLEANFILES+= crt1.s gcrt1.s Scrt1.s
crt1.s: crt1.c
${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
crt1.o: crt1.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} crt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} crt1.s
gcrt1.s: crt1.c
${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
gcrt1.o: gcrt1.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} gcrt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} gcrt1.s
Scrt1.s: crt1.c
${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
Scrt1.o: Scrt1.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} Scrt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s
realinstall:
${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
diff --git a/lib/csu/amd64/crt1.c b/lib/csu/amd64/crt1.c
index 998477aafd0c..f33aad64fbf6 100644
--- a/lib/csu/amd64/crt1.c
+++ b/lib/csu/amd64/crt1.c
@@ -37,16 +37,10 @@ __FBSDID("$FreeBSD$");
#include "libc_private.h"
#include "crtbrand.c"
-
-extern int _DYNAMIC;
-#pragma weak _DYNAMIC
+#include "ignore_init.c"
typedef void (*fptr)(void);
-extern void _fini(void);
-extern void _init(void);
-extern int main(int, char **, char **);
-
#ifdef GCRT
extern void _mcleanup(void);
extern void monstartup(void *, void *);
@@ -54,9 +48,6 @@ extern int eprol;
extern int etext;
#endif
-char **environ;
-const char *__progname = "";
-
void _start(char **, void (*)(void));
/* The entry function. */
@@ -66,18 +57,13 @@ _start(char **ap, void (*cleanup)(void))
int argc;
char **argv;
char **env;
- const char *s;
argc = *(long *)(void *)ap;
argv = ap + 1;
env = ap + 2 + argc;
environ = env;
- if (argc > 0 && argv[0] != NULL) {
- __progname = argv[0];
- for (s = __progname; *s != '\0'; s++)
- if (*s == '/')
- __progname = s + 1;
- }
+ if (argc > 0 && argv[0] != NULL)
+ handle_progname(argv[0]);
if (&_DYNAMIC != NULL)
atexit(cleanup);
@@ -86,12 +72,10 @@ _start(char **ap, void (*cleanup)(void))
#ifdef GCRT
atexit(_mcleanup);
-#endif
- atexit(_fini);
-#ifdef GCRT
monstartup(&eprol, &etext);
__asm__("eprol:");
#endif
- _init();
- exit( main(argc, argv, env) );
+
+ handle_static_init(argc, argv, env);
+ exit(main(argc, argv, env));
}
diff --git a/lib/csu/arm/Makefile b/lib/csu/arm/Makefile
index 095a9ad14a68..bf4c7b15c422 100644
--- a/lib/csu/arm/Makefile
+++ b/lib/csu/arm/Makefile
@@ -18,24 +18,24 @@ CLEANFILES+= crt1.s gcrt1.s Scrt1.s
crt1.s: crt1.c
${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
crt1.o: crt1.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} crt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} crt1.s
gcrt1.s: crt1.c
${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
gcrt1.o: gcrt1.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} gcrt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} gcrt1.s
Scrt1.s: crt1.c
${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
Scrt1.o: Scrt1.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} Scrt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s
realinstall:
${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
diff --git a/lib/csu/arm/crt1.c b/lib/csu/arm/crt1.c
index f2d4dbf8aae0..127c28d6e7b4 100644
--- a/lib/csu/arm/crt1.c
+++ b/lib/csu/arm/crt1.c
@@ -52,16 +52,11 @@ __FBSDID("$FreeBSD$");
#include "libc_private.h"
#include "crtbrand.c"
+#include "ignore_init.c"
struct Struct_Obj_Entry;
struct ps_strings;
-extern int _DYNAMIC;
-#pragma weak _DYNAMIC
-
-extern void _fini(void);
-extern void _init(void);
-extern int main(int, char **, char **);
extern void _start(int, char **, char **, const struct Struct_Obj_Entry *,
void (*)(void), struct ps_strings *);
@@ -72,8 +67,6 @@ extern int eprol;
extern int etext;
#endif
-char **environ;
-const char *__progname = "";
struct ps_strings *__ps_strings;
void __start(int, char **, char **, struct ps_strings *,
@@ -104,16 +97,11 @@ void
__start(int argc, char **argv, char **env, struct ps_strings *ps_strings,
const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void))
{
- const char *s;
environ = env;
- if (argc > 0 && argv[0] != NULL) {
- __progname = argv[0];
- for (s = __progname; *s != '\0'; s++)
- if (*s == '/')
- __progname = s + 1;
- }
+ if (argc > 0 && argv[0] != NULL)
+ handle_progname(argv[0]);
if (ps_strings != (struct ps_strings *)0)
__ps_strings = ps_strings;
@@ -124,13 +112,10 @@ __start(int argc, char **argv, char **env, struct ps_strings *ps_strings,
_init_tls();
#ifdef GCRT
atexit(_mcleanup);
-#endif
- atexit(_fini);
-#ifdef GCRT
monstartup(&eprol, &etext);
#endif
- _init();
- exit( main(argc, argv, env) );
+ handle_static_init(argc, argv, env);
+ exit(main(argc, argv, env));
}
#ifdef GCRT
diff --git a/lib/csu/common/crtbrand.c b/lib/csu/common/crtbrand.c
index 444d7f128729..04df686ba731 100644
--- a/lib/csu/common/crtbrand.c
+++ b/lib/csu/common/crtbrand.c
@@ -27,10 +27,7 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
-
-#define ABI_VENDOR "FreeBSD"
-#define ABI_SECTION ".note.ABI-tag"
-#define ABI_NOTETYPE 1
+#include "notes.h"
/*
* Special ".note" entry specifying the ABI version. See
@@ -55,15 +52,15 @@ __FBSDID("$FreeBSD$");
* These steps are done in the invididual Makefiles for each applicable arch.
*/
static const struct {
- int32_t namesz;
- int32_t descsz;
- int32_t type;
- char name[sizeof ABI_VENDOR];
- int32_t desc;
-} abitag __attribute__ ((section (ABI_SECTION), aligned(4))) __used = {
- sizeof ABI_VENDOR,
- sizeof(int32_t),
- ABI_NOTETYPE,
- ABI_VENDOR,
- __FreeBSD_version
+ int32_t namesz;
+ int32_t descsz;
+ int32_t type;
+ char name[sizeof(NOTE_FREEBSD_VENDOR)];
+ int32_t desc;
+} abitag __attribute__ ((section (NOTE_SECTION), aligned(4))) __used = {
+ .namesz = sizeof(NOTE_FREEBSD_VENDOR),
+ .descsz = sizeof(int32_t),
+ .type = ABI_NOTETYPE,
+ .name = NOTE_FREEBSD_VENDOR,
+ .desc = __FreeBSD_version
};
diff --git a/lib/csu/common/ignore_init.c b/lib/csu/common/ignore_init.c
new file mode 100644
index 000000000000..e3d2441936b3
--- /dev/null
+++ b/lib/csu/common/ignore_init.c
@@ -0,0 +1,114 @@
+/*-
+ * Copyright 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>
+__FBSDID("$FreeBSD$");
+
+#include "notes.h"
+
+extern int main(int, char **, char **);
+
+extern void (*__preinit_array_start[])(int, char **, char **) __hidden;
+extern void (*__preinit_array_end[])(int, char **, char **) __hidden;
+extern void (*__init_array_start[])(int, char **, char **) __hidden;
+extern void (*__init_array_end[])(int, char **, char **) __hidden;
+extern void (*__fini_array_start[])(void) __hidden;
+extern void (*__fini_array_end[])(void) __hidden;
+extern void _fini(void) __hidden;
+extern void _init(void) __hidden;
+
+extern int _DYNAMIC;
+#pragma weak _DYNAMIC
+
+char **environ;
+const char *__progname = "";
+
+static void
+finalizer(void)
+{
+ void (*fn)(void);
+ size_t array_size, n;
+
+ array_size = __fini_array_end - __fini_array_start;
+ for (n = array_size; n > 0; n--) {
+ fn = __fini_array_start[n - 1];
+ if ((uintptr_t)fn != 0 && (uintptr_t)fn != 1)
+ (fn)();
+ }
+ _fini();
+}
+
+static inline void
+handle_static_init(int argc, char **argv, char **env)
+{
+ void (*fn)(int, char **, char **);
+ size_t array_size, n;
+
+ if (&_DYNAMIC != NULL)
+ return;
+
+ atexit(finalizer);
+
+ array_size = __preinit_array_end - __preinit_array_start;
+ for (n = 0; n < array_size; n++) {
+ fn = __preinit_array_start[n];
+ if ((uintptr_t)fn != 0 && (uintptr_t)fn != 1)
+ fn(argc, argv, env);
+ }
+ _init();
+ array_size = __init_array_end - __init_array_start;
+ for (n = 0; n < array_size; n++) {
+ fn = __init_array_start[n];
+ if ((uintptr_t)fn != 0 && (uintptr_t)fn != 1)
+ fn(argc, argv, env);
+ }
+}
+
+static inline void
+handle_progname(const char *v)
+{
+ const char *s;
+
+ __progname = v;
+ for (s = __progname; *s != '\0'; s++) {
+ if (*s == '/')
+ __progname = s + 1;
+ }
+}
+
+static const struct {
+ int32_t namesz;
+ int32_t descsz;
+ int32_t type;
+ char name[sizeof(NOTE_FREEBSD_VENDOR)];
+ uint32_t desc;
+} crt_noinit_tag __attribute__ ((section (NOTE_SECTION),
+ aligned(4))) __used = {
+ .namesz = sizeof(NOTE_FREEBSD_VENDOR),
+ .descsz = sizeof(uint32_t),
+ .type = CRT_NOINIT_NOTETYPE,
+ .name = NOTE_FREEBSD_VENDOR,
+ .desc = 0
+};
diff --git a/lib/csu/common/notes.h b/lib/csu/common/notes.h
new file mode 100644
index 000000000000..fcc2b6684617
--- /dev/null
+++ b/lib/csu/common/notes.h
@@ -0,0 +1,38 @@
+/*-
+ * Copyright 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef CSU_COMMON_NOTES_H
+#define CSU_COMMON_NOTES_H
+
+#define NOTE_FREEBSD_VENDOR "FreeBSD"
+
+#define NOTE_SECTION ".note.tag"
+
+#define ABI_NOTETYPE 1
+#define CRT_NOINIT_NOTETYPE 2
+
+#endif
diff --git a/lib/csu/i386-elf/Makefile b/lib/csu/i386-elf/Makefile
index b100d7a2bca2..286c15cb9055 100644
--- a/lib/csu/i386-elf/Makefile
+++ b/lib/csu/i386-elf/Makefile
@@ -18,20 +18,20 @@ CLEANFILES+= crt1_c.s gcrt1_c.s Scrt1_c.s
gcrt1_c.s: crt1_c.c
${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1_c.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
gcrt1_c.o: gcrt1_c.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} gcrt1_c.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} gcrt1_c.s
gcrt1.o: gcrt1_c.o crt1_s.o
${LD} ${LDFLAGS} -o gcrt1.o -r crt1_s.o gcrt1_c.o
crt1_c.s: crt1_c.c
${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1_c.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
crt1_c.o: crt1_c.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} crt1_c.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} crt1_c.s
crt1.o: crt1_c.o crt1_s.o
${LD} ${LDFLAGS} -o crt1.o -r crt1_s.o crt1_c.o
@@ -39,10 +39,10 @@ crt1.o: crt1_c.o crt1_s.o
Scrt1_c.s: crt1_c.c
${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1_c.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
Scrt1_c.o: Scrt1_c.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} Scrt1_c.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1_c.s
Scrt1.o: Scrt1_c.o crt1_s.o
${LD} ${LDFLAGS} -o Scrt1.o -r crt1_s.o Scrt1_c.o
diff --git a/lib/csu/i386-elf/crt1_c.c b/lib/csu/i386-elf/crt1_c.c
index 1eadc7c01c08..324906955e73 100644
--- a/lib/csu/i386-elf/crt1_c.c
+++ b/lib/csu/i386-elf/crt1_c.c
@@ -39,15 +39,10 @@ __FBSDID("$FreeBSD$");
#include "libc_private.h"
#include "crtbrand.c"
-
-extern int _DYNAMIC;
-#pragma weak _DYNAMIC
+#include "ignore_init.c"
typedef void (*fptr)(void);
-extern void _fini(void);
-extern void _init(void);
-extern int main(int, char **, char **);
extern void _start(char *, ...);
#ifdef GCRT
@@ -57,9 +52,6 @@ extern int eprol;
extern int etext;
#endif
-char **environ;
-const char *__progname = "";
-
void _start1(fptr, int, char *[]) __dead2;
/* The entry function, C part. */
@@ -67,16 +59,11 @@ void
_start1(fptr cleanup, int argc, char *argv[])
{
char **env;
- const char *s;
env = argv + argc + 1;
environ = env;
- if (argc > 0 && argv[0] != NULL) {
- __progname = argv[0];
- for (s = __progname; *s != '\0'; s++)
- if (*s == '/')
- __progname = s + 1;
- }
+ if (argc > 0 && argv[0] != NULL)
+ handle_progname(argv[0]);
if (&_DYNAMIC != NULL)
atexit(cleanup);
@@ -85,14 +72,12 @@ _start1(fptr cleanup, int argc, char *argv[])
#ifdef GCRT
atexit(_mcleanup);
-#endif
- atexit(_fini);
-#ifdef GCRT
monstartup(&eprol, &etext);
__asm__("eprol:");
#endif
- _init();
- exit( main(argc, argv, env) );
+
+ handle_static_init(argc, argv, env);
+ exit(main(argc, argv, env));
}
__asm(".hidden _start1");
diff --git a/lib/csu/ia64/Makefile b/lib/csu/ia64/Makefile
index 41d2b9cf8f46..b12e88822d17 100644
--- a/lib/csu/ia64/Makefile
+++ b/lib/csu/ia64/Makefile
@@ -24,7 +24,7 @@ crtbrand.s: crtbrand.c
sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
crtbrand.o: crtbrand.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} crtbrand.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} crtbrand.s
crt1.o: crt1_.o crtbrand.o
${LD} ${LDFLAGS} -r -o ${.TARGET} crt1_.o crtbrand.o
@@ -37,7 +37,7 @@ gcrtbrand.s: crtbrand.c
sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
gcrtbrand.o: gcrtbrand.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} gcrtbrand.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} gcrtbrand.s
gcrt1.o: gcrt1_.o gcrtbrand.o
${LD} ${LDFLAGS} -r -o ${.TARGET} ${.ALLSRC}
@@ -50,7 +50,7 @@ Scrtbrand.s: crtbrand.c
sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
Scrtbrand.o: Scrtbrand.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} Scrtbrand.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrtbrand.s
Scrt1.o: Scrt1_.o Scrtbrand.o
${LD} ${LDFLAGS} -r -o ${.TARGET} ${.ALLSRC}
diff --git a/lib/csu/mips/Makefile b/lib/csu/mips/Makefile
index 095a9ad14a68..bf4c7b15c422 100644
--- a/lib/csu/mips/Makefile
+++ b/lib/csu/mips/Makefile
@@ -18,24 +18,24 @@ CLEANFILES+= crt1.s gcrt1.s Scrt1.s
crt1.s: crt1.c
${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
crt1.o: crt1.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} crt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} crt1.s
gcrt1.s: crt1.c
${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
gcrt1.o: gcrt1.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} gcrt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} gcrt1.s
Scrt1.s: crt1.c
${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
Scrt1.o: Scrt1.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} Scrt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s
realinstall:
${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
diff --git a/lib/csu/mips/crt1.c b/lib/csu/mips/crt1.c
index 5fd7b8a81a92..1968f06f3180 100644
--- a/lib/csu/mips/crt1.c
+++ b/lib/csu/mips/crt1.c
@@ -43,19 +43,11 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include "libc_private.h"
#include "crtbrand.c"
+#include "ignore_init.c"
struct Struct_Obj_Entry;
struct ps_strings;
-#ifndef NOSHARED
-extern int _DYNAMIC;
-#pragma weak _DYNAMIC
-#endif
-
-extern void _init(void);
-extern void _fini(void);
-extern int main(int, char **, char **);
-
#ifdef GCRT
extern void _mcleanup(void);
extern void monstartup(void *, void *);
@@ -63,9 +55,6 @@ extern int eprol;
extern int etext;
#endif
-char **environ;
-const char *__progname = "";
-
void __start(char **, void (*)(void), struct Struct_Obj_Entry *, struct ps_strings *);
/* The entry function. */
@@ -83,29 +72,21 @@ __start(char **ap,
argv = ap + 1;
env = ap + 2 + argc;
environ = env;
- if (argc > 0 && argv[0] != NULL) {
- const char *s;
- __progname = argv[0];
- for (s = __progname; *s != '\0'; s++)
- if (*s == '/')
- __progname = s + 1;
- }
+ if (argc > 0 && argv[0] != NULL)
+ handle_progname(argv[0]);
-#ifndef NOSHARED
if (&_DYNAMIC != NULL)
atexit(cleanup);
-#endif
+ else
+ _init_tls();
+
#ifdef GCRT
atexit(_mcleanup);
-#endif
- atexit(_fini);
-#ifdef GCRT
monstartup(&eprol, &etext);
#endif
-#ifndef NOGPREL
- _init();
-#endif
- exit( main(argc, argv, env) );
+
+ handle_static_init(argc, argv, env);
+ exit(main(argc, argv, env));
}
#ifdef GCRT
diff --git a/lib/csu/powerpc/Makefile b/lib/csu/powerpc/Makefile
index 095a9ad14a68..bf4c7b15c422 100644
--- a/lib/csu/powerpc/Makefile
+++ b/lib/csu/powerpc/Makefile
@@ -18,24 +18,24 @@ CLEANFILES+= crt1.s gcrt1.s Scrt1.s
crt1.s: crt1.c
${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
crt1.o: crt1.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} crt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} crt1.s
gcrt1.s: crt1.c
${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
gcrt1.o: gcrt1.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} gcrt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} gcrt1.s
Scrt1.s: crt1.c
${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
Scrt1.o: Scrt1.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} Scrt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s
realinstall:
${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
diff --git a/lib/csu/powerpc/crt1.c b/lib/csu/powerpc/crt1.c
index 67de2f5d6f42..c3be90da3481 100644
--- a/lib/csu/powerpc/crt1.c
+++ b/lib/csu/powerpc/crt1.c
@@ -52,17 +52,11 @@ __FBSDID("$FreeBSD$");
#include "libc_private.h"
#include "crtbrand.c"
+#include "ignore_init.c"
struct Struct_Obj_Entry;
struct ps_strings;
-extern int _DYNAMIC;
-#pragma weak _DYNAMIC
-
-extern void _fini(void);
-extern void _init(void);
-extern int main(int, char **, char **);
-
#ifdef GCRT
extern void _mcleanup(void);
extern void monstartup(void *, void *);
@@ -70,8 +64,6 @@ extern int eprol;
extern int etext;
#endif
-char **environ;
-const char *__progname = "";
struct ps_strings *__ps_strings;
void _start(int, char **, char **, const struct Struct_Obj_Entry *,
@@ -88,16 +80,11 @@ _start(int argc, char **argv, char **env,
const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void),
struct ps_strings *ps_strings)
{
- const char *s;
environ = env;
- if (argc > 0 && argv[0] != NULL) {
- __progname = argv[0];
- for (s = __progname; *s != '\0'; s++)
- if (*s == '/')
- __progname = s + 1;
- }
+ if (argc > 0 && argv[0] != NULL)
+ handle_progname(argv[0]);
if (ps_strings != (struct ps_strings *)0)
__ps_strings = ps_strings;
@@ -109,13 +96,11 @@ _start(int argc, char **argv, char **env,
#ifdef GCRT
atexit(_mcleanup);
-#endif
- atexit(_fini);
-#ifdef GCRT
monstartup(&eprol, &etext);
#endif
- _init();
- exit( main(argc, argv, env) );
+
+ handle_static_init(argc, argv, env);
+ exit(main(argc, argv, env));
}
#ifdef GCRT
diff --git a/lib/csu/powerpc64/Makefile b/lib/csu/powerpc64/Makefile
index 095a9ad14a68..123391e12a55 100644
--- a/lib/csu/powerpc64/Makefile
+++ b/lib/csu/powerpc64/Makefile
@@ -6,7 +6,8 @@ SRCS= crt1.c crti.S crtn.S
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
CFLAGS+= -I${.CURDIR}/../common \
- -I${.CURDIR}/../../libc/include
+ -I${.CURDIR}/../../libc/include \
+ -mlongcall
all: ${OBJS}
@@ -18,24 +19,24 @@ CLEANFILES+= crt1.s gcrt1.s Scrt1.s
crt1.s: crt1.c
${CC} ${CFLAGS} -S -o ${.TARGET} ${.CURDIR}/crt1.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
crt1.o: crt1.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} crt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} crt1.s
gcrt1.s: crt1.c
${CC} ${CFLAGS} -DGCRT -S -o ${.TARGET} ${.CURDIR}/crt1.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
gcrt1.o: gcrt1.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} gcrt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} gcrt1.s
Scrt1.s: crt1.c
${CC} ${CFLAGS} -fPIC -DPIC -S -o ${.TARGET} ${.CURDIR}/crt1.c
- sed -i "" -e '/\.note\.ABI-tag/s/progbits/note/' ${.TARGET}
+ sed ${SED_FIX_NOTE} ${.TARGET}
Scrt1.o: Scrt1.s
- ${CC} ${CFLAGS} -c -o ${.TARGET} Scrt1.s
+ ${CC} ${ACFLAGS} -c -o ${.TARGET} Scrt1.s
realinstall:
${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
diff --git a/lib/csu/powerpc64/crt1.c b/lib/csu/powerpc64/crt1.c
index 080bd4d54d28..a7c3581361f0 100644
--- a/lib/csu/powerpc64/crt1.c
+++ b/lib/csu/powerpc64/crt1.c
@@ -52,16 +52,11 @@ __FBSDID("$FreeBSD$");
#include "libc_private.h"
#include "crtbrand.c"
+#include "ignore_init.c"
struct Struct_Obj_Entry;
struct ps_strings;
-extern int _DYNAMIC;
-#pragma weak _DYNAMIC
-
-extern void _fini(void);
-extern void _init(void);
-extern int main(int, char **, char **);
extern void _start(int, char **, char **, const struct Struct_Obj_Entry *,
void (*)(void), struct ps_strings *);
@@ -72,8 +67,6 @@ extern int eprol;
extern int etext;
#endif
-char **environ;
-const char *__progname = "";
struct ps_strings *__ps_strings;
/* The entry function. */
@@ -87,16 +80,11 @@ _start(int argc, char **argv, char **env,
const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void),
struct ps_strings *ps_strings)
{
- const char *s;
environ = env;
- if (argc > 0 && argv[0] != NULL) {
- __progname = argv[0];
- for (s = __progname; *s != '\0'; s++)
- if (*s == '/')
- __progname = s + 1;
- }
+ if (argc > 0 && argv[0] != NULL)
+ handle_progname(argv[0]);
if (ps_strings != (struct ps_strings *)0)
__ps_strings = ps_strings;
@@ -108,13 +96,11 @@ _start(int argc, char **argv, char **env,
#ifdef GCRT
atexit(_mcleanup);
-#endif
- atexit(_fini);
-#ifdef GCRT
monstartup(&eprol, &etext);
#endif
- _init();
- exit( main(argc, argv, env) );
+
+ handle_static_init(argc, argv, env);
+ exit(main(argc, argv, env));
}
#ifdef GCRT
diff --git a/lib/csu/sparc64/crt1.c b/lib/csu/sparc64/crt1.c
index 3593c956520b..3b3ecc268e6f 100644
--- a/lib/csu/sparc64/crt1.c
+++ b/lib/csu/sparc64/crt1.c
@@ -43,16 +43,11 @@ __FBSDID("$FreeBSD$");
#include "libc_private.h"
#include "crtbrand.c"
+#include "ignore_init.c"
struct Struct_Obj_Entry;
struct ps_strings;
-extern int _DYNAMIC;
-#pragma weak _DYNAMIC
-
-extern void _fini(void);
-extern void _init(void);
-extern int main(int, char **, char **);
extern void __sparc_utrap_setup(void);
#ifdef GCRT
@@ -62,9 +57,6 @@ extern int eprol;
extern int etext;
#endif
-char **environ;
-const char *__progname = "";
-
void _start(char **, void (*)(void), struct Struct_Obj_Entry *,
struct ps_strings *);
@@ -89,18 +81,13 @@ _start(char **ap, void (*cleanup)(void), struct Struct_Obj_Entry *obj __unused,
int argc;
char **argv;
char **env;
- const char *s;
argc = *(long *)(void *)ap;
argv = ap + 1;
env = ap + 2 + argc;
environ = env;
- if (argc > 0 && argv[0] != NULL) {
- __progname = argv[0];
- for (s = __progname; *s != '\0'; s++)
- if (*s == '/')
- __progname = s + 1;
- }
+ if (argc > 0 && argv[0] != NULL)
+ handle_progname(argv[0]);
if (&_DYNAMIC != NULL)
atexit(cleanup);
@@ -110,13 +97,11 @@ _start(char **ap, void (*cleanup)(void), struct Struct_Obj_Entry *obj __unused,
}
#ifdef GCRT
atexit(_mcleanup);
-#endif
- atexit(_fini);
-#ifdef GCRT
monstartup(&eprol, &etext);
#endif
- _init();
- exit( main(argc, argv, env) );
+
+ handle_static_init(argc, argv, env);
+ exit(main(argc, argv, env));
}
#ifdef GCRT
diff --git a/lib/libarchive/Makefile b/lib/libarchive/Makefile
index 92ca9544871c..018ad321fee3 100644
--- a/lib/libarchive/Makefile
+++ b/lib/libarchive/Makefile
@@ -20,7 +20,7 @@ LDADD+= -lbsdxml
# FreeBSD SHLIB_MAJOR value is managed as part of the FreeBSD system.
# It has no real relation to the libarchive version number.
-SHLIB_MAJOR= 5
+SHLIB_MAJOR= 6
CFLAGS+= -DPLATFORM_CONFIG_H=\"${.CURDIR}/config_freebsd.h\"
CFLAGS+= -I${.OBJDIR}
@@ -34,44 +34,69 @@ DPADD+= ${LIBMD}
LDADD+= -lmd
.endif
+.if ${MK_ICONV} != "no"
+CFLAGS+= -DHAVE_ICONV=1 -DHAVE_ICONV_H=1 -DICONV_CONST=const
+.endif
+
+.if ${MACHINE_ARCH:Marm*} != "" || ${MACHINE_ARCH:Mmips*} != "" || \
+ ${MACHINE_ARCH:Msparc64*} != "" || ${MACHINE_ARCH:Mia64*} != ""
+NO_WCAST_ALIGN= yes
+.if ${MACHINE_ARCH:M*64*} == ""
+CFLAGS+= -DPPMD_32BIT
+.endif
+.endif
+NO_WCAST_ALIGN.clang=
+
.PATH: ${LIBARCHIVEDIR}/libarchive
# Headers to be installed in /usr/include
INCS= archive.h archive_entry.h
# Sources to be compiled.
-SRCS= archive_check_magic.c \
+SRCS= archive_acl.c \
+ archive_check_magic.c \
+ archive_crypto.c \
archive_entry.c \
archive_entry_copy_stat.c \
+ archive_entry_link_resolver.c \
+ archive_entry_sparse.c \
archive_entry_stat.c \
archive_entry_strmode.c \
- archive_entry_link_resolver.c \
archive_entry_xattr.c \
+ archive_options.c \
+ archive_ppmd7.c \
+ archive_rb.c \
archive_read.c \
archive_read_data_into_fd.c \
- archive_read_disk.c \
archive_read_disk_entry_from_file.c \
+ archive_read_disk_posix.c \
archive_read_disk_set_standard_lookup.c \
archive_read_extract.c \
archive_read_open_fd.c \
archive_read_open_file.c \
archive_read_open_filename.c \
archive_read_open_memory.c \
- archive_read_support_compression_all.c \
- archive_read_support_compression_bzip2.c \
- archive_read_support_compression_compress.c \
- archive_read_support_compression_gzip.c \
- archive_read_support_compression_none.c \
- archive_read_support_compression_program.c \
- archive_read_support_compression_rpm.c \
- archive_read_support_compression_uu.c \
- archive_read_support_compression_xz.c \
+ archive_read_set_options.c \
+ archive_read_support_filter_all.c \
+ archive_read_support_filter_bzip2.c \
+ archive_read_support_filter_compress.c \
+ archive_read_support_filter_gzip.c \
+ archive_read_support_filter_none.c \
+ archive_read_support_filter_program.c \
+ archive_read_support_filter_rpm.c \
+ archive_read_support_filter_uu.c \
+ archive_read_support_filter_xz.c \
+ archive_read_support_format_7zip.c \
archive_read_support_format_all.c \
archive_read_support_format_ar.c \
+ archive_read_support_format_by_code.c \
+ archive_read_support_format_cab.c \
archive_read_support_format_cpio.c \
archive_read_support_format_empty.c \
archive_read_support_format_iso9660.c \
+ archive_read_support_format_lha.c \
archive_read_support_format_mtree.c \
+ archive_read_support_format_rar.c \
archive_read_support_format_raw.c \
archive_read_support_format_tar.c \
archive_read_support_format_xar.c \
@@ -81,150 +106,231 @@ SRCS= archive_check_magic.c \
archive_util.c \
archive_virtual.c \
archive_write.c \
- archive_write_disk.c \
archive_write_disk_set_standard_lookup.c \
+ archive_write_disk_posix.c \
archive_write_open_fd.c \
archive_write_open_file.c \
archive_write_open_filename.c \
archive_write_open_memory.c \
- archive_write_set_compression_bzip2.c \
- archive_write_set_compression_compress.c \
- archive_write_set_compression_gzip.c \
- archive_write_set_compression_none.c \
- archive_write_set_compression_program.c \
- archive_write_set_compression_xz.c \
+ archive_write_add_filter_bzip2.c \
+ archive_write_add_filter_compress.c \
+ archive_write_add_filter_gzip.c \
+ archive_write_add_filter_none.c \
+ archive_write_add_filter_program.c \
+ archive_write_add_filter_xz.c \
archive_write_set_format.c \
+ archive_write_set_format_7zip.c \
archive_write_set_format_ar.c \
archive_write_set_format_by_name.c \
archive_write_set_format_cpio.c \
archive_write_set_format_cpio_newc.c \
+ archive_write_set_format_gnutar.c \
+ archive_write_set_format_iso9660.c \
archive_write_set_format_mtree.c \
archive_write_set_format_pax.c \
archive_write_set_format_shar.c \
archive_write_set_format_ustar.c \
+ archive_write_set_format_xar.c \
archive_write_set_format_zip.c \
+ archive_write_set_options.c \
filter_fork.c
# Man pages to be installed.
MAN= archive_entry.3 \
+ archive_entry_acl.3 \
+ archive_entry_linkify.3 \
+ archive_entry_paths.3 \
+ archive_entry_perms.3 \
+ archive_entry_stat.3 \
+ archive_entry_time.3 \
archive_read.3 \
+ archive_read_data.3 \
archive_read_disk.3 \
+ archive_read_extract.3 \
+ archive_read_filter.3 \
+ archive_read_format.3 \
+ archive_read_free.3 \
+ archive_read_header.3 \
+ archive_read_new.3 \
+ archive_read_open.3 \
+ archive_read_set_options.3 \
archive_util.3 \
archive_write.3 \
+ archive_write_blocksize.3 \
+ archive_write_data.3 \
archive_write_disk.3 \
+ archive_write_filter.3 \
+ archive_write_finish_entry.3 \
+ archive_write_format.3 \
+ archive_write_free.3 \
+ archive_write_header.3 \
+ archive_write_new.3 \
+ archive_write_open.3 \
+ archive_write_set_options.3 \
cpio.5 \
libarchive.3 \
+ libarchive_internals.3 \
libarchive-formats.5 \
tar.5
# Symlink the man pages under each function name.
-MLINKS+= archive_entry.3 archive_entry_acl_add_entry.3
-MLINKS+= archive_entry.3 archive_entry_acl_add_entry_w.3
-MLINKS+= archive_entry.3 archive_entry_acl_clear.3
-MLINKS+= archive_entry.3 archive_entry_acl_count.3
-MLINKS+= archive_entry.3 archive_entry_acl_next.3
-MLINKS+= archive_entry.3 archive_entry_acl_next_w.3
-MLINKS+= archive_entry.3 archive_entry_acl_reset.3
-MLINKS+= archive_entry.3 archive_entry_acl_text_w.3
MLINKS+= archive_entry.3 archive_entry_clear.3
MLINKS+= archive_entry.3 archive_entry_clone.3
-MLINKS+= archive_entry.3 archive_entry_copy_fflags_text.3
-MLINKS+= archive_entry.3 archive_entry_copy_fflags_text_w.3
-MLINKS+= archive_entry.3 archive_entry_copy_gname.3
-MLINKS+= archive_entry.3 archive_entry_copy_gname_w.3
-MLINKS+= archive_entry.3 archive_entry_copy_hardlink_w.3
-MLINKS+= archive_entry.3 archive_entry_copy_link.3
-MLINKS+= archive_entry.3 archive_entry_copy_link_w.3
-MLINKS+= archive_entry.3 archive_entry_copy_pathname_w.3
-MLINKS+= archive_entry.3 archive_entry_copy_stat.3
-MLINKS+= archive_entry.3 archive_entry_copy_symlink_w.3
-MLINKS+= archive_entry.3 archive_entry_copy_uname.3
-MLINKS+= archive_entry.3 archive_entry_copy_uname_w.3
-MLINKS+= archive_entry.3 archive_entry_dev.3
-MLINKS+= archive_entry.3 archive_entry_devmajor.3
-MLINKS+= archive_entry.3 archive_entry_devminor.3
-MLINKS+= archive_entry.3 archive_entry_filetype.3
-MLINKS+= archive_entry.3 archive_entry_fflags.3
-MLINKS+= archive_entry.3 archive_entry_fflags_text.3
MLINKS+= archive_entry.3 archive_entry_free.3
-MLINKS+= archive_entry.3 archive_entry_gid.3
-MLINKS+= archive_entry.3 archive_entry_gname.3
-MLINKS+= archive_entry.3 archive_entry_gname_w.3
-MLINKS+= archive_entry.3 archive_entry_hardlink.3
-MLINKS+= archive_entry.3 archive_entry_ino.3
-MLINKS+= archive_entry.3 archive_entry_mode.3
-MLINKS+= archive_entry.3 archive_entry_mtime.3
-MLINKS+= archive_entry.3 archive_entry_mtime_nsec.3
-MLINKS+= archive_entry.3 archive_entry_nlink.3
MLINKS+= archive_entry.3 archive_entry_new.3
-MLINKS+= archive_entry.3 archive_entry_pathname.3
-MLINKS+= archive_entry.3 archive_entry_pathname_w.3
-MLINKS+= archive_entry.3 archive_entry_rdev.3
-MLINKS+= archive_entry.3 archive_entry_rdevmajor.3
-MLINKS+= archive_entry.3 archive_entry_rdevminor.3
-MLINKS+= archive_entry.3 archive_entry_set_atime.3
-MLINKS+= archive_entry.3 archive_entry_set_ctime.3
-MLINKS+= archive_entry.3 archive_entry_set_dev.3
-MLINKS+= archive_entry.3 archive_entry_set_devmajor.3
-MLINKS+= archive_entry.3 archive_entry_set_devminor.3
-MLINKS+= archive_entry.3 archive_entry_set_fflags.3
-MLINKS+= archive_entry.3 archive_entry_set_gid.3
-MLINKS+= archive_entry.3 archive_entry_set_gname.3
-MLINKS+= archive_entry.3 archive_entry_set_hardlink.3
-MLINKS+= archive_entry.3 archive_entry_set_link.3
-MLINKS+= archive_entry.3 archive_entry_set_mode.3
-MLINKS+= archive_entry.3 archive_entry_set_mtime.3
-MLINKS+= archive_entry.3 archive_entry_set_nlink.3
-MLINKS+= archive_entry.3 archive_entry_set_pathname.3
-MLINKS+= archive_entry.3 archive_entry_set_rdev.3
-MLINKS+= archive_entry.3 archive_entry_set_rdevmajor.3
-MLINKS+= archive_entry.3 archive_entry_set_rdevminor.3
-MLINKS+= archive_entry.3 archive_entry_set_size.3
-MLINKS+= archive_entry.3 archive_entry_set_symlink.3
-MLINKS+= archive_entry.3 archive_entry_set_uid.3
-MLINKS+= archive_entry.3 archive_entry_set_uname.3
-MLINKS+= archive_entry.3 archive_entry_size.3
-MLINKS+= archive_entry.3 archive_entry_stat.3
-MLINKS+= archive_entry.3 archive_entry_symlink.3
-MLINKS+= archive_entry.3 archive_entry_uid.3
-MLINKS+= archive_entry.3 archive_entry_uname.3
-MLINKS+= archive_entry.3 archive_entry_uname_w.3
-MLINKS+= archive_read.3 archive_read_data.3
-MLINKS+= archive_read.3 archive_read_data_block.3
-MLINKS+= archive_read.3 archive_read_data_into_buffer.3
-MLINKS+= archive_read.3 archive_read_data_into_fd.3
-MLINKS+= archive_read.3 archive_read_data_skip.3
-MLINKS+= archive_read.3 archive_read_extract.3
-MLINKS+= archive_read.3 archive_read_extract_set_progress_callback.3
-MLINKS+= archive_read.3 archive_read_extract_set_skip_file.3
-MLINKS+= archive_read.3 archive_read_finish.3
-MLINKS+= archive_read.3 archive_read_new.3
-MLINKS+= archive_read.3 archive_read_next_header.3
-MLINKS+= archive_read.3 archive_read_next_header2.3
-MLINKS+= archive_read.3 archive_read_open.3
-MLINKS+= archive_read.3 archive_read_open2.3
-MLINKS+= archive_read.3 archive_read_open_FILE.3
-MLINKS+= archive_read.3 archive_read_open_fd.3
-MLINKS+= archive_read.3 archive_read_open_file.3
-MLINKS+= archive_read.3 archive_read_open_filename.3
-MLINKS+= archive_read.3 archive_read_open_memory.3
-MLINKS+= archive_read.3 archive_read_support_compression_all.3
-MLINKS+= archive_read.3 archive_read_support_compression_bzip2.3
-MLINKS+= archive_read.3 archive_read_support_compression_compress.3
-MLINKS+= archive_read.3 archive_read_support_compression_gzip.3
-MLINKS+= archive_read.3 archive_read_support_compression_lzma.3
-MLINKS+= archive_read.3 archive_read_support_compression_none.3
-MLINKS+= archive_read.3 archive_read_support_compression_program.3
-MLINKS+= archive_read.3 archive_read_support_compression_program_signature.3
-MLINKS+= archive_read.3 archive_read_support_compression_xz.3
-MLINKS+= archive_read.3 archive_read_support_format_all.3
-MLINKS+= archive_read.3 archive_read_support_format_ar.3
-MLINKS+= archive_read.3 archive_read_support_format_cpio.3
-MLINKS+= archive_read.3 archive_read_support_format_empty.3
-MLINKS+= archive_read.3 archive_read_support_format_iso9660.3
-MLINKS+= archive_read.3 archive_read_support_format_raw.3
-MLINKS+= archive_read.3 archive_read_support_format_tar.3
-MLINKS+= archive_read.3 archive_read_support_format_zip.3
+MLINKS+= archive_entry_acl.3 archive_entry_acl_add_entry.3
+MLINKS+= archive_entry_acl.3 archive_entry_acl_add_entry_w.3
+MLINKS+= archive_entry_acl.3 archive_entry_acl_clear.3
+MLINKS+= archive_entry_acl.3 archive_entry_acl_count.3
+MLINKS+= archive_entry_acl.3 archive_entry_acl_next.3
+MLINKS+= archive_entry_acl.3 archive_entry_acl_next_w.3
+MLINKS+= archive_entry_acl.3 archive_entry_acl_reset.3
+MLINKS+= archive_entry_acl.3 archive_entry_acl_text_w.3
+MLINKS+= archive_entry_linkify.3 archive_entry_linkresolver.3
+MLINKS+= archive_entry_linkify.3 archive_entry_linkresolver_new.3
+MLINKS+= archive_entry_linkify.3 archive_entry_linkresolver_set_strategy.3
+MLINKS+= archive_entry_linkify.3 archive_entry_linkresolver_free.3
+MLINKS+= archive_entry_paths.3 archive_entry_copy_hardlink.3
+MLINKS+= archive_entry_paths.3 archive_entry_copy_hardlink_w.3
+MLINKS+= archive_entry_paths.3 archive_entry_copy_link.3
+MLINKS+= archive_entry_paths.3 archive_entry_copy_link_w.3
+MLINKS+= archive_entry_paths.3 archive_entry_copy_pathname.3
+MLINKS+= archive_entry_paths.3 archive_entry_copy_pathname_w.3
+MLINKS+= archive_entry_paths.3 archive_entry_copy_sourcepath.3
+MLINKS+= archive_entry_paths.3 archive_entry_copy_symlink.3
+MLINKS+= archive_entry_paths.3 archive_entry_copy_symlink_w.3
+MLINKS+= archive_entry_paths.3 archive_entry_hardlink.3
+MLINKS+= archive_entry_paths.3 archive_entry_hardlink_w.3
+MLINKS+= archive_entry_paths.3 archive_entry_pathname.3
+MLINKS+= archive_entry_paths.3 archive_entry_pathname_w.3
+MLINKS+= archive_entry_paths.3 archive_entry_set_hardlink.3
+MLINKS+= archive_entry_paths.3 archive_entry_set_link.3
+MLINKS+= archive_entry_paths.3 archive_entry_set_pathname.3
+MLINKS+= archive_entry_paths.3 archive_entry_set_symlink.3
+MLINKS+= archive_entry_paths.3 archive_entry_symlink.3
+MLINKS+= archive_entry_paths.3 archive_entry_symlink_w.3
+MLINKS+= archive_entry_paths.3 archive_entry_update_symlink_utf8.3
+MLINKS+= archive_entry_paths.3 archive_entry_update_hardlink_utf8.3
+MLINKS+= archive_entry_perms.3 archive_entry_copy_fflags_text.3
+MLINKS+= archive_entry_perms.3 archive_entry_copy_fflags_text_w.3
+MLINKS+= archive_entry_perms.3 archive_entry_copy_gname.3
+MLINKS+= archive_entry_perms.3 archive_entry_copy_gname_w.3
+MLINKS+= archive_entry_perms.3 archive_entry_copy_uname.3
+MLINKS+= archive_entry_perms.3 archive_entry_copy_uname_w.3
+MLINKS+= archive_entry_perms.3 archive_entry_fflags.3
+MLINKS+= archive_entry_perms.3 archive_entry_fflags_text.3
+MLINKS+= archive_entry_perms.3 archive_entry_gid.3
+MLINKS+= archive_entry_perms.3 archive_entry_gname.3
+MLINKS+= archive_entry_perms.3 archive_entry_gname_w.3
+MLINKS+= archive_entry_perms.3 archive_entry_set_fflags.3
+MLINKS+= archive_entry_perms.3 archive_entry_set_gid.3
+MLINKS+= archive_entry_perms.3 archive_entry_set_gname.3
+MLINKS+= archive_entry_perms.3 archive_entry_perm.3
+MLINKS+= archive_entry_perms.3 archive_entry_set_fflags.3
+MLINKS+= archive_entry_perms.3 archive_entry_set_gid.3
+MLINKS+= archive_entry_perms.3 archive_entry_set_gname.3
+MLINKS+= archive_entry_perms.3 archive_entry_set_perm.3
+MLINKS+= archive_entry_perms.3 archive_entry_set_uid.3
+MLINKS+= archive_entry_perms.3 archive_entry_set_uname.3
+MLINKS+= archive_entry_perms.3 archive_entry_strmode.3
+MLINKS+= archive_entry_perms.3 archive_entry_uid.3
+MLINKS+= archive_entry_perms.3 archive_entry_uname.3
+MLINKS+= archive_entry_perms.3 archive_entry_uname_w.3
+MLINKS+= archive_entry_perms.3 archive_entry_update_gname_utf8.3
+MLINKS+= archive_entry_perms.3 archive_entry_update_uname_utf8.3
+MLINKS+= archive_entry_stat.3 archive_entry_copy_stat.3
+MLINKS+= archive_entry_stat.3 archive_entry_dev.3
+MLINKS+= archive_entry_stat.3 archive_entry_dev_is_set.3
+MLINKS+= archive_entry_stat.3 archive_entry_devmajor.3
+MLINKS+= archive_entry_stat.3 archive_entry_devminor.3
+MLINKS+= archive_entry_stat.3 archive_entry_filetype.3
+MLINKS+= archive_entry_stat.3 archive_entry_ino.3
+MLINKS+= archive_entry_stat.3 archive_entry_ino64.3
+MLINKS+= archive_entry_stat.3 archive_entry_ino_is_set.3
+MLINKS+= archive_entry_stat.3 archive_entry_mode.3
+MLINKS+= archive_entry_stat.3 archive_entry_nlink.3
+MLINKS+= archive_entry_stat.3 archive_entry_rdev.3
+MLINKS+= archive_entry_stat.3 archive_entry_rdevmajor.3
+MLINKS+= archive_entry_stat.3 archive_entry_rdevminor.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_dev.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_devmajor.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_devminor.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_filetype.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_ino.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_ino64.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_mode.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_rdev.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_rdevmajor.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_rdevminor.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_size.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_nlink.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_rdev.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_rdevmajor.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_rdevminor.3
+MLINKS+= archive_entry_stat.3 archive_entry_set_size.3
+MLINKS+= archive_entry_stat.3 archive_entry_size.3
+MLINKS+= archive_entry_stat.3 archive_entry_size_is_set.3
+MLINKS+= archive_entry_stat.3 archive_entry_unset_size.3
+MLINKS+= archive_entry_time.3 archive_entry_atime.3
+MLINKS+= archive_entry_time.3 archive_entry_atime_is_set.3
+MLINKS+= archive_entry_time.3 archive_entry_atime_nsec.3
+MLINKS+= archive_entry_time.3 archive_entry_birthtime.3
+MLINKS+= archive_entry_time.3 archive_entry_birthtime_is_set.3
+MLINKS+= archive_entry_time.3 archive_entry_birthtime_nsec.3
+MLINKS+= archive_entry_time.3 archive_entry_ctime.3
+MLINKS+= archive_entry_time.3 archive_entry_ctime_is_set.3
+MLINKS+= archive_entry_time.3 archive_entry_ctime_nsec.3
+MLINKS+= archive_entry_time.3 archive_entry_mtime.3
+MLINKS+= archive_entry_time.3 archive_entry_mtime_is_set.3
+MLINKS+= archive_entry_time.3 archive_entry_mtime_nsec.3
+MLINKS+= archive_entry_time.3 archive_entry_set_atime.3
+MLINKS+= archive_entry_time.3 archive_entry_set_birthtime.3
+MLINKS+= archive_entry_time.3 archive_entry_set_ctime.3
+MLINKS+= archive_entry_time.3 archive_entry_set_mtime.3
+MLINKS+= archive_entry_time.3 archive_entry_unset_atime.3
+MLINKS+= archive_entry_time.3 archive_entry_unset_birthtime.3
+MLINKS+= archive_entry_time.3 archive_entry_unset_ctime.3
+MLINKS+= archive_entry_time.3 archive_entry_unset_mtime.3
+MLINKS+= archive_read_data.3 archive_read_data_block.3
+MLINKS+= archive_read_data.3 archive_read_data_into_fd.3
+MLINKS+= archive_read_data.3 archive_read_data_skip.3
+MLINKS+= archive_read_header.3 archive_read_next_header.3
+MLINKS+= archive_read_header.3 archive_read_next_header2.3
+MLINKS+= archive_read_extract.3 archive_read_extract2.3
+MLINKS+= archive_read_extract.3 archive_read_extract_set_progress_callback.3
+MLINKS+= archive_read_extract.3 archive_read_extract_set_skip_file.3
+MLINKS+= archive_read_open.3 archive_read_open2.3
+MLINKS+= archive_read_open.3 archive_read_open_FILE.3
+MLINKS+= archive_read_open.3 archive_read_open_fd.3
+MLINKS+= archive_read_open.3 archive_read_open_file.3
+MLINKS+= archive_read_open.3 archive_read_open_filename.3
+MLINKS+= archive_read_open.3 archive_read_open_memory.3
+MLINKS+= archive_read_free.3 archive_read_close.3
+MLINKS+= archive_read_free.3 archive_read_finish.3
+MLINKS+= archive_read_filter.3 archive_read_support_filter_all.3
+MLINKS+= archive_read_filter.3 archive_read_support_filter_bzip2.3
+MLINKS+= archive_read_filter.3 archive_read_support_filter_compress.3
+MLINKS+= archive_read_filter.3 archive_read_support_filter_gzip.3
+MLINKS+= archive_read_filter.3 archive_read_support_filter_lzma.3
+MLINKS+= archive_read_filter.3 archive_read_support_filter_none.3
+MLINKS+= archive_read_filter.3 archive_read_support_filter_xz.3
+MLINKS+= archive_read_filter.3 archive_read_support_filter_program.3
+MLINKS+= archive_read_filter.3 archive_read_support_filter_program_signature.3
+MLINKS+= archive_read_format.3 archive_read_support_format_7zip.3
+MLINKS+= archive_read_format.3 archive_read_support_format_all.3
+MLINKS+= archive_read_format.3 archive_read_support_format_ar.3
+MLINKS+= archive_read_format.3 archive_read_support_format_by_code.3
+MLINKS+= archive_read_format.3 archive_read_support_format_cab.3
+MLINKS+= archive_read_format.3 archive_read_support_format_cpio.3
+MLINKS+= archive_read_format.3 archive_read_support_format_empty.3
+MLINKS+= archive_read_format.3 archive_read_support_format_iso9660.3
+MLINKS+= archive_read_format.3 archive_read_support_format_lha.3
+MLINKS+= archive_read_format.3 archive_read_support_format_mtree.3
+MLINKS+= archive_read_format.3 archive_read_support_format_rar.3
+MLINKS+= archive_read_format.3 archive_read_support_format_raw.3
+MLINKS+= archive_read_format.3 archive_read_support_format_tar.3
+MLINKS+= archive_read_format.3 archive_read_support_format_xar.3
+MLINKS+= archive_read_format.3 archive_read_support_format_zip.3
MLINKS+= archive_read_disk.3 archive_read_disk_entry_from_file.3
MLINKS+= archive_read_disk.3 archive_read_disk_gname.3
MLINKS+= archive_read_disk.3 archive_read_disk_new.3
@@ -235,46 +341,58 @@ MLINKS+= archive_read_disk.3 archive_read_disk_set_symlink_logical.3
MLINKS+= archive_read_disk.3 archive_read_disk_set_symlink_physical.3
MLINKS+= archive_read_disk.3 archive_read_disk_set_uname_lookup.3
MLINKS+= archive_read_disk.3 archive_read_disk_uname.3
+MLINKS+= archive_read_set_options.3 archive_read_set_filter_option.3
+MLINKS+= archive_read_set_options.3 archive_read_set_format_option.3
+MLINKS+= archive_read_set_options.3 archive_read_set_option.3
MLINKS+= archive_util.3 archive_clear_error.3
MLINKS+= archive_util.3 archive_compression.3
MLINKS+= archive_util.3 archive_compression_name.3
+MLINKS+= archive_util.3 archive_copy_error.3
MLINKS+= archive_util.3 archive_errno.3
MLINKS+= archive_util.3 archive_error_string.3
MLINKS+= archive_util.3 archive_file_count.3
+MLINKS+= archive_util.3 archive_filter_code.3
+MLINKS+= archive_util.3 archive_filter_count.3
+MLINKS+= archive_util.3 archive_filter_name.3
MLINKS+= archive_util.3 archive_format.3
MLINKS+= archive_util.3 archive_format_name.3
+MLINKS+= archive_util.3 archive_position.3
MLINKS+= archive_util.3 archive_set_error.3
-MLINKS+= archive_write.3 archive_write_close.3
-MLINKS+= archive_write.3 archive_write_data.3
-MLINKS+= archive_write.3 archive_write_finish.3
-MLINKS+= archive_write.3 archive_write_finish_entry.3
-MLINKS+= archive_write.3 archive_write_get_bytes_in_last_block.3
-MLINKS+= archive_write.3 archive_write_get_bytes_per_block.3
-MLINKS+= archive_write.3 archive_write_header.3
-MLINKS+= archive_write.3 archive_write_new.3
-MLINKS+= archive_write.3 archive_write_open.3
-MLINKS+= archive_write.3 archive_write_open_FILE.3
-MLINKS+= archive_write.3 archive_write_open_fd.3
-MLINKS+= archive_write.3 archive_write_open_file.3
-MLINKS+= archive_write.3 archive_write_open_filename.3
-MLINKS+= archive_write.3 archive_write_open_memory.3
-MLINKS+= archive_write.3 archive_write_set_bytes_in_last_block.3
-MLINKS+= archive_write.3 archive_write_set_bytes_per_block.3
-MLINKS+= archive_write.3 archive_write_set_callbacks.3
-MLINKS+= archive_write.3 archive_write_set_compression_bzip2.3
-MLINKS+= archive_write.3 archive_write_set_compression_compress.3
-MLINKS+= archive_write.3 archive_write_set_compression_gzip.3
-MLINKS+= archive_write.3 archive_write_set_compression_none.3
-MLINKS+= archive_write.3 archive_write_set_compression_program.3
-MLINKS+= archive_write.3 archive_write_set_format_pax.3
-MLINKS+= archive_write.3 archive_write_set_format_shar.3
-MLINKS+= archive_write.3 archive_write_set_format_ustar.3
+MLINKS+= archive_write_blocksize.3 archive_write_get_bytes_in_last_block.3
+MLINKS+= archive_write_blocksize.3 archive_write_get_bytes_per_block.3
+MLINKS+= archive_write_blocksize.3 archive_write_set_bytes_in_last_block.3
+MLINKS+= archive_write_blocksize.3 archive_write_set_bytes_per_block.3
+MLINKS+= archive_write_disk.3 archive_write_data_block.3
MLINKS+= archive_write_disk.3 archive_write_disk_new.3
MLINKS+= archive_write_disk.3 archive_write_disk_set_group_lookup.3
MLINKS+= archive_write_disk.3 archive_write_disk_set_options.3
MLINKS+= archive_write_disk.3 archive_write_disk_set_skip_file.3
MLINKS+= archive_write_disk.3 archive_write_disk_set_standard_lookup.3
MLINKS+= archive_write_disk.3 archive_write_disk_set_user_lookup.3
+MLINKS+= archive_write_filter.3 archive_write_add_filter_bzip2.3
+MLINKS+= archive_write_filter.3 archive_write_add_filter_compress.3
+MLINKS+= archive_write_filter.3 archive_write_add_filter_gzip.3
+MLINKS+= archive_write_filter.3 archive_write_add_filter_lzip.3
+MLINKS+= archive_write_filter.3 archive_write_add_filter_lzma.3
+MLINKS+= archive_write_filter.3 archive_write_add_filter_none.3
+MLINKS+= archive_write_filter.3 archive_write_add_filter_program.3
+MLINKS+= archive_write_filter.3 archive_write_add_filter_xz.3
+MLINKS+= archive_write_format.3 archive_write_set_format_cpio.3
+MLINKS+= archive_write_format.3 archive_write_set_format_pax.3
+MLINKS+= archive_write_format.3 archive_write_set_format_pax_restricted.3
+MLINKS+= archive_write_format.3 archive_write_set_format_shar.3
+MLINKS+= archive_write_format.3 archive_write_set_format_shar_dump.3
+MLINKS+= archive_write_format.3 archive_write_set_format_ustar.3
+MLINKS+= archive_write_free.3 archive_write_close.3
+MLINKS+= archive_write_free.3 archive_write_finish.3
+MLINKS+= archive_write_open.3 archive_write_open_FILE.3
+MLINKS+= archive_write_open.3 archive_write_open_fd.3
+MLINKS+= archive_write_open.3 archive_write_open_file.3
+MLINKS+= archive_write_open.3 archive_write_open_filename.3
+MLINKS+= archive_write_open.3 archive_write_open_memory.3
+MLINKS+= archive_write_set_options.3 archive_write_set_filter_option.3
+MLINKS+= archive_write_set_options.3 archive_write_set_format_option.3
+MLINKS+= archive_write_set_options.3 archive_write_set_option.3
MLINKS+= libarchive.3 archive.3
.PHONY: check test clean-test
diff --git a/lib/libarchive/config_freebsd.h b/lib/libarchive/config_freebsd.h
index b4694ea136e4..0a39aa67b623 100644
--- a/lib/libarchive/config_freebsd.h
+++ b/lib/libarchive/config_freebsd.h
@@ -27,158 +27,210 @@
/* FreeBSD 5.0 and later have ACL and extattr support. */
#if __FreeBSD__ > 4
-#define HAVE_ACL_CREATE_ENTRY 1
-#define HAVE_ACL_GET_LINK_NP 1
-#define HAVE_ACL_GET_PERM_NP 1
-#define HAVE_ACL_INIT 1
-#define HAVE_ACL_SET_FD 1
-#define HAVE_ACL_SET_FD_NP 1
-#define HAVE_ACL_SET_FILE 1
-#define HAVE_ACL_USER 1
-#define HAVE_EXTATTR_GET_FILE 1
-#define HAVE_EXTATTR_LIST_FILE 1
-#define HAVE_EXTATTR_SET_FD 1
-#define HAVE_EXTATTR_SET_FILE 1
-#define HAVE_SYS_ACL_H 1
-#define HAVE_SYS_EXTATTR_H 1
+#define HAVE_ACL_CREATE_ENTRY 1
+#define HAVE_ACL_GET_LINK_NP 1
+#define HAVE_ACL_GET_PERM_NP 1
+#define HAVE_ACL_INIT 1
+#define HAVE_ACL_PERMSET_T 1
+#define HAVE_ACL_SET_FD 1
+#define HAVE_ACL_SET_FD_NP 1
+#define HAVE_ACL_SET_FILE 1
+#define HAVE_ACL_USER 1
+#define HAVE_EXTATTR_GET_FILE 1
+#define HAVE_EXTATTR_LIST_FILE 1
+#define HAVE_EXTATTR_SET_FD 1
+#define HAVE_EXTATTR_SET_FILE 1
+#define HAVE_SYS_ACL_H 1
+#define HAVE_SYS_EXTATTR_H 1
#endif
#ifdef WITH_OPENSSL
-#define HAVE_OPENSSL_MD5_H 1
-#define HAVE_OPENSSL_RIPEMD_H 1
-#define HAVE_OPENSSL_SHA_H 1
-#define HAVE_OPENSSL_SHA256_INIT 1
-#define HAVE_OPENSSL_SHA384_INIT 1
-#define HAVE_OPENSSL_SHA512_INIT 1
-#define HAVE_SHA256 1
-#define HAVE_SHA384 1
-#define HAVE_SHA512 1
+#define HAVE_OPENSSL_MD5_H 1
+#define HAVE_OPENSSL_RIPEMD_H 1
+#define HAVE_OPENSSL_SHA_H 1
+#define HAVE_OPENSSL_SHA256_INIT 1
+#define HAVE_OPENSSL_SHA384_INIT 1
+#define HAVE_OPENSSL_SHA512_INIT 1
+#define HAVE_SHA256 1
+#define HAVE_SHA384 1
+#define HAVE_SHA512 1
#else
-#define HAVE_MD5_H 1
-#define HAVE_MD5INIT 1
-#define HAVE_SHA_H 1
-#define HAVE_SHA1 1
-#define HAVE_SHA1_INIT 1
-#define HAVE_SHA256 1
-#define HAVE_SHA256_H 1
-#define HAVE_SHA256_INIT 1
-#define HAVE_SHA512 1
-#define HAVE_SHA512_H 1
-#define HAVE_SHA512_INIT 1
+#define HAVE_MD5_H 1
+#define HAVE_MD5INIT 1
+#define HAVE_SHA_H 1
+#define HAVE_SHA1 1
+#define HAVE_SHA1_INIT 1
+#define HAVE_SHA256 1
+#define HAVE_SHA256_H 1
+#define HAVE_SHA256_INIT 1
+#define HAVE_SHA512 1
+#define HAVE_SHA512_H 1
+#define HAVE_SHA512_INIT 1
#endif
-#define HAVE_BSDXML_H 1
-#define HAVE_BZLIB_H 1
-#define HAVE_CHFLAGS 1
-#define HAVE_CHOWN 1
-#define HAVE_DECL_EXTATTR_NAMESPACE_USER 1
-#define HAVE_DECL_INT64_MAX 1
-#define HAVE_DECL_INT64_MIN 1
-#define HAVE_DECL_SIZE_MAX 1
-#define HAVE_DECL_SSIZE_MAX 1
-#define HAVE_DECL_STRERROR_R 1
-#define HAVE_DECL_UINT32_MAX 1
-#define HAVE_DECL_UINT64_MAX 1
-#define HAVE_DIRENT_H 1
-#define HAVE_EFTYPE 1
-#define HAVE_EILSEQ 1
-#define HAVE_ERRNO_H 1
-#define HAVE_FCHDIR 1
-#define HAVE_FCHFLAGS 1
-#define HAVE_FCHMOD 1
-#define HAVE_FCHOWN 1
-#define HAVE_FCNTL 1
-#define HAVE_FCNTL_H 1
-#define HAVE_FSEEKO 1
-#define HAVE_FSTAT 1
-#define HAVE_FTRUNCATE 1
-#define HAVE_FUTIMES 1
-#define HAVE_GETEUID 1
-#define HAVE_GETGRGID_R 1
-#define HAVE_GETPID 1
-#define HAVE_GETPWUID_R 1
-#define HAVE_GRP_H 1
-#define HAVE_INTTYPES_H 1
-#define HAVE_LCHFLAGS 1
-#define HAVE_LCHMOD 1
-#define HAVE_LCHOWN 1
-#define HAVE_LIMITS_H 1
-#define HAVE_LINK 1
-#define HAVE_LSTAT 1
-#define HAVE_LUTIMES 1
-#define HAVE_MALLOC 1
-#define HAVE_MD5 1
-#define HAVE_MEMMOVE 1
-#define HAVE_MKDIR 1
-#define HAVE_MKFIFO 1
-#define HAVE_MKNOD 1
-#define HAVE_PIPE 1
-#define HAVE_POLL 1
-#define HAVE_POLL_H 1
-#define HAVE_PWD_H 1
-#define HAVE_READLINK 1
-#define HAVE_RMD160 1
-#define HAVE_SELECT 1
-#define HAVE_SETENV 1
-#define HAVE_SIGNAL_H 1
-#define HAVE_STDINT_H 1
-#define HAVE_STDLIB_H 1
-#define HAVE_STRCHR 1
-#define HAVE_STRDUP 1
-#define HAVE_STRERROR 1
-#define HAVE_STRERROR_R 1
-#define HAVE_STRINGS_H 1
-#define HAVE_STRING_H 1
-#define HAVE_STRRCHR 1
-#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
-#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1
-#define HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC 1
-#define HAVE_STRUCT_STAT_ST_FLAGS 1
-#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
-#define HAVE_SYMLINK 1
-#define HAVE_SYS_CDEFS_H 1
-#define HAVE_SYS_IOCTL_H 1
-#define HAVE_SYS_SELECT_H 1
-#define HAVE_SYS_STAT_H 1
-#define HAVE_SYS_TIME_H 1
-#define HAVE_SYS_TYPES_H 1
-#undef HAVE_SYS_UTIME_H
-#define HAVE_SYS_WAIT_H 1
-#define HAVE_TIMEGM 1
-#define HAVE_TZSET 1
-#define HAVE_UNISTD_H 1
-#define HAVE_UNSETENV 1
-#define HAVE_UTIME 1
-#define HAVE_UTIMES 1
-#define HAVE_UTIME_H 1
-#define HAVE_VFORK 1
-#define HAVE_WCHAR_H 1
-#define HAVE_WCSCMP 1
-#define HAVE_WCSCPY 1
-#define HAVE_WCSLEN 1
-#define HAVE_WCTOMB 1
-#define HAVE_WMEMCMP 1
-#define HAVE_WMEMCPY 1
-#define HAVE_ZLIB_H 1
-#define TIME_WITH_SYS_TIME 1
+#define HAVE_BSDXML_H 1
+#define HAVE_BZLIB_H 1
+#define HAVE_CHFLAGS 1
+#define HAVE_CHOWN 1
+#define HAVE_CHROOT 1
+#define HAVE_CTIME_R 1
+#define HAVE_CTYPE_H 1
+#define HAVE_DECL_EXTATTR_NAMESPACE_USER 1
+#define HAVE_DECL_INT64_MAX 1
+#define HAVE_DECL_INT64_MIN 1
+#define HAVE_DECL_SIZE_MAX 1
+#define HAVE_DECL_SSIZE_MAX 1
+#define HAVE_DECL_STRERROR_R 1
+#define HAVE_DECL_UINT32_MAX 1
+#define HAVE_DECL_UINT64_MAX 1
+#define HAVE_DIRENT_H 1
+#define HAVE_DLFCN_H 1
+#define HAVE_D_MD_ORDER 1
+#define HAVE_EFTYPE 1
+#define HAVE_EILSEQ 1
+#define HAVE_ERRNO_H 1
+#define HAVE_FCHDIR 1
+#define HAVE_FCHFLAGS 1
+#define HAVE_FCHMOD 1
+#define HAVE_FCHOWN 1
+#define HAVE_FCNTL 1
+#define HAVE_FCNTL_H 1
+#define HAVE_FDOPENDIR 1
+#define HAVE_FORK 1
+#define HAVE_FSEEKO 1
+#define HAVE_FSTAT 1
+#define HAVE_FSTATAT 1
+#define HAVE_FSTATFS 1
+#define HAVE_FSTATVFS 1
+#define HAVE_FTRUNCATE 1
+#define HAVE_FUTIMES 1
+#define HAVE_FUTIMESAT 1
+#define HAVE_GETEUID 1
+#define HAVE_GETGRGID_R 1
+#define HAVE_GETGRNAM_R 1
+#define HAVE_GETPID 1
+#define HAVE_GETPWNAM_R 1
+#define HAVE_GETPWUID_R 1
+#define HAVE_GETVFSBYNAME 1
+#define HAVE_GMTIME_R 1
+#define HAVE_GRP_H 1
+#define HAVE_INTMAX_T 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_LANGINFO_H 1
+#define HAVE_LCHFLAGS 1
+#define HAVE_LCHMOD 1
+#define HAVE_LCHOWN 1
+#define HAVE_LIBZ 1
+#define HAVE_LIMITS_H 1
+#define HAVE_LINK 1
+#define HAVE_LOCALE_H 1
+#define HAVE_LOCALTIME_R 1
+#define HAVE_LONG_LONG_INT 1
+#define HAVE_LSTAT 1
+#define HAVE_LUTIMES 1
+#define HAVE_MBRTOWC 1
+#define HAVE_MBSNRTOWCS 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MEMORY_H 1
+#define HAVE_MEMSET 1
+#define HAVE_MKDIR 1
+#define HAVE_MKFIFO 1
+#define HAVE_MKNOD 1
+#define HAVE_MKSTEMP 1
+#define HAVE_NL_LANGINFO 1
+#define HAVE_OPENAT 1
+#define HAVE_PATHS_H 1
+#define HAVE_PIPE 1
+#define HAVE_POLL 1
+#define HAVE_POLL_H 1
+#define HAVE_PWD_H 1
+#define HAVE_READDIR_R 1
+#define HAVE_READLINK 1
+#define HAVE_READLINKAT 1
+#define HAVE_REGEX_H 1
+#define HAVE_SELECT 1
+#define HAVE_SETENV 1
+#define HAVE_SETLOCALE 1
+#define HAVE_SIGACTION 1
+#define HAVE_SIGNAL_H 1
+#define HAVE_STATFS 1
+#define HAVE_STATVFS 1
+#define HAVE_STDARG_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRCHR 1
+#define HAVE_STRDUP 1
+#define HAVE_STRERROR 1
+#define HAVE_STRERROR_R 1
+#define HAVE_STRFTIME 1
+#define HAVE_STRINGS_H 1
+#define HAVE_STRING_H 1
+#define HAVE_STRRCHR 1
+#define HAVE_STRUCT_STATFS_F_NAMEMAX 1
+#define HAVE_STRUCT_STAT_ST_BIRTHTIME 1
+#define HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC 1
+#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
+#define HAVE_STRUCT_STAT_ST_FLAGS 1
+#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1
+#define HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1
+#define HAVE_STRUCT_TM_TM_GMTOFF 1
+#define HAVE_SYMLINK 1
+#define HAVE_SYS_CDEFS_H 1
+#define HAVE_SYS_IOCTL_H 1
+#define HAVE_SYS_MOUNT_H 1
+#define HAVE_SYS_PARAM_H 1
+#define HAVE_SYS_POLL_H 1
+#define HAVE_SYS_SELECT_H 1
+#define HAVE_SYS_STATVFS_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_TIME_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_SYS_UTSNAME_H 1
+#define HAVE_SYS_WAIT_H 1
+#define HAVE_TIMEGM 1
+#define HAVE_TIME_H 1
+#define HAVE_TZSET 1
+#define HAVE_UINTMAX_T 1
+#define HAVE_UNISTD_H 1
+#define HAVE_UNSETENV 1
+#define HAVE_UNSIGNED_LONG_LONG 1
+#define HAVE_UNSIGNED_LONG_LONG_INT 1
+#define HAVE_UTIME 1
+#define HAVE_UTIMES 1
+#define HAVE_UTIME_H 1
+#define HAVE_VFORK 1
+#define HAVE_VPRINTF 1
+#define HAVE_WCHAR_H 1
+#define HAVE_WCHAR_T 1
+#define HAVE_WCRTOMB 1
+#define HAVE_WCSCMP 1
+#define HAVE_WCSCPY 1
+#define HAVE_WCSLEN 1
+#define HAVE_WCSNRTOMBS 1
+#define HAVE_WCTOMB 1
+#define HAVE_WCTYPE_H 1
+#define HAVE_WMEMCMP 1
+#define HAVE_WMEMCPY 1
+#define HAVE_ZLIB_H 1
+#define TIME_WITH_SYS_TIME 1
/* FreeBSD 4 and earlier lack intmax_t/uintmax_t */
#if __FreeBSD__ < 5
-#define intmax_t int64_t
-#define uintmax_t uint64_t
+#define intmax_t int64_t
+#define uintmax_t uint64_t
#endif
/* FreeBSD defines for archive_hash.h */
#ifdef WITH_OPENSSL
-#define ARCHIVE_HASH_MD5_OPENSSL 1
-#define ARCHIVE_HASH_RMD160_OPENSSL 1
-#define ARCHIVE_HASH_SHA1_OPENSSL
-#define ARCHIVE_HASH_SHA256_OPENSSL 1
-#define ARCHIVE_HASH_SHA384_OPENSSL 1
-#define ARCHIVE_HASH_SHA512_OPENSSL 1
+#define ARCHIVE_HASH_MD5_OPENSSL 1
+#define ARCHIVE_HASH_RMD160_OPENSSL 1
+#define ARCHIVE_HASH_SHA1_OPENSSL
+#define ARCHIVE_HASH_SHA256_OPENSSL 1
+#define ARCHIVE_HASH_SHA384_OPENSSL 1
+#define ARCHIVE_HASH_SHA512_OPENSSL 1
#else
-#define ARCHIVE_HASH_MD5_LIBMD 1
-#define ARCHIVE_HASH_SHA1_LIBMD 1
-#define ARCHIVE_HASH_SHA256_LIBMD 1
-#define ARCHIVE_HASH_SHA512_LIBMD 1
+#define ARCHIVE_HASH_MD5_LIBMD 1
+#define ARCHIVE_HASH_SHA1_LIBMD 1
+#define ARCHIVE_HASH_SHA256_LIBMD 1
+#define ARCHIVE_HASH_SHA512_LIBMD 1
#endif
diff --git a/lib/libarchive/test/Makefile b/lib/libarchive/test/Makefile
index c8fc0a65bc3f..f4865b918fbb 100644
--- a/lib/libarchive/test/Makefile
+++ b/lib/libarchive/test/Makefile
@@ -10,7 +10,7 @@ DPADD=${LIBBZ2} ${LIBZ} ${LIBMD} ${LIBCRYPTO} ${LIBBSDXML}
LDADD= -L ${.OBJDIR}/.. -larchive
LDADD+= -lz -lbz2 -llzma -lmd -lcrypto -lbsdxml
CFLAGS+= -g
-CFLAGS+= -I${.CURDIR}/.. -I${LIBARCHIVEDIR} -I${.OBJDIR}
+CFLAGS+= -I${.CURDIR}/.. -I${LIBARCHIVEDIR}/libarchive -I${.OBJDIR}
CFLAGS+= -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1
# Uncomment to link against dmalloc
@@ -19,17 +19,42 @@ CFLAGS+= -DHAVE_LIBLZMA=1 -DHAVE_LZMA_H=1
.PATH: ${LIBARCHIVEDIR}/libarchive/test
TESTS= \
- test_acl_basic.c \
test_acl_freebsd.c \
+ test_acl_nfs4.c \
test_acl_pax.c \
+ test_acl_posix1e.c \
test_archive_api_feature.c \
+ test_archive_clear_error.c \
+ test_archive_crypto.c \
+ test_archive_read_close_twice.c \
+ test_archive_read_close_twice_open_fd.c \
+ test_archive_read_close_twice_open_filename.c \
+ test_archive_read_next_header_empty.c \
+ test_archive_read_next_header_raw.c \
+ test_archive_read_open2.c \
+ test_archive_read_set_filter_option.c \
+ test_archive_read_set_format_option.c \
+ test_archive_read_set_option.c \
+ test_archive_read_set_options.c \
+ test_archive_read_support.c \
+ test_archive_set_error.c \
+ test_archive_string.c \
+ test_archive_string_conversion.c \
+ test_archive_write_set_filter_option.c \
+ test_archive_write_set_format_option.c \
+ test_archive_write_set_option.c \
+ test_archive_write_set_options.c \
test_bad_fd.c \
test_compat_bzip2.c \
test_compat_cpio.c \
test_compat_gtar.c \
test_compat_gzip.c \
+ test_compat_lzip.c \
test_compat_lzma.c \
+ test_compat_mac.c \
+ test_compat_pax_libarchive_2x.c \
test_compat_solaris_tar_acl.c \
+ test_compat_solaris_pax_sparse.c \
test_compat_tar_hardlink.c \
test_compat_xz.c \
test_compat_zip.c \
@@ -37,7 +62,9 @@ TESTS= \
test_entry.c \
test_entry_strmode.c \
test_extattr_freebsd.c \
+ test_filter_count.c \
test_fuzz.c \
+ test_gnutar_filename_encoding.c \
test_link_resolver.c \
test_open_fd.c \
test_open_failure.c \
@@ -47,86 +74,118 @@ TESTS= \
test_read_compress_program.c \
test_read_data_large.c \
test_read_disk.c \
+ test_read_disk_directory_traversals.c \
test_read_disk_entry_from_file.c \
test_read_extract.c \
test_read_file_nonexistent.c \
+ test_read_format_7zip.c \
test_read_format_ar.c \
+ test_read_format_cab.c \
+ test_read_format_cab_filename.c \
+ test_read_format_cpio_afio.c \
test_read_format_cpio_bin.c \
test_read_format_cpio_bin_Z.c \
test_read_format_cpio_bin_be.c \
test_read_format_cpio_bin_bz2.c \
test_read_format_cpio_bin_gz.c \
+ test_read_format_cpio_bin_lzip.c \
test_read_format_cpio_bin_lzma.c \
test_read_format_cpio_bin_xz.c \
+ test_read_format_cpio_filename.c \
test_read_format_cpio_odc.c \
test_read_format_cpio_svr4_gzip.c \
test_read_format_cpio_svr4c_Z.c \
test_read_format_cpio_svr4_bzip2_rpm.c \
test_read_format_cpio_svr4_gzip_rpm.c \
test_read_format_empty.c \
+ test_read_format_gtar_filename.c \
test_read_format_gtar_gz.c \
test_read_format_gtar_lzma.c \
test_read_format_gtar_sparse.c \
test_read_format_iso_Z.c \
test_read_format_iso_multi_extent.c \
+ test_read_format_iso_xorriso.c \
test_read_format_isorr_rr_moved.c \
test_read_format_isojoliet_bz2.c \
test_read_format_isojoliet_long.c \
test_read_format_isojoliet_rr.c \
+ test_read_format_isojoliet_versioned.c \
test_read_format_isorr_bz2.c \
test_read_format_isorr_ce.c \
test_read_format_isorr_new_bz2.c \
test_read_format_isozisofs_bz2.c \
+ test_read_format_lha.c \
+ test_read_format_lha_filename.c \
test_read_format_mtree.c \
test_read_format_pax_bz2.c \
+ test_read_format_rar.c \
test_read_format_raw.c \
test_read_format_tar.c \
test_read_format_tar_empty_filename.c \
+ test_read_format_tar_filename.c \
test_read_format_tbz.c \
test_read_format_tgz.c \
test_read_format_tlz.c \
test_read_format_txz.c \
test_read_format_tz.c \
+ test_read_format_ustar_filename.c \
test_read_format_xar.c \
test_read_format_zip.c \
+ test_read_format_zip_filename.c \
test_read_large.c \
test_read_pax_truncated.c \
test_read_position.c \
test_read_truncated.c \
+ test_read_truncated_filter.c \
test_read_uu.c \
+ test_sparse_basic.c \
test_tar_filenames.c \
test_tar_large.c \
test_ustar_filenames.c \
+ test_ustar_filename_encoding.c \
test_write_compress.c \
test_write_compress_bzip2.c \
test_write_compress_gzip.c \
+ test_write_compress_lzip.c \
test_write_compress_lzma.c \
test_write_compress_program.c \
test_write_compress_xz.c \
test_write_disk.c \
test_write_disk_failures.c \
test_write_disk_hardlink.c \
+ test_write_disk_lookup.c \
test_write_disk_perms.c \
test_write_disk_secure.c \
test_write_disk_sparse.c \
test_write_disk_symlink.c \
test_write_disk_times.c \
+ test_write_format_7zip.c \
test_write_format_ar.c \
test_write_format_cpio.c \
test_write_format_cpio_empty.c \
test_write_format_cpio_newc.c \
test_write_format_cpio_odc.c \
+ test_write_format_gnutar.c \
+ test_write_format_iso9660.c \
+ test_write_format_iso9660_boot.c \
+ test_write_format_iso9660_empty.c \
+ test_write_format_iso9660_filename.c \
+ test_write_format_iso9660_zisofs.c \
test_write_format_mtree.c \
+ test_write_format_mtree_fflags.c \
test_write_format_pax.c \
test_write_format_shar_empty.c \
test_write_format_tar.c \
test_write_format_tar_empty.c \
+ test_write_format_tar_sparse.c \
test_write_format_tar_ustar.c \
+ test_write_format_xar.c \
+ test_write_format_xar_empty.c \
test_write_format_zip.c \
test_write_format_zip_empty.c \
test_write_format_zip_no_compression.c \
- test_write_open_memory.c
-
+ test_write_open_memory.c \
+ test_zip_filename_encoding.c
# Build the test program.
SRCS= \
diff --git a/lib/libbluetooth/bluetooth.3 b/lib/libbluetooth/bluetooth.3
index cf7e3edbfb42..aa738d4be7e6 100644
--- a/lib/libbluetooth/bluetooth.3
+++ b/lib/libbluetooth/bluetooth.3
@@ -511,7 +511,7 @@ The function returns 0 on success, or -1 if an error occurred.
.Pp
The
.Fn bt_devfilter_pkt_set ,
-.Fn bt_devfilter_pkt_clr
+.Fn bt_devfilter_pkt_clr
and
.Fn bt_devfilter_pkt_tst
functions can be used to modify and test the
@@ -526,7 +526,7 @@ packet type.
.Pp
The
.Fn bt_devfilter_evt_set ,
-.Fn bt_devfilter_evt_clr
+.Fn bt_devfilter_evt_clr
and
.Fn bt_devfilter_evt_tst
functions can be used to modify and test the
diff --git a/lib/libc++/Makefile b/lib/libc++/Makefile
index 3b76dff68f39..fc35ea5369ae 100644
--- a/lib/libc++/Makefile
+++ b/lib/libc++/Makefile
@@ -39,7 +39,7 @@ WARNS= 0
CXXFLAGS+= -I${HDRDIR} -I${LIBCXXRTDIR} -std=c++0x -nostdlib -DLIBCXXRT
DPADD= ${LIBCXXRT}
-LDADD= -L${.OBJDIR}/../libcxxrt/ -lcxxrt
+LDADD= -lcxxrt
LDFLAGS+= --verbose
INCSGROUPS= STD EXT
@@ -58,6 +58,7 @@ STD_HEADERS= __bit_reference\
__tree\
__tuple\
__tuple_03\
+ __undef_min_max\
algorithm\
array\
atomic\
diff --git a/lib/libc/Makefile b/lib/libc/Makefile
index bcf1797c4e33..22223846695e 100644
--- a/lib/libc/Makefile
+++ b/lib/libc/Makefile
@@ -79,6 +79,7 @@ NOASM=
.include "${.CURDIR}/resolv/Makefile.inc"
.include "${.CURDIR}/stdio/Makefile.inc"
.include "${.CURDIR}/stdlib/Makefile.inc"
+.include "${.CURDIR}/stdlib/jemalloc/Makefile.inc"
.include "${.CURDIR}/stdtime/Makefile.inc"
.include "${.CURDIR}/string/Makefile.inc"
.include "${.CURDIR}/sys/Makefile.inc"
diff --git a/lib/libc/amd64/gen/Makefile.inc b/lib/libc/amd64/gen/Makefile.inc
index 30fb05f89cb7..fb4f7f4d30f0 100644
--- a/lib/libc/amd64/gen/Makefile.inc
+++ b/lib/libc/amd64/gen/Makefile.inc
@@ -2,7 +2,7 @@
# $FreeBSD$
SRCS+= _setjmp.S _set_tp.c rfork_thread.S setjmp.S sigsetjmp.S \
- fabs.S \
+ fabs.S getcontextx.c \
infinity.c ldexp.c makecontext.c signalcontext.c \
flt_rounds.c fpgetmask.c fpsetmask.c fpgetprec.c fpsetprec.c \
fpgetround.c fpsetround.c fpgetsticky.c
diff --git a/lib/libc/amd64/gen/getcontextx.c b/lib/libc/amd64/gen/getcontextx.c
new file mode 100644
index 000000000000..7412560b80dd
--- /dev/null
+++ b/lib/libc/amd64/gen/getcontextx.c
@@ -0,0 +1,101 @@
+/*
+ * 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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/ucontext.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <machine/cpufunc.h>
+#include <machine/fpu.h>
+#include <machine/specialreg.h>
+#include <machine/sysarch.h>
+
+static int xstate_sz = -1;
+
+int
+__getcontextx_size(void)
+{
+ u_int p[4];
+
+ if (xstate_sz == -1) {
+ do_cpuid(1, p);
+ if ((p[2] & CPUID2_OSXSAVE) != 0) {
+ cpuid_count(0xd, 0x0, p);
+ xstate_sz = p[1] - sizeof(struct savefpu);
+ } else
+ xstate_sz = 0;
+ }
+
+ return (sizeof(ucontext_t) + xstate_sz);
+}
+
+int
+__fillcontextx(char *ctx)
+{
+ struct amd64_get_xfpustate xfpu;
+ ucontext_t *ucp;
+
+ ucp = (ucontext_t *)ctx;
+ if (getcontext(ucp) == -1)
+ return (-1);
+ if (xstate_sz != 0) {
+ xfpu.addr = (char *)(ucp + 1);
+ xfpu.len = xstate_sz;
+ if (sysarch(AMD64_GET_XFPUSTATE, &xfpu) == -1)
+ return (-1);
+ ucp->uc_mcontext.mc_xfpustate = (__register_t)xfpu.addr;
+ ucp->uc_mcontext.mc_xfpustate_len = xstate_sz;
+ ucp->uc_mcontext.mc_flags |= _MC_HASFPXSTATE;
+ } else {
+ ucp->uc_mcontext.mc_xfpustate = 0;
+ ucp->uc_mcontext.mc_xfpustate_len = 0;
+ }
+ 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/arm/Symbol.map b/lib/libc/arm/Symbol.map
index 2cc515783074..dc460130eb40 100644
--- a/lib/libc/arm/Symbol.map
+++ b/lib/libc/arm/Symbol.map
@@ -40,6 +40,7 @@ FBSDprivate_1.0 {
__sys_exit;
_set_tp;
+ __aeabi_read_tp;
___longjmp;
__umodsi3;
__modsi3;
diff --git a/lib/libc/arm/_fpmath.h b/lib/libc/arm/_fpmath.h
index b0ce8f4965f6..4c189459770c 100644
--- a/lib/libc/arm/_fpmath.h
+++ b/lib/libc/arm/_fpmath.h
@@ -55,9 +55,10 @@ union IEEEl2bits {
};
#define LDBL_NBIT 0
+#define LDBL_IMPLICIT_NBIT
#define mask_nbit_l(u) ((void)0)
-#define LDBL_MANH_SIZE 32
+#define LDBL_MANH_SIZE 20
#define LDBL_MANL_SIZE 32
#define LDBL_TO_ARRAY32(u, a) do { \
diff --git a/lib/libc/arm/gen/Makefile.inc b/lib/libc/arm/gen/Makefile.inc
index fb9d88559127..a78cbb94260d 100644
--- a/lib/libc/arm/gen/Makefile.inc
+++ b/lib/libc/arm/gen/Makefile.inc
@@ -2,5 +2,5 @@
# $FreeBSD$
SRCS+= _ctx_start.S _setjmp.S _set_tp.c alloca.S fabs.c \
- infinity.c ldexp.c makecontext.c \
- setjmp.S signalcontext.c sigsetjmp.S divsi3.S
+ getcontextx.c infinity.c ldexp.c makecontext.c \
+ __aeabi_read_tp.S setjmp.S signalcontext.c sigsetjmp.S divsi3.S flt_rounds.c
diff --git a/lib/libc/arm/gen/__aeabi_read_tp.S b/lib/libc/arm/gen/__aeabi_read_tp.S
new file mode 100644
index 000000000000..228acff9dbf0
--- /dev/null
+++ b/lib/libc/arm/gen/__aeabi_read_tp.S
@@ -0,0 +1,40 @@
+/*-
+ * Copyright (c) 2012 Oleksandr Tymoshenko
+ * Copyright (c) 2012 Andrew Turner
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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>
+__FBSDID("$FreeBSD$");
+
+#include <machine/sysarch.h>
+
+ENTRY(__aeabi_read_tp)
+ ldr r0, .Larm_tp_address
+ ldr r0, [r0]
+ RET
+
+.Larm_tp_address:
+ .word ARM_TP_ADDRESS
+
diff --git a/lib/libc/arm/gen/_set_tp.c b/lib/libc/arm/gen/_set_tp.c
index 4c26dffa0114..44bbdd8ba763 100644
--- a/lib/libc/arm/gen/_set_tp.c
+++ b/lib/libc/arm/gen/_set_tp.c
@@ -27,9 +27,13 @@
*/
#include <string.h>
-#include <stdint.h>
+#include <sys/types.h>
+
+#include <machine/sysarch.h>
void
_set_tp(void *tp)
{
+
+ *((struct tcb **)ARM_TP_ADDRESS) = tp;
}
diff --git a/lib/libc/arm/gen/flt_rounds.c b/lib/libc/arm/gen/flt_rounds.c
new file mode 100644
index 000000000000..81ab08b34c74
--- /dev/null
+++ b/lib/libc/arm/gen/flt_rounds.c
@@ -0,0 +1,65 @@
+/*-
+ * Copyright (c) 2012 Ian Lepore <freebsd@damnhippie.dyndns.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>
+__FBSDID("$FreeBSD$");
+
+#include <fenv.h>
+#include <float.h>
+
+#include "softfloat-for-gcc.h"
+#include "milieu.h"
+#include "softfloat.h"
+
+int
+__flt_rounds(void)
+{
+
+#ifndef ARM_HARD_FLOAT
+ /*
+ * Translate our rounding modes to the unnamed
+ * manifest constants required by C99 et. al.
+ */
+ switch (__softfloat_float_rounding_mode) {
+ case FE_TOWARDZERO:
+ return (0);
+ case FE_TONEAREST:
+ return (1);
+ case FE_UPWARD:
+ return (2);
+ case FE_DOWNWARD:
+ return (3);
+ }
+ return (-1);
+#else /* ARM_HARD_FLOAT */
+ /*
+ * Apparently, the rounding mode is specified as part of the
+ * instruction format on ARM, so the dynamic rounding mode is
+ * indeterminate. Some FPUs may differ.
+ */
+ return (-1);
+#endif /* ARM_HARD_FLOAT */
+}
diff --git a/lib/libc/arm/gen/getcontextx.c b/lib/libc/arm/gen/getcontextx.c
new file mode 100644
index 000000000000..307978a466dd
--- /dev/null
+++ b/lib/libc/arm/gen/getcontextx.c
@@ -0,0 +1,69 @@
+/*
+ * 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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/ucontext.h>
+#include <errno.h>
+#include <stdlib.h>
+
+int
+__getcontextx_size(void)
+{
+
+ return (sizeof(ucontext_t));
+}
+
+int
+__fillcontextx(char *ctx)
+{
+ ucontext_t *ucp;
+
+ ucp = (ucontext_t *)ctx;
+ return (getcontext(ucp));
+}
+
+__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/arm/softfloat/softfloat.h b/lib/libc/arm/softfloat/softfloat.h
index 50b5fa6fb466..6aef49975a38 100644
--- a/lib/libc/arm/softfloat/softfloat.h
+++ b/lib/libc/arm/softfloat/softfloat.h
@@ -45,7 +45,7 @@ the `FLOAT128' macro and the quadruple-precision format `float128'.
/* #define FLOATX80 */
/* #define FLOAT128 */
-#include <machine/ieeefp.h>
+#include <fenv.h>
/*
-------------------------------------------------------------------------------
@@ -84,12 +84,12 @@ enum {
Software IEC/IEEE floating-point rounding mode.
-------------------------------------------------------------------------------
*/
-extern fp_rnd_t float_rounding_mode;
+extern int float_rounding_mode;
enum {
- float_round_nearest_even = FP_RN,
- float_round_to_zero = FP_RZ,
- float_round_down = FP_RM,
- float_round_up = FP_RP
+ float_round_nearest_even = FE_TONEAREST,
+ float_round_to_zero = FE_TOWARDZERO,
+ float_round_down = FE_DOWNWARD,
+ float_round_up = FE_UPWARD
};
/*
@@ -97,14 +97,14 @@ enum {
Software IEC/IEEE floating-point exception flags.
-------------------------------------------------------------------------------
*/
-extern fp_except float_exception_flags;
-extern fp_except float_exception_mask;
+extern int float_exception_flags;
+extern int float_exception_mask;
enum {
- float_flag_inexact = FP_X_IMP,
- float_flag_underflow = FP_X_UFL,
- float_flag_overflow = FP_X_OFL,
- float_flag_divbyzero = FP_X_DZ,
- float_flag_invalid = FP_X_INV
+ float_flag_inexact = FE_INEXACT,
+ float_flag_underflow = FE_UNDERFLOW,
+ float_flag_overflow = FE_OVERFLOW,
+ float_flag_divbyzero = FE_DIVBYZERO,
+ float_flag_invalid = FE_INVALID
};
/*
@@ -113,7 +113,7 @@ Routine to raise any or all of the software IEC/IEEE floating-point
exception flags.
-------------------------------------------------------------------------------
*/
-void float_raise( fp_except );
+void float_raise( int );
/*
-------------------------------------------------------------------------------
diff --git a/lib/libc/compat-43/killpg.2 b/lib/libc/compat-43/killpg.2
index 6793e41d5267..b23b773ef508 100644
--- a/lib/libc/compat-43/killpg.2
+++ b/lib/libc/compat-43/killpg.2
@@ -28,7 +28,7 @@
.\" @(#)killpg.2 8.1 (Berkeley) 6/2/93
.\" $FreeBSD$
.\"
-.Dd October 10, 2006
+.Dd March 15, 2012
.Dt KILLPG 2
.Os
.Sh NAME
@@ -79,9 +79,6 @@ is not a valid signal number.
.It Bq Er ESRCH
No process can be found in the process group specified by
.Fa pgrp .
-.It Bq Er ESRCH
-The process group was given as 0
-but the sending process does not have a process group.
.It Bq Er EPERM
The sending process is not the super-user and one or more
of the target processes has an effective user ID different from that
diff --git a/lib/libc/db/man/hash.3 b/lib/libc/db/man/hash.3
index 133885d841c9..a2a8bca65c14 100644
--- a/lib/libc/db/man/hash.3
+++ b/lib/libc/db/man/hash.3
@@ -65,7 +65,7 @@ typedef struct {
u_int ffactor;
u_int nelem;
u_int cachesize;
- u_int32_t (*hash)(const void *, size_t);
+ uint32_t (*hash)(const void *, size_t);
int lorder;
} HASHINFO;
.Ed
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index 1e068a55a78c..0362ce0c10b6 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -54,7 +54,7 @@ SYM_MAPS+=${.CURDIR}/gen/Symbol.map
MAN+= alarm.3 arc4random.3 \
basename.3 check_utility_compat.3 clock.3 \
confstr.3 ctermid.3 daemon.3 devname.3 directory.3 dirname.3 \
- dladdr.3 dlinfo.3 dllockinit.3 dlopen.3 \
+ dl_iterate_phdr.3 dladdr.3 dlinfo.3 dllockinit.3 dlopen.3 \
err.3 exec.3 \
feature_present.3 fmtcheck.3 fmtmsg.3 fnmatch.3 fpclassify.3 frexp.3 \
ftok.3 fts.3 ftw.3 \
@@ -95,8 +95,8 @@ MLINKS+=directory.3 closedir.3 directory.3 dirfd.3 directory.3 opendir.3 \
directory.3 fdopendir.3 \
directory.3 readdir.3 directory.3 readdir_r.3 directory.3 rewinddir.3 \
directory.3 seekdir.3 directory.3 telldir.3
-MLINKS+=dlopen.3 dlclose.3 dlopen.3 dlerror.3 dlopen.3 dlfunc.3 \
- dlopen.3 dlsym.3
+MLINKS+=dlopen.3 fdlopen.3 dlopen.3 dlclose.3 dlopen.3 dlerror.3 \
+ dlopen.3 dlfunc.3 dlopen.3 dlsym.3
MLINKS+=err.3 err_set_exit.3 err.3 err_set_file.3 err.3 errc.3 err.3 errx.3 \
err.3 verr.3 err.3 verrc.3 err.3 verrx.3 err.3 vwarn.3 err.3 vwarnc.3 \
err.3 vwarnx.3 err.3 warnc.3 err.3 warn.3 err.3 warnx.3
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index adc5964f3fff..d794c0a32ac2 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -382,7 +382,9 @@ FBSD_1.2 {
};
FBSD_1.3 {
+ fdlopen;
__FreeBSD_libc_enter_restricted_mode;
+ getcontextx;
};
FBSDprivate_1.0 {
@@ -506,4 +508,6 @@ FBSDprivate_1.0 {
__elf_aux_vector;
__pthread_map_stacks_exec;
+ __fillcontextx;
+ __getcontextx_size;
};
diff --git a/lib/libc/gen/arc4random.3 b/lib/libc/gen/arc4random.3
index be1f69092fcd..e1124c622e77 100644
--- a/lib/libc/gen/arc4random.3
+++ b/lib/libc/gen/arc4random.3
@@ -44,12 +44,12 @@
.Lb libc
.Sh SYNOPSIS
.In stdlib.h
-.Ft u_int32_t
+.Ft uint32_t
.Fn arc4random "void"
.Ft void
.Fn arc4random_buf "void *buf" "size_t nbytes"
-.Ft u_int32_t
-.Fn arc4random_uniform "u_int32_t upper_bound"
+.Ft uint32_t
+.Fn arc4random_uniform "uint32_t upper_bound"
.Ft void
.Fn arc4random_stir "void"
.Ft void
diff --git a/lib/libc/gen/aux.c b/lib/libc/gen/aux.c
index b5c079bfde56..4bf8643af166 100644
--- a/lib/libc/gen/aux.c
+++ b/lib/libc/gen/aux.c
@@ -1,5 +1,5 @@
/*-
- * Copyright 2010 Konstantin Belousov <kib@FreeBSD.ORG>.
+ * Copyright 2010, 2012 Konstantin Belousov <kib@FreeBSD.ORG>.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -36,10 +36,34 @@ __FBSDID("$FreeBSD$");
#include "un-namespace.h"
#include "libc_private.h"
-Elf_Auxinfo *__elf_aux_vector;
+extern char **environ;
+extern int _DYNAMIC;
+#pragma weak _DYNAMIC
-static pthread_once_t aux_once = PTHREAD_ONCE_INIT;
+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;
static char *canary, *pagesizes;
@@ -86,6 +110,7 @@ _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);
diff --git a/lib/libc/gen/closedir.c b/lib/libc/gen/closedir.c
index 44e2bdf48c27..5db351bbd7da 100644
--- a/lib/libc/gen/closedir.c
+++ b/lib/libc/gen/closedir.c
@@ -48,14 +48,12 @@ __FBSDID("$FreeBSD$");
* close a directory.
*/
int
-closedir(dirp)
- DIR *dirp;
+closedir(DIR *dirp)
{
int fd;
if (__isthreaded)
_pthread_mutex_lock(&dirp->dd_lock);
- _seekdir(dirp, dirp->dd_rewind); /* free seekdir storage */
fd = dirp->dd_fd;
dirp->dd_fd = -1;
dirp->dd_loc = 0;
diff --git a/lib/libc/gen/directory.3 b/lib/libc/gen/directory.3
index 992d2fcde520..1c568fc14b1b 100644
--- a/lib/libc/gen/directory.3
+++ b/lib/libc/gen/directory.3
@@ -122,9 +122,12 @@ function
returns a pointer to the next directory entry.
It returns
.Dv NULL
-upon reaching the end of the directory or detecting an invalid
-.Fn seekdir
-operation.
+upon reaching the end of the directory or on error.
+In the event of an error,
+.Va errno
+may be set to any of the values documented for the
+.Xr getdirentries 2
+system call.
.Pp
The
.Fn readdir_r
diff --git a/lib/libc/gen/dl_iterate_phdr.3 b/lib/libc/gen/dl_iterate_phdr.3
new file mode 100644
index 000000000000..f148ab104c4e
--- /dev/null
+++ b/lib/libc/gen/dl_iterate_phdr.3
@@ -0,0 +1,115 @@
+.\" Copyright (c) 2005 Mark Kettenis
+.\" Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.org>
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.\" $OpenBSD: dl_iterate_phdr.3,v 1.3 2007/05/31 19:19:48 jmc Exp $
+.\" $FreeBSD$
+.Dd February 15, 2012
+.Dt DL_ITERATE_PHDR 3
+.Os
+.Sh NAME
+.Nm dl_iterate_phdr
+.Nd iterate over program headers
+.Sh LIBRARY
+For the dynamically linked binaries, the service is provided by
+.Xr ld-elf.so.1 1
+dynamic linker.
+Statically linked programs use an implementation of
+.Fn dl_iterate_phdr
+from libc.
+.Sh SYNOPSIS
+.Fd #include <link.h>
+.Ft int
+.Fn dl_iterate_phdr "int (*callback)(struct dl_phdr_info *, size_t, void *)" "void *data"
+.Sh DESCRIPTION
+The
+.Fn dl_iterate_phdr
+function iterates over all ELF objects loaded into a process's
+address space, calling
+.Fa callback
+for each object, passing it information about the object's
+program headers and the
+.Fa data
+argument.
+The iteration is aborted when all objects are passed, or when the next
+.Fa callback
+call returns non-zero value.
+The information about the program headers is passed in a structure
+that is defined as:
+.Bd -literal
+struct dl_phdr_info {
+ Elf_Addr dlpi_addr;
+ const char *dlpi_name;
+ const Elf_Phdr *dlpi_phdr;
+ Elf_Half dlpi_phnum;
+ unsigned long long int dlpi_adds;
+ unsigned long long int dlpi_subs;
+ size_t dlpi_tls_modid;
+ void *dlpi_tls_data;
+};
+.Ed
+.Pp
+The members of
+.Li struct dl_phdr_info
+have the following meaning:
+.Bl -tag -width dlpi_tls_modid
+.It Fa dlpi_addr
+The base address at which the object is mapped into the address
+space of the calling process.
+.It Fa dlpi_name
+The name of the ELF object.
+.It Fa dlpi_phdr
+A pointer to the object's program headers.
+.It Fa dlpi_phnum
+The number of program headers in the object.
+.It Fa dlpi_adds
+The counter of the object loads performed by the dynamic linker.
+.It Fa dlpi_subs
+The counter of the object unloads performed by the dynamic linker.
+.It Fa dlpi_tls_modid
+The TLS index of the object.
+.It Fa dlpi_tls_data
+A pointer to the initialization data for the object TLS segment.
+.El
+.Pp
+Future versions of
+.Fx
+might add more members to this structure.
+To make it possible for programs to check whether any new members have
+been added, the size of the structure is passed as an second argument to
+.Fa callback .
+.Pp
+The third argument to callback is the
+.Fa data
+value passed to the call to
+.Fn dl_iterate_phdr ,
+allowing the
+.Fa callback
+to have a context.
+.Sh RETURN VALUES
+The
+.Fn dl_iterate_phdr
+returns the value returned by the last
+.Fa callback
+call executed.
+.Sh SEE ALSO
+.Xr ld 1 ,
+.Xr ld-elf.so.1 1 ,
+.Xr dlopen 3 ,
+.Xr elf 5
+.Sh HISTORY
+The
+.Nm
+function first appeared in
+.Fx 7.0 .
diff --git a/lib/libc/gen/dlfcn.c b/lib/libc/gen/dlfcn.c
index b109cc900ddc..ad24bb4914ca 100644
--- a/lib/libc/gen/dlfcn.c
+++ b/lib/libc/gen/dlfcn.c
@@ -34,6 +34,10 @@ __FBSDID("$FreeBSD$");
#include <dlfcn.h>
#include <link.h>
#include <stddef.h>
+#include "namespace.h"
+#include <pthread.h>
+#include "un-namespace.h"
+#include "libc_private.h"
static char sorry[] = "Service unavailable";
@@ -138,13 +142,67 @@ _rtld_thread_init(void * li)
_rtld_error(sorry);
}
+static pthread_once_t dl_phdr_info_once = PTHREAD_ONCE_INIT;
+static struct dl_phdr_info phdr_info;
+
+static void
+dl_init_phdr_info(void)
+{
+ Elf_Auxinfo *auxp;
+ size_t phent;
+ unsigned int i;
+
+ phent = 0;
+ for (auxp = __elf_aux_vector; auxp->a_type != AT_NULL; auxp++) {
+ switch (auxp->a_type) {
+ case AT_BASE:
+ phdr_info.dlpi_addr = (Elf_Addr)auxp->a_un.a_ptr;
+ break;
+ case AT_EXECPATH:
+ phdr_info.dlpi_name = (const char *)auxp->a_un.a_ptr;
+ break;
+ case AT_PHDR:
+ phdr_info.dlpi_phdr =
+ (const Elf_Phdr *)auxp->a_un.a_ptr;
+ break;
+ case AT_PHENT:
+ phent = auxp->a_un.a_val;
+ break;
+ case AT_PHNUM:
+ phdr_info.dlpi_phnum = (Elf_Half)auxp->a_un.a_val;
+ break;
+ }
+ }
+ for (i = 0; i < phdr_info.dlpi_phnum; i++) {
+ if (phdr_info.dlpi_phdr[i].p_type == PT_TLS) {
+ phdr_info.dlpi_tls_modid = 1;
+ phdr_info.dlpi_tls_data =
+ (void*)phdr_info.dlpi_phdr[i].p_vaddr;
+ }
+ }
+ phdr_info.dlpi_adds = 1;
+}
+
#pragma weak dl_iterate_phdr
int
dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *),
void *data)
{
+
+ __init_elf_aux_vector();
+ if (__elf_aux_vector == NULL)
+ return (1);
+ _once(&dl_phdr_info_once, dl_init_phdr_info);
+ return (callback(&phdr_info, sizeof(phdr_info), data));
+}
+
+#pragma weak fdlopen
+void *
+fdlopen(int fd, int mode)
+{
+
_rtld_error(sorry);
- return 0;
+ return NULL;
}
#pragma weak _rtld_atfork_pre
diff --git a/lib/libc/gen/dlopen.3 b/lib/libc/gen/dlopen.3
index 3da9b6e923d2..089e63192b0a 100644
--- a/lib/libc/gen/dlopen.3
+++ b/lib/libc/gen/dlopen.3
@@ -32,11 +32,12 @@
.\" @(#) dlopen.3 1.6 90/01/31 SMI
.\" $FreeBSD$
.\"
-.Dd July 7, 2009
+.Dd December 21, 2011
.Dt DLOPEN 3
.Os
.Sh NAME
.Nm dlopen ,
+.Nm fdlopen ,
.Nm dlsym ,
.Nm dlfunc ,
.Nm dlerror ,
@@ -49,6 +50,8 @@
.Ft void *
.Fn dlopen "const char *path" "int mode"
.Ft void *
+.Fn fdlopen "int fd" "int mode"
+.Ft void *
.Fn dlsym "void * restrict handle" "const char * restrict symbol"
.Ft dlfunc_t
.Fn dlfunc "void * restrict handle" "const char * restrict symbol"
@@ -164,6 +167,36 @@ be interrogated with
.Fn dlerror .
.Pp
The
+.Fn fdlopen
+function is similar to
+.Fn dlopen ,
+but it takes the file descriptor argument
+.Fa fd ,
+which is used for the file operations needed to load an object
+into the address space.
+The file descriptor
+.Fa fd
+is not closed by the function regardless a result of execution,
+but a duplicate of the file descriptor is.
+This may be important if a
+.Xr lockf 3
+lock is held on the passed descriptor.
+The
+.Fa fd
+argument -1 is interpreted as a reference to the main
+executable of the process, similar to
+.Va NULL
+value for the
+.Fa name
+argument to
+.Fn dlopen .
+The
+.Fn fdlopen
+function can be used by the code that needs to perform
+additional checks on the loaded objects, to prevent races with
+symlinking or renames.
+.Pp
+The
.Fn dlsym
function
returns the address binding of the symbol described in the null-terminated
@@ -354,6 +387,7 @@ option to the C language compiler.
.Sh ERRORS
The
.Fn dlopen ,
+.Fn fdlopen ,
.Fn dlsym ,
and
.Fn dlfunc
diff --git a/lib/libc/gen/fmtmsg.c b/lib/libc/gen/fmtmsg.c
index e6b1b960d64b..c6ecbd5f7653 100644
--- a/lib/libc/gen/fmtmsg.c
+++ b/lib/libc/gen/fmtmsg.c
@@ -45,10 +45,6 @@ static const char
*sevinfo(int);
static int validmsgverb(const char *);
-static const char *validlist[] = {
- "label", "severity", "text", "action", "tag", NULL
-};
-
int
fmtmsg(long class, const char *label, int sev, const char *text,
const char *action, const char *tag)
@@ -205,14 +201,18 @@ sevinfo(int sev)
static int
validmsgverb(const char *msgverb)
{
+ const char *validlist = "label\0severity\0text\0action\0tag\0";
char *msgcomp;
- int i, equality;
+ size_t len1, len2;
+ const char *p;
+ int equality;
equality = 0;
while ((msgcomp = nextcomp(msgverb)) != NULL) {
equality--;
- for (i = 0; validlist[i] != NULL; i++) {
- if (strcmp(msgcomp, validlist[i]) == 0)
+ len1 = strlen(msgcomp);
+ for (p = validlist; (len2 = strlen(p)) != 0; p += len2 + 1) {
+ if (len1 == len2 && memcmp(msgcomp, p, len1) == 0)
equality++;
}
}
diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c
index 9dac476c4c67..b2c28ad53d4a 100644
--- a/lib/libc/gen/fstab.c
+++ b/lib/libc/gen/fstab.c
@@ -91,7 +91,7 @@ fixfsfile()
struct stat sb;
struct statfs sf;
- if (strcmp(_fs_fstab.fs_file, "/") != 0)
+ if (_fs_fstab.fs_file != NULL && strcmp(_fs_fstab.fs_file, "/") != 0)
return;
if (statfs("/", &sf) != 0)
return;
diff --git a/lib/libc/gen/fts.3 b/lib/libc/gen/fts.3
index 4b051578c1e2..35e4d459238f 100644
--- a/lib/libc/gen/fts.3
+++ b/lib/libc/gen/fts.3
@@ -28,7 +28,7 @@
.\" @(#)fts.3 8.5 (Berkeley) 4/16/94
.\" $FreeBSD$
.\"
-.Dd November 25, 2009
+.Dd March 18, 2012
.Dt FTS 3
.Os
.Sh NAME
@@ -419,14 +419,17 @@ be provided to the
.Fn fts_open
function.
.It Dv FTS_NOCHDIR
-As a performance optimization, the
+To allow descending to arbitrary depths
+(independent of
+.Brq Dv PATH_MAX )
+and improve performance, the
.Nm
functions change directories as they walk the file hierarchy.
This has the side-effect that an application cannot rely on being
in any particular directory during the traversal.
The
.Dv FTS_NOCHDIR
-option turns off this optimization, and the
+option turns off this feature, and the
.Nm
functions will not change the current directory.
Note that applications should not themselves change their current directory
@@ -798,3 +801,13 @@ functions were introduced in
principally to provide for alternative interfaces to the
.Nm
functionality using different data structures.
+.Sh BUGS
+The
+.Fn fts_open
+function will automatically set the
+.Dv FTS_NOCHDIR
+option if the
+.Dv FTS_LOGICAL
+option is provided, or if it cannot
+.Xr open 2
+the current directory.
diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c
index f727003c13d5..1344464585ad 100644
--- a/lib/libc/gen/fts.c
+++ b/lib/libc/gen/fts.c
@@ -226,9 +226,7 @@ mem1: free(sp);
}
static void
-fts_load(sp, p)
- FTS *sp;
- FTSENT *p;
+fts_load(FTS *sp, FTSENT *p)
{
size_t len;
char *cp;
@@ -252,8 +250,7 @@ fts_load(sp, p)
}
int
-fts_close(sp)
- FTS *sp;
+fts_close(FTS *sp)
{
FTSENT *freep, *p;
int saved_errno;
@@ -307,8 +304,7 @@ fts_close(sp)
? p->fts_pathlen - 1 : p->fts_pathlen)
FTSENT *
-fts_read(sp)
- FTS *sp;
+fts_read(FTS *sp)
{
FTSENT *p, *tmp;
int instr;
@@ -501,10 +497,7 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent);
*/
/* ARGSUSED */
int
-fts_set(sp, p, instr)
- FTS *sp;
- FTSENT *p;
- int instr;
+fts_set(FTS *sp, FTSENT *p, int instr)
{
if (instr != 0 && instr != FTS_AGAIN && instr != FTS_FOLLOW &&
instr != FTS_NOINSTR && instr != FTS_SKIP) {
@@ -516,9 +509,7 @@ fts_set(sp, p, instr)
}
FTSENT *
-fts_children(sp, instr)
- FTS *sp;
- int instr;
+fts_children(FTS *sp, int instr)
{
FTSENT *p;
int fd;
@@ -628,9 +619,7 @@ fts_set_clientptr(FTS *sp, void *clientptr)
* been found, cutting the stat calls by about 2/3.
*/
static FTSENT *
-fts_build(sp, type)
- FTS *sp;
- int type;
+fts_build(FTS *sp, int type)
{
struct dirent *dp;
FTSENT *p, *head;
@@ -876,10 +865,7 @@ mem1: saved_errno = errno;
}
static int
-fts_stat(sp, p, follow)
- FTS *sp;
- FTSENT *p;
- int follow;
+fts_stat(FTS *sp, FTSENT *p, int follow)
{
FTSENT *t;
dev_t dev;
@@ -974,10 +960,7 @@ fts_compar(const void *a, const void *b)
}
static FTSENT *
-fts_sort(sp, head, nitems)
- FTS *sp;
- FTSENT *head;
- size_t nitems;
+fts_sort(FTS *sp, FTSENT *head, size_t nitems)
{
FTSENT **ap, *p;
@@ -1006,10 +989,7 @@ fts_sort(sp, head, nitems)
}
static FTSENT *
-fts_alloc(sp, name, namelen)
- FTS *sp;
- char *name;
- size_t namelen;
+fts_alloc(FTS *sp, char *name, size_t namelen)
{
FTSENT *p;
size_t len;
@@ -1056,8 +1036,7 @@ fts_alloc(sp, name, namelen)
}
static void
-fts_lfree(head)
- FTSENT *head;
+fts_lfree(FTSENT *head)
{
FTSENT *p;
@@ -1075,9 +1054,7 @@ fts_lfree(head)
* plus 256 bytes so don't realloc the path 2 bytes at a time.
*/
static int
-fts_palloc(sp, more)
- FTS *sp;
- size_t more;
+fts_palloc(FTS *sp, size_t more)
{
sp->fts_pathlen += more + 256;
@@ -1090,9 +1067,7 @@ fts_palloc(sp, more)
* already returned.
*/
static void
-fts_padjust(sp, head)
- FTS *sp;
- FTSENT *head;
+fts_padjust(FTS *sp, FTSENT *head)
{
FTSENT *p;
char *addr = sp->fts_path;
@@ -1133,11 +1108,7 @@ fts_maxarglen(argv)
* Assumes p->fts_dev and p->fts_ino are filled in.
*/
static int
-fts_safe_changedir(sp, p, fd, path)
- FTS *sp;
- FTSENT *p;
- int fd;
- char *path;
+fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path)
{
int ret, oerrno, newfd;
struct stat sb;
diff --git a/lib/libc/gen/getcontext.3 b/lib/libc/gen/getcontext.3
index 2fda6b8ced42..5b801fd3d353 100644
--- a/lib/libc/gen/getcontext.3
+++ b/lib/libc/gen/getcontext.3
@@ -35,11 +35,11 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 10, 2002
+.Dd December 26, 2011
.Dt GETCONTEXT 3
.Os
.Sh NAME
-.Nm getcontext , setcontext
+.Nm getcontext , getcontextx , setcontext
.Nd get and set user thread context
.Sh LIBRARY
.Lb libc
@@ -59,6 +59,20 @@ This saved context may then later be restored by calling
.Fn setcontext .
.Pp
The
+.Fn getcontextx
+function saves the current execution context in the newly allocated structure
+.Vt ucontext_t ,
+which is returned on success.
+If architecture defines additional CPU states that can be stored in extended
+blocks referenced from the
+.Vt ucontext_t ,
+the memory for them may be allocated and their context also stored.
+Memory returned by
+.Fn getcontextx
+function shall be freed using
+.Fn free 3 .
+.Pp
+The
.Fn setcontext
function
makes a previously saved thread context the current thread context, i.e.,
@@ -109,11 +123,24 @@ If successful,
returns zero and
.Fn setcontext
does not return; otherwise \-1 is returned.
+The
+.Fn getcontextx
+returns pointer to the allocated and initialized context on success, and
+.Va NULL
+on failure.
.Sh ERRORS
No errors are defined for
.Fn getcontext
or
.Fn setcontext .
+The
+.Fn getcontextx
+may return the following errors in
+.Va errno :
+.Bl -tag -width Er
+.It Bq Er ENOMEM
+No memory was available to allocate for the context or some extended state.
+.El
.Sh SEE ALSO
.Xr sigaction 2 ,
.Xr sigaltstack 2 ,
diff --git a/lib/libc/gen/getgrouplist.3 b/lib/libc/gen/getgrouplist.3
index 3f7faa2431ab..44d95f50077f 100644
--- a/lib/libc/gen/getgrouplist.3
+++ b/lib/libc/gen/getgrouplist.3
@@ -28,7 +28,7 @@
.\" @(#)getgrouplist.3 8.1 (Berkeley) 6/9/93
.\" $FreeBSD$
.\"
-.Dd June 9, 1993
+.Dd February 20, 2012
.Dt GETGROUPLIST 3
.Os
.Sh NAME
@@ -64,7 +64,7 @@ the actual number of groups found is returned in
The
.Fn getgrouplist
function
-returns \-1 if the size of the group list is too small to
+returns 0 on success and \-1 if the size of the group list is too small to
hold all the user's groups.
Here, the group array will be filled with as many groups as will fit.
.Sh FILES
diff --git a/lib/libc/gen/getpagesizes.3 b/lib/libc/gen/getpagesizes.3
index 959df8155864..854e2f7858fe 100644
--- a/lib/libc/gen/getpagesizes.3
+++ b/lib/libc/gen/getpagesizes.3
@@ -56,7 +56,7 @@ array referenced by
These page sizes are expressed in bytes.
In this case,
.Fn getpagesizes
-returns the number of such page sizes that it assigned to the array.
+returns the number of such page sizes that it assigned to the array.
.Sh RETURN VALUES
If successful, the
.Fn getpagesizes
diff --git a/lib/libc/gen/getutxent.3 b/lib/libc/gen/getutxent.3
index e7bfae430a28..2ea09712d8d4 100644
--- a/lib/libc/gen/getutxent.3
+++ b/lib/libc/gen/getutxent.3
@@ -418,13 +418,12 @@ The file format is invalid.
.Sh SEE ALSO
.Xr last 1 ,
.Xr write 1 ,
-.Xr wtmpcvt 1 ,
.Xr getpid 2 ,
.Xr gettimeofday 2 ,
.Xr tty 4 ,
.Xr ac 8 ,
.Xr newsyslog 8 ,
-.Xr utxrm 8
+.Xr utx 8
.Sh STANDARDS
The
.Fn endutxent ,
diff --git a/lib/libc/gen/getutxent.c b/lib/libc/gen/getutxent.c
index 556df56220ed..a2e938a988f5 100644
--- a/lib/libc/gen/getutxent.c
+++ b/lib/libc/gen/getutxent.c
@@ -38,8 +38,13 @@ __FBSDID("$FreeBSD$");
#include "utxdb.h"
#include "un-namespace.h"
+#ifdef __NO_TLS
static FILE *uf = NULL;
static int udb;
+#else
+static _Thread_local FILE *uf = NULL;
+static _Thread_local int udb;
+#endif
int
setutxdb(int db, const char *file)
@@ -70,13 +75,18 @@ setutxdb(int db, const char *file)
if (uf == NULL)
return (-1);
- /* Safety check: never use broken files. */
- if (db != UTXDB_LOG && _fstat(fileno(uf), &sb) != -1 &&
- sb.st_size % sizeof(struct futx) != 0) {
- fclose(uf);
- uf = NULL;
- errno = EFTYPE;
- return (-1);
+ if (db != UTXDB_LOG) {
+ /* Safety check: never use broken files. */
+ if (_fstat(fileno(uf), &sb) != -1 &&
+ sb.st_size % sizeof(struct futx) != 0) {
+ fclose(uf);
+ uf = NULL;
+ errno = EFTYPE;
+ return (-1);
+ }
+ /* Prevent reading of partial records. */
+ (void)setvbuf(uf, NULL, _IOFBF,
+ rounddown(BUFSIZ, sizeof(struct futx)));
}
udb = db;
diff --git a/lib/libc/gen/opendir.c b/lib/libc/gen/opendir.c
index 407c0478c06b..3beead7fbd19 100644
--- a/lib/libc/gen/opendir.c
+++ b/lib/libc/gen/opendir.c
@@ -66,7 +66,17 @@ opendir(const char *name)
DIR *
fdopendir(int fd)
{
+ struct stat statb;
+ /* Check that fd is associated with a directory. */
+ if (_fstat(fd, &statb) != 0)
+ return (NULL);
+ if (!S_ISDIR(statb.st_mode)) {
+ errno = ENOTDIR;
+ return (NULL);
+ }
+ if (_fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
+ return (NULL);
return (__opendir_common(fd, NULL, DTF_HIDEW|DTF_NODUP));
}
@@ -74,21 +84,11 @@ DIR *
__opendir2(const char *name, int flags)
{
int fd;
- struct stat statb;
DIR *dir;
int saved_errno;
- /*
- * stat() before _open() because opening of special files may be
- * harmful.
- */
- if (stat(name, &statb) != 0)
- return (NULL);
- if (!S_ISDIR(statb.st_mode)) {
- errno = ENOTDIR;
- return (NULL);
- }
- if ((fd = _open(name, O_RDONLY | O_NONBLOCK | O_DIRECTORY)) == -1)
+ if ((fd = _open(name,
+ O_RDONLY | O_NONBLOCK | O_DIRECTORY | O_CLOEXEC)) == -1)
return (NULL);
dir = __opendir_common(fd, name, flags);
@@ -119,19 +119,9 @@ __opendir_common(int fd, const char *name, int flags)
int saved_errno;
int unionstack;
int fd2;
- struct stat statb;
- dirp = NULL;
- /* _fstat() the open handler because the file may have changed. */
- if (_fstat(fd, &statb) != 0)
- goto fail;
- if (!S_ISDIR(statb.st_mode)) {
- errno = ENOTDIR;
- goto fail;
- }
- if (_fcntl(fd, F_SETFD, FD_CLOEXEC) == -1 ||
- (dirp = malloc(sizeof(DIR) + sizeof(struct _telldir))) == NULL)
- goto fail;
+ if ((dirp = malloc(sizeof(DIR) + sizeof(struct _telldir))) == NULL)
+ return (NULL);
dirp->dd_td = (struct _telldir *)((char *)dirp + sizeof(DIR));
LIST_INIT(&dirp->dd_td->td_locq);
diff --git a/lib/libc/gen/psignal.3 b/lib/libc/gen/psignal.3
index 5986ffa0870e..231acfa5e107 100644
--- a/lib/libc/gen/psignal.3
+++ b/lib/libc/gen/psignal.3
@@ -79,7 +79,7 @@ immediately followed by a colon and a space.
If the signal number is not recognized
.Pq Xr sigaction 2 ,
the string
-.Dq "Unknown signal
+.Dq "Unknown signal"
is produced.
.Pp
The message strings can be accessed directly
diff --git a/lib/libc/gen/sem.c b/lib/libc/gen/sem.c
index e9ae6691090d..71cd0517743d 100644
--- a/lib/libc/gen/sem.c
+++ b/lib/libc/gen/sem.c
@@ -312,15 +312,24 @@ _libc_sem_unlink_compat(const char *name)
}
static int
-_umtx_wait_uint(volatile unsigned *mtx, unsigned id, const struct timespec *timeout)
+_umtx_wait_uint(volatile unsigned *mtx, unsigned id, const struct timespec *abstime)
{
- if (timeout && (timeout->tv_sec < 0 || (timeout->tv_sec == 0 &&
- timeout->tv_nsec <= 0))) {
- errno = ETIMEDOUT;
- return (-1);
+ struct _umtx_time *tm_p, timeout;
+ size_t tm_size;
+
+ if (abstime == NULL) {
+ tm_p = NULL;
+ tm_size = 0;
+ } else {
+ timeout._clockid = CLOCK_REALTIME;
+ timeout._flags = UMTX_ABSTIME;
+ timeout._timeout = *abstime;
+ tm_p = &timeout;
+ tm_size = sizeof(timeout);
}
return _umtx_op(__DEVOLATILE(void *, mtx),
- UMTX_OP_WAIT_UINT_PRIVATE, id, NULL, __DECONST(void*, timeout));
+ UMTX_OP_WAIT_UINT_PRIVATE, id,
+ (void *)tm_size, __DECONST(void*, tm_p));
}
static int
@@ -355,7 +364,6 @@ int
_libc_sem_timedwait_compat(sem_t * __restrict sem,
const struct timespec * __restrict abstime)
{
- struct timespec ts, ts2;
int val, retval;
if (sem_check_validity(sem) != 0)
@@ -384,13 +392,11 @@ _libc_sem_timedwait_compat(sem_t * __restrict sem,
errno = EINVAL;
return (-1);
}
- clock_gettime(CLOCK_REALTIME, &ts);
- TIMESPEC_SUB(&ts2, abstime, &ts);
}
atomic_add_int(&(*sem)->nwaiters, 1);
pthread_cleanup_push(sem_cancel_handler, sem);
_pthread_cancel_enter(1);
- retval = _umtx_wait_uint(&(*sem)->count, 0, abstime ? &ts2 : NULL);
+ retval = _umtx_wait_uint(&(*sem)->count, 0, abstime);
_pthread_cancel_leave(0);
pthread_cleanup_pop(0);
atomic_add_int(&(*sem)->nwaiters, -1);
@@ -434,7 +440,7 @@ _libc_sem_post_compat(sem_t *sem)
return ksem_post((*sem)->semid);
atomic_add_rel_int(&(*sem)->count, 1);
-
+ rmb();
if ((*sem)->nwaiters)
return _umtx_wake(&(*sem)->count);
return (0);
diff --git a/lib/libc/gen/sem_new.c b/lib/libc/gen/sem_new.c
index 2698b4056536..b748b49235af 100644
--- a/lib/libc/gen/sem_new.c
+++ b/lib/libc/gen/sem_new.c
@@ -162,10 +162,16 @@ _sem_open(const char *name, int flags, ...)
_pthread_mutex_lock(&sem_llock);
LIST_FOREACH(ni, &sem_list, next) {
if (strcmp(name, ni->name) == 0) {
- ni->open_count++;
- sem = ni->sem;
- _pthread_mutex_unlock(&sem_llock);
- return (sem);
+ if ((flags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL)) {
+ _pthread_mutex_unlock(&sem_llock);
+ errno = EEXIST;
+ return (SEM_FAILED);
+ } else {
+ ni->open_count++;
+ sem = ni->sem;
+ _pthread_mutex_unlock(&sem_llock);
+ return (sem);
+ }
}
}
@@ -332,21 +338,27 @@ _sem_getvalue(sem_t * __restrict sem, int * __restrict sval)
static __inline int
usem_wake(struct _usem *sem)
{
- if (!sem->_has_waiters)
- return (0);
return _umtx_op(sem, UMTX_OP_SEM_WAKE, 0, NULL, NULL);
}
static __inline int
-usem_wait(struct _usem *sem, const struct timespec *timeout)
+usem_wait(struct _usem *sem, const struct timespec *abstime)
{
- if (timeout && (timeout->tv_sec < 0 || (timeout->tv_sec == 0 &&
- timeout->tv_nsec <= 0))) {
- errno = ETIMEDOUT;
- return (-1);
+ struct _umtx_time *tm_p, timeout;
+ size_t tm_size;
+
+ if (abstime == NULL) {
+ tm_p = NULL;
+ tm_size = 0;
+ } else {
+ timeout._clockid = CLOCK_REALTIME;
+ timeout._flags = UMTX_ABSTIME;
+ timeout._timeout = *abstime;
+ tm_p = &timeout;
+ tm_size = sizeof(timeout);
}
- return _umtx_op(sem, UMTX_OP_SEM_WAIT, 0, NULL,
- __DECONST(void*, timeout));
+ return _umtx_op(sem, UMTX_OP_SEM_WAIT, 0,
+ (void *)tm_size, __DECONST(void*, tm_p));
}
int
@@ -365,22 +377,10 @@ _sem_trywait(sem_t *sem)
return (-1);
}
-#define TIMESPEC_SUB(dst, src, val) \
- do { \
- (dst)->tv_sec = (src)->tv_sec - (val)->tv_sec; \
- (dst)->tv_nsec = (src)->tv_nsec - (val)->tv_nsec; \
- if ((dst)->tv_nsec < 0) { \
- (dst)->tv_sec--; \
- (dst)->tv_nsec += 1000000000; \
- } \
- } while (0)
-
-
int
_sem_timedwait(sem_t * __restrict sem,
const struct timespec * __restrict abstime)
{
- struct timespec ts, ts2;
int val, retval;
if (sem_check_validity(sem) != 0)
@@ -407,11 +407,9 @@ _sem_timedwait(sem_t * __restrict sem,
errno = EINVAL;
return (-1);
}
- clock_gettime(CLOCK_REALTIME, &ts);
- TIMESPEC_SUB(&ts2, abstime, &ts);
}
_pthread_cancel_enter(1);
- retval = usem_wait(&sem->_kern, abstime ? &ts2 : NULL);
+ retval = usem_wait(&sem->_kern, abstime);
_pthread_cancel_leave(0);
}
return (retval);
@@ -432,10 +430,16 @@ _sem_wait(sem_t *sem)
int
_sem_post(sem_t *sem)
{
+ unsigned int count;
if (sem_check_validity(sem) != 0)
return (-1);
- atomic_add_rel_int(&sem->_kern._count, 1);
- return usem_wake(&sem->_kern);
+ do {
+ count = sem->_kern._count;
+ if (count + 1 > SEM_VALUE_MAX)
+ return (EOVERFLOW);
+ } while(!atomic_cmpset_rel_int(&sem->_kern._count, count, count+1));
+ (void)usem_wake(&sem->_kern);
+ return (0);
}
diff --git a/lib/libc/gen/sysconf.3 b/lib/libc/gen/sysconf.3
index 51f7eebb3fc4..4af6f821f138 100644
--- a/lib/libc/gen/sysconf.3
+++ b/lib/libc/gen/sysconf.3
@@ -211,7 +211,7 @@ Maximum number of functions that may be registered with
.It Li _SC_XOPEN_VERSION
An integer value greater than or equal to 4,
indicating the version of the X/Open Portability Guide to which this
-system conforms.
+system conforms.
.It Li _SC_XOPEN_XCU_VERSION
An integer value indicating the version of the XCU Specification to which
this system conforms.
diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3
index a841545f2d54..b3737e2d1aaa 100644
--- a/lib/libc/gen/sysctl.3
+++ b/lib/libc/gen/sysctl.3
@@ -28,7 +28,7 @@
.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95
.\" $FreeBSD$
.\"
-.Dd April 25, 2010
+.Dd February 11, 2012
.Dt SYSCTL 3
.Os
.Sh NAME
@@ -554,6 +554,7 @@ The fifth and sixth level names are as follows:
.It "NET_RT_DUMP None"
.It "NET_RT_IFLIST 0 or if_index"
.It "NET_RT_IFMALIST 0 or if_index"
+.It "NET_RT_IFLISTL 0 or if_index"
.El
.Pp
The
@@ -561,6 +562,19 @@ The
name returns information about multicast group memberships on all interfaces
if 0 is specified, or for the interface specified by
.Va if_index .
+.Pp
+The
+.Dv NET_RT_IFLISTL
+is like
+.Dv NET_RT_IFLIST ,
+just returning message header structs with additional fields allowing the
+interface to be extended without breaking binary compatibility.
+The
+.Dv NET_RT_IFLISTL
+uses 'l' versions of the message header structures:
+.Va struct if_msghdrl
+and
+.Va struct ifa_msghdrl .
.It Li PF_INET
Get or set various global information about the IPv4
(Internet Protocol version 4).
diff --git a/lib/libc/gen/tls.c b/lib/libc/gen/tls.c
index 9d8467997b94..466f9579acb4 100644
--- a/lib/libc/gen/tls.c
+++ b/lib/libc/gen/tls.c
@@ -39,6 +39,11 @@
#include "libc_private.h"
+/* Provided by jemalloc to avoid bootstrapping issues. */
+void *__jemalloc_a0malloc(size_t size);
+void *__jemalloc_a0calloc(size_t num, size_t size);
+void __jemalloc_a0free(void *ptr);
+
__weak_reference(__libc_allocate_tls, _rtld_allocate_tls);
__weak_reference(__libc_free_tls, _rtld_free_tls);
@@ -66,11 +71,11 @@ void __libc_free_tls(void *tls, size_t tcbsize, size_t tcbalign);
#error TLS_TCB_ALIGN undefined for target architecture
#endif
-#if defined(__ia64__) || defined(__powerpc__)
+#if defined(__arm__) || defined(__ia64__) || defined(__mips__) || \
+ defined(__powerpc__)
#define TLS_VARIANT_I
#endif
-#if defined(__i386__) || defined(__amd64__) || defined(__sparc64__) || \
- defined(__arm__) || defined(__mips__)
+#if defined(__i386__) || defined(__amd64__) || defined(__sparc64__)
#define TLS_VARIANT_II
#endif
@@ -120,8 +125,8 @@ __libc_free_tls(void *tcb, size_t tcbsize, size_t tcbalign __unused)
tls = (Elf_Addr **)((Elf_Addr)tcb + tcbsize - TLS_TCB_SIZE);
dtv = tls[0];
- free(dtv);
- free(tcb);
+ __jemalloc_a0free(dtv);
+ __jemalloc_a0free(tcb);
}
/*
@@ -137,18 +142,18 @@ __libc_allocate_tls(void *oldtcb, size_t tcbsize, size_t tcbalign __unused)
if (oldtcb != NULL && tcbsize == TLS_TCB_SIZE)
return (oldtcb);
- tcb = calloc(1, tls_static_space + tcbsize - TLS_TCB_SIZE);
+ tcb = __jemalloc_a0calloc(1, tls_static_space + tcbsize - TLS_TCB_SIZE);
tls = (Elf_Addr **)(tcb + tcbsize - TLS_TCB_SIZE);
if (oldtcb != NULL) {
memcpy(tls, oldtcb, tls_static_space);
- free(oldtcb);
+ __jemalloc_a0free(oldtcb);
/* Adjust the DTV. */
dtv = tls[0];
dtv[2] = (Elf_Addr)tls + TLS_TCB_SIZE;
} else {
- dtv = malloc(3 * sizeof(Elf_Addr));
+ dtv = __jemalloc_a0malloc(3 * sizeof(Elf_Addr));
tls[0] = dtv;
dtv[0] = 1;
dtv[1] = 1;
@@ -189,8 +194,8 @@ __libc_free_tls(void *tcb, size_t tcbsize __unused, size_t tcbalign)
dtv = ((Elf_Addr**)tcb)[1];
tlsend = (Elf_Addr) tcb;
tlsstart = tlsend - size;
- free((void*) tlsstart);
- free(dtv);
+ __jemalloc_a0free((void*) tlsstart);
+ __jemalloc_a0free(dtv);
}
/*
@@ -208,8 +213,8 @@ __libc_allocate_tls(void *oldtls, size_t tcbsize, size_t tcbalign)
if (tcbsize < 2 * sizeof(Elf_Addr))
tcbsize = 2 * sizeof(Elf_Addr);
- tls = calloc(1, size + tcbsize);
- dtv = malloc(3 * sizeof(Elf_Addr));
+ tls = __jemalloc_a0calloc(1, size + tcbsize);
+ dtv = __jemalloc_a0malloc(3 * sizeof(Elf_Addr));
segbase = (Elf_Addr)(tls + size);
((Elf_Addr*)segbase)[0] = segbase;
@@ -308,6 +313,13 @@ _init_tls()
}
}
+#ifdef TLS_VARIANT_I
+ /*
+ * tls_static_space should include space for TLS structure
+ */
+ tls_static_space += TLS_TCB_SIZE;
+#endif
+
tls = _rtld_allocate_tls(NULL, TLS_TCB_SIZE, TLS_TCB_ALIGN);
_set_tp(tls);
diff --git a/lib/libc/gen/ucontext.3 b/lib/libc/gen/ucontext.3
index 05743224a82b..69ecbc1793e0 100644
--- a/lib/libc/gen/ucontext.3
+++ b/lib/libc/gen/ucontext.3
@@ -92,6 +92,9 @@ structures:
.Ft int
.Fn getcontext "ucontext_t *" ;
.It
+.Ft "ucontext_t *"
+.Fn getcontextx "void" ;
+.It
.Ft int
.Fn setcontext "const ucontext_t *" ;
.It
@@ -104,4 +107,5 @@ structures:
.Sh SEE ALSO
.Xr sigaltstack 2 ,
.Xr getcontext 3 ,
+.Xr getcontextx 3 ,
.Xr makecontext 3
diff --git a/lib/libc/gen/utxdb.c b/lib/libc/gen/utxdb.c
index 743629dd5f9d..66671290dc4b 100644
--- a/lib/libc/gen/utxdb.c
+++ b/lib/libc/gen/utxdb.c
@@ -126,7 +126,11 @@ utx_to_futx(const struct utmpx *ut, struct futx *fu)
struct utmpx *
futx_to_utx(const struct futx *fu)
{
+#ifdef __NO_TLS
static struct utmpx *ut;
+#else
+ static _Thread_local struct utmpx *ut;
+#endif
if (ut == NULL) {
ut = calloc(1, sizeof *ut);
diff --git a/lib/libc/i386/gen/Makefile.inc b/lib/libc/i386/gen/Makefile.inc
index 45e69cad1d0f..73dcabbece53 100644
--- a/lib/libc/i386/gen/Makefile.inc
+++ b/lib/libc/i386/gen/Makefile.inc
@@ -2,5 +2,5 @@
# $FreeBSD$
SRCS+= _ctx_start.S _setjmp.S _set_tp.c fabs.S \
- flt_rounds.c infinity.c ldexp.c makecontext.c \
+ flt_rounds.c getcontextx.c infinity.c ldexp.c makecontext.c \
rfork_thread.S setjmp.S signalcontext.c sigsetjmp.S
diff --git a/lib/libc/i386/gen/getcontextx.c b/lib/libc/i386/gen/getcontextx.c
new file mode 100644
index 000000000000..5908ce774ba8
--- /dev/null
+++ b/lib/libc/i386/gen/getcontextx.c
@@ -0,0 +1,133 @@
+/*
+ * 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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/ucontext.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <machine/npx.h>
+#include <machine/specialreg.h>
+#include <machine/sysarch.h>
+
+static int xstate_sz = -1;
+
+int
+__getcontextx_size(void)
+{
+ u_int p[4];
+ int cpuid_supported;
+
+ if (xstate_sz == -1) {
+ __asm __volatile(
+ " pushfl\n"
+ " popl %%eax\n"
+ " movl %%eax,%%ecx\n"
+ " xorl $0x200000,%%eax\n"
+ " pushl %%eax\n"
+ " popfl\n"
+ " pushfl\n"
+ " popl %%eax\n"
+ " xorl %%eax,%%ecx\n"
+ " je 1f\n"
+ " movl $1,%0\n"
+ " jmp 2f\n"
+ "1: movl $0,%0\n"
+ "2:\n"
+ : "=r" (cpuid_supported) : : "eax", "ecx");
+ if (cpuid_supported) {
+ __asm __volatile(
+ " pushl %%ebx\n"
+ " cpuid\n"
+ " movl %%ebx,%1\n"
+ " popl %%ebx\n"
+ : "=a" (p[0]), "=r" (p[1]), "=c" (p[2]), "=d" (p[3])
+ : "0" (0x0));
+ if ((p[2] & CPUID2_OSXSAVE) != 0) {
+ __asm __volatile(
+ " pushl %%ebx\n"
+ " cpuid\n"
+ " movl %%ebx,%1\n"
+ " popl %%ebx\n"
+ : "=a" (p[0]), "=r" (p[1]), "=c" (p[2]),
+ "=d" (p[3])
+ : "0" (0xd), "2" (0x0));
+ xstate_sz = p[1] - sizeof(struct savexmm);
+ } else
+ xstate_sz = 0;
+ } else
+ xstate_sz = 0;
+ }
+
+ return (sizeof(ucontext_t) + xstate_sz);
+}
+
+int
+__fillcontextx(char *ctx)
+{
+ struct i386_get_xfpustate xfpu;
+ ucontext_t *ucp;
+
+ ucp = (ucontext_t *)ctx;
+ if (getcontext(ucp) == -1)
+ return (-1);
+ if (xstate_sz != 0) {
+ xfpu.addr = (char *)(ucp + 1);
+ xfpu.len = xstate_sz;
+ if (sysarch(I386_GET_XFPUSTATE, &xfpu) == -1)
+ return (-1);
+ ucp->uc_mcontext.mc_xfpustate = (__register_t)xfpu.addr;
+ ucp->uc_mcontext.mc_xfpustate_len = xstate_sz;
+ ucp->uc_mcontext.mc_flags |= _MC_HASFPXSTATE;
+ } else {
+ ucp->uc_mcontext.mc_xfpustate = 0;
+ ucp->uc_mcontext.mc_xfpustate_len = 0;
+ }
+ 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/i386/string/strchr.S b/lib/libc/i386/string/strchr.S
index 4162da2101ba..57fc6dd6fbea 100644
--- a/lib/libc/i386/string/strchr.S
+++ b/lib/libc/i386/string/strchr.S
@@ -63,6 +63,6 @@ L2:
ret
END(strchr)
-STRONG_ALIAS(index, strchr)
+WEAK_ALIAS(index, strchr)
.section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/i386/string/strrchr.S b/lib/libc/i386/string/strrchr.S
index a07ecd8ff95d..29942c498004 100644
--- a/lib/libc/i386/string/strrchr.S
+++ b/lib/libc/i386/string/strrchr.S
@@ -64,6 +64,6 @@ L2:
ret
END(strrchr)
-STRONG_ALIAS(rindex, strrchr)
+WEAK_ALIAS(rindex, strrchr)
.section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/i386/sys/i386_get_ioperm.2 b/lib/libc/i386/sys/i386_get_ioperm.2
index 4d3bbf18262b..75fdd10e94b9 100644
--- a/lib/libc/i386/sys/i386_get_ioperm.2
+++ b/lib/libc/i386/sys/i386_get_ioperm.2
@@ -25,8 +25,8 @@
.\" $FreeBSD$
.\"
.Dd July 27, 1998
-.Os
.Dt I386_GET_IOPERM 2
+.Os
.Sh NAME
.Nm i386_get_ioperm ,
.Nm i386_set_ioperm
diff --git a/lib/libc/i386/sys/i386_set_watch.3 b/lib/libc/i386/sys/i386_set_watch.3
index f818ee7656ce..9f37c9d65136 100644
--- a/lib/libc/i386/sys/i386_set_watch.3
+++ b/lib/libc/i386/sys/i386_set_watch.3
@@ -28,8 +28,8 @@
.\" $FreeBSD$
.\"
.Dd August 24, 2000
-.Os
.Dt I386_SET_WATCH 3
+.Os
.Sh NAME
.Nm i386_clr_watch ,
.Nm i386_set_watch
diff --git a/lib/libc/i386/sys/i386_vm86.2 b/lib/libc/i386/sys/i386_vm86.2
index 03c1873c8984..5958f31d2cbf 100644
--- a/lib/libc/i386/sys/i386_vm86.2
+++ b/lib/libc/i386/sys/i386_vm86.2
@@ -25,8 +25,8 @@
.\" $FreeBSD$
.\"
.Dd July 27, 1998
-.Os
.Dt I386_VM86 2
+.Os
.Sh NAME
.Nm i386_vm86
.Nd control vm86-related functions
diff --git a/lib/libc/ia64/gen/Makefile.inc b/lib/libc/ia64/gen/Makefile.inc
index 685ab86c9f46..1e3373a6d650 100644
--- a/lib/libc/ia64/gen/Makefile.inc
+++ b/lib/libc/ia64/gen/Makefile.inc
@@ -3,7 +3,7 @@
SRCS+= __divdf3.S __divdi3.S __divsf3.S __divsi3.S __moddi3.S __modsi3.S \
__udivdi3.S __udivsi3.S __umoddi3.S __umodsi3.S _mcount.S _set_tp.c \
_setjmp.S fabs.S flt_rounds.c fpgetmask.c fpgetround.c fpsetmask.c \
- fpsetround.c infinity.c ldexp.c makecontext.c setjmp.S \
+ fpsetround.c getcontextx.c infinity.c ldexp.c makecontext.c setjmp.S \
signalcontext.c sigsetjmp.S
# The following may go away if function _Unwind_FindTableEntry()
diff --git a/lib/libc/ia64/gen/getcontextx.c b/lib/libc/ia64/gen/getcontextx.c
new file mode 100644
index 000000000000..307978a466dd
--- /dev/null
+++ b/lib/libc/ia64/gen/getcontextx.c
@@ -0,0 +1,69 @@
+/*
+ * 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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/ucontext.h>
+#include <errno.h>
+#include <stdlib.h>
+
+int
+__getcontextx_size(void)
+{
+
+ return (sizeof(ucontext_t));
+}
+
+int
+__fillcontextx(char *ctx)
+{
+ ucontext_t *ucp;
+
+ ucp = (ucontext_t *)ctx;
+ return (getcontext(ucp));
+}
+
+__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/iconv/iconv.3 b/lib/libc/iconv/iconv.3
index 9b658e9cd238..939d4420a153 100644
--- a/lib/libc/iconv/iconv.3
+++ b/lib/libc/iconv/iconv.3
@@ -26,7 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd Juny 16, 2010
+.Dd June 16, 2010
.Dt ICONV 3
.Os
.Sh NAME
diff --git a/lib/libc/iconv/iconvctl.3 b/lib/libc/iconv/iconvctl.3
index 30fc0aa49a75..f0121573af99 100644
--- a/lib/libc/iconv/iconvctl.3
+++ b/lib/libc/iconv/iconvctl.3
@@ -61,7 +61,7 @@ parameter specifies the operation to accomplish and
is an operation-specific argument.
.Pp
The possible operations are the following:
-.Bl -tag -width -indent
+.Bl -tag -width indent
.It ICONV_TRIVIALP
In this case
.Fa argument
@@ -110,6 +110,7 @@ variable, which is passed to
via
.Fa argument
by its address.
+.El
.\" XXX: fallbacks are unimplemented and trying to set them will always
.\" return EOPNOTSUPP but definitions are provided for source-level
.\" compatibility.
@@ -140,6 +141,7 @@ Unknown or unimplemented operation.
The conversion descriptor specified by
.Fa cd
is invalid.
+.El
.Sh SEE ALSO
.Xr iconv 1 ,
.Xr iconv 3
diff --git a/lib/libc/iconv/iconvlist.3 b/lib/libc/iconv/iconvlist.3
index e3fc43c1dd93..d474d9beefa7 100644
--- a/lib/libc/iconv/iconvlist.3
+++ b/lib/libc/iconv/iconvlist.3
@@ -46,7 +46,7 @@
.Sh SYNOPSIS
.In iconv.h
.Ft void
-.Fo iconvlist "char ***names" "size_t count" "bool paired"
+.Fo iconvlist
.Fa "int \*[lp]*do_one\*[rp]\*[lp]unsigned int *count, const char * const *names, void *arg\*[rp]"
.Fa "void *arg"
.Fc
diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h
index c7284cc3afee..2182f4689719 100644
--- a/lib/libc/include/libc_private.h
+++ b/lib/libc/include/libc_private.h
@@ -44,6 +44,15 @@
extern int __isthreaded;
/*
+ * Elf_Auxinfo *__elf_aux_vector, the pointer to the ELF aux vector
+ * provided by kernel. Either set for us by rtld, or found at runtime
+ * on stack for static binaries.
+ *
+ * Type is void to avoid polluting whole libc with ELF types.
+ */
+extern void *__elf_aux_vector;
+
+/*
* libc should use libc_dlopen internally, which respects a global
* flag where loading of new shared objects can be restricted.
*/
@@ -72,6 +81,19 @@ void _rtld_error(const char *fmt, ...);
#define FLOCKFILE(fp) if (__isthreaded) _FLOCKFILE(fp)
#define FUNLOCKFILE(fp) if (__isthreaded) _funlockfile(fp)
+struct _spinlock;
+extern struct _spinlock __stdio_thread_lock;
+#define STDIO_THREAD_LOCK() \
+do { \
+ if (__isthreaded) \
+ _SPINLOCK(&__stdio_thread_lock); \
+} while (0)
+#define STDIO_THREAD_UNLOCK() \
+do { \
+ if (__isthreaded) \
+ _SPINUNLOCK(&__stdio_thread_lock); \
+} while (0)
+
/*
* Indexes into the pthread jump table.
*
@@ -229,6 +251,7 @@ 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 _pthread_cancel_enter(int);
void _pthread_cancel_leave(int);
diff --git a/lib/libc/locale/Makefile.inc b/lib/libc/locale/Makefile.inc
index 55800d02799f..adae8bd042f4 100644
--- a/lib/libc/locale/Makefile.inc
+++ b/lib/libc/locale/Makefile.inc
@@ -26,6 +26,7 @@ SRCS+= ascii.c big5.c btowc.c collate.c collcmp.c euc.c fix_grouping.c \
SYM_MAPS+=${.CURDIR}/locale/Symbol.map
MAN+= btowc.3 \
+ ctype_l.3 \
ctype.3 digittoint.3 isalnum.3 isalpha.3 isascii.3 isblank.3 iscntrl.3 \
isdigit.3 isgraph.3 isideogram.3 islower.3 isphonogram.3 isprint.3 \
ispunct.3 isrune.3 isspace.3 isspecial.3 \
diff --git a/lib/libc/locale/Symbol.map b/lib/libc/locale/Symbol.map
index 01242b694f7a..f6367dacf3fd 100644
--- a/lib/libc/locale/Symbol.map
+++ b/lib/libc/locale/Symbol.map
@@ -193,7 +193,12 @@ FBSD_1.3 {
wcstoul_l;
wcstoull_l;
wcstoumax_l;
+ __sbistype_l;
+ __maskrune_l;
+ __sbmaskrune_l;
+ __istype_l;
__runes_for_locale;
+ _ThreadRuneLocale;
};
FBSDprivate_1.0 {
diff --git a/lib/libc/locale/btowc.3 b/lib/libc/locale/btowc.3
index 85ee7515f948..d9c3e9cf34ee 100644
--- a/lib/libc/locale/btowc.3
+++ b/lib/libc/locale/btowc.3
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 3, 2002
+.Dd February 13, 2012
.Dt BTOWC 3
.Os
.Sh NAME
@@ -39,6 +39,12 @@
.Fn btowc "int c"
.Ft int
.Fn wctob "wint_t c"
+.In wchar.h
+.In xlocale.h
+.Ft wint_t
+.Fn btowc "int c"
+.Ft int
+.Fn wctob "wint_t c"
.Sh DESCRIPTION
The
.Fn btowc
@@ -58,7 +64,10 @@ If the wide character is
or not able to be represented as a single byte in the initial shift state,
.Fn wctob
returns
-.Dv WEOF .
+.Dv EOF .
+.Pp
+The _l-suffixed versions take an explicit locale argument, while the
+non-suffixed versions use the current global or per-thread locale.
.Sh SEE ALSO
.Xr mbrtowc 3 ,
.Xr multibyte 3 ,
diff --git a/lib/libc/locale/collate.c b/lib/libc/locale/collate.c
index e87b6dc7e1be..448e605491a8 100644
--- a/lib/libc/locale/collate.c
+++ b/lib/libc/locale/collate.c
@@ -8,11 +8,6 @@
* Portions of this software were developed by David Chisnall
* under sponsorship from the FreeBSD Foundation.
*
- * Copyright (c) 2011 The FreeBSD Foundation
- * All rights reserved.
- * Portions of this software were developed by David Chisnall
- * 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:
diff --git a/lib/libc/locale/ctype.3 b/lib/libc/locale/ctype.3
index fdc135878f7f..62ec05fbbed2 100644
--- a/lib/libc/locale/ctype.3
+++ b/lib/libc/locale/ctype.3
@@ -55,7 +55,7 @@
.Nm toascii ,
.Nm tolower ,
.Nm toupper
-.Nd character classification macros
+.Nd character classification functions
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
diff --git a/lib/libc/locale/ctype_l.3 b/lib/libc/locale/ctype_l.3
new file mode 100644
index 000000000000..385125ec8b83
--- /dev/null
+++ b/lib/libc/locale/ctype_l.3
@@ -0,0 +1,138 @@
+.\" Copyright (c) 2011 The FreeBSD Foundation
+.\" All rights reserved.
+.\"
+.\" This documentation was written by David Chisnall 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd March 6, 2012
+.Dt CTYPE_L 3
+.Os
+.Sh NAME
+.Nm digittoint_l ,
+.Nm isalnum_l ,
+.Nm isalpha_l ,
+.Nm isascii_l ,
+.Nm isblank_l ,
+.Nm iscntrl_l ,
+.Nm isdigit_l ,
+.Nm isgraph_l ,
+.Nm ishexnumber_l ,
+.Nm isideogram_l ,
+.Nm islower_l ,
+.Nm isnumber_l ,
+.Nm isphonogram_l ,
+.Nm isprint_l ,
+.Nm ispunct_l ,
+.Nm isrune_l ,
+.Nm isspace_l ,
+.Nm isspecial_l ,
+.Nm isupper_l ,
+.Nm isxdigit_l ,
+.Nm tolower_l ,
+.Nm toupper_l
+.Nd character classification functions
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In ctype.h
+.Ft int
+.Fn digittoint_l "int c" "locale_t loc"
+.Ft int
+.Fn isalnum_l "int c" "locale_t loc"
+.Ft int
+.Fn isalpha_l "int c" "locale_t loc"
+.Ft int
+.Fn isascii_l "int c" "locale_t loc"
+.Ft int
+.Fn iscntrl_l "int c" "locale_t loc"
+.Ft int
+.Fn isdigit_l "int c" "locale_t loc"
+.Ft int
+.Fn isgraph_l "int c" "locale_t loc"
+.Ft int
+.Fn ishexnumber_l "int c" "locale_t loc"
+.Ft int
+.Fn isideogram_l "int c" "locale_t loc"
+.Ft int
+.Fn islower_l "int c" "locale_t loc"
+.Ft int
+.Fn isnumber_l "int c" "locale_t loc"
+.Ft int
+.Fn isphonogram_l "int c" "locale_t loc"
+.Ft int
+.Fn isspecial_l "int c" "locale_t loc"
+.Ft int
+.Fn isprint_l "int c" "locale_t loc"
+.Ft int
+.Fn ispunct_l "int c" "locale_t loc"
+.Ft int
+.Fn isrune_l "int c" "locale_t loc"
+.Ft int
+.Fn isspace_l "int c" "locale_t loc"
+.Ft int
+.Fn isupper_l "int c" "locale_t loc"
+.Ft int
+.Fn isxdigit_l "int c" "locale_t loc"
+.Ft int
+.Fn tolower_l "int c" "locale_t loc"
+.Ft int
+.Fn toupper_l "int c" "locale_t loc"
+.Sh DESCRIPTION
+The above functions perform character tests and conversions on the integer
+.Fa c
+in the locale
+.Fa loc .
+They behave in the same way as the versions without the _l suffix, but use the
+specified locale rather than the global or per-thread locale.
+.In ctype.h ,
+or as true functions in the C library.
+See the specific manual pages for more information.
+.Sh SEE ALSO
+.Xr digittoint 3 ,
+.Xr isalnum 3 ,
+.Xr isalpha 3 ,
+.Xr isascii 3 ,
+.Xr isblank 3 ,
+.Xr iscntrl 3 ,
+.Xr isdigit 3 ,
+.Xr isgraph 3 ,
+.Xr isideogram 3 ,
+.Xr islower 3 ,
+.Xr isphonogram 3 ,
+.Xr isprint 3 ,
+.Xr ispunct 3 ,
+.Xr isrune 3 ,
+.Xr isspace 3 ,
+.Xr isspecial 3 ,
+.Xr isupper 3 ,
+.Xr isxdigit 3 ,
+.Xr tolower 3 ,
+.Xr toupper 3 ,
+.Xr wctype 3 ,
+.Xr xlocale 3
+.Sh STANDARDS
+These functions conform to
+.St -p1003.1-2008 .
diff --git a/lib/libc/locale/digittoint.3 b/lib/libc/locale/digittoint.3
index 372e00f2f8d8..4a7f2e2107ad 100644
--- a/lib/libc/locale/digittoint.3
+++ b/lib/libc/locale/digittoint.3
@@ -40,12 +40,20 @@
.In ctype.h
.Ft int
.Fn digittoint "int c"
+.Ft int
+.Fn digittoint_l "int c" "locale_t loc"
.Sh DESCRIPTION
The
.Fn digittoint
function converts a numeric character to its corresponding integer value.
The character can be any decimal digit or hexadecimal digit.
With hexadecimal characters, the case of the values does not matter.
+.Pp
+The
+.Fn digittoint_l
+function takes an explicit locale argument, whereas the
+.Fn digittoint
+function use the current global or per-thread locale.
.Sh RETURN VALUES
The
.Fn digittoint
@@ -56,4 +64,5 @@ the function will return 0.
.Sh SEE ALSO
.Xr ctype 3 ,
.Xr isdigit 3 ,
-.Xr isxdigit 3
+.Xr isxdigit 3,
+.Xr xlocale 3
diff --git a/lib/libc/locale/duplocale.3 b/lib/libc/locale/duplocale.3
index 9c14c5250bbb..73c0b3e7d9bf 100644
--- a/lib/libc/locale/duplocale.3
+++ b/lib/libc/locale/duplocale.3
@@ -56,18 +56,8 @@ associated with the current thread by
.Xr uselocale 3 .
These calls are therefore only thread safe on threads with a unique per-thread
locale.
-.Pt
The locale returned by this call must be freed with
.Xr freelocale 3 .
-.Sh BUGS
-Ideally,
-.Xr uselocale 3
-should make a copy of the
-.Fa locale_t
-implicitly to ensure thread safety,
-and a copy of the global locale should be installed lazily on each thread.
-The FreeBSD implementation does not do this,
-for compatibility with Darwin.
.Sh SEE ALSO
.Xr freelocale 3 ,
.Xr localeconv 3 ,
@@ -78,3 +68,12 @@ for compatibility with Darwin.
.Sh STANDARDS
This function, conforms to
.St -p1003.1-2008
+.Sh BUGS
+Ideally,
+.Xr uselocale 3
+should make a copy of the
+.Fa locale_t
+implicitly to ensure thread safety,
+and a copy of the global locale should be installed lazily on each thread.
+The FreeBSD implementation does not do this,
+for compatibility with Darwin.
diff --git a/lib/libc/locale/isalnum.3 b/lib/libc/locale/isalnum.3
index 038c5cf413c3..816191793d15 100644
--- a/lib/libc/locale/isalnum.3
+++ b/lib/libc/locale/isalnum.3
@@ -44,6 +44,8 @@
.In ctype.h
.Ft int
.Fn isalnum "int c"
+.Ft int
+.Fn isalnum_l "int c" "locale_t loc"
.Sh DESCRIPTION
The
.Fn isalnum
@@ -60,20 +62,26 @@ or the value of
In the ASCII character set, this includes the following characters
(with their numeric values shown in octal):
.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__
-.It "\&060\ ``0'' \t061\ ``1'' \t062\ ``2'' \t063\ ``3'' \t064\ ``4''"
-.It "\&065\ ``5'' \t066\ ``6'' \t067\ ``7'' \t070\ ``8'' \t071\ ``9''"
-.It "\&101\ ``A'' \t102\ ``B'' \t103\ ``C'' \t104\ ``D'' \t105\ ``E''"
-.It "\&106\ ``F'' \t107\ ``G'' \t110\ ``H'' \t111\ ``I'' \t112\ ``J''"
-.It "\&113\ ``K'' \t114\ ``L'' \t115\ ``M'' \t116\ ``N'' \t117\ ``O''"
-.It "\&120\ ``P'' \t121\ ``Q'' \t122\ ``R'' \t123\ ``S'' \t124\ ``T''"
-.It "\&125\ ``U'' \t126\ ``V'' \t127\ ``W'' \t130\ ``X'' \t131\ ``Y''"
-.It "\&132\ ``Z'' \t141\ ``a'' \t142\ ``b'' \t143\ ``c'' \t144\ ``d''"
-.It "\&145\ ``e'' \t146\ ``f'' \t147\ ``g'' \t150\ ``h'' \t151\ ``i''"
-.It "\&152\ ``j'' \t153\ ``k'' \t154\ ``l'' \t155\ ``m'' \t156\ ``n''"
-.It "\&157\ ``o'' \t160\ ``p'' \t161\ ``q'' \t162\ ``r'' \t163\ ``s''"
-.It "\&164\ ``t'' \t165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x''"
-.It "\&171\ ``y'' \t172\ ``z''"
+.It "\&060\ ``0''" Ta "061\ ``1''" Ta "062\ ``2''" Ta "063\ ``3''" Ta "064\ ``4''"
+.It "\&065\ ``5''" Ta "066\ ``6''" Ta "067\ ``7''" Ta "070\ ``8''" Ta "071\ ``9''"
+.It "\&101\ ``A''" Ta "102\ ``B''" Ta "103\ ``C''" Ta "104\ ``D''" Ta "105\ ``E''"
+.It "\&106\ ``F''" Ta "107\ ``G''" Ta "110\ ``H''" Ta "111\ ``I''" Ta "112\ ``J''"
+.It "\&113\ ``K''" Ta "114\ ``L''" Ta "115\ ``M''" Ta "116\ ``N''" Ta "117\ ``O''"
+.It "\&120\ ``P''" Ta "121\ ``Q''" Ta "122\ ``R''" Ta "123\ ``S''" Ta "124\ ``T''"
+.It "\&125\ ``U''" Ta "126\ ``V''" Ta "127\ ``W''" Ta "130\ ``X''" Ta "131\ ``Y''"
+.It "\&132\ ``Z''" Ta "141\ ``a''" Ta "142\ ``b''" Ta "143\ ``c''" Ta "144\ ``d''"
+.It "\&145\ ``e''" Ta "146\ ``f''" Ta "147\ ``g''" Ta "150\ ``h''" Ta "151\ ``i''"
+.It "\&152\ ``j''" Ta "153\ ``k''" Ta "154\ ``l''" Ta "155\ ``m''" Ta "156\ ``n''"
+.It "\&157\ ``o''" Ta "160\ ``p''" Ta "161\ ``q''" Ta "162\ ``r''" Ta "163\ ``s''"
+.It "\&164\ ``t''" Ta "165\ ``u''" Ta "166\ ``v''" Ta "167\ ``w''" Ta "170\ ``x''"
+.It "\&171\ ``y''" Ta "172\ ``z''" Ta \& Ta \& Ta \&
.El
+.Pp
+The
+.Fn isalnum_l
+function takes an explicit locale argument, whereas the
+.Fn isalnum
+function uses the current global or per-thread locale.
.Sh RETURN VALUES
The
.Fn isalnum
@@ -94,9 +102,14 @@ function should be used instead.
.Xr isalpha 3 ,
.Xr isdigit 3 ,
.Xr iswalnum 3 ,
+.Xr xlocale 3 ,
.Xr ascii 7
.Sh STANDARDS
The
.Fn isalnum
function conforms to
.St -isoC .
+The
+.Fn isalnum_l
+function conforms to
+.St -p1003.1-2008 .
diff --git a/lib/libc/locale/isalpha.3 b/lib/libc/locale/isalpha.3
index 689b6cd54add..0ea3a8822ac8 100644
--- a/lib/libc/locale/isalpha.3
+++ b/lib/libc/locale/isalpha.3
@@ -44,6 +44,8 @@
.In ctype.h
.Ft int
.Fn isalpha "int c"
+.Ft int
+.Fn isalpha_l "int c" "locale_t loc"
.Sh DESCRIPTION
The
.Fn isalpha
@@ -60,18 +62,24 @@ or the value of
In the ASCII character set, this includes the following characters
(with their numeric values shown in octal):
.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__
-.It "\&101\ ``A'' \t102\ ``B'' \t103\ ``C'' \t104\ ``D'' \t105\ ``E''"
-.It "\&106\ ``F'' \t107\ ``G'' \t110\ ``H'' \t111\ ``I'' \t112\ ``J''"
-.It "\&113\ ``K'' \t114\ ``L'' \t115\ ``M'' \t116\ ``N'' \t117\ ``O''"
-.It "\&120\ ``P'' \t121\ ``Q'' \t122\ ``R'' \t123\ ``S'' \t124\ ``T''"
-.It "\&125\ ``U'' \t126\ ``V'' \t127\ ``W'' \t130\ ``X'' \t131\ ``Y''"
-.It "\&132\ ``Z'' \t141\ ``a'' \t142\ ``b'' \t143\ ``c'' \t144\ ``d''"
-.It "\&145\ ``e'' \t146\ ``f'' \t147\ ``g'' \t150\ ``h'' \t151\ ``i''"
-.It "\&152\ ``j'' \t153\ ``k'' \t154\ ``l'' \t155\ ``m'' \t156\ ``n''"
-.It "\&157\ ``o'' \t160\ ``p'' \t161\ ``q'' \t162\ ``r'' \t163\ ``s''"
-.It "\&164\ ``t'' \t165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x''"
-.It "\&171\ ``y'' \t172\ ``z''"
+.It "\&101\ ``A''" Ta "102\ ``B''" Ta "103\ ``C''" Ta "104\ ``D''" Ta "105\ ``E''"
+.It "\&106\ ``F''" Ta "107\ ``G''" Ta "110\ ``H''" Ta "111\ ``I''" Ta "112\ ``J''"
+.It "\&113\ ``K''" Ta "114\ ``L''" Ta "115\ ``M''" Ta "116\ ``N''" Ta "117\ ``O''"
+.It "\&120\ ``P''" Ta "121\ ``Q''" Ta "122\ ``R''" Ta "123\ ``S''" Ta "124\ ``T''"
+.It "\&125\ ``U''" Ta "126\ ``V''" Ta "127\ ``W''" Ta "130\ ``X''" Ta "131\ ``Y''"
+.It "\&132\ ``Z''" Ta "141\ ``a''" Ta "142\ ``b''" Ta "143\ ``c''" Ta "144\ ``d''"
+.It "\&145\ ``e''" Ta "146\ ``f''" Ta "147\ ``g''" Ta "150\ ``h''" Ta "151\ ``i''"
+.It "\&152\ ``j''" Ta "153\ ``k''" Ta "154\ ``l''" Ta "155\ ``m''" Ta "156\ ``n''"
+.It "\&157\ ``o''" Ta "160\ ``p''" Ta "161\ ``q''" Ta "162\ ``r''" Ta "163\ ``s''"
+.It "\&164\ ``t''" Ta "165\ ``u''" Ta "166\ ``v''" Ta "167\ ``w''" Ta "170\ ``x''"
+.It "\&171\ ``y''" Ta "172\ ``z''" Ta \& Ta \& Ta \&
.El
+.Pp
+The
+.Fn isalpha_l
+function takes an explicit locale argument, whereas the
+.Fn isalpha
+function uses the current global or per-thread locale.
.Sh RETURN VALUES
The
.Fn isalpha
@@ -92,9 +100,14 @@ function should be used instead.
.Xr islower 3 ,
.Xr isupper 3 ,
.Xr iswalpha 3 ,
+.Xr xlocale 3 ,
.Xr ascii 7
.Sh STANDARDS
The
.Fn isalpha
function conforms to
.St -isoC .
+The
+.Fn isalpha_l
+function conforms to
+.St -p1003.1-2008 .
diff --git a/lib/libc/locale/isblank.3 b/lib/libc/locale/isblank.3
index 2668e93d93d6..5542280eb36f 100644
--- a/lib/libc/locale/isblank.3
+++ b/lib/libc/locale/isblank.3
@@ -40,6 +40,8 @@
.In ctype.h
.Ft int
.Fn isblank "int c"
+.Ft int
+.Fn isblank "int c" "locale_t loc"
.Sh DESCRIPTION
The
.Fn isblank
@@ -56,6 +58,12 @@ The value of the argument must be representable as an
.Vt "unsigned char"
or the value of
.Dv EOF .
+.Pp
+The
+.Fn isblank_l
+function takes an explicit locale argument, whereas the
+.Fn isblank
+function uses the current global or per-thread locale.
.Sh RETURN VALUES
The
.Fn isblank
@@ -74,6 +82,7 @@ function should be used instead.
.Sh SEE ALSO
.Xr ctype 3 ,
.Xr iswblank 3 ,
+.Xr xlocale 3 ,
.Xr ascii 7
.Sh STANDARDS
The
@@ -81,3 +90,7 @@ The
function
conforms to
.St -isoC-99 .
+The
+.Fn isblank_l
+function conforms to
+.St -p1003.1-2008 .
diff --git a/lib/libc/locale/iscntrl.3 b/lib/libc/locale/iscntrl.3
index a67e6a42bb61..e973f204b4b8 100644
--- a/lib/libc/locale/iscntrl.3
+++ b/lib/libc/locale/iscntrl.3
@@ -44,6 +44,8 @@
.In ctype.h
.Ft int
.Fn iscntrl "int c"
+.Ft int
+.Fn iscntrl_l "int c" "locale_t loc"
.Sh DESCRIPTION
The
.Fn iscntrl
@@ -55,16 +57,21 @@ or the value of
.Pp
In the ASCII character set, this includes the following characters
(with their numeric values shown in octal):
-.Pp
.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__
-.It "\&000\ NUL \t001\ SOH \t002\ STX \t003\ ETX \t004\ EOT"
-.It "\&005\ ENQ \t006\ ACK \t007\ BEL \t010\ BS \t011\ HT"
-.It "\&012\ NL \t013\ VT \t014\ NP \t015\ CR \t016\ SO"
-.It "\&017\ SI \t020\ DLE \t021\ DC1 \t022\ DC2 \t023\ DC3"
-.It "\&024\ DC4 \t025\ NAK \t026\ SYN \t027\ ETB \t030\ CAN"
-.It "\&031\ EM \t032\ SUB \t033\ ESC \t034\ FS \t035\ GS"
-.It "\&036\ RS \t037\ US \t177\ DEL"
+.It "\&000\ NUL" Ta "001\ SOH" Ta "002\ STX" Ta "003\ ETX" Ta "004\ EOT"
+.It "\&005\ ENQ" Ta "006\ ACK" Ta "007\ BEL" Ta "010\ BS" Ta "011\ HT"
+.It "\&012\ NL" Ta "013\ VT" Ta "014\ NP" Ta "015\ CR" Ta "016\ SO"
+.It "\&017\ SI" Ta "020\ DLE" Ta "021\ DC1" Ta "022\ DC2" Ta "023\ DC3"
+.It "\&024\ DC4" Ta "025\ NAK" Ta "026\ SYN" Ta "027\ ETB" Ta "030\ CAN"
+.It "\&031\ EM" Ta "032\ SUB" Ta "033\ ESC" Ta "034\ FS" Ta "035\ GS"
+.It "\&036\ RS" Ta "037\ US" Ta "177\ DEL" Ta \& Ta \&
.El
+.Pp
+The
+.Fn iscntrl_l
+function takes an explicit locale argument, whereas the
+.Fn iscntrl
+function uses the current global or per-thread locale.
.Sh RETURN VALUES
The
.Fn iscntrl
@@ -83,9 +90,14 @@ function should be used instead.
.Sh SEE ALSO
.Xr ctype 3 ,
.Xr iswcntrl 3 ,
+.Xr xlocale 3 ,
.Xr ascii 7
.Sh STANDARDS
The
.Fn iscntrl
function conforms to
.St -isoC .
+The
+.Fn iscntrl_l
+function conforms to
+.St -p1003.1-2008 .
diff --git a/lib/libc/locale/isdigit.3 b/lib/libc/locale/isdigit.3
index 53b198606e7f..a648ced9c819 100644
--- a/lib/libc/locale/isdigit.3
+++ b/lib/libc/locale/isdigit.3
@@ -46,15 +46,18 @@
.Fn isdigit "int c"
.Ft int
.Fn isnumber "int c"
+.Ft int
+.Fn isdigit_l "int c" "locale_t loc"
+.Ft int
+.Fn isnumber_l "int c" "locale_t loc"
.Sh DESCRIPTION
The
.Fn isdigit
function tests for a decimal digit character.
Regardless of locale, this includes the following characters only:
-.Pp
.Bl -column \&``0''______ \&``0''______ \&``0''______ \&``0''______ \&``0''______
-.It "\&``0''\t``1''\t``2''\t``3''\t``4''"
-.It "\&``5''\t``6''\t``7''\t``8''\t``9''"
+.It "\&``0''" Ta "``1''" Ta "``2''" Ta "``3''" Ta "``4''"
+.It "\&``5''" Ta "``6''" Ta "``7''" Ta "``8''" Ta "``9''"
.El
.Pp
The
@@ -68,6 +71,9 @@ The value of the argument must be representable as an
.Vt "unsigned char"
or the value of
.Dv EOF .
+.Pp
+The _l-suffixed versions take an explicit locale argument, whereas the
+non-suffixed versions use the current global or per-thread locale.
.Sh RETURN VALUES
The
.Fn isdigit
@@ -89,12 +95,17 @@ function should be used instead.
.Xr ctype 3 ,
.Xr iswdigit 3 ,
.Xr multibyte 3 ,
+.Xr xlocale 3 ,
.Xr ascii 7
.Sh STANDARDS
The
.Fn isdigit
function conforms to
.St -isoC .
+The
+.Fn isdigit_l
+function conforms to
+.St -p1003.1-2008 .
.Sh HISTORY
The
.Fn isnumber
diff --git a/lib/libc/locale/isgraph.3 b/lib/libc/locale/isgraph.3
index ec304d03b713..bedf31e619c1 100644
--- a/lib/libc/locale/isgraph.3
+++ b/lib/libc/locale/isgraph.3
@@ -58,27 +58,26 @@ or the value of
.Pp
In the ASCII character set, this includes the following characters
(with their numeric values shown in octal):
-.Pp
.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__
-.It "\&041\ ``!'' \t042\ ``""'' \t043\ ``#'' \t044\ ``$'' \t045\ ``%''"
-.It "\&046\ ``&'' \t047\ ``''' \t050\ ``('' \t051\ ``)'' \t052\ ``*''"
-.It "\&053\ ``+'' \t054\ ``,'' \t055\ ``-'' \t056\ ``.'' \t057\ ``/''"
-.It "\&060\ ``0'' \t061\ ``1'' \t062\ ``2'' \t063\ ``3'' \t064\ ``4''"
-.It "\&065\ ``5'' \t066\ ``6'' \t067\ ``7'' \t070\ ``8'' \t071\ ``9''"
-.It "\&072\ ``:'' \t073\ ``;'' \t074\ ``<'' \t075\ ``='' \t076\ ``>''"
-.It "\&077\ ``?'' \t100\ ``@'' \t101\ ``A'' \t102\ ``B'' \t103\ ``C''"
-.It "\&104\ ``D'' \t105\ ``E'' \t106\ ``F'' \t107\ ``G'' \t110\ ``H''"
-.It "\&111\ ``I'' \t112\ ``J'' \t113\ ``K'' \t114\ ``L'' \t115\ ``M''"
-.It "\&116\ ``N'' \t117\ ``O'' \t120\ ``P'' \t121\ ``Q'' \t122\ ``R''"
-.It "\&123\ ``S'' \t124\ ``T'' \t125\ ``U'' \t126\ ``V'' \t127\ ``W''"
-.It "\&130\ ``X'' \t131\ ``Y'' \t132\ ``Z'' \t133\ ``['' \t134\ ``\e\|''"
-.It "\&135\ ``]'' \t136\ ``^'' \t137\ ``_'' \t140\ ```'' \t141\ ``a''"
-.It "\&142\ ``b'' \t143\ ``c'' \t144\ ``d'' \t145\ ``e'' \t146\ ``f''"
-.It "\&147\ ``g'' \t150\ ``h'' \t151\ ``i'' \t152\ ``j'' \t153\ ``k''"
-.It "\&154\ ``l'' \t155\ ``m'' \t156\ ``n'' \t157\ ``o'' \t160\ ``p''"
-.It "\&161\ ``q'' \t162\ ``r'' \t163\ ``s'' \t164\ ``t'' \t165\ ``u''"
-.It "\&166\ ``v'' \t167\ ``w'' \t170\ ``x'' \t171\ ``y'' \t172\ ``z''"
-.It "\&173\ ``{'' \t174\ ``|'' \t175\ ``}'' \t176\ ``~''"
+.It "\&041\ ``!''" Ta "042\ ``""''" Ta "043\ ``#''" Ta "044\ ``$''" Ta "045\ ``%''"
+.It "\&046\ ``&''" Ta "047\ ``'''" Ta "050\ ``(''" Ta "051\ ``)''" Ta "052\ ``*''"
+.It "\&053\ ``+''" Ta "054\ ``,''" Ta "055\ ``-''" Ta "056\ ``.''" Ta "057\ ``/''"
+.It "\&060\ ``0''" Ta "061\ ``1''" Ta "062\ ``2''" Ta "063\ ``3''" Ta "064\ ``4''"
+.It "\&065\ ``5''" Ta "066\ ``6''" Ta "067\ ``7''" Ta "070\ ``8''" Ta "071\ ``9''"
+.It "\&072\ ``:''" Ta "073\ ``;''" Ta "074\ ``<''" Ta "075\ ``=''" Ta "076\ ``>''"
+.It "\&077\ ``?''" Ta "100\ ``@''" Ta "101\ ``A''" Ta "102\ ``B''" Ta "103\ ``C''"
+.It "\&104\ ``D''" Ta "105\ ``E''" Ta "106\ ``F''" Ta "107\ ``G''" Ta "110\ ``H''"
+.It "\&111\ ``I''" Ta "112\ ``J''" Ta "113\ ``K''" Ta "114\ ``L''" Ta "115\ ``M''"
+.It "\&116\ ``N''" Ta "117\ ``O''" Ta "120\ ``P''" Ta "121\ ``Q''" Ta "122\ ``R''"
+.It "\&123\ ``S''" Ta "124\ ``T''" Ta "125\ ``U''" Ta "126\ ``V''" Ta "127\ ``W''"
+.It "\&130\ ``X''" Ta "131\ ``Y''" Ta "132\ ``Z''" Ta "133\ ``[''" Ta "134\ ``\e\|''"
+.It "\&135\ ``]''" Ta "136\ ``^''" Ta "137\ ``_''" Ta "140\ ```''" Ta "141\ ``a''"
+.It "\&142\ ``b''" Ta "143\ ``c''" Ta "144\ ``d''" Ta "145\ ``e''" Ta "146\ ``f''"
+.It "\&147\ ``g''" Ta "150\ ``h''" Ta "151\ ``i''" Ta "152\ ``j''" Ta "153\ ``k''"
+.It "\&154\ ``l''" Ta "155\ ``m''" Ta "156\ ``n''" Ta "157\ ``o''" Ta "160\ ``p''"
+.It "\&161\ ``q''" Ta "162\ ``r''" Ta "163\ ``s''" Ta "164\ ``t''" Ta "165\ ``u''"
+.It "\&166\ ``v''" Ta "167\ ``w''" Ta "170\ ``x''" Ta "171\ ``y''" Ta "172\ ``z''"
+.It "\&173\ ``{''" Ta "174\ ``|''" Ta "175\ ``}''" Ta "176\ ``~''" Ta \&
.El
.Sh RETURN VALUES
The
diff --git a/lib/libc/locale/islower.3 b/lib/libc/locale/islower.3
index d72e7cf5b121..987ff594a587 100644
--- a/lib/libc/locale/islower.3
+++ b/lib/libc/locale/islower.3
@@ -55,14 +55,13 @@ or the value of
.Pp
In the ASCII character set, this includes the following characters
(with their numeric values shown in octal):
-.Pp
.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__
-.It "\&141\ ``a'' \t142\ ``b'' \t143\ ``c'' \t144\ ``d'' \t145\ ``e''"
-.It "\&146\ ``f'' \t147\ ``g'' \t150\ ``h'' \t151\ ``i'' \t152\ ``j''"
-.It "\&153\ ``k'' \t154\ ``l'' \t155\ ``m'' \t156\ ``n'' \t157\ ``o''"
-.It "\&160\ ``p'' \t161\ ``q'' \t162\ ``r'' \t163\ ``s'' \t164\ ``t''"
-.It "\&165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x'' \t171\ ``y''"
-.It "\&172\ ``z''"
+.It "\&141\ ``a''" Ta "142\ ``b''" Ta "143\ ``c''" Ta "144\ ``d''" Ta "145\ ``e''"
+.It "\&146\ ``f''" Ta "147\ ``g''" Ta "150\ ``h''" Ta "151\ ``i''" Ta "152\ ``j''"
+.It "\&153\ ``k''" Ta "154\ ``l''" Ta "155\ ``m''" Ta "156\ ``n''" Ta "157\ ``o''"
+.It "\&160\ ``p''" Ta "161\ ``q''" Ta "162\ ``r''" Ta "163\ ``s''" Ta "164\ ``t''"
+.It "\&165\ ``u''" Ta "166\ ``v''" Ta "167\ ``w''" Ta "170\ ``x''" Ta "171\ ``y''"
+.It "\&172\ ``z''" Ta \& Ta \& Ta \& Ta \&
.El
.Sh RETURN VALUES
The
diff --git a/lib/libc/locale/isprint.3 b/lib/libc/locale/isprint.3
index d8adf1da37f3..e752c0340294 100644
--- a/lib/libc/locale/isprint.3
+++ b/lib/libc/locale/isprint.3
@@ -56,27 +56,26 @@ or the value of
.Pp
In the ASCII character set, this includes the following characters
(with their numeric values shown in octal):
-.Pp
.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__
-.It "\&040\ sp \t041\ ``!'' \t042\ ``""'' \t043\ ``#'' \t044\ ``$''"
-.It "\&045\ ``%'' \t046\ ``&'' \t047\ ``''' \t050\ ``('' \t051\ ``)''"
-.It "\&052\ ``*'' \t053\ ``+'' \t054\ ``,'' \t055\ ``-'' \t056\ ``.''"
-.It "\&057\ ``/'' \t060\ ``0'' \t061\ ``1'' \t062\ ``2'' \t063\ ``3''"
-.It "\&064\ ``4'' \t065\ ``5'' \t066\ ``6'' \t067\ ``7'' \t070\ ``8''"
-.It "\&071\ ``9'' \t072\ ``:'' \t073\ ``;'' \t074\ ``<'' \t075\ ``=''"
-.It "\&076\ ``>'' \t077\ ``?'' \t100\ ``@'' \t101\ ``A'' \t102\ ``B''"
-.It "\&103\ ``C'' \t104\ ``D'' \t105\ ``E'' \t106\ ``F'' \t107\ ``G''"
-.It "\&110\ ``H'' \t111\ ``I'' \t112\ ``J'' \t113\ ``K'' \t114\ ``L''"
-.It "\&115\ ``M'' \t116\ ``N'' \t117\ ``O'' \t120\ ``P'' \t121\ ``Q''"
-.It "\&122\ ``R'' \t123\ ``S'' \t124\ ``T'' \t125\ ``U'' \t126\ ``V''"
-.It "\&127\ ``W'' \t130\ ``X'' \t131\ ``Y'' \t132\ ``Z'' \t133\ ``[''"
-.It "\&134\ ``\e\|'' \t135\ ``]'' \t136\ ``^'' \t137\ ``_'' \t140\ ```''"
-.It "\&141\ ``a'' \t142\ ``b'' \t143\ ``c'' \t144\ ``d'' \t145\ ``e''"
-.It "\&146\ ``f'' \t147\ ``g'' \t150\ ``h'' \t151\ ``i'' \t152\ ``j''"
-.It "\&153\ ``k'' \t154\ ``l'' \t155\ ``m'' \t156\ ``n'' \t157\ ``o''"
-.It "\&160\ ``p'' \t161\ ``q'' \t162\ ``r'' \t163\ ``s'' \t164\ ``t''"
-.It "\&165\ ``u'' \t166\ ``v'' \t167\ ``w'' \t170\ ``x'' \t171\ ``y''"
-.It "\&172\ ``z'' \t173\ ``{'' \t174\ ``|'' \t175\ ``}'' \t176\ ``~''"
+.It "\&040\ sp" Ta "041\ ``!''" Ta "042\ ``""''" Ta "043\ ``#''" Ta "044\ ``$''"
+.It "\&045\ ``%''" Ta "046\ ``&''" Ta "047\ ``'''" Ta "050\ ``(''" Ta "051\ ``)''"
+.It "\&052\ ``*''" Ta "053\ ``+''" Ta "054\ ``,''" Ta "055\ ``-''" Ta "056\ ``.''"
+.It "\&057\ ``/''" Ta "060\ ``0''" Ta "061\ ``1''" Ta "062\ ``2''" Ta "063\ ``3''"
+.It "\&064\ ``4''" Ta "065\ ``5''" Ta "066\ ``6''" Ta "067\ ``7''" Ta "070\ ``8''"
+.It "\&071\ ``9''" Ta "072\ ``:''" Ta "073\ ``;''" Ta "074\ ``<''" Ta "075\ ``=''"
+.It "\&076\ ``>''" Ta "077\ ``?''" Ta "100\ ``@''" Ta "101\ ``A''" Ta "102\ ``B''"
+.It "\&103\ ``C''" Ta "104\ ``D''" Ta "105\ ``E''" Ta "106\ ``F''" Ta "107\ ``G''"
+.It "\&110\ ``H''" Ta "111\ ``I''" Ta "112\ ``J''" Ta "113\ ``K''" Ta "114\ ``L''"
+.It "\&115\ ``M''" Ta "116\ ``N''" Ta "117\ ``O''" Ta "120\ ``P''" Ta "121\ ``Q''"
+.It "\&122\ ``R''" Ta "123\ ``S''" Ta "124\ ``T''" Ta "125\ ``U''" Ta "126\ ``V''"
+.It "\&127\ ``W''" Ta "130\ ``X''" Ta "131\ ``Y''" Ta "132\ ``Z''" Ta "133\ ``[''"
+.It "\&134\ ``\e\|''" Ta "135\ ``]''" Ta "136\ ``^''" Ta "137\ ``_''" Ta "140\ ```''"
+.It "\&141\ ``a''" Ta "142\ ``b''" Ta "143\ ``c''" Ta "144\ ``d''" Ta "145\ ``e''"
+.It "\&146\ ``f''" Ta "147\ ``g''" Ta "150\ ``h''" Ta "151\ ``i''" Ta "152\ ``j''"
+.It "\&153\ ``k''" Ta "154\ ``l''" Ta "155\ ``m''" Ta "156\ ``n''" Ta "157\ ``o''"
+.It "\&160\ ``p''" Ta "161\ ``q''" Ta "162\ ``r''" Ta "163\ ``s''" Ta "164\ ``t''"
+.It "\&165\ ``u''" Ta "166\ ``v''" Ta "167\ ``w''" Ta "170\ ``x''" Ta "171\ ``y''"
+.It "\&172\ ``z''" Ta "173\ ``{''" Ta "174\ ``|''" Ta "175\ ``}''" Ta "176\ ``~''"
.El
.Sh RETURN VALUES
The
diff --git a/lib/libc/locale/ispunct.3 b/lib/libc/locale/ispunct.3
index aa0246107e4e..8fcfe544f32f 100644
--- a/lib/libc/locale/ispunct.3
+++ b/lib/libc/locale/ispunct.3
@@ -60,15 +60,14 @@ or the value of
.Pp
In the ASCII character set, this includes the following characters
(with their numeric values shown in octal):
-.Pp
.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__
-.It "\&041\ ``!'' \t042\ ``""'' \t043\ ``#'' \t044\ ``$'' \t045\ ``%''"
-.It "\&046\ ``&'' \t047\ ``''' \t050\ ``('' \t051\ ``)'' \t052\ ``*''"
-.It "\&053\ ``+'' \t054\ ``,'' \t055\ ``-'' \t056\ ``.'' \t057\ ``/''"
-.It "\&072\ ``:'' \t073\ ``;'' \t074\ ``<'' \t075\ ``='' \t076\ ``>''"
-.It "\&077\ ``?'' \t100\ ``@'' \t133\ ``['' \t134\ ``\e\|'' \t135\ ``]''"
-.It "\&136\ ``^'' \t137\ ``_'' \t140\ ```'' \t173\ ``{'' \t174\ ``|''"
-.It "\&175\ ``}'' \t176\ ``~''"
+.It "\&041\ ``!''" Ta "042\ ``""''" Ta "043\ ``#''" Ta "044\ ``$''" Ta "045\ ``%''"
+.It "\&046\ ``&''" Ta "047\ ``'''" Ta "050\ ``(''" Ta "051\ ``)''" Ta "052\ ``*''"
+.It "\&053\ ``+''" Ta "054\ ``,''" Ta "055\ ``-''" Ta "056\ ``.''" Ta "057\ ``/''"
+.It "\&072\ ``:''" Ta "073\ ``;''" Ta "074\ ``<''" Ta "075\ ``=''" Ta "076\ ``>''"
+.It "\&077\ ``?''" Ta "100\ ``@''" Ta "133\ ``[''" Ta "134\ ``\e\|''" Ta "135\ ``]''"
+.It "\&136\ ``^''" Ta "137\ ``_''" Ta "140\ ```''" Ta "173\ ``{''" Ta "174\ ``|''"
+.It "\&175\ ``}''" Ta "176\ ``~''" Ta \& Ta \& Ta \&
.El
.Sh RETURN VALUES
The
diff --git a/lib/libc/locale/isspace.3 b/lib/libc/locale/isspace.3
index eab6cfcd5633..6dfeb5fa10dd 100644
--- a/lib/libc/locale/isspace.3
+++ b/lib/libc/locale/isspace.3
@@ -49,9 +49,8 @@ The
.Fn isspace
function tests for white-space characters.
For any locale, this includes the following standard characters:
-.Pp
.Bl -column \&`\et''___ \&``\et''___ \&``\et''___ \&``\et''___ \&``\et''___ \&``\et''___
-.It "\&``\et''\t``\en''\t``\ev''\t``\ef''\t``\er''\t`` ''"
+.It "\&``\et''" Ta "``\en''" Ta "``\ev''" Ta "``\ef''" Ta "``\er''" Ta "`` ''"
.El
.Pp
In the "C" locale,
diff --git a/lib/libc/locale/isupper.3 b/lib/libc/locale/isupper.3
index 6aeb5ac9aa3d..570e076518d9 100644
--- a/lib/libc/locale/isupper.3
+++ b/lib/libc/locale/isupper.3
@@ -55,14 +55,13 @@ or the value of
.Pp
In the ASCII character set, this includes the following characters
(with their numeric values shown in octal):
-.Pp
.Bl -column \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__ \&000_``0''__
-.It "\&101\ ``A'' \t102\ ``B'' \t103\ ``C'' \t104\ ``D'' \t105\ ``E''"
-.It "\&106\ ``F'' \t107\ ``G'' \t110\ ``H'' \t111\ ``I'' \t112\ ``J''"
-.It "\&113\ ``K'' \t114\ ``L'' \t115\ ``M'' \t116\ ``N'' \t117\ ``O''"
-.It "\&120\ ``P'' \t121\ ``Q'' \t122\ ``R'' \t123\ ``S'' \t124\ ``T''"
-.It "\&125\ ``U'' \t126\ ``V'' \t127\ ``W'' \t130\ ``X'' \t131\ ``Y''"
-.It "\&132\ ``Z''"
+.It "\&101\ ``A''" Ta "102\ ``B''" Ta "103\ ``C''" Ta "104\ ``D''" Ta "105\ ``E''"
+.It "\&106\ ``F''" Ta "107\ ``G''" Ta "110\ ``H''" Ta "111\ ``I''" Ta "112\ ``J''"
+.It "\&113\ ``K''" Ta "114\ ``L''" Ta "115\ ``M''" Ta "116\ ``N''" Ta "117\ ``O''"
+.It "\&120\ ``P''" Ta "121\ ``Q''" Ta "122\ ``R''" Ta "123\ ``S''" Ta "124\ ``T''"
+.It "\&125\ ``U''" Ta "126\ ``V''" Ta "127\ ``W''" Ta "130\ ``X''" Ta "131\ ``Y''"
+.It "\&132\ ``Z''" Ta \& Ta \& Ta \& Ta \&
.El
.Sh RETURN VALUES
The
diff --git a/lib/libc/locale/isxdigit.3 b/lib/libc/locale/isxdigit.3
index 1fb54bf94f5d..eb9f8d5b861e 100644
--- a/lib/libc/locale/isxdigit.3
+++ b/lib/libc/locale/isxdigit.3
@@ -51,13 +51,12 @@ The
.Fn isxdigit
function tests for any hexadecimal-digit character.
Regardless of locale, this includes the following characters only:
-.Pp
.Bl -column \&``0''______ \&``0''______ \&``0''______ \&``0''______ \&``0''______
-.It "\&``0''\t``1''\t``2''\t``3''\t``4''"
-.It "\&``5''\t``6''\t``7''\t``8''\t``9''"
-.It "\&``A''\t``B''\t``C''\t``D''\t``E''"
-.It "\&``F''\t``a''\t``b''\t``c''\t``d''"
-.It "\&``e''\t``f''"
+.It "\&``0''" Ta "``1''" Ta "``2''" Ta "``3''" Ta "``4''"
+.It "\&``5''" Ta "``6''" Ta "``7''" Ta "``8''" Ta "``9''"
+.It "\&``A''" Ta "``B''" Ta "``C''" Ta "``D''" Ta "``E''"
+.It "\&``F''" Ta "``a''" Ta "``b''" Ta "``c''" Ta "``d''"
+.It "\&``e''" Ta "``f''" Ta \& Ta \& Ta \&
.El
.Pp
The
diff --git a/lib/libc/locale/newlocale.3 b/lib/libc/locale/newlocale.3
index 1cabc98a4cd3..599f148eeab8 100644
--- a/lib/libc/locale/newlocale.3
+++ b/lib/libc/locale/newlocale.3
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.Dd September 17 2011
-.Dt newlocale 3
+.Dt NEWLOCALE 3
.Os
.Sh NAME
.Nm newlocale
@@ -36,7 +36,7 @@
.Lb libc
.Sh SYNOPSIS
.In xlocale
-.Ft
+.Ft locale_t
.Fn newlocale "int mask" "const char * locale" "locale_t base"
.Sh DESCRIPTION
Creates a new locale, inheriting some properties from an existing locale.
@@ -48,7 +48,6 @@ name specified in the
parameter.
Any other components will be inherited from
.Fa base .
-.Pt
The
.Fa mask
is either
@@ -93,7 +92,6 @@ Set a locale for formatting dates and times using the
.Xr strftime 3
function.
.El
-
This function uses the same rules for loading locale components as
.Xr setlocale 3 .
.Sh RETURN VALUES
diff --git a/lib/libc/locale/nomacros.c b/lib/libc/locale/nomacros.c
index ba49a1fe0b37..66cf40e61ec9 100644
--- a/lib/libc/locale/nomacros.c
+++ b/lib/libc/locale/nomacros.c
@@ -9,4 +9,10 @@ __FBSDID("$FreeBSD$");
*/
#define _EXTERNALIZE_CTYPE_INLINES_
+/*
+ * Also make sure <runetype.h> does not generate an inline definition
+ * of __getCurrentRuneLocale().
+ */
+#define __RUNETYPE_INTERNAL
+
#include <ctype.h>
diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c
index 61ce5d9f925c..bc04e9e4798b 100644
--- a/lib/libc/locale/setrunelocale.c
+++ b/lib/libc/locale/setrunelocale.c
@@ -38,6 +38,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#define __RUNETYPE_INTERNAL 1
+
#include <runetype.h>
#include <errno.h>
#include <limits.h>
@@ -50,6 +52,15 @@ __FBSDID("$FreeBSD$");
#include "mblocal.h"
#include "setlocale.h"
+#undef _CurrentRuneLocale
+extern _RuneLocale const *_CurrentRuneLocale;
+#ifndef __NO_TLS
+/*
+ * A cached version of the runes for this thread. Used by ctype.h
+ */
+_Thread_local const _RuneLocale *_ThreadRuneLocale;
+#endif
+
extern int __mb_sb_limit;
extern _RuneLocale *_Read_RuneMagi(FILE *);
@@ -72,7 +83,8 @@ static void destruct_ctype(void *v)
free(l->runes);
free(l);
}
-_RuneLocale *__getCurrentRuneLocale(void)
+
+const _RuneLocale *__getCurrentRuneLocale(void)
{
return XLOCALE_CTYPE(__get_locale())->runes;
}
@@ -168,9 +180,24 @@ __wrap_setrunelocale(const char *locale)
}
__mb_cur_max = __xlocale_global_ctype.__mb_cur_max;
__mb_sb_limit = __xlocale_global_ctype.__mb_sb_limit;
+ _CurrentRuneLocale = __xlocale_global_ctype.runes;
return (_LDP_LOADED);
}
-void *__ctype_load(const char *locale, locale_t unused)
+
+#ifndef __NO_TLS
+void
+__set_thread_rune_locale(locale_t loc) {
+
+ if (loc == NULL) {
+ _ThreadRuneLocale = &_DefaultRuneLocale;
+ } else {
+ _ThreadRuneLocale = XLOCALE_CTYPE(loc)->runes;
+ }
+}
+#endif
+
+void *
+__ctype_load(const char *locale, locale_t unused)
{
struct xlocale_ctype *l = calloc(sizeof(struct xlocale_ctype), 1);
l->header.header.destructor = destruct_ctype;
diff --git a/lib/libc/locale/table.c b/lib/libc/locale/table.c
index 8c876e95a124..e89d4799b394 100644
--- a/lib/libc/locale/table.c
+++ b/lib/libc/locale/table.c
@@ -251,7 +251,7 @@ const _RuneLocale _DefaultRuneLocale = {
};
#undef _CurrentRuneLocale
-_RuneLocale *_CurrentRuneLocale = (_RuneLocale*)&_DefaultRuneLocale;
+const _RuneLocale *_CurrentRuneLocale = &_DefaultRuneLocale;
_RuneLocale *
__runes_for_locale(locale_t locale, int *mb_sb_limit)
diff --git a/lib/libc/locale/xlocale.3 b/lib/libc/locale/xlocale.3
index 7172ad550caa..11a392dca184 100644
--- a/lib/libc/locale/xlocale.3
+++ b/lib/libc/locale/xlocale.3
@@ -65,21 +65,6 @@ LC_GLOBAL_LOCALE refers to the global locale.
The global locale is the locale set with the
.Xr setlocale 3
function.
-.Sh CAVEATS
-The
-.Xr setlocale 3
-function, and others in the family, refer to the global locale.
-Other functions that depend on the locale, however,
-will take the thread-local locale if one has been set.
-This means that the idiom of setting the locale using
-.Xr setlocale 3 ,
-calling a locale-dependent function,
-and then restoring the locale will not
-have the expected behavior if the current thread has had a locale set using
-.Xr uselocale 3 .
-You should avoid this idiom and prefer to use the
-.Fa _l
-suffixed versions instead.
.Sh SEE ALSO
.Xr duplocale 3 ,
.Xr freelocale 3 ,
@@ -118,7 +103,6 @@ which defines
For reference,
a complete list of the locale-aware functions that are available in this form,
along with the headers that expose them, is provided here:
-.Pp
.Bl -tag -width "<monetary.h> "
.It In wctype.h
.Xr iswalnum_l 3 ,
@@ -279,3 +263,18 @@ The xlocale APIs first appeared in Darwin 8.0.
This implementation was written by David Chisnall,
under sponsorship from the FreeBSD Foundation and first appeared in
.Fx 9.1 .
+.Sh CAVEATS
+The
+.Xr setlocale 3
+function, and others in the family, refer to the global locale.
+Other functions that depend on the locale, however,
+will take the thread-local locale if one has been set.
+This means that the idiom of setting the locale using
+.Xr setlocale 3 ,
+calling a locale-dependent function,
+and then restoring the locale will not
+have the expected behavior if the current thread has had a locale set using
+.Xr uselocale 3 .
+You should avoid this idiom and prefer to use the
+.Fa _l
+suffixed versions instead.
diff --git a/lib/libc/locale/xlocale.c b/lib/libc/locale/xlocale.c
index ece00766d386..e114bac74f2c 100644
--- a/lib/libc/locale/xlocale.c
+++ b/lib/libc/locale/xlocale.c
@@ -6,17 +6,18 @@
* 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.
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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
+ * 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)
@@ -31,6 +32,7 @@
#include <pthread.h>
#include <stdio.h>
#include <string.h>
+#include <runetype.h>
#include "libc_private.h"
#include "xlocale_private.h"
@@ -50,6 +52,17 @@ extern struct xlocale_component __xlocale_global_messages;
*/
extern struct xlocale_component __xlocale_C_collate;
extern struct xlocale_component __xlocale_C_ctype;
+
+#ifndef __NO_TLS
+/*
+ * The locale for this thread.
+ */
+_Thread_local locale_t __thread_locale;
+#endif
+/*
+ * Flag indicating that one or more per-thread locales exist.
+ */
+int __has_thread_locale;
/*
* Private functions in setlocale.c.
*/
@@ -103,6 +116,7 @@ static locale_t thread_local_locale;
static void init_key(void)
{
+
pthread_key_create(&locale_info_key, xlocale_release);
pthread_setspecific(locale_info_key, (void*)42);
if (pthread_getspecific(locale_info_key) == (void*)42) {
@@ -110,6 +124,8 @@ static void init_key(void)
} else {
fake_tls = 1;
}
+ /* At least one per-thread locale has now been set. */
+ __has_thread_locale = 1;
__detect_path_locale();
}
@@ -118,12 +134,14 @@ static pthread_once_t once_control = PTHREAD_ONCE_INIT;
static locale_t
get_thread_locale(void)
{
+
_once(&once_control, init_key);
return (fake_tls ? thread_local_locale :
pthread_getspecific(locale_info_key));
}
+#ifdef __NO_TLS
locale_t
__get_locale(void)
{
@@ -131,11 +149,13 @@ __get_locale(void)
return (l ? l : &__xlocale_global_locale);
}
+#endif
static void
set_thread_locale(locale_t loc)
{
- pthread_once(&once_control, init_key);
+
+ _once(&once_control, init_key);
if (NULL != loc) {
xlocale_retain((struct xlocale_refcounted*)loc);
@@ -149,6 +169,10 @@ set_thread_locale(locale_t loc)
} else {
pthread_setspecific(locale_info_key, loc);
}
+#ifndef __NO_TLS
+ __thread_locale = loc;
+ __set_thread_rune_locale(loc);
+#endif
}
/**
@@ -159,6 +183,7 @@ static void
destruct_locale(void *l)
{
locale_t loc = l;
+
for (int type=0 ; type<XLC_LAST ; type++) {
if (loc->components[type]) {
xlocale_release(loc->components[type]);
@@ -177,6 +202,7 @@ static locale_t
alloc_locale(void)
{
locale_t new = calloc(sizeof(struct _xlocale), 1);
+
new->header.destructor = destruct_locale;
new->monetary_locale_changed = 1;
new->numeric_locale_changed = 1;
@@ -193,19 +219,23 @@ copyflags(locale_t new, locale_t old)
static int dupcomponent(int type, locale_t base, locale_t new)
{
- /* Always copy from the global locale, since it has mutable components. */
+ /* Always copy from the global locale, since it has mutable components.
+ */
struct xlocale_component *src = base->components[type];
+
if (&__xlocale_global_locale == base) {
new->components[type] = constructors[type](src->locale, new);
if (new->components[type]) {
- strncpy(new->components[type]->locale, src->locale, ENCODING_LEN);
+ strncpy(new->components[type]->locale, src->locale,
+ ENCODING_LEN);
}
} else if (base->components[type]) {
new->components[type] = xlocale_retain(base->components[type]);
} else {
- /* If the component was NULL, return success - if base is a valid
- * locale then the flag indicating that this isn't present should be
- * set. If it isn't a valid locale, then we're stuck anyway. */
+ /* If the component was NULL, return success - if base is a
+ * valid locale then the flag indicating that this isn't
+ * present should be set. If it isn't a valid locale, then
+ * we're stuck anyway. */
return 1;
}
return (0 != new->components[type]);
@@ -244,9 +274,11 @@ locale_t newlocale(int mask, const char *locale, locale_t base)
if (useenv) {
realLocale = __get_locale_env(type);
}
- new->components[type] = constructors[type](realLocale, new);
+ new->components[type] =
+ constructors[type](realLocale, new);
if (new->components[type]) {
- strncpy(new->components[type]->locale, realLocale, ENCODING_LEN);
+ strncpy(new->components[type]->locale,
+ realLocale, ENCODING_LEN);
} else {
success = 0;
break;
@@ -319,7 +351,7 @@ const char *querylocale(int mask, locale_t loc)
return (NULL);
if (loc->components[type])
return (loc->components[type]->locale);
- return "C";
+ return ("C");
}
/*
diff --git a/lib/libc/locale/xlocale_private.h b/lib/libc/locale/xlocale_private.h
index 272d15ec8c83..813f71994052 100644
--- a/lib/libc/locale/xlocale_private.h
+++ b/lib/libc/locale/xlocale_private.h
@@ -8,16 +8,16 @@
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this 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
+ * 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)
@@ -85,14 +85,14 @@ struct _xlocale {
struct xlocale_refcounted header;
/** Components for the locale. */
struct xlocale_component *components[XLC_LAST];
- /** Flag indicating if components[XLC_MONETARY] has changed since the last
- * call to localeconv_l() with this locale. */
+ /** Flag indicating if components[XLC_MONETARY] has changed since the
+ * last call to localeconv_l() with this locale. */
int monetary_locale_changed;
/** Flag indicating whether this locale is actually using a locale for
* LC_MONETARY (1), or if it should use the C default instead (0). */
int using_monetary_locale;
- /** Flag indicating if components[XLC_NUMERIC] has changed since the last
- * call to localeconv_l() with this locale. */
+ /** Flag indicating if components[XLC_NUMERIC] has changed since the
+ * last call to localeconv_l() with this locale. */
int numeric_locale_changed;
/** Flag indicating whether this locale is actually using a locale for
* LC_NUMERIC (1), or if it should use the C default instead (0). */
@@ -170,12 +170,38 @@ extern struct _xlocale __xlocale_global_locale;
extern struct _xlocale __xlocale_C_locale;
/**
+ * Caches the rune table in TLS for fast access.
+ */
+void __set_thread_rune_locale(locale_t loc);
+/**
+ * Flag indicating whether a per-thread locale has been set. If no per-thread
+ * locale has ever been set, then we always use the global locale.
+ */
+extern int __has_thread_locale;
+#ifndef __NO_TLS
+/**
+ * The per-thread locale. Avoids the need to use pthread lookup functions when
+ * getting the per-thread locale.
+ */
+extern _Thread_local locale_t __thread_locale;
+
+/**
* Returns the current locale for this thread, or the global locale if none is
* set. The caller does not have to free the locale. The return value from
* this call is not guaranteed to remain valid after the locale changes. As
* such, this should only be called within libc functions.
*/
+static inline locale_t __get_locale(void)
+{
+
+ if (!__has_thread_locale) {
+ return (&__xlocale_global_locale);
+ }
+ return (__thread_locale ? __thread_locale : &__xlocale_global_locale);
+}
+#else
locale_t __get_locale(void);
+#endif
/**
* Two magic values are allowed for locale_t objects. NULL and -1. This
diff --git a/lib/libc/mips/gen/Makefile.inc b/lib/libc/mips/gen/Makefile.inc
index 8ee69d051ddb..9d9cc7aaedfa 100644
--- a/lib/libc/mips/gen/Makefile.inc
+++ b/lib/libc/mips/gen/Makefile.inc
@@ -6,4 +6,5 @@ SRCS+= infinity.c fabs.c ldexp.c
# SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \
# fpsetround.c fpsetsticky.c
-SRCS+= _ctx_start.S _set_tp.c _setjmp.S makecontext.c setjmp.S signalcontext.c sigsetjmp.S
+SRCS+= _ctx_start.S _set_tp.c _setjmp.S getcontextx.c makecontext.c \
+ setjmp.S signalcontext.c sigsetjmp.S
diff --git a/lib/libc/mips/gen/_set_tp.c b/lib/libc/mips/gen/_set_tp.c
index 4c26dffa0114..0bf04b525acc 100644
--- a/lib/libc/mips/gen/_set_tp.c
+++ b/lib/libc/mips/gen/_set_tp.c
@@ -29,7 +29,11 @@
#include <string.h>
#include <stdint.h>
+#include <machine/sysarch.h>
+
void
_set_tp(void *tp)
{
+
+ sysarch(MIPS_SET_TLS, tp);
}
diff --git a/lib/libc/mips/gen/getcontextx.c b/lib/libc/mips/gen/getcontextx.c
new file mode 100644
index 000000000000..307978a466dd
--- /dev/null
+++ b/lib/libc/mips/gen/getcontextx.c
@@ -0,0 +1,69 @@
+/*
+ * 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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/ucontext.h>
+#include <errno.h>
+#include <stdlib.h>
+
+int
+__getcontextx_size(void)
+{
+
+ return (sizeof(ucontext_t));
+}
+
+int
+__fillcontextx(char *ctx)
+{
+ ucontext_t *ucp;
+
+ ucp = (ucontext_t *)ctx;
+ return (getcontext(ucp));
+}
+
+__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/mips/softfloat/softfloat.h b/lib/libc/mips/softfloat/softfloat.h
index 50b5fa6fb466..6aef49975a38 100644
--- a/lib/libc/mips/softfloat/softfloat.h
+++ b/lib/libc/mips/softfloat/softfloat.h
@@ -45,7 +45,7 @@ the `FLOAT128' macro and the quadruple-precision format `float128'.
/* #define FLOATX80 */
/* #define FLOAT128 */
-#include <machine/ieeefp.h>
+#include <fenv.h>
/*
-------------------------------------------------------------------------------
@@ -84,12 +84,12 @@ enum {
Software IEC/IEEE floating-point rounding mode.
-------------------------------------------------------------------------------
*/
-extern fp_rnd_t float_rounding_mode;
+extern int float_rounding_mode;
enum {
- float_round_nearest_even = FP_RN,
- float_round_to_zero = FP_RZ,
- float_round_down = FP_RM,
- float_round_up = FP_RP
+ float_round_nearest_even = FE_TONEAREST,
+ float_round_to_zero = FE_TOWARDZERO,
+ float_round_down = FE_DOWNWARD,
+ float_round_up = FE_UPWARD
};
/*
@@ -97,14 +97,14 @@ enum {
Software IEC/IEEE floating-point exception flags.
-------------------------------------------------------------------------------
*/
-extern fp_except float_exception_flags;
-extern fp_except float_exception_mask;
+extern int float_exception_flags;
+extern int float_exception_mask;
enum {
- float_flag_inexact = FP_X_IMP,
- float_flag_underflow = FP_X_UFL,
- float_flag_overflow = FP_X_OFL,
- float_flag_divbyzero = FP_X_DZ,
- float_flag_invalid = FP_X_INV
+ float_flag_inexact = FE_INEXACT,
+ float_flag_underflow = FE_UNDERFLOW,
+ float_flag_overflow = FE_OVERFLOW,
+ float_flag_divbyzero = FE_DIVBYZERO,
+ float_flag_invalid = FE_INVALID
};
/*
@@ -113,7 +113,7 @@ Routine to raise any or all of the software IEC/IEEE floating-point
exception flags.
-------------------------------------------------------------------------------
*/
-void float_raise( fp_except );
+void float_raise( int );
/*
-------------------------------------------------------------------------------
diff --git a/lib/libc/mips/string/strchr.S b/lib/libc/mips/string/strchr.S
index 9a9f8dcdd4d9..198366f87a69 100644
--- a/lib/libc/mips/string/strchr.S
+++ b/lib/libc/mips/string/strchr.S
@@ -58,4 +58,4 @@ fnd:
j ra
END(strchr)
-STRONG_ALIAS(index, strchr)
+WEAK_ALIAS(index, strchr)
diff --git a/lib/libc/mips/string/strrchr.S b/lib/libc/mips/string/strrchr.S
index a742b3593024..5a88a42c8e17 100644
--- a/lib/libc/mips/string/strrchr.S
+++ b/lib/libc/mips/string/strrchr.S
@@ -56,4 +56,4 @@ LEAF(strrchr)
j ra
END(strrchr)
-STRONG_ALIAS(rindex, strrchr)
+WEAK_ALIAS(rindex, strrchr)
diff --git a/lib/libc/net/eui64.3 b/lib/libc/net/eui64.3
index 7cc5718ca964..fc563d157a14 100644
--- a/lib/libc/net/eui64.3
+++ b/lib/libc/net/eui64.3
@@ -221,10 +221,3 @@ These functions first appears in
They are derived from the
.Xr ethers 3
family of functions.
-.Sh BUGS
-The
-.Fn eui64_aton
-and
-.Fn eui64_ntoa
-functions returns values that are stored in static memory areas
-which may be overwritten the next time they are called.
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index 830e464c0125..8083c390b3b6 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -847,8 +847,6 @@ set_source(struct ai_order *aio, struct policyhead *ph)
struct in6_ifreq ifr6;
u_int32_t flags6;
- /* XXX: interface name should not be hardcoded */
- strncpy(ifr6.ifr_name, "lo0", sizeof(ifr6.ifr_name));
memset(&ifr6, 0, sizeof(ifr6));
memcpy(&ifr6.ifr_addr, ai.ai_addr, ai.ai_addrlen);
if (_ioctl(s, SIOCGIFAFLAG_IN6, &ifr6) == 0) {
@@ -1576,7 +1574,8 @@ ip6_str2scopeid(char *scope, struct sockaddr_in6 *sin6, u_int32_t *scopeid)
if (*scope == '\0')
return -1;
- if (IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) {
+ if (IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6) ||
+ IN6_IS_ADDR_MC_NODELOCAL(a6)) {
/*
* We currently assume a one-to-one mapping between links
* and interfaces, so we simply use interface indices for
diff --git a/lib/libc/net/getifaddrs.c b/lib/libc/net/getifaddrs.c
index aada929c1e42..f8633d5b959a 100644
--- a/lib/libc/net/getifaddrs.c
+++ b/lib/libc/net/getifaddrs.c
@@ -72,19 +72,6 @@ __FBSDID("$FreeBSD$");
#define ALIGN(p) (((u_long)(p) + ALIGNBYTES) &~ ALIGNBYTES)
#endif
-#if _BSDI_VERSION >= 199701
-#define HAVE_IFM_DATA
-#endif
-
-#if (_BSDI_VERSION >= 199802) || (__FreeBSD_version >= 1000003)
-/* ifam_data is very specific to recent versions of bsdi */
-#define HAVE_IFAM_DATA
-#endif
-
-#if defined(__NetBSD__) || defined(__OpenBSD__) || defined(__FreeBSD__)
-#define HAVE_IFM_DATA
-#endif
-
#define MAX_SYSCTL_TRY 5
int
@@ -93,7 +80,6 @@ getifaddrs(struct ifaddrs **pif)
int icnt = 1;
int dcnt = 0;
int ncnt = 0;
-#ifdef NET_RT_IFLIST
int ntry = 0;
int mib[6];
size_t needed;
@@ -102,30 +88,23 @@ getifaddrs(struct ifaddrs **pif)
struct ifaddrs *cif = 0;
char *p, *p0;
struct rt_msghdr *rtm;
- struct if_msghdr *ifm;
- struct ifa_msghdr *ifam;
+ struct if_msghdrl *ifm;
+ struct ifa_msghdrl *ifam;
struct sockaddr_dl *dl;
struct sockaddr *sa;
struct ifaddrs *ifa, *ift;
+ struct if_data *if_data;
u_short idx = 0;
-#else /* NET_RT_IFLIST */
- char buf[1024];
- int m, sock;
- struct ifconf ifc;
- struct ifreq *ifr;
- struct ifreq *lifr;
-#endif /* NET_RT_IFLIST */
int i;
size_t len, alen;
char *data;
char *names;
-#ifdef NET_RT_IFLIST
mib[0] = CTL_NET;
mib[1] = PF_ROUTE;
mib[2] = 0; /* protocol */
mib[3] = 0; /* wildcard address family */
- mib[4] = NET_RT_IFLIST;
+ mib[4] = NET_RT_IFLISTL;/* extra fields for extensible msghdr structs */
mib[5] = 0; /* no flags */
do {
/*
@@ -159,34 +138,33 @@ getifaddrs(struct ifaddrs **pif)
continue;
switch (rtm->rtm_type) {
case RTM_IFINFO:
- ifm = (struct if_msghdr *)(void *)rtm;
+ ifm = (struct if_msghdrl *)(void *)rtm;
if (ifm->ifm_addrs & RTA_IFP) {
idx = ifm->ifm_index;
++icnt;
- dl = (struct sockaddr_dl *)(void *)(ifm + 1);
+ if_data = IF_MSGHDRL_IFM_DATA(ifm);
+ dcnt += if_data->ifi_datalen;
+ dl = (struct sockaddr_dl *)IF_MSGHDRL_RTA(ifm);
dcnt += SA_RLEN((struct sockaddr *)(void*)dl) +
ALIGNBYTES;
-#ifdef HAVE_IFM_DATA
- dcnt += sizeof(ifm->ifm_data);
-#endif /* HAVE_IFM_DATA */
ncnt += dl->sdl_nlen + 1;
} else
idx = 0;
break;
case RTM_NEWADDR:
- ifam = (struct ifa_msghdr *)(void *)rtm;
+ ifam = (struct ifa_msghdrl *)(void *)rtm;
if (idx && ifam->ifam_index != idx)
abort(); /* this cannot happen */
#define RTA_MASKS (RTA_NETMASK | RTA_IFA | RTA_BRD)
if (idx == 0 || (ifam->ifam_addrs & RTA_MASKS) == 0)
break;
- p = (char *)(void *)(ifam + 1);
+ p = (char *)IFA_MSGHDRL_RTA(ifam);
++icnt;
-#ifdef HAVE_IFAM_DATA
- dcnt += sizeof(ifam->ifam_data) + ALIGNBYTES;
-#endif /* HAVE_IFAM_DATA */
+ if_data = IFA_MSGHDRL_IFAM_DATA(ifam);
+ dcnt += if_data->ifi_datalen + ALIGNBYTES;
+
/* Scan to look for length of address */
alen = 0;
for (p0 = p, i = 0; i < RTAX_MAX; i++) {
@@ -216,34 +194,6 @@ getifaddrs(struct ifaddrs **pif)
break;
}
}
-#else /* NET_RT_IFLIST */
- ifc.ifc_buf = buf;
- ifc.ifc_len = sizeof(buf);
-
- if ((sock = _socket(AF_INET, SOCK_STREAM, 0)) < 0)
- return (-1);
- i = _ioctl(sock, SIOCGIFCONF, (char *)&ifc);
- _close(sock);
- if (i < 0)
- return (-1);
-
- ifr = ifc.ifc_req;
- lifr = (struct ifreq *)&ifc.ifc_buf[ifc.ifc_len];
-
- while (ifr < lifr) {
- struct sockaddr *sa;
-
- sa = &ifr->ifr_addr;
- ++icnt;
- dcnt += SA_RLEN(sa);
- ncnt += sizeof(ifr->ifr_name) + 1;
-
- if (SA_LEN(sa) < sizeof(*sa))
- ifr = (struct ifreq *)(((char *)sa) + sizeof(*sa));
- else
- ifr = (struct ifreq *)(((char *)sa) + SA_LEN(sa));
- }
-#endif /* NET_RT_IFLIST */
if (icnt + dcnt + ncnt == 1) {
*pif = NULL;
@@ -263,7 +213,6 @@ getifaddrs(struct ifaddrs **pif)
memset(ifa, 0, sizeof(struct ifaddrs) * icnt);
ift = ifa;
-#ifdef NET_RT_IFLIST
idx = 0;
for (next = buf; next < buf + needed; next += rtm->rtm_msglen) {
rtm = (struct rt_msghdr *)(void *)next;
@@ -271,41 +220,38 @@ getifaddrs(struct ifaddrs **pif)
continue;
switch (rtm->rtm_type) {
case RTM_IFINFO:
- ifm = (struct if_msghdr *)(void *)rtm;
- if (ifm->ifm_addrs & RTA_IFP) {
- idx = ifm->ifm_index;
- dl = (struct sockaddr_dl *)(void *)(ifm + 1);
-
- cif = ift;
- ift->ifa_name = names;
- ift->ifa_flags = (int)ifm->ifm_flags;
- memcpy(names, dl->sdl_data,
- (size_t)dl->sdl_nlen);
- names[dl->sdl_nlen] = 0;
- names += dl->sdl_nlen + 1;
-
- ift->ifa_addr = (struct sockaddr *)(void *)data;
- memcpy(data, dl,
- (size_t)SA_LEN((struct sockaddr *)
- (void *)dl));
- data += SA_RLEN((struct sockaddr *)(void *)dl);
-
-#ifdef HAVE_IFM_DATA
- /* ifm_data needs to be aligned */
- ift->ifa_data = data = (void *)ALIGN(data);
- memcpy(data, &ifm->ifm_data, sizeof(ifm->ifm_data));
- data += sizeof(ifm->ifm_data);
-#else /* HAVE_IFM_DATA */
- ift->ifa_data = NULL;
-#endif /* HAVE_IFM_DATA */
-
- ift = (ift->ifa_next = ift + 1);
- } else
+ ifm = (struct if_msghdrl *)(void *)rtm;
+ if ((ifm->ifm_addrs & RTA_IFP) == 0) {
idx = 0;
+ break;
+ }
+
+ idx = ifm->ifm_index;
+ dl = (struct sockaddr_dl *)IF_MSGHDRL_RTA(ifm);
+
+ cif = ift;
+ ift->ifa_name = names;
+ ift->ifa_flags = (int)ifm->ifm_flags;
+ memcpy(names, dl->sdl_data, (size_t)dl->sdl_nlen);
+ names[dl->sdl_nlen] = 0;
+ names += dl->sdl_nlen + 1;
+
+ ift->ifa_addr = (struct sockaddr *)(void *)data;
+ memcpy(data, dl, (size_t)SA_LEN((struct sockaddr *)
+ (void *)dl));
+ data += SA_RLEN((struct sockaddr *)(void *)dl);
+
+ if_data = IF_MSGHDRL_IFM_DATA(ifm);
+ /* ifm_data needs to be aligned */
+ ift->ifa_data = data = (void *)ALIGN(data);
+ memcpy(data, if_data, if_data->ifi_datalen);
+ data += if_data->ifi_datalen;
+
+ ift = (ift->ifa_next = ift + 1);
break;
case RTM_NEWADDR:
- ifam = (struct ifa_msghdr *)(void *)rtm;
+ ifam = (struct ifa_msghdrl *)(void *)rtm;
if (idx && ifam->ifam_index != idx)
abort(); /* this cannot happen */
@@ -314,7 +260,8 @@ getifaddrs(struct ifaddrs **pif)
ift->ifa_name = cif->ifa_name;
ift->ifa_flags = cif->ifa_flags;
ift->ifa_data = NULL;
- p = (char *)(void *)(ifam + 1);
+
+ p = (char *)IFA_MSGHDRL_RTA(ifam);
/* Scan to look for length of address */
alen = 0;
for (p0 = p, i = 0; i < RTAX_MAX; i++) {
@@ -365,12 +312,11 @@ getifaddrs(struct ifaddrs **pif)
p += len;
}
-#ifdef HAVE_IFAM_DATA
+ if_data = IFA_MSGHDRL_IFAM_DATA(ifam);
/* ifam_data needs to be aligned */
ift->ifa_data = data = (void *)ALIGN(data);
- memcpy(data, &ifam->ifam_data, sizeof(ifam->ifam_data));
- data += sizeof(ifam->ifam_data);
-#endif /* HAVE_IFAM_DATA */
+ memcpy(data, if_data, if_data->ifi_datalen);
+ data += if_data->ifi_datalen;
ift = (ift->ifa_next = ift + 1);
break;
@@ -378,28 +324,7 @@ getifaddrs(struct ifaddrs **pif)
}
free(buf);
-#else /* NET_RT_IFLIST */
- ifr = ifc.ifc_req;
- lifr = (struct ifreq *)&ifc.ifc_buf[ifc.ifc_len];
-
- while (ifr < lifr) {
- struct sockaddr *sa;
-
- ift->ifa_name = names;
- names[sizeof(ifr->ifr_name)] = 0;
- strncpy(names, ifr->ifr_name, sizeof(ifr->ifr_name));
- while (*names++)
- ;
-
- ift->ifa_addr = (struct sockaddr *)data;
- sa = &ifr->ifr_addr;
- memcpy(data, sa, SA_LEN(sa));
- data += SA_RLEN(sa);
-
- ifr = (struct ifreq *)(((char *)sa) + SA_LEN(sa));
- ift = (ift->ifa_next = ift + 1);
- }
-#endif /* NET_RT_IFLIST */
+
if (--ift >= ifa) {
ift->ifa_next = NULL;
*pif = ifa;
diff --git a/lib/libc/net/getipnodebyname.3 b/lib/libc/net/getipnodebyname.3
index 615c5bb22d84..0697c64e68bd 100644
--- a/lib/libc/net/getipnodebyname.3
+++ b/lib/libc/net/getipnodebyname.3
@@ -108,13 +108,13 @@ We note that a special flags value of
(defined below)
should handle most applications.
That is, porting simple applications to use IPv6 replaces the call
-.Bd -literal -offset
- hptr = gethostbyname(name);
+.Bd -literal -offset indent
+hptr = gethostbyname(name);
.Ed
.Pp
with
-.Bd -literal -offset
- hptr = getipnodebyname(name, AF_INET6, AI_DEFAULT, &error_num);
+.Bd -literal -offset indent
+hptr = getipnodebyname(name, AF_INET6, AI_DEFAULT, &error_num);
.Ed
.Pp
Applications desiring finer control over the types of addresses
@@ -270,8 +270,8 @@ records are returned as IPv4-mapped IPv6 addresses;
The special flags value of
.Dv AI_DEFAULT
is defined as
-.Bd -literal -offset
- #define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
+.Bd -literal -offset indent
+#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
.Ed
.Pp
We noted that the
diff --git a/lib/libc/net/getnameinfo.3 b/lib/libc/net/getnameinfo.3
index e9d17ff67f97..327c13597782 100644
--- a/lib/libc/net/getnameinfo.3
+++ b/lib/libc/net/getnameinfo.3
@@ -135,7 +135,7 @@ and
.El
.Pp
This implementation allows numeric IPv6 address notation with scope identifier,
-as documented in chapter 11 of draft-ietf-ipv6-scoping-arch-02.txt.
+as documented in chapter 11 of RFC 4007.
IPv6 link-local address will appear as a string like
.Dq Li fe80::1%ne0 .
Refer to
diff --git a/lib/libc/net/if_nametoindex.c b/lib/libc/net/if_nametoindex.c
index d0ca5212755d..9d47089971e4 100644
--- a/lib/libc/net/if_nametoindex.c
+++ b/lib/libc/net/if_nametoindex.c
@@ -70,6 +70,9 @@ if_nametoindex(const char *ifname)
s = _socket(AF_INET, SOCK_DGRAM, 0);
if (s != -1) {
+#ifdef PURIFY
+ memset(&ifr, 0, sizeof(ifr));
+#endif
strlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
if (_ioctl(s, SIOCGIFINDEX, &ifr) != -1) {
_close(s);
diff --git a/lib/libc/net/inet_net.3 b/lib/libc/net/inet_net.3
index 1da5975eec33..9a12cc764dca 100644
--- a/lib/libc/net/inet_net.3
+++ b/lib/libc/net/inet_net.3
@@ -95,7 +95,6 @@ The
argument
is the size of the result buffer
.Fa dst .
-.Pp
.Sh NETWORK NUMBERS (IP VERSION 4)
Internet network numbers may be specified in one of the following forms:
.Bd -literal -offset indent
diff --git a/lib/libc/net/name6.c b/lib/libc/net/name6.c
index 4864bf4a6f55..0031f462ffc2 100644
--- a/lib/libc/net/name6.c
+++ b/lib/libc/net/name6.c
@@ -884,8 +884,6 @@ set_source(struct hp_order *aio, struct policyhead *ph)
struct in6_ifreq ifr6;
u_int32_t flags6;
- /* XXX: interface name should not be hardcoded */
- strncpy(ifr6.ifr_name, "lo0", sizeof(ifr6.ifr_name));
memset(&ifr6, 0, sizeof(ifr6));
memcpy(&ifr6.ifr_addr, &ss, ss.ss_len);
if (_ioctl(s, SIOCGIFAFLAG_IN6, &ifr6) == 0) {
diff --git a/lib/libc/net/nsdispatch.3 b/lib/libc/net/nsdispatch.3
index d1d8d5a0e71e..a1da892d4fc4 100644
--- a/lib/libc/net/nsdispatch.3
+++ b/lib/libc/net/nsdispatch.3
@@ -85,7 +85,7 @@ typedef struct _ns_dtab {
void *mdata;
} ns_dtab;
.Ed
-.Bd -ragged -offset indent
+.Pp
The
.Fa dtab
array should consist of one entry for each source type that is
@@ -105,7 +105,6 @@ values for
.Va method ,
and
.Va mdata .
-.Ed
.Pp
Additionally, methods may be implemented in NSS modules, in
which case they are selected using the
@@ -129,10 +128,10 @@ structures, which have the following format:
.Bd -literal -offset indent
typedef struct _ns_src {
const char *src;
- u_int32_t flags;
+ uint32_t flags;
} ns_src;
.Ed
-.Bd -ragged -offset indent
+.Pp
The
.Fa defaults
array should consist of one entry for each source to be configured by
@@ -157,12 +156,13 @@ and
set to 0.
.Pp
For convenience, a global variable defined as:
+.Pp
.Dl extern const ns_src __nsdefaultsrc[];
+.Pp
exists which contains a single default entry for the source
.Sq files
that may be used by callers which do not require complicated default
rules.
-.Ed
.Pp
.Sq Va ...
are optional extra arguments, which are passed to the appropriate method
@@ -183,7 +183,6 @@ While there is support for arbitrary sources, the following
Refer to
.Xr nsswitch.conf 5
for a complete description of what each source type is.
-.Pp
.Ss Method return values
The
.Vt nss_method
diff --git a/lib/libc/net/sctp_bindx.3 b/lib/libc/net/sctp_bindx.3
index d0471267f988..403cf7d1e758 100644
--- a/lib/libc/net/sctp_bindx.3
+++ b/lib/libc/net/sctp_bindx.3
@@ -55,7 +55,7 @@ This allows a user to bind a subset of
addresses.
The
.Fn sctp_bindx
-call operates similarly to
+call operates similarly to
.Fn bind
but allows a list of addresses and also allows a bind or an
unbind.
@@ -98,7 +98,7 @@ This value is returned if the
field is not one of the allowed values (see above).
.It Bq Er ENOMEM
This value is returned if the number of addresses
-being added causes a memory allocation failure in
+being added causes a memory allocation failure in
the call.
.It Bq Er EBADF
The argument
diff --git a/lib/libc/net/sctp_connectx.3 b/lib/libc/net/sctp_connectx.3
index d454bb9f5ba6..1851d4a32932 100644
--- a/lib/libc/net/sctp_connectx.3
+++ b/lib/libc/net/sctp_connectx.3
@@ -58,18 +58,18 @@ This allows a fault tolerant method
of initiating an association.
When one of the peers addresses
is unreachable, the subsequent listed addresses will also be used
-to set up the association with the peer.
+to set up the association with the peer.
.Pp
-The user also needs to consider that any address listed in an
+The user also needs to consider that any address listed in an
.Fn sctp_connectx
call is also considered "confirmed".
A confirmed address is one in
which the SCTP transport will trust is a part of the association
and it will not send a confirmation heartbeat to it with
-a random nonce.
+a random nonce.
.Pp
If the peer SCTP stack does not list one or more of
-the provided addresses in its response message then
+the provided addresses in its response message then
the extra addresses sent in the
.Fn sctp_connectx
call will be silently discarded from the association.
diff --git a/lib/libc/net/sctp_freepaddrs.3 b/lib/libc/net/sctp_freepaddrs.3
index a6815f4c461a..77a8488177a0 100644
--- a/lib/libc/net/sctp_freepaddrs.3
+++ b/lib/libc/net/sctp_freepaddrs.3
@@ -46,9 +46,9 @@
.In sys/socket.h
.In netinet/sctp.h
.Ft void
-.Fn sctp_freepaddrs "struct sockaddr *"
+.Fn sctp_freepaddrs "struct sockaddr *"
.Ft void
-.Fn sctp_freeladdrs "struct sockaddr *"
+.Fn sctp_freeladdrs "struct sockaddr *"
.Sh DESCRIPTION
The
.Fn sctp_freepaddrs
diff --git a/lib/libc/net/sctp_getaddrlen.3 b/lib/libc/net/sctp_getaddrlen.3
index 762e32dc9448..7259635f79fb 100644
--- a/lib/libc/net/sctp_getaddrlen.3
+++ b/lib/libc/net/sctp_getaddrlen.3
@@ -62,7 +62,7 @@ system calls.
If for some reason a SCTP socket cannot
be created or the
.Fn getsockopt
-call fails, an error will be returned
+call fails, an error will be returned
with
.Va errno
set as specified in the
diff --git a/lib/libc/net/sctp_getassocid.3 b/lib/libc/net/sctp_getassocid.3
index 909b9c773442..f347a1341c58 100644
--- a/lib/libc/net/sctp_getassocid.3
+++ b/lib/libc/net/sctp_getassocid.3
@@ -50,8 +50,7 @@ The
.Fn sctp_getassocid
call attempts to look up the specified socket address
.Fa addr
-and find the respective association identification.
-.Pp
+and find the respective association identification.
.Sh RETURN VALUES
The call returns the association id upon success and
0 is returned upon failure.
diff --git a/lib/libc/net/sctp_getpaddrs.3 b/lib/libc/net/sctp_getpaddrs.3
index 6ad5ea03176b..8bdf2ccf370a 100644
--- a/lib/libc/net/sctp_getpaddrs.3
+++ b/lib/libc/net/sctp_getpaddrs.3
@@ -53,7 +53,7 @@
The
.Fn sctp_getpaddrs
function is used to get the list of the peers addresses.
-The
+The
.Fn sctp_getladdrs
function is used to get the list of the local addresses.
The association of interest is identified by the
diff --git a/lib/libc/net/sctp_opt_info.3 b/lib/libc/net/sctp_opt_info.3
index df8faa67f0cd..02b0f852156f 100644
--- a/lib/libc/net/sctp_opt_info.3
+++ b/lib/libc/net/sctp_opt_info.3
@@ -50,7 +50,7 @@
The
.Fn sctp_opt_info
call provides a multi-os compatible method for getting
-specific
+specific
.Fn getsockopt
data where an association identification needs to be passed
into the operating system.
@@ -70,7 +70,7 @@ who wish to write portable code amongst multiple operating systems
this call should be used for the following SCTP
socket options.
.Pp
-.Dv SCTP_RTOINFO
+.Dv SCTP_RTOINFO
.Pp
.Dv SCTP_ASSOCINFO
.Pp
diff --git a/lib/libc/net/sctp_recvmsg.3 b/lib/libc/net/sctp_recvmsg.3
index 8ddbeb82acbc..37323c871594 100644
--- a/lib/libc/net/sctp_recvmsg.3
+++ b/lib/libc/net/sctp_recvmsg.3
@@ -56,11 +56,11 @@ 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
+successful
.Fn connect
-call or after the application has performed a
-.Fn listen
-followed by a successful
+call or after the application has performed a
+.Fn listen
+followed by a successful
.Fn accept .
For a one-to-many (SOCK_SEQPACKET) type socket, an endpoint may call
.Fn sctp_recvmsg
@@ -77,7 +77,7 @@ with a positive backlog to enable the reception of new associations.
.Pp
The address of the sender is held in the
.Fa from
-argument with
+argument with
.Fa fromlen
specifying its size.
At the completion of a successful
@@ -88,16 +88,16 @@ will hold the address of the peer and
.Fa fromlen
will hold the length of that address.
Note that
-the address is bounded by the initial value of
+the address is bounded by the initial value of
.Fa fromlen
which is used as an in/out variable.
.Pp
-The length of the message
+The length of the message
.Fa msg
to be received is bounded by
.Fa len .
If the message is too long to fit in the users
-receive buffer, then the
+receive buffer, then the
.Fa flags
argument will
.Em not
@@ -105,16 +105,16 @@ have the
.Dv MSG_EOF
flag applied.
If the message is a complete message then
-the
+the
.Fa flags
argument will have
.Dv MSG_EOF
set.
-Locally detected errors are
+Locally detected errors are
indicated by a return value of -1 with
.Va errno
set accordingly.
-The
+The
.Fa flags
argument may also hold the value
.Dv MSG_NOTIFICATION .
@@ -141,7 +141,7 @@ The
system call may be used to determine when it is possible to
receive a message.
.Pp
-The
+The
.Fa sinfo
argument is defined as follows.
.Bd -literal
@@ -161,7 +161,7 @@ struct sctp_sndrcvinfo {
The
.Fa sinfo->sinfo_ppid
field is an opaque 32 bit value that is passed transparently
-through the stack from the peer endpoint.
+through the stack from the peer endpoint.
Note that the stack passes this value without regard to byte
order.
.Pp
@@ -182,7 +182,7 @@ was delivered in order within the stream it was received.
.Pp
The
.Fa sinfo->sinfo_stream
-field is the SCTP stream that the message was received on.
+field is the SCTP stream that the message was received on.
Streams in SCTP are reliable (or partially reliable) flows of ordered
messages.
.Pp
@@ -194,7 +194,7 @@ context with the
socket option.
Optionally a user process can use this value to index some application
specific data structure for all data coming from a specific
-association.
+association.
.Pp
The
.Fa sinfo->sinfo_ssn
@@ -230,12 +230,12 @@ sockets this value can be used to send data to the peer without
the use of an address field.
It is also quite useful in
setting various socket options on the specific association
-(see
+(see
.Xr sctp 4 ) .
.Pp
The
.Fa sinfo->info_timetolive
-field is not used by
+field is not used by
.Fn sctp_recvmsg .
.Sh RETURN VALUES
The call returns the number of bytes received, or -1
diff --git a/lib/libc/net/sctp_send.3 b/lib/libc/net/sctp_send.3
index 9acb616be5bb..d195b7ab4899 100644
--- a/lib/libc/net/sctp_send.3
+++ b/lib/libc/net/sctp_send.3
@@ -62,14 +62,14 @@ is used to transmit a message to another SCTP endpoint.
.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.
-The length of the message
+The length of the message
.Fa msg
is given by
.Fa len .
If the message is too long to pass atomically through the
underlying protocol,
.Va errno
-is set to
+is set to
.Er EMSGSIZE ,
-1 is returned, and
the message is not transmitted.
@@ -88,7 +88,7 @@ The
system call may be used to determine when it is possible to
send more data on one-to-one type (SOCK_STREAM) sockets.
.Pp
-The
+The
.Fa sinfo
structure is used to control various SCTP features
and has the following format:
@@ -106,7 +106,7 @@ struct sctp_sndrcvinfo {
};
.Ed
.Pp
-The
+The
.Fa sinfo->sinfo_ppid
argument is an opaque 32 bit value that is passed transparently
through the stack to the peer endpoint. It will be available on
@@ -131,7 +131,7 @@ argument may include one or more of the following:
#define SCTP_PR_SCTP_RTX 0x0003 /* Number of retransmissions based PR-SCTP */
.Ed
.Pp
-The flag
+The flag
.Dv SCTP_EOF
is used to instruct the SCTP stack to queue this message
and then start a graceful shutdown of the association.
@@ -158,7 +158,7 @@ is used to specify that a specific address should be used.
Normally
SCTP will use only one of a multi-homed peers addresses as the primary
address to send to.
-By default, no matter what the
+By default, no matter what the
.Fa to
argument is, this primary address is used to send data.
By specifying
@@ -193,14 +193,14 @@ skipped and no longer transmitted.
Note that this policy does
not even assure that the data will ever be sent.
In times of a congestion
-with large amounts of data being queued, the
+with large amounts of data being queued, the
.Fa sinfo->sinfo_timetolive
may expire before the first transmission is ever made.
.Pp
The
.Dv SCTP_PR_SCTP_BUF
based policy transforms the
-.Fa sinfo->sinfo_timetolive
+.Fa sinfo->sinfo_timetolive
field into a total number of bytes allowed on the outbound
send queue.
If that number or more bytes are in queue, then
@@ -208,19 +208,19 @@ other buffer-based sends are looked to be removed and
skipped.
Note that this policy may also result in the data
never being sent if no buffer based sends are in queue and
-the maximum specified by
-.Fa timetolive
+the maximum specified by
+.Fa timetolive
bytes is in queue.
.Pp
The
.Dv SCTP_PR_SCTP_RTX
policy transforms the
-.Fa sinfo->sinfo_timetolive
+.Fa sinfo->sinfo_timetolive
into a number of retransmissions to allow.
This policy
always assures that at a minimum one send attempt is
made of the data.
-After which no more than
+After which no more than
.Fa sinfo->sinfo_timetolive
retransmissions will be made before the data is skipped.
.Pp
@@ -228,11 +228,11 @@ retransmissions will be made before the data is skipped.
is the SCTP stream that you wish to send the
message on.
Streams in SCTP are reliable (or partially reliable) flows of ordered
-messages.
+messages.
.Pp
The
.Fa sinfo->sinfo_assoc_id
-field is used to
+field is used to
select the association to send to on a one-to-many socket.
For a one-to-one socket, this field is ignored.
.Pp
@@ -256,16 +256,16 @@ The fields
.Fa sinfo->sinfo_ssn ,
.Fa sinfo->sinfo_tsn ,
and
-.Fa sinfo->sinfo_cumtsn
+.Fa sinfo->sinfo_cumtsn
are used only when receiving messages and are thus ignored by
.Fn sctp_send .
The function
-.Fn sctp_sendx
-has the same properties as
+.Fn sctp_sendx
+has the same properties as
.Fn sctp_send
with the additional arguments of an array of sockaddr structures
passed in.
-With the
+With the
.Fa addrs
argument being given as an array of addresses to be sent to and
the
@@ -277,7 +277,7 @@ when an implicit association is being set up.
This allows the
user the equivalent behavior as doing a
.Fn sctp_connectx
-followed by a
+followed by a
.Fn sctp_send
to the association.
Note that if the
diff --git a/lib/libc/net/sctp_sendmsg.3 b/lib/libc/net/sctp_sendmsg.3
index ddd88b43c9f9..4158932ebc64 100644
--- a/lib/libc/net/sctp_sendmsg.3
+++ b/lib/libc/net/sctp_sendmsg.3
@@ -72,10 +72,10 @@ Data sent in such an instance will result in
the data being sent on the third leg of the SCTP four-way handshake.
Note that if
the socket is a one-to-one type (SOCK_STREAM) socket then an association must
-be in existence (by use of the
+be in existence (by use of the
.Xr connect 2
system call).
-Calling
+Calling
.Fn sctp_sendmsg
or
.Fn sctp_sendmsgx
@@ -90,14 +90,14 @@ The address of the target is given by
with
.Fa tolen
specifying its size.
-The length of the message
+The length of the message
.Fa msg
is given by
.Fa len .
If the message is too long to pass atomically through the
underlying protocol,
.Va errno
-is set to
+is set to
.Er EMSGSIZE ,
-1 is returned, and
the message is not transmitted.
@@ -117,7 +117,7 @@ The
system call may be used to determine when it is possible to
send more data on one-to-one type (SOCK_STREAM) sockets.
.Pp
-The
+The
.Fa ppid
argument is an opaque 32 bit value that is passed transparently
through the stack to the peer endpoint.
@@ -143,7 +143,7 @@ argument may include one or more of the following:
#define SCTP_PR_SCTP_RTX 0x0003 /* Number of retransmissions based PR-SCTP */
.Ed
.Pp
-The flag
+The flag
.Dv SCTP_EOF
is used to instruct the SCTP stack to queue this message
and then start a graceful shutdown of the association.
@@ -170,7 +170,7 @@ is used to specify that an specific address should be used.
Normally
SCTP will use only one of a multi-homed peers addresses as the primary
address to send to.
-By default, no matter what the
+By default, no matter what the
.Fa to
argument is, this primary address is used to send data.
By specifying
@@ -205,14 +205,14 @@ skipped and no longer transmitted.
Note that this policy does
not even assure that the data will ever be sent.
In times of a congestion
-with large amounts of data being queued, the
+with large amounts of data being queued, the
.Fa timetolive
may expire before the first transmission is ever made.
.Pp
The
.Dv SCTP_PR_SCTP_BUF
based policy transforms the
-.Fa timetolive
+.Fa timetolive
field into a total number of bytes allowed on the outbound
send queue.
If that number or more bytes are in queue, then
@@ -220,19 +220,19 @@ other buffer based sends are looked to be removed and
skipped.
Note that this policy may also result in the data
never being sent if no buffer based sends are in queue and
-the maximum specified by
-.Fa timetolive
+the maximum specified by
+.Fa timetolive
bytes is in queue.
.Pp
The
.Dv SCTP_PR_SCTP_RTX
policy transforms the
-.Fa timetolive
+.Fa timetolive
into a number of retransmissions to allow.
This policy
always assures that at a minimum one send attempt is
made of the data.
-After which no more than
+After which no more than
.Fa timetolive
retransmissions will be made before the data is skipped.
.Pp
@@ -241,7 +241,7 @@ is the SCTP stream that you wish to send the
message on.
Streams in SCTP are reliable (or partially reliable) flows of ordered
messages.
-The
+The
.Fa context
field is used only in the event the message cannot be sent.
This is an opaque
@@ -251,7 +251,7 @@ is given if that notification is enabled (see
Normally a user process can use this value to index some application
specific data structure when a send cannot be fulfilled.
.Fn sctp_sendmsgx
-is identical to
+is identical to
.Fn sctp_sendmsg
with the exception that it takes an array of sockaddr structures in the
argument
@@ -262,7 +262,7 @@ which specifies how many addresses are in the array.
This allows a
caller to implicitly set up an association passing multiple addresses
as if
-.Fn sctp_connectx
+.Fn sctp_connectx
had been called to set up the association.
.Sh RETURN VALUES
The call returns the number of characters sent, or -1
@@ -325,7 +325,7 @@ is not connected and is a one-to-one style socket.
.Xr sctp 4
.Sh BUGS
Because in the one-to-many style socket
-.Fn sctp_sendmsg
+.Fn sctp_sendmsg
or
.Fn sctp_sendmsgx
may have multiple associations under one endpoint, a
diff --git a/lib/libc/net/sourcefilter.3 b/lib/libc/net/sourcefilter.3
index 46f61a891ad5..c7293e05b9de 100644
--- a/lib/libc/net/sourcefilter.3
+++ b/lib/libc/net/sourcefilter.3
@@ -220,7 +220,7 @@ operation.
.Sh SEE ALSO
.Xr ip 4 ,
.Xr ip6 4 ,
-.Xr multicast 4,
+.Xr multicast 4,
.Xr ifmcstat 8
.Rs
.%A D. Thaler
diff --git a/lib/libc/posix1e/acl_add_flag_np.3 b/lib/libc/posix1e/acl_add_flag_np.3
index 7ae83e28c0d7..057de0393ca1 100644
--- a/lib/libc/posix1e/acl_add_flag_np.3
+++ b/lib/libc/posix1e/acl_add_flag_np.3
@@ -30,7 +30,7 @@
.Os
.Sh NAME
.Nm acl_add_flag_np
-.Nd add flags to a flagset
+.Nd add flags to a flagset
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
@@ -52,10 +52,10 @@ that already exist in the flagset.
.Pp
Valid values are:
.Bl -column -offset 3n "ACL_ENTRY_NO_PROPAGATE_INHERIT"
-.It ACL_ENTRY_FILE_INHERIT Will be inherited by files.
-.It ACL_ENTRY_DIRECTORY_INHERIT Will be inherited by directories.
-.It ACL_ENTRY_NO_PROPAGATE_INHERIT Will not propagate.
-.It ACL_ENTRY_INHERIT_ONLY Inherit-only.
+.It ACL_ENTRY_FILE_INHERIT Ta "Will be inherited by files."
+.It ACL_ENTRY_DIRECTORY_INHERIT Ta "Will be inherited by directories."
+.It ACL_ENTRY_NO_PROPAGATE_INHERIT Ta "Will not propagate."
+.It ACL_ENTRY_INHERIT_ONLY Ta "Inherit-only."
.El
.Sh RETURN VALUES
.Rv -std acl_add_flag_np
diff --git a/lib/libc/posix1e/acl_add_perm.3 b/lib/libc/posix1e/acl_add_perm.3
index beb5f98a0f7c..564b83d9a332 100644
--- a/lib/libc/posix1e/acl_add_perm.3
+++ b/lib/libc/posix1e/acl_add_perm.3
@@ -59,22 +59,22 @@ For POSIX.1e ACLs, valid values are:
.Pp
For NFSv4 ACLs, valid values are:
.Bl -column -offset 3n "ACL_WRITE_NAMED_ATTRS"
-.It ACL_READ_DATA Read permission
-.It ACL_LIST_DIRECTORY Same as ACL_READ_DATA
-.It ACL_WRITE_DATA Write permission, or permission to create files
-.It ACL_ADD_FILE Same as ACL_READ_DATA
-.It ACL_APPEND_DATA Permission to create directories. Ignored for files
-.It ACL_ADD_SUBDIRECTORY Same as ACL_APPEND_DATA
-.It ACL_READ_NAMED_ATTRS Ignored
-.It ACL_WRITE_NAMED_ATTRS Ignored
-.It ACL_EXECUTE Execute permission
-.It ACL_DELETE_CHILD Permission to delete files and subdirectories
-.It ACL_READ_ATTRIBUTES Permission to read basic attributes
-.It ACL_WRITE_ATTRIBUTES Permission to change basic attributes
-.It ACL_DELETE Permission to delete the object this ACL is placed on
-.It ACL_READ_ACL Permission to read ACL
-.It ACL_WRITE_ACL Permission to change the ACL and file mode
-.It ACL_SYNCHRONIZE Ignored
+.It ACL_READ_DATA Ta "Read permission"
+.It ACL_LIST_DIRECTORY Ta "Same as ACL_READ_DATA"
+.It ACL_WRITE_DATA Ta "Write permission, or permission to create files"
+.It ACL_ADD_FILE Ta "Same as ACL_READ_DATA"
+.It ACL_APPEND_DATA Ta "Permission to create directories. Ignored for files"
+.It ACL_ADD_SUBDIRECTORY Ta "Same as ACL_APPEND_DATA"
+.It ACL_READ_NAMED_ATTRS Ta "Ignored"
+.It ACL_WRITE_NAMED_ATTRS Ta "Ignored"
+.It ACL_EXECUTE Ta "Execute permission"
+.It ACL_DELETE_CHILD Ta "Permission to delete files and subdirectories"
+.It ACL_READ_ATTRIBUTES Ta "Permission to read basic attributes"
+.It ACL_WRITE_ATTRIBUTES Ta "Permission to change basic attributes"
+.It ACL_DELETE Ta "Permission to delete the object this ACL is placed on"
+.It ACL_READ_ACL Ta "Permission to read ACL"
+.It ACL_WRITE_ACL Ta "Permission to change the ACL and file mode"
+.It ACL_SYNCHRONIZE Ta "Ignored"
.El
.Pp
Calling
diff --git a/lib/libc/posix1e/acl_create_entry.3 b/lib/libc/posix1e/acl_create_entry.3
index 24427831a15a..784f6875cf9b 100644
--- a/lib/libc/posix1e/acl_create_entry.3
+++ b/lib/libc/posix1e/acl_create_entry.3
@@ -39,7 +39,7 @@
.In sys/acl.h
.Ft int
.Fn acl_create_entry "acl_t *acl_p" "acl_entry_t *entry_p"
-.Ft int
+.Ft int
.Fn acl_create_entry_np "acl_t *acl_p" "acl_entry_t *entry_p" "int index"
.Sh DESCRIPTION
The
diff --git a/lib/libc/posix1e/acl_set_entry_type_np.3 b/lib/libc/posix1e/acl_set_entry_type_np.3
index bda0c481846d..648775d4e837 100644
--- a/lib/libc/posix1e/acl_set_entry_type_np.3
+++ b/lib/libc/posix1e/acl_set_entry_type_np.3
@@ -49,8 +49,8 @@ to the value referred to by
.Pp
Valid values are:
.Bl -column -offset 3n "ACL_ENTRY_TYPE_ALLOW"
-.It ACL_ENTRY_TYPE_ALLOW "allow" type entry
-.It ACL_ENTRY_TYPE_DENY "deny" type entry
+.It ACL_ENTRY_TYPE_ALLOW Ta "allow" type entry
+.It ACL_ENTRY_TYPE_DENY Ta "deny" type entry
.El
.Pp
This call brands the ACL as NFSv4.
diff --git a/lib/libc/posix1e/acl_set_tag_type.3 b/lib/libc/posix1e/acl_set_tag_type.3
index 88aad72b2c7b..79526a004453 100644
--- a/lib/libc/posix1e/acl_set_tag_type.3
+++ b/lib/libc/posix1e/acl_set_tag_type.3
@@ -49,14 +49,14 @@ to the value of
.Pp
Valid values are:
.Bl -column -offset 3n "ACL_OTHER_OBJ"
-.It ACL_USER_OBJ Permissions apply to file owner
-.It ACL_USER Permissions apply to additional user specified by qualifier
-.It ACL_GROUP_OBJ Permissions apply to file group
-.It ACL_GROUP Permissions apply to additional group specified by qualifier
-.It ACL_MASK Permissions specify mask
-.It ACL_OTHER Permissions apply to "other"
-.It ACL_OTHER_OBJ Same as ACL_OTHER
-.It ACL_EVERYONE Permissions apply to "everyone@"
+.It ACL_USER_OBJ Ta "Permissions apply to file owner"
+.It ACL_USER Ta "Permissions apply to additional user specified by qualifier"
+.It ACL_GROUP_OBJ Ta "Permissions apply to file group"
+.It ACL_GROUP Ta "Permissions apply to additional group specified by qualifier"
+.It ACL_MASK Ta "Permissions specify mask"
+.It ACL_OTHER Ta Permissions apply to "other"
+.It ACL_OTHER_OBJ Ta "Same as ACL_OTHER"
+.It ACL_EVERYONE Ta Permissions apply to "everyone@"
.El
.Pp
Calling
diff --git a/lib/libc/posix1e/acl_to_text.3 b/lib/libc/posix1e/acl_to_text.3
index 46ae42184183..08fec2005195 100644
--- a/lib/libc/posix1e/acl_to_text.3
+++ b/lib/libc/posix1e/acl_to_text.3
@@ -66,11 +66,10 @@ flag is given.
The flags specified are formed by
.Em or Ns 'ing
the following values
-.Pp
.Bl -column -offset 3n "ACL_TEXT_NUMERIC_IDS"
-.It ACL_TEXT_VERBOSE Format ACL using verbose form
-.It ACL_TEXT_NUMERIC_IDS Do not resolve IDs into user or group names
-.It ACL_TEXT_APPEND_ID In addition to user and group names, append numeric IDs
+.It ACL_TEXT_VERBOSE Ta "Format ACL using verbose form"
+.It ACL_TEXT_NUMERIC_IDS Ta "Do not resolve IDs into user or group names"
+.It ACL_TEXT_APPEND_ID Ta "In addition to user and group names, append numeric IDs"
.El
.Pp
This function allocates any memory necessary to contain the string and
diff --git a/lib/libc/powerpc/SYS.h b/lib/libc/powerpc/SYS.h
index 7ec3075fdf32..0bd793f3353a 100644
--- a/lib/libc/powerpc/SYS.h
+++ b/lib/libc/powerpc/SYS.h
@@ -33,43 +33,38 @@
#include <sys/syscall.h>
#include <machine/asm.h>
-#define _SYSCALL(x) \
+#define _SYSCALL(name) \
.text; \
.align 2; \
- li 0,(__CONCAT(SYS_,x)); \
+ li 0,(__CONCAT(SYS_, name)); \
sc
-#define SYSCALL(x) \
+#define SYSCALL(name) \
.text; \
.align 2; \
2: b PIC_PLT(CNAME(HIDENAME(cerror))); \
-ENTRY(__CONCAT(__sys_,x)); \
- .weak CNAME(x); \
- .set CNAME(x),CNAME(__CONCAT(__sys_,x)); \
- .weak CNAME(__CONCAT(_,x)); \
- .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
- _SYSCALL(x); \
+ENTRY(__CONCAT(__sys_, name)); \
+ WEAK_REFERENCE(__CONCAT(__sys_, name), name); \
+ WEAK_REFERENCE(__CONCAT(__sys_, name), __CONCAT(_, name));\
+ _SYSCALL(name); \
bso 2b
-#define PSEUDO(x) \
+#define PSEUDO(name) \
.text; \
.align 2; \
-ENTRY(__CONCAT(__sys_,x)); \
- .weak CNAME(__CONCAT(_,x)); \
- .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
- _SYSCALL(x); \
+ENTRY(__CONCAT(__sys_, name)); \
+ WEAK_REFERENCE(__CONCAT(__sys_, name), __CONCAT(_, name));\
+ _SYSCALL(name); \
bnslr; \
b PIC_PLT(CNAME(HIDENAME(cerror)))
-#define RSYSCALL(x) \
+#define RSYSCALL(name) \
.text; \
.align 2; \
2: b PIC_PLT(CNAME(HIDENAME(cerror))); \
-ENTRY(__CONCAT(__sys_,x)); \
- .weak CNAME(x); \
- .set CNAME(x),CNAME(__CONCAT(__sys_,x)); \
- .weak CNAME(__CONCAT(_,x)); \
- .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
- _SYSCALL(x); \
+ENTRY(__CONCAT(__sys_, name)); \
+ WEAK_REFERENCE(__CONCAT(__sys_, name), name); \
+ WEAK_REFERENCE(__CONCAT(__sys_, name), __CONCAT(_, name));\
+ _SYSCALL(name); \
bnslr; \
b PIC_PLT(CNAME(HIDENAME(cerror)))
diff --git a/lib/libc/powerpc/gen/Makefile.inc b/lib/libc/powerpc/gen/Makefile.inc
index 3bfabdadd585..79a274656e82 100644
--- a/lib/libc/powerpc/gen/Makefile.inc
+++ b/lib/libc/powerpc/gen/Makefile.inc
@@ -1,7 +1,7 @@
# $FreeBSD$
SRCS += _ctx_start.S fabs.S flt_rounds.c fpgetmask.c fpgetround.c \
- fpgetsticky.c fpsetmask.c fpsetround.c \
+ fpgetsticky.c fpsetmask.c fpsetround.c getcontextx.c \
infinity.c ldexp.c makecontext.c _setjmp.S \
setjmp.S sigsetjmp.S signalcontext.c syncicache.c \
_set_tp.c
diff --git a/lib/libc/powerpc/gen/_setjmp.S b/lib/libc/powerpc/gen/_setjmp.S
index 9b9f86edb840..bbf8644357ec 100644
--- a/lib/libc/powerpc/gen/_setjmp.S
+++ b/lib/libc/powerpc/gen/_setjmp.S
@@ -63,7 +63,6 @@ ENTRY(_longjmp)
lmw %r9,20(%r3)
mtlr %r11
mtcr %r12
- mr %r2,%r9
mr %r1,%r10
or. %r3,%r4,%r4
bnelr
diff --git a/lib/libc/powerpc/gen/getcontextx.c b/lib/libc/powerpc/gen/getcontextx.c
new file mode 100644
index 000000000000..307978a466dd
--- /dev/null
+++ b/lib/libc/powerpc/gen/getcontextx.c
@@ -0,0 +1,69 @@
+/*
+ * 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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/ucontext.h>
+#include <errno.h>
+#include <stdlib.h>
+
+int
+__getcontextx_size(void)
+{
+
+ return (sizeof(ucontext_t));
+}
+
+int
+__fillcontextx(char *ctx)
+{
+ ucontext_t *ucp;
+
+ ucp = (ucontext_t *)ctx;
+ return (getcontext(ucp));
+}
+
+__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/powerpc/gen/setjmp.S b/lib/libc/powerpc/gen/setjmp.S
index 6aaf81c7832d..6df4f937ff17 100644
--- a/lib/libc/powerpc/gen/setjmp.S
+++ b/lib/libc/powerpc/gen/setjmp.S
@@ -69,14 +69,12 @@ ENTRY(setjmp)
li %r3,0 /* return (0) */
blr
- .weak CNAME(longjmp)
- .set CNAME(longjmp),CNAME(__longjmp)
+ WEAK_REFERENCE(CNAME(__longjmp), longjmp)
ENTRY(__longjmp)
lmw %r9,20(%r3) /* restore regs */
mr %r6,%r4 /* save val param */
mtlr %r11 /* r11 -> link reg */
mtcr %r12 /* r12 -> condition reg */
- mr %r2,%r9 /* r9 -> global ptr */
mr %r1,%r10 /* r10 -> stackptr */
mr %r4,%r3
li %r3,3 /* SIG_SETMASK */
diff --git a/lib/libc/powerpc/gen/sigsetjmp.S b/lib/libc/powerpc/gen/sigsetjmp.S
index 5a6fd2141e77..9639dd11c81e 100644
--- a/lib/libc/powerpc/gen/sigsetjmp.S
+++ b/lib/libc/powerpc/gen/sigsetjmp.S
@@ -80,7 +80,6 @@ ENTRY(siglongjmp)
mr %r6,%r4
mtlr %r11
mtcr %r12
- mr %r2,%r9
mr %r1,%r10
or. %r7,%r7,%r7
beq 1f
diff --git a/lib/libc/powerpc64/SYS.h b/lib/libc/powerpc64/SYS.h
index a361767c15b7..8b3281fb1a4a 100644
--- a/lib/libc/powerpc64/SYS.h
+++ b/lib/libc/powerpc64/SYS.h
@@ -33,13 +33,13 @@
#include <sys/syscall.h>
#include <machine/asm.h>
-#define _SYSCALL(x) \
+#define _SYSCALL(name) \
.text; \
.align 2; \
- li 0,(__CONCAT(SYS_,x)); \
+ li 0,(__CONCAT(SYS_, name)); \
sc
-#define SYSCALL(x) \
+#define SYSCALL(name) \
.text; \
.align 2; \
2: mflr %r0; \
@@ -51,21 +51,18 @@
ld %r0,16(%r1); \
mtlr %r0; \
blr; \
-ENTRY(__CONCAT(__sys_,x)); \
- .weak CNAME(x); \
- .set CNAME(x),CNAME(__CONCAT(__sys_,x)); \
- .weak CNAME(__CONCAT(_,x)); \
- .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
- _SYSCALL(x); \
+ENTRY(__CONCAT(__sys_, name)); \
+ WEAK_REFERENCE(__CONCAT(__sys_, name), name); \
+ WEAK_REFERENCE(__CONCAT(__sys_, name), __CONCAT(_, name)); \
+ _SYSCALL(name); \
bso 2b
-#define PSEUDO(x) \
+#define PSEUDO(name) \
.text; \
.align 2; \
-ENTRY(__CONCAT(__sys_,x)); \
- .weak CNAME(__CONCAT(_,x)); \
- .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
- _SYSCALL(x); \
+ENTRY(__CONCAT(__sys_, name)); \
+ WEAK_REFERENCE(__CONCAT(__sys_, name), __CONCAT(_, name)); \
+ _SYSCALL(name); \
bnslr; \
mflr %r0; \
std %r0,16(%r1); \
@@ -77,15 +74,13 @@ ENTRY(__CONCAT(__sys_,x)); \
mtlr %r0; \
blr;
-#define RSYSCALL(x) \
+#define RSYSCALL(name) \
.text; \
.align 2; \
-ENTRY(__CONCAT(__sys_,x)); \
- .weak CNAME(x); \
- .set CNAME(x),CNAME(__CONCAT(__sys_,x)); \
- .weak CNAME(__CONCAT(_,x)); \
- .set CNAME(__CONCAT(_,x)),CNAME(__CONCAT(__sys_,x)); \
- _SYSCALL(x); \
+ENTRY(__CONCAT(__sys_, name)); \
+ WEAK_REFERENCE(__CONCAT(__sys_, name), name); \
+ WEAK_REFERENCE(__CONCAT(__sys_, name), __CONCAT(_, name));\
+ _SYSCALL(name); \
bnslr; \
\
mflr %r0; \
diff --git a/lib/libc/powerpc64/gen/Makefile.inc b/lib/libc/powerpc64/gen/Makefile.inc
index 3bfabdadd585..79a274656e82 100644
--- a/lib/libc/powerpc64/gen/Makefile.inc
+++ b/lib/libc/powerpc64/gen/Makefile.inc
@@ -1,7 +1,7 @@
# $FreeBSD$
SRCS += _ctx_start.S fabs.S flt_rounds.c fpgetmask.c fpgetround.c \
- fpgetsticky.c fpsetmask.c fpsetround.c \
+ fpgetsticky.c fpsetmask.c fpsetround.c getcontextx.c \
infinity.c ldexp.c makecontext.c _setjmp.S \
setjmp.S sigsetjmp.S signalcontext.c syncicache.c \
_set_tp.c
diff --git a/lib/libc/powerpc64/gen/_setjmp.S b/lib/libc/powerpc64/gen/_setjmp.S
index a5c247dd81fa..ac0555e28850 100644
--- a/lib/libc/powerpc64/gen/_setjmp.S
+++ b/lib/libc/powerpc64/gen/_setjmp.S
@@ -86,7 +86,6 @@ ENTRY(_longjmp)
ld %r10,40 + 1*8(%r3)
ld %r11,40 + 2*8(%r3)
ld %r12,40 + 3*8(%r3)
- ld %r13,40 + 4*8(%r3)
ld %r14,40 + 5*8(%r3)
ld %r15,40 + 6*8(%r3)
ld %r16,40 + 7*8(%r3)
diff --git a/lib/libc/powerpc64/gen/getcontextx.c b/lib/libc/powerpc64/gen/getcontextx.c
new file mode 100644
index 000000000000..307978a466dd
--- /dev/null
+++ b/lib/libc/powerpc64/gen/getcontextx.c
@@ -0,0 +1,69 @@
+/*
+ * 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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/ucontext.h>
+#include <errno.h>
+#include <stdlib.h>
+
+int
+__getcontextx_size(void)
+{
+
+ return (sizeof(ucontext_t));
+}
+
+int
+__fillcontextx(char *ctx)
+{
+ ucontext_t *ucp;
+
+ ucp = (ucontext_t *)ctx;
+ return (getcontext(ucp));
+}
+
+__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/powerpc64/gen/makecontext.c b/lib/libc/powerpc64/gen/makecontext.c
index 6d980f3e044a..b01c5c1c40a7 100644
--- a/lib/libc/powerpc64/gen/makecontext.c
+++ b/lib/libc/powerpc64/gen/makecontext.c
@@ -111,7 +111,7 @@ __makecontext(ucontext_t *ucp, void (*start)(void), int argc, ...)
* Use caller-saved regs 14/15 to hold params that _ctx_start
* will use to invoke the user-supplied func
*/
- mc->mc_srr0 = (uintptr_t) _ctx_start;
+ mc->mc_srr0 = *(uintptr_t *)_ctx_start;
mc->mc_gpr[1] = (uintptr_t) sp; /* new stack pointer */
mc->mc_gpr[14] = (uintptr_t) start; /* r14 <- start */
mc->mc_gpr[15] = (uintptr_t) ucp; /* r15 <- ucp */
diff --git a/lib/libc/powerpc64/gen/setjmp.S b/lib/libc/powerpc64/gen/setjmp.S
index 0f33ab2ebb00..8fe285201dc2 100644
--- a/lib/libc/powerpc64/gen/setjmp.S
+++ b/lib/libc/powerpc64/gen/setjmp.S
@@ -93,16 +93,12 @@ ENTRY(setjmp)
li %r3,0 /* return (0) */
blr
- .weak CNAME(longjmp)
- .set CNAME(longjmp),CNAME(__longjmp)
- .weak CNAME(.longjmp)
- .set CNAME(.longjmp),CNAME(.__longjmp)
+ WEAK_REFERENCE(__longjmp, longjmp)
ENTRY(__longjmp)
ld %r9,40 + 0*8(%r3)
ld %r10,40 + 1*8(%r3)
ld %r11,40 + 2*8(%r3)
ld %r12,40 + 3*8(%r3)
- ld %r13,40 + 4*8(%r3)
ld %r14,40 + 5*8(%r3)
ld %r15,40 + 6*8(%r3)
ld %r16,40 + 7*8(%r3)
diff --git a/lib/libc/powerpc64/gen/sigsetjmp.S b/lib/libc/powerpc64/gen/sigsetjmp.S
index 7b50f9fd7d2c..d5341eaf47b9 100644
--- a/lib/libc/powerpc64/gen/sigsetjmp.S
+++ b/lib/libc/powerpc64/gen/sigsetjmp.S
@@ -103,7 +103,6 @@ ENTRY(siglongjmp)
ld %r10,40 + 1*8(%r3)
ld %r11,40 + 2*8(%r3)
ld %r12,40 + 3*8(%r3)
- ld %r13,40 + 4*8(%r3)
ld %r14,40 + 5*8(%r3)
ld %r15,40 + 6*8(%r3)
ld %r16,40 + 7*8(%r3)
diff --git a/lib/libc/powerpc64/sys/cerror.S b/lib/libc/powerpc64/sys/cerror.S
index 9bf33bf03d7f..515d7e541cab 100644
--- a/lib/libc/powerpc64/sys/cerror.S
+++ b/lib/libc/powerpc64/sys/cerror.S
@@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$");
* programs and the initial threaded in threaded programs,
* it returns a pointer to the global errno variable.
*/
-ENTRY(HIDENAME(cerror))
+ENTRY_NOPROF(HIDENAME(cerror))
mflr %r0
std %r0,16(%r1) /* save lr */
stdu %r1,-64(%r1) /* allocate new stack frame */
diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c
index c24b3826416d..68ffa66a1df1 100644
--- a/lib/libc/regex/regcomp.c
+++ b/lib/libc/regex/regcomp.c
@@ -11,11 +11,6 @@
* This code is derived from software contributed to Berkeley by
* Henry Spencer.
*
- * Copyright (c) 2011 The FreeBSD Foundation
- * All rights reserved.
- * Portions of this software were developed by David Chisnall
- * 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:
diff --git a/lib/libc/rpc/Makefile.inc b/lib/libc/rpc/Makefile.inc
index db0b8ad3e785..32e8f86b7169 100644
--- a/lib/libc/rpc/Makefile.inc
+++ b/lib/libc/rpc/Makefile.inc
@@ -34,7 +34,7 @@ CFLAGS+= -I${.CURDIR}/rpc
CLEANFILES+= crypt_clnt.c crypt_xdr.c crypt.h
RPCDIR= ${DESTDIR}/usr/include/rpcsvc
-RPCGEN= rpcgen -C
+RPCGEN= RPCGEN_CPP=${CPP:Q} rpcgen -C
crypt_clnt.c: ${RPCDIR}/crypt.x crypt.h
${RPCGEN} -l -o ${.TARGET} ${RPCDIR}/crypt.x
diff --git a/lib/libc/rpc/rpc.3 b/lib/libc/rpc/rpc.3
index 81a24ca63163..4fa3e2cee58f 100644
--- a/lib/libc/rpc/rpc.3
+++ b/lib/libc/rpc/rpc.3
@@ -119,12 +119,12 @@ file.
.Sh Derived Types
The derived types used in the RPC interfaces are defined as follows:
.Bd -literal
- typedef u_int32_t rpcprog_t;
- typedef u_int32_t rpcvers_t;
- typedef u_int32_t rpcproc_t;
- typedef u_int32_t rpcprot_t;
- typedef u_int32_t rpcport_t;
- typedef int32_t rpc_inline_t;
+ typedef uint32_t rpcprog_t;
+ typedef uint32_t rpcvers_t;
+ typedef uint32_t rpcproc_t;
+ typedef uint32_t rpcprot_t;
+ typedef uint32_t rpcport_t;
+ typedef int32_t rpc_inline_t;
.Ed
.Sh "Data Structures"
Some of the data structures used by the
diff --git a/lib/libc/rpc/rpc_clnt_create.3 b/lib/libc/rpc/rpc_clnt_create.3
index 34c90ed77d1d..079c9eb729bf 100644
--- a/lib/libc/rpc/rpc_clnt_create.3
+++ b/lib/libc/rpc/rpc_clnt_create.3
@@ -106,10 +106,10 @@ Set the timeout argument to 0 for batching calls.
.It Dv CLGET_FD Ta "int *" Ta "get fd from handle"
.It Dv CLSET_FD_CLOSE Ta "void" Ta "close fd on destroy"
.It Dv CLSET_FD_NCLOSE Ta void Ta "do not close fd on destroy"
-.It Dv CLGET_VERS Ta "u_int32_t *" Ta "get RPC program version"
-.It Dv CLSET_VERS Ta "u_int32_t *" Ta "set RPC program version"
-.It Dv CLGET_XID Ta "u_int32_t *" Ta "get XID of previous call"
-.It Dv CLSET_XID Ta "u_int32_t *" Ta "set XID of next call"
+.It Dv CLGET_VERS Ta "uint32_t *" Ta "get RPC program version"
+.It Dv CLSET_VERS Ta "uint32_t *" Ta "set RPC program version"
+.It Dv CLGET_XID Ta "uint32_t *" Ta "get XID of previous call"
+.It Dv CLSET_XID Ta "uint32_t *" Ta "set XID of next call"
.El
.Pp
The following operations are valid for connectionless transports only:
diff --git a/lib/libc/rpc/rpc_soc.3 b/lib/libc/rpc/rpc_soc.3
index ebc666b7bcec..8dedaa870046 100644
--- a/lib/libc/rpc/rpc_soc.3
+++ b/lib/libc/rpc/rpc_soc.3
@@ -111,8 +111,8 @@ Secure
can be used only if
.Tn DES
encryption is available.
-.Bl -tag -width indent -compact
.Pp
+.Bl -tag -width indent -compact
.It Xo
.Ft void
.Xc
@@ -394,12 +394,10 @@ the supported values of
.Fa req
and their argument types and what they do are:
.Bl -column "CLSET_RETRY_TIMEOUT" "struct sockaddr_in"
-.It Dv CLSET_TIMEOUT Ta Xo
+.It Dv CLSET_TIMEOUT Ta
.Vt "struct timeval" Ta "set total timeout"
-.Xc
-.It Dv CLGET_TIMEOUT Ta Xo
+.It Dv CLGET_TIMEOUT Ta
.Vt "struct timeval" Ta "get total timeout"
-.Xc
.El
.Pp
Note: if you set the timeout using
@@ -408,21 +406,18 @@ the timeout argument passed to
.Fn clnt_call
will be ignored in all future calls.
.Bl -column "CLSET_RETRY_TIMEOUT" "struct sockaddr_in"
-.It Dv CLGET_SERVER_ADDR Ta Xo
+.It Dv CLGET_SERVER_ADDR Ta
.Vt "struct sockaddr_in" Ta "get server's address"
-.Xc
.El
.Pp
The following operations are valid for
.Tn UDP
only:
.Bl -column "CLSET_RETRY_TIMEOUT" "struct sockaddr_in"
-.It Dv CLSET_RETRY_TIMEOUT Ta Xo
+.It Dv CLSET_RETRY_TIMEOUT Ta
.Vt "struct timeval" Ta "set the retry timeout"
-.Xc
-.It Dv CLGET_RETRY_TIMEOUT Ta Xo
+.It Dv CLGET_RETRY_TIMEOUT Ta
.Vt "struct timeval" Ta "get the retry timeout"
-.Xc
.El
.Pp
The retry timeout is the time that
diff --git a/lib/libc/softfloat/Makefile.inc b/lib/libc/softfloat/Makefile.inc
index ac7fbf781278..221340372c5e 100644
--- a/lib/libc/softfloat/Makefile.inc
+++ b/lib/libc/softfloat/Makefile.inc
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.inc,v 1.3 2003/05/06 08:58:20 rearnsha Exp $
+# $NetBSD: Makefile.inc,v 1.10 2011/07/04 02:53:15 mrg Exp $
# $FreeBSD$
SOFTFLOAT_BITS?=64
@@ -17,4 +17,14 @@ SRCS+= eqsf2.c nesf2.c gtsf2.c gesf2.c ltsf2.c lesf2.c negsf2.c \
eqdf2.c nedf2.c gtdf2.c gedf2.c ltdf2.c ledf2.c negdf2.c \
unordsf2.c unorddf2.c
+.if defined(SOFTFLOAT_128)
+CFLAGS+= -DFLOAT128
+SRCS+= eqtf2.c netf2.c gttf2.c getf2.c lttf2.c letf2.c negtf2.c
+.endif
+
+.if defined(SOFTFLOAT_X80)
+CFLAGS+= -DFLOATX80
+SRCS+= nexf2.c gtxf2.c gexf2.c negxf2.c
+.endif
+
SYM_MAPS+= ${.CURDIR}/softfloat/Symbol.map
diff --git a/lib/libc/softfloat/Symbol.map b/lib/libc/softfloat/Symbol.map
index 12fb33549bc8..9c9662a71d38 100644
--- a/lib/libc/softfloat/Symbol.map
+++ b/lib/libc/softfloat/Symbol.map
@@ -18,16 +18,10 @@ FBSD_1.0 {
};
FBSDprivate_1.0 {
- _softfloat_float_exception_flags;
- _softfloat_float_exception_mask;
- _softfloat_float_rounding_mode;
- _softfloat_float_raise;
- _softfloat_float32_eq;
- _softfloat_float32_le;
- _softfloat_float32_lt;
- _softfloat_float64_eq;
- _softfloat_float64_le;
- _softfloat_float64_lt;
+ __softfloat_float_exception_flags;
+ __softfloat_float_exception_mask;
+ __softfloat_float_rounding_mode;
+ __softfloat_float_raise;
__eqdf2;
__eqsf2;
__gedf2;
diff --git a/lib/libc/softfloat/bits32/softfloat-macros b/lib/libc/softfloat/bits32/softfloat-macros
index 4fd4f2f9fc66..db4e038eb0b7 100644
--- a/lib/libc/softfloat/bits32/softfloat-macros
+++ b/lib/libc/softfloat/bits32/softfloat-macros
@@ -312,7 +312,7 @@ INLINE void
carry0 = ( z1 < a1 );
z0 = a0 + b0;
z1 += carry1;
- z0 += ( z1 < carry1 );
+ z0 += ( z1 < (bits32)carry1 );
z0 += carry0;
*z2Ptr = z2;
*z1Ptr = z1;
@@ -369,7 +369,7 @@ INLINE void
z1 = a1 - b1;
borrow0 = ( a1 < b1 );
z0 = a0 - b0;
- z0 -= ( z1 < borrow1 );
+ z0 -= ( z1 < (bits32)borrow1 );
z1 -= borrow1;
z0 -= borrow0;
*z2Ptr = z2;
diff --git a/lib/libc/softfloat/bits32/softfloat.c b/lib/libc/softfloat/bits32/softfloat.c
index 7785c4ea11e8..ad7c016bf043 100644
--- a/lib/libc/softfloat/bits32/softfloat.c
+++ b/lib/libc/softfloat/bits32/softfloat.c
@@ -77,8 +77,8 @@ __FBSDID("$FreeBSD$");
Floating-point rounding mode and exception flags.
-------------------------------------------------------------------------------
*/
-fp_rnd_t float_rounding_mode = float_round_nearest_even;
-fp_except float_exception_flags = 0;
+int float_rounding_mode = float_round_nearest_even;
+int float_exception_flags = 0;
/*
-------------------------------------------------------------------------------
diff --git a/lib/libc/softfloat/bits64/softfloat-macros b/lib/libc/softfloat/bits64/softfloat-macros
index 9b478e884eba..f4647def2bd4 100644
--- a/lib/libc/softfloat/bits64/softfloat-macros
+++ b/lib/libc/softfloat/bits64/softfloat-macros
@@ -1,4 +1,4 @@
-/* $NetBSD: softfloat-macros,v 1.1 2002/05/21 23:51:08 bjh21 Exp $ */
+/* $NetBSD: softfloat-macros,v 1.2 2009/02/16 10:23:35 tron Exp $ */
/* $FreeBSD$ */
/*
@@ -387,7 +387,7 @@ INLINE void
carry0 = ( z1 < a1 );
z0 = a0 + b0;
z1 += carry1;
- z0 += ( z1 < carry1 );
+ z0 += ( z1 < (bits64)carry1 );
z0 += carry0;
*z2Ptr = z2;
*z1Ptr = z1;
@@ -444,7 +444,7 @@ INLINE void
z1 = a1 - b1;
borrow0 = ( a1 < b1 );
z0 = a0 - b0;
- z0 -= ( z1 < borrow1 );
+ z0 -= ( z1 < (bits64)borrow1 );
z1 -= borrow1;
z0 -= borrow0;
*z2Ptr = z2;
diff --git a/lib/libc/softfloat/bits64/softfloat.c b/lib/libc/softfloat/bits64/softfloat.c
index ffd5661d6719..79993fb207f5 100644
--- a/lib/libc/softfloat/bits64/softfloat.c
+++ b/lib/libc/softfloat/bits64/softfloat.c
@@ -1,4 +1,4 @@
-/* $NetBSD: softfloat.c,v 1.2 2003/07/26 19:24:52 salo Exp $ */
+/* $NetBSD: softfloat.c,v 1.8 2011/07/10 04:52:23 matt Exp $ */
/*
* This version hacked for use with gcc -msoft-float by bjh21.
@@ -71,8 +71,8 @@ Floating-point rounding mode, extended double-precision rounding precision,
and exception flags.
-------------------------------------------------------------------------------
*/
-fp_rnd_t float_rounding_mode = float_round_nearest_even;
-fp_except float_exception_flags = 0;
+int float_rounding_mode = float_round_nearest_even;
+int float_exception_flags = 0;
#ifdef FLOATX80
int8 floatx80_rounding_precision = 80;
#endif
@@ -1126,6 +1126,17 @@ float32 int32_to_float32( int32 a )
}
+#ifndef SOFTFLOAT_FOR_GCC /* __floatunsisf is in libgcc */
+float32 uint32_to_float32( uint32 a )
+{
+ if ( a == 0 ) return 0;
+ if ( a & (bits32) 0x80000000 )
+ return normalizeRoundAndPackFloat32( 0, 0x9D, a >> 1 );
+ return normalizeRoundAndPackFloat32( 0, 0x9C, a );
+}
+#endif
+
+
/*
-------------------------------------------------------------------------------
Returns the result of converting the 32-bit two's complement integer `a'
@@ -1149,6 +1160,19 @@ float64 int32_to_float64( int32 a )
}
+#ifndef SOFTFLOAT_FOR_GCC /* __floatunsidf is in libgcc */
+float64 uint32_to_float64( uint32 a )
+{
+ int8 shiftCount;
+ bits64 zSig = a;
+
+ if ( a == 0 ) return 0;
+ shiftCount = countLeadingZeros32( a ) + 21;
+ return packFloat64( 0, 0x432 - shiftCount, zSig<<shiftCount );
+
+}
+#endif
+
#ifdef FLOATX80
/*
@@ -1175,6 +1199,17 @@ floatx80 int32_to_floatx80( int32 a )
}
+floatx80 uint32_to_floatx80( uint32 a )
+{
+ int8 shiftCount;
+ bits64 zSig = a;
+
+ if ( a == 0 ) return packFloatx80( 0, 0, 0 );
+ shiftCount = countLeadingZeros32( a ) + 32;
+ return packFloatx80( 0, 0x403E - shiftCount, zSig<<shiftCount );
+
+}
+
#endif
#ifdef FLOAT128
@@ -1202,6 +1237,17 @@ float128 int32_to_float128( int32 a )
}
+float128 uint32_to_float128( uint32 a )
+{
+ int8 shiftCount;
+ bits64 zSig0 = a;
+
+ if ( a == 0 ) return packFloat128( 0, 0, 0, 0 );
+ shiftCount = countLeadingZeros32( a ) + 17;
+ return packFloat128( 0, 0x402E - shiftCount, zSig0<<shiftCount, 0 );
+
+}
+
#endif
#ifndef SOFTFLOAT_FOR_GCC /* __floatdi?f is in libgcc2.c */
@@ -4438,6 +4484,59 @@ int64 float128_to_int64_round_to_zero( float128 a )
}
+#if (defined(SOFTFLOATSPARC64_FOR_GCC) || defined(SOFTFLOAT_FOR_GCC)) \
+ && defined(SOFTFLOAT_NEED_FIXUNS)
+/*
+ * just like above - but do not care for overflow of signed results
+ */
+uint64 float128_to_uint64_round_to_zero( float128 a )
+{
+ flag aSign;
+ int32 aExp, shiftCount;
+ bits64 aSig0, aSig1;
+ uint64 z;
+
+ aSig1 = extractFloat128Frac1( a );
+ aSig0 = extractFloat128Frac0( a );
+ aExp = extractFloat128Exp( a );
+ aSign = extractFloat128Sign( a );
+ if ( aExp ) aSig0 |= LIT64( 0x0001000000000000 );
+ shiftCount = aExp - 0x402F;
+ if ( 0 < shiftCount ) {
+ if ( 0x403F <= aExp ) {
+ aSig0 &= LIT64( 0x0000FFFFFFFFFFFF );
+ if ( ( a.high == LIT64( 0xC03E000000000000 ) )
+ && ( aSig1 < LIT64( 0x0002000000000000 ) ) ) {
+ if ( aSig1 ) float_exception_flags |= float_flag_inexact;
+ }
+ else {
+ float_raise( float_flag_invalid );
+ }
+ return LIT64( 0xFFFFFFFFFFFFFFFF );
+ }
+ z = ( aSig0<<shiftCount ) | ( aSig1>>( ( - shiftCount ) & 63 ) );
+ if ( (bits64) ( aSig1<<shiftCount ) ) {
+ float_exception_flags |= float_flag_inexact;
+ }
+ }
+ else {
+ if ( aExp < 0x3FFF ) {
+ if ( aExp | aSig0 | aSig1 ) {
+ float_exception_flags |= float_flag_inexact;
+ }
+ return 0;
+ }
+ z = aSig0>>( - shiftCount );
+ if (aSig1 || ( shiftCount && (bits64) ( aSig0<<( shiftCount & 63 ) ) ) ) {
+ float_exception_flags |= float_flag_inexact;
+ }
+ }
+ if ( aSign ) z = - z;
+ return z;
+
+}
+#endif /* (SOFTFLOATSPARC64_FOR_GCC || SOFTFLOAT_FOR_GCC) && SOFTFLOAT_NEED_FIXUNS */
+
/*
-------------------------------------------------------------------------------
Returns the result of converting the quadruple-precision floating-point
@@ -5110,7 +5209,7 @@ float128 float128_rem( float128 a, float128 b )
sub128( aSig0, aSig1, bSig0, bSig1, &aSig0, &aSig1 );
} while ( 0 <= (sbits64) aSig0 );
add128(
- aSig0, aSig1, alternateASig0, alternateASig1, &sigMean0, &sigMean1 );
+ aSig0, aSig1, alternateASig0, alternateASig1, (bits64 *)&sigMean0, &sigMean1 );
if ( ( sigMean0 < 0 )
|| ( ( ( sigMean0 | sigMean1 ) == 0 ) && ( q & 1 ) ) ) {
aSig0 = alternateASig0;
diff --git a/lib/libc/softfloat/eqtf2.c b/lib/libc/softfloat/eqtf2.c
new file mode 100644
index 000000000000..1839404e1b1a
--- /dev/null
+++ b/lib/libc/softfloat/eqtf2.c
@@ -0,0 +1,24 @@
+/* $NetBSD: eqtf2.c,v 1.1 2011/01/17 10:08:35 matt Exp $ */
+
+/*
+ * Written by Matt Thomas, 2011. This file is in the Public Domain.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "softfloat-for-gcc.h"
+#include "milieu.h"
+#include "softfloat.h"
+
+#ifdef FLOAT128
+flag __eqtf2(float128, float128);
+
+flag
+__eqtf2(float128 a, float128 b)
+{
+
+ /* libgcc1.c says !(a == b) */
+ return !float128_eq(a, b);
+}
+#endif /* FLOAT128 */
diff --git a/lib/libc/softfloat/getf2.c b/lib/libc/softfloat/getf2.c
new file mode 100644
index 000000000000..8639c4d3916a
--- /dev/null
+++ b/lib/libc/softfloat/getf2.c
@@ -0,0 +1,26 @@
+/* $NetBSD: getf2.c,v 1.1 2011/01/17 10:08:35 matt Exp $ */
+
+/*
+ * Written by Matt Thomas, 2011. This file is in the Public Domain.
+ */
+
+#include "softfloat-for-gcc.h"
+#include "milieu.h"
+#include "softfloat.h"
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#ifdef FLOAT128
+
+flag __getf2(float128, float128);
+
+flag
+__getf2(float128 a, float128 b)
+{
+
+ /* libgcc1.c says (a >= b) - 1 */
+ return float128_le(b, a) - 1;
+}
+
+#endif /* FLOAT128 */
diff --git a/lib/libc/softfloat/gexf2.c b/lib/libc/softfloat/gexf2.c
new file mode 100644
index 000000000000..70cf1c32d7ec
--- /dev/null
+++ b/lib/libc/softfloat/gexf2.c
@@ -0,0 +1,25 @@
+/* $NetBSD: gexf2.c,v 1.2 2004/09/27 10:16:24 he Exp $ */
+
+/*
+ * Written by Ben Harris, 2000. This file is in the Public Domain.
+ */
+
+#include "softfloat-for-gcc.h"
+#include "milieu.h"
+#include "softfloat.h"
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#ifdef FLOATX80
+
+flag __gexf2(floatx80, floatx80);
+
+flag
+__gexf2(floatx80 a, floatx80 b)
+{
+
+ /* libgcc1.c says (a >= b) - 1 */
+ return floatx80_le(b, a) - 1;
+}
+#endif /* FLOATX80 */
diff --git a/lib/libc/softfloat/gttf2.c b/lib/libc/softfloat/gttf2.c
new file mode 100644
index 000000000000..519ea845f00c
--- /dev/null
+++ b/lib/libc/softfloat/gttf2.c
@@ -0,0 +1,26 @@
+/* $NetBSD: gttf2.c,v 1.1 2011/01/17 10:08:35 matt Exp $ */
+
+/*
+ * Written by Matt Thomas, 2011. This file is in the Public Domain.
+ */
+
+#include "softfloat-for-gcc.h"
+#include "milieu.h"
+#include "softfloat.h"
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#ifdef FLOAT128
+
+flag __gttf2(float128, float128);
+
+flag
+__gttf2(float128 a, float128 b)
+{
+
+ /* libgcc1.c says a > b */
+ return float128_lt(b, a);
+}
+
+#endif /* FLOAT128 */
diff --git a/lib/libc/softfloat/gtxf2.c b/lib/libc/softfloat/gtxf2.c
new file mode 100644
index 000000000000..fe8be52e7e2d
--- /dev/null
+++ b/lib/libc/softfloat/gtxf2.c
@@ -0,0 +1,25 @@
+/* $NetBSD: gtxf2.c,v 1.2 2004/09/27 10:16:24 he Exp $ */
+
+/*
+ * Written by Ben Harris, 2000. This file is in the Public Domain.
+ */
+
+#include "softfloat-for-gcc.h"
+#include "milieu.h"
+#include "softfloat.h"
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#ifdef FLOATX80
+
+flag __gtxf2(floatx80, floatx80);
+
+flag
+__gtxf2(floatx80 a, floatx80 b)
+{
+
+ /* libgcc1.c says a > b */
+ return floatx80_lt(b, a);
+}
+#endif /* FLOATX80 */
diff --git a/lib/libc/softfloat/letf2.c b/lib/libc/softfloat/letf2.c
new file mode 100644
index 000000000000..e9a18f8d5e5d
--- /dev/null
+++ b/lib/libc/softfloat/letf2.c
@@ -0,0 +1,26 @@
+/* $NetBSD: letf2.c,v 1.1 2011/01/17 10:08:35 matt Exp $ */
+
+/*
+ * Written by Matt Thomas, 2011. This file is in the Public Domain.
+ */
+
+#include "softfloat-for-gcc.h"
+#include "milieu.h"
+#include "softfloat.h"
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#ifdef FLOAT128
+
+flag __letf2(float128, float128);
+
+flag
+__letf2(float128 a, float128 b)
+{
+
+ /* libgcc1.c says 1 - (a <= b) */
+ return 1 - float128_le(a, b);
+}
+
+#endif /* FLOAT128 */
diff --git a/lib/libc/softfloat/lttf2.c b/lib/libc/softfloat/lttf2.c
new file mode 100644
index 000000000000..13c01b19528d
--- /dev/null
+++ b/lib/libc/softfloat/lttf2.c
@@ -0,0 +1,26 @@
+/* $NetBSD: lttf2.c,v 1.1 2011/01/17 10:08:35 matt Exp $ */
+
+/*
+ * Written by Matt Thomas, 2011. This file is in the Public Domain.
+ */
+
+#include "softfloat-for-gcc.h"
+#include "milieu.h"
+#include "softfloat.h"
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#ifdef FLOAT128
+
+flag __lttf2(float128, float128);
+
+flag
+__lttf2(float128 a, float128 b)
+{
+
+ /* libgcc1.c says -(a < b) */
+ return -float128_lt(a, b);
+}
+
+#endif /* FLOAT128 */
diff --git a/lib/libc/softfloat/negtf2.c b/lib/libc/softfloat/negtf2.c
new file mode 100644
index 000000000000..5be582dd8937
--- /dev/null
+++ b/lib/libc/softfloat/negtf2.c
@@ -0,0 +1,27 @@
+/* $NetBSD: negtf2.c,v 1.1 2011/01/17 10:08:35 matt Exp $ */
+
+/*
+ * Written by Matt Thomas, 2011. This file is in the Public Domain.
+ */
+
+#include "softfloat-for-gcc.h"
+#include "milieu.h"
+#include "softfloat.h"
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#ifdef FLOAT128
+
+float128 __negtf2(float128);
+
+float128
+__negtf2(float128 a)
+{
+
+ /* libgcc1.c says -a */
+ a.high ^= FLOAT64_MANGLE(0x8000000000000000ULL);
+ return a;
+}
+
+#endif /* FLOAT128 */
diff --git a/lib/libc/softfloat/negxf2.c b/lib/libc/softfloat/negxf2.c
new file mode 100644
index 000000000000..0e2d08b25a67
--- /dev/null
+++ b/lib/libc/softfloat/negxf2.c
@@ -0,0 +1,25 @@
+/* $NetBSD: negxf2.c,v 1.2 2004/09/27 10:16:24 he Exp $ */
+
+/*
+ * Written by Ben Harris, 2000. This file is in the Public Domain.
+ */
+
+#include "softfloat-for-gcc.h"
+#include "milieu.h"
+#include "softfloat.h"
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#ifdef FLOATX80
+
+floatx80 __negxf2(floatx80);
+
+floatx80
+__negxf2(floatx80 a)
+{
+
+ /* libgcc1.c says -a */
+ return __mulxf3(a,__floatsixf(-1));
+}
+#endif /* FLOATX80 */
diff --git a/lib/libc/softfloat/netf2.c b/lib/libc/softfloat/netf2.c
new file mode 100644
index 000000000000..26e17cd1f52d
--- /dev/null
+++ b/lib/libc/softfloat/netf2.c
@@ -0,0 +1,26 @@
+/* $NetBSD: netf2.c,v 1.1 2011/01/17 10:08:35 matt Exp $ */
+
+/*
+ * Written by Matt Thomas, 2011. This file is in the Public Domain.
+ */
+
+#include "softfloat-for-gcc.h"
+#include "milieu.h"
+#include "softfloat.h"
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#ifdef FLOAT128
+
+flag __netf2(float128, float128);
+
+flag
+__netf2(float128 a, float128 b)
+{
+
+ /* libgcc1.c says a != b */
+ return !float128_eq(a, b);
+}
+
+#endif /* FLOAT128 */
diff --git a/lib/libc/softfloat/nexf2.c b/lib/libc/softfloat/nexf2.c
new file mode 100644
index 000000000000..153a70392d16
--- /dev/null
+++ b/lib/libc/softfloat/nexf2.c
@@ -0,0 +1,25 @@
+/* $NetBSD: nexf2.c,v 1.2 2004/09/27 10:16:24 he Exp $ */
+
+/*
+ * Written by Ben Harris, 2000. This file is in the Public Domain.
+ */
+
+#include "softfloat-for-gcc.h"
+#include "milieu.h"
+#include "softfloat.h"
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#ifdef FLOATX80
+
+flag __nexf2(floatx80, floatx80);
+
+flag
+__nexf2(floatx80 a, floatx80 b)
+{
+
+ /* libgcc1.c says a != b */
+ return !floatx80_eq(a, b);
+}
+#endif /* FLOATX80 */
diff --git a/lib/libc/softfloat/softfloat-for-gcc.h b/lib/libc/softfloat/softfloat-for-gcc.h
index fa5b3e8c9050..cf17e56768a9 100644
--- a/lib/libc/softfloat/softfloat-for-gcc.h
+++ b/lib/libc/softfloat/softfloat-for-gcc.h
@@ -1,21 +1,24 @@
-/* $NetBSD: softfloat-for-gcc.h,v 1.6 2003/07/26 19:24:51 salo Exp $ */
+/* $NetBSD: softfloat-for-gcc.h,v 1.8 2009/12/14 01:07:42 matt Exp $ */
/* $FreeBSD$ */
/*
* Move private identifiers with external linkage into implementation
* namespace. -- Klaus Klein <kleink@NetBSD.org>, May 5, 1999
*/
-#define float_exception_flags _softfloat_float_exception_flags
-#define float_exception_mask _softfloat_float_exception_mask
-#define float_rounding_mode _softfloat_float_rounding_mode
-#define float_raise _softfloat_float_raise
+#define float_exception_flags __softfloat_float_exception_flags
+#define float_exception_mask __softfloat_float_exception_mask
+#define float_rounding_mode __softfloat_float_rounding_mode
+#define float_raise __softfloat_float_raise
/* The following batch are called by GCC through wrappers */
-#define float32_eq _softfloat_float32_eq
-#define float32_le _softfloat_float32_le
-#define float32_lt _softfloat_float32_lt
-#define float64_eq _softfloat_float64_eq
-#define float64_le _softfloat_float64_le
-#define float64_lt _softfloat_float64_lt
+#define float32_eq __softfloat_float32_eq
+#define float32_le __softfloat_float32_le
+#define float32_lt __softfloat_float32_lt
+#define float64_eq __softfloat_float64_eq
+#define float64_le __softfloat_float64_le
+#define float64_lt __softfloat_float64_lt
+#define float128_eq __softfloat_float128_eq
+#define float128_le __softfloat_float128_le
+#define float128_lt __softfloat_float128_lt
/*
* Macros to define functions with the GCC expected names
@@ -23,21 +26,144 @@
#define float32_add __addsf3
#define float64_add __adddf3
+#define floatx80_add __addxf3
+#define float128_add __addtf3
+
#define float32_sub __subsf3
#define float64_sub __subdf3
+#define floatx80_sub __subxf3
+#define float128_sub __subtf3
+
#define float32_mul __mulsf3
#define float64_mul __muldf3
+#define floatx80_mul __mulxf3
+#define float128_mul __multf3
+
#define float32_div __divsf3
#define float64_div __divdf3
+#define floatx80_div __divxf3
+#define float128_div __divtf3
+
+#if 0
+#define float32_neg __negsf2
+#define float64_neg __negdf2
+#define floatx80_neg __negxf2
+#define float128_neg __negtf2
+#endif
+
#define int32_to_float32 __floatsisf
#define int32_to_float64 __floatsidf
+#define int32_to_floatx80 __floatsixf
+#define int32_to_float128 __floatsitf
+
#define int64_to_float32 __floatdisf
#define int64_to_float64 __floatdidf
+#define int64_to_floatx80 __floatdixf
+#define int64_to_float128 __floatditf
+
+#define int128_to_float32 __floattisf
+#define int128_to_float64 __floattidf
+#define int128_to_floatx80 __floattixf
+#define int128_to_float128 __floattitf
+
+#define uint32_to_float32 __floatunsisf
+#define uint32_to_float64 __floatunsidf
+#define uint32_to_floatx80 __floatunsixf
+#define uint32_to_float128 __floatunsitf
+
+#define uint64_to_float32 __floatundisf
+#define uint64_to_float64 __floatundidf
+#define uint64_to_floatx80 __floatundixf
+#define uint64_to_float128 __floatunditf
+
+#define uint128_to_float32 __floatuntisf
+#define uint128_to_float64 __floatuntidf
+#define uint128_to_floatx80 __floatuntixf
+#define uint128_to_float128 __floatuntitf
+
#define float32_to_int32_round_to_zero __fixsfsi
#define float64_to_int32_round_to_zero __fixdfsi
+#define floatx80_to_int32_round_to_zero __fixxfsi
+#define float128_to_int32_round_to_zero __fixtfsi
+
#define float32_to_int64_round_to_zero __fixsfdi
#define float64_to_int64_round_to_zero __fixdfdi
+#define floatx80_to_int64_round_to_zero __fixxfdi
+#define float128_to_int64_round_to_zero __fixtfdi
+
+#define float32_to_int128_round_to_zero __fixsfti
+#define float64_to_int128_round_to_zero __fixdfti
+#define floatx80_to_int128_round_to_zero __fixxfti
+#define float128_to_int128_round_to_zero __fixtfti
+
#define float32_to_uint32_round_to_zero __fixunssfsi
#define float64_to_uint32_round_to_zero __fixunsdfsi
+#define floatx80_to_uint32_round_to_zero __fixunsxfsi
+#define float128_to_uint32_round_to_zero __fixunstfsi
+
+#define float32_to_uint64_round_to_zero __fixunssfdi
+#define float64_to_uint64_round_to_zero __fixunsdfdi
+#define floatx80_to_uint64_round_to_zero __fixunsxfdi
+#define float128_to_uint64_round_to_zero __fixunstfdi
+
+#define float32_to_uint128_round_to_zero __fixunssfti
+#define float64_to_uint128_round_to_zero __fixunsdfti
+#define floatx80_to_uint128_round_to_zero __fixunsxfti
+#define float128_to_uint128_round_to_zero __fixunstfti
+
#define float32_to_float64 __extendsfdf2
+#define float32_to_floatx80 __extendsfxf2
+#define float32_to_float128 __extendsftf2
+#define float64_to_floatx80 __extenddfxf2
+#define float64_to_float128 __extenddftf2
+
+#define float128_to_float64 __trunctfdf2
+#define floatx80_to_float64 __truncxfdf2
+#define float128_to_float32 __trunctfsf2
+#define floatx80_to_float32 __truncxfsf2
#define float64_to_float32 __truncdfsf2
+
+#if 0
+#define float32_cmp __cmpsf2
+#define float32_unord __unordsf2
+#define float32_eq __eqsf2
+#define float32_ne __nesf2
+#define float32_ge __gesf2
+#define float32_lt __ltsf2
+#define float32_le __lesf2
+#define float32_gt __gtsf2
+#endif
+
+#if 0
+#define float64_cmp __cmpdf2
+#define float64_unord __unorddf2
+#define float64_eq __eqdf2
+#define float64_ne __nedf2
+#define float64_ge __gedf2
+#define float64_lt __ltdf2
+#define float64_le __ledf2
+#define float64_gt __gtdf2
+#endif
+
+/* XXX not in libgcc */
+#if 1
+#define floatx80_cmp __cmpxf2
+#define floatx80_unord __unordxf2
+#define floatx80_eq __eqxf2
+#define floatx80_ne __nexf2
+#define floatx80_ge __gexf2
+#define floatx80_lt __ltxf2
+#define floatx80_le __lexf2
+#define floatx80_gt __gtxf2
+#endif
+
+#if 0
+#define float128_cmp __cmptf2
+#define float128_unord __unordtf2
+#define float128_eq __eqtf2
+#define float128_ne __netf2
+#define float128_ge __getf2
+#define float128_lt __lttf2
+#define float128_le __letf2
+#define float128_gt __gttf2
+#endif
diff --git a/lib/libc/softfloat/softfloat-source.txt b/lib/libc/softfloat/softfloat-source.txt
index 06759664ebe6..2a15f2add95b 100644
--- a/lib/libc/softfloat/softfloat-source.txt
+++ b/lib/libc/softfloat/softfloat-source.txt
@@ -1,4 +1,4 @@
-$NetBSD: softfloat-source.txt,v 1.1 2000/06/06 08:15:10 bjh21 Exp $
+$NetBSD: softfloat-source.txt,v 1.2 2006/11/24 19:46:58 christos Exp $
$FreeBSD$
SoftFloat Release 2a Source Documentation
@@ -33,7 +33,7 @@ C Compiler (`gcc') for several platforms.
Limitations
SoftFloat as written requires an ISO/ANSI-style C compiler. No attempt has
-been made to accomodate compilers that are not ISO-conformant. Older ``K&R-
+been made to accommodate compilers that are not ISO-conformant. Older ``K&R-
style'' compilers are not adequate for compiling SoftFloat. All testing I
have done so far has been with the GNU C Compiler. Compilation with other
compilers should be possible but has not been tested.
diff --git a/lib/libc/softfloat/softfloat-specialize b/lib/libc/softfloat/softfloat-specialize
index e8585cea7f59..b5eb8c34cdc8 100644
--- a/lib/libc/softfloat/softfloat-specialize
+++ b/lib/libc/softfloat/softfloat-specialize
@@ -1,4 +1,4 @@
-/* $NetBSD: softfloat-specialize,v 1.3 2002/05/12 13:12:45 bjh21 Exp $ */
+/* $NetBSD: softfloat-specialize,v 1.6 2011/03/06 10:27:37 martin Exp $ */
/* $FreeBSD$ */
/* This is a derivative work. */
@@ -34,6 +34,8 @@ this code that are retained.
*/
#include <signal.h>
+#include <string.h>
+#include <unistd.h>
/*
-------------------------------------------------------------------------------
@@ -58,16 +60,39 @@ substitute a result value. If traps are not implemented, this routine
should be simply `float_exception_flags |= flags;'.
-------------------------------------------------------------------------------
*/
-fp_except float_exception_mask = 0;
-void float_raise( fp_except flags )
+#ifdef SOFTFLOAT_FOR_GCC
+#define float_exception_mask __softfloat_float_exception_mask
+#endif
+int float_exception_mask = 0;
+void float_raise( int flags )
{
float_exception_flags |= flags;
if ( flags & float_exception_mask ) {
+#if 0
+ siginfo_t info;
+ memset(&info, 0, sizeof info);
+ info.si_signo = SIGFPE;
+ info.si_pid = getpid();
+ info.si_uid = geteuid();
+ if (flags & float_flag_underflow)
+ info.si_code = FPE_FLTUND;
+ else if (flags & float_flag_overflow)
+ info.si_code = FPE_FLTOVF;
+ else if (flags & float_flag_divbyzero)
+ info.si_code = FPE_FLTDIV;
+ else if (flags & float_flag_invalid)
+ info.si_code = FPE_FLTINV;
+ else if (flags & float_flag_inexact)
+ info.si_code = FPE_FLTRES;
+ sigqueueinfo(getpid(), &info);
+#else
raise( SIGFPE );
+#endif
}
}
+#undef float_exception_mask
/*
-------------------------------------------------------------------------------
@@ -108,7 +133,8 @@ Returns 1 if the single-precision floating-point value `a' is a signaling
NaN; otherwise returns 0.
-------------------------------------------------------------------------------
*/
-#if defined(SOFTFLOAT_FOR_GCC) && !defined(SOFTFLOATSPARC64_FOR_GCC)
+#if defined(SOFTFLOAT_FOR_GCC) && !defined(SOFTFLOATSPARC64_FOR_GCC) && \
+ !defined(SOFTFLOAT_M68K_FOR_GCC)
static
#endif
flag float32_is_signaling_nan( float32 a )
@@ -207,7 +233,8 @@ Returns 1 if the double-precision floating-point value `a' is a signaling
NaN; otherwise returns 0.
-------------------------------------------------------------------------------
*/
-#if defined(SOFTFLOAT_FOR_GCC) && !defined(SOFTFLOATSPARC64_FOR_GCC)
+#if defined(SOFTFLOAT_FOR_GCC) && !defined(SOFTFLOATSPARC64_FOR_GCC) && \
+ !defined(SOFTFLOATM68K_FOR_GCC)
static
#endif
flag float64_is_signaling_nan( float64 a )
diff --git a/lib/libc/softfloat/softfloat.txt b/lib/libc/softfloat/softfloat.txt
index bd63324faa96..414506f7fef2 100644
--- a/lib/libc/softfloat/softfloat.txt
+++ b/lib/libc/softfloat/softfloat.txt
@@ -1,4 +1,4 @@
-$NetBSD: softfloat.txt,v 1.1 2000/06/06 08:15:10 bjh21 Exp $
+$NetBSD: softfloat.txt,v 1.2 2006/11/24 19:46:58 christos Exp $
$FreeBSD$
SoftFloat Release 2a General Documentation
@@ -27,7 +27,7 @@ Limitations
SoftFloat is written in C and is designed to work with other C code. The
SoftFloat header files assume an ISO/ANSI-style C compiler. No attempt
-has been made to accomodate compilers that are not ISO-conformant. In
+has been made to accommodate compilers that are not ISO-conformant. In
particular, the distributed header files will not be acceptable to any
compiler that does not recognize function prototypes.
diff --git a/lib/libc/sparc64/fpu/fpu_emu.h b/lib/libc/sparc64/fpu/fpu_emu.h
index 0d1d16dd1e56..0822de89e143 100644
--- a/lib/libc/sparc64/fpu/fpu_emu.h
+++ b/lib/libc/sparc64/fpu/fpu_emu.h
@@ -159,7 +159,8 @@ struct fpemu {
* Each of these may modify its inputs (f1,f2) and/or the temporary.
* Each returns a pointer to the result and/or sets exceptions.
*/
-#define __fpu_sub(fe) ((fe)->fe_f2.fp_sign ^= 1, __fpu_add(fe))
+#define __fpu_sub(fe) (ISNAN(&(fe)->fe_f2) ? 0 : ((fe)->fe_f2.fp_sign ^= 1), \
+ __fpu_add(fe))
#ifdef FPU_DEBUG
#define FPE_INSN 0x1
diff --git a/lib/libc/sparc64/fpu/fpu_mul.c b/lib/libc/sparc64/fpu/fpu_mul.c
index 173810ecf76f..3fe27c4e9113 100644
--- a/lib/libc/sparc64/fpu/fpu_mul.c
+++ b/lib/libc/sparc64/fpu/fpu_mul.c
@@ -125,10 +125,8 @@ __fpu_mul(fe)
* The result is x * y (XOR sign, multiply bits, add exponents).
*/
ORDER(x, y);
- if (ISNAN(y)) {
- y->fp_sign ^= x->fp_sign;
+ if (ISNAN(y))
return (y);
- }
if (ISINF(y)) {
if (ISZERO(x))
return (__fpu_newnan(fe));
diff --git a/lib/libc/sparc64/gen/Makefile.inc b/lib/libc/sparc64/gen/Makefile.inc
index f82f22588a74..d3fbfe4e2acf 100644
--- a/lib/libc/sparc64/gen/Makefile.inc
+++ b/lib/libc/sparc64/gen/Makefile.inc
@@ -2,5 +2,5 @@
SRCS+= _ctx_start.S _setjmp.S fabs.S fixunsdfsi.S flt_rounds.c fpgetmask.c \
fpgetround.c fpgetsticky.c fpsetmask.c fpsetround.c \
- infinity.c ldexp.c makecontext.c \
+ getcontextx.c infinity.c ldexp.c makecontext.c \
signalcontext.c setjmp.S sigsetjmp.S _set_tp.c
diff --git a/lib/libc/sparc64/gen/getcontextx.c b/lib/libc/sparc64/gen/getcontextx.c
new file mode 100644
index 000000000000..307978a466dd
--- /dev/null
+++ b/lib/libc/sparc64/gen/getcontextx.c
@@ -0,0 +1,69 @@
+/*
+ * 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/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/ucontext.h>
+#include <errno.h>
+#include <stdlib.h>
+
+int
+__getcontextx_size(void)
+{
+
+ return (sizeof(ucontext_t));
+}
+
+int
+__fillcontextx(char *ctx)
+{
+ ucontext_t *ucp;
+
+ ucp = (ucontext_t *)ctx;
+ return (getcontext(ucp));
+}
+
+__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/stdio/fclose.c b/lib/libc/stdio/fclose.c
index f0629e830d0e..3957b6a427e3 100644
--- a/lib/libc/stdio/fclose.c
+++ b/lib/libc/stdio/fclose.c
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <stdlib.h>
#include "un-namespace.h"
+#include <spinlock.h>
#include "libc_private.h"
#include "local.h"
@@ -65,7 +66,20 @@ fclose(FILE *fp)
FREELB(fp);
fp->_file = -1;
fp->_r = fp->_w = 0; /* Mess up if reaccessed. */
+
+ /*
+ * Lock the spinlock used to protect __sglue list walk in
+ * __sfp(). The __sfp() uses fp->_flags == 0 test as an
+ * indication of the unused FILE.
+ *
+ * Taking the lock prevents possible compiler or processor
+ * reordering of the writes performed before the final _flags
+ * cleanup, making sure that we are done with the FILE before
+ * it is considered available.
+ */
+ STDIO_THREAD_LOCK();
fp->_flags = 0; /* Release this FILE for reuse. */
+ STDIO_THREAD_UNLOCK();
FUNLOCKFILE(fp);
return (r);
}
diff --git a/lib/libc/stdio/findfp.c b/lib/libc/stdio/findfp.c
index 89c05363966a..6d0b673395f6 100644
--- a/lib/libc/stdio/findfp.c
+++ b/lib/libc/stdio/findfp.c
@@ -82,9 +82,7 @@ static struct glue *lastglue = &uglue;
static struct glue * moreglue(int);
-static spinlock_t thread_lock = _SPINLOCK_INITIALIZER;
-#define THREAD_LOCK() if (__isthreaded) _SPINLOCK(&thread_lock)
-#define THREAD_UNLOCK() if (__isthreaded) _SPINUNLOCK(&thread_lock)
+spinlock_t __stdio_thread_lock = _SPINLOCK_INITIALIZER;
#if NOT_YET
#define SET_GLUE_PTR(ptr, val) atomic_set_rel_ptr(&(ptr), (uintptr_t)(val))
@@ -127,22 +125,22 @@ __sfp()
/*
* The list must be locked because a FILE may be updated.
*/
- THREAD_LOCK();
+ STDIO_THREAD_LOCK();
for (g = &__sglue; g != NULL; g = g->next) {
for (fp = g->iobs, n = g->niobs; --n >= 0; fp++)
if (fp->_flags == 0)
goto found;
}
- THREAD_UNLOCK(); /* don't hold lock while malloc()ing. */
+ STDIO_THREAD_UNLOCK(); /* don't hold lock while malloc()ing. */
if ((g = moreglue(NDYNAMIC)) == NULL)
return (NULL);
- THREAD_LOCK(); /* reacquire the lock */
+ STDIO_THREAD_LOCK(); /* reacquire the lock */
SET_GLUE_PTR(lastglue->next, g); /* atomically append glue to list */
lastglue = g; /* not atomic; only accessed when locked */
fp = g->iobs;
found:
fp->_flags = 1; /* reserve this slot; caller sets real flags */
- THREAD_UNLOCK();
+ STDIO_THREAD_UNLOCK();
fp->_p = NULL; /* no current pointer */
fp->_w = 0; /* nothing to read or write */
fp->_r = 0;
@@ -183,10 +181,10 @@ f_prealloc(void)
for (g = &__sglue; (n -= g->niobs) > 0 && g->next; g = g->next)
/* void */;
if ((n > 0) && ((g = moreglue(n)) != NULL)) {
- THREAD_LOCK();
+ STDIO_THREAD_LOCK();
SET_GLUE_PTR(lastglue->next, g);
lastglue = g;
- THREAD_UNLOCK();
+ STDIO_THREAD_UNLOCK();
}
}
diff --git a/lib/libc/stdio/fputws.c b/lib/libc/stdio/fputws.c
index a318e2d8acdf..fa8d31784e09 100644
--- a/lib/libc/stdio/fputws.c
+++ b/lib/libc/stdio/fputws.c
@@ -61,8 +61,8 @@ fputws_l(const wchar_t * __restrict ws, FILE * __restrict fp, locale_t locale)
uio.uio_iov = &iov;
uio.uio_iovcnt = 1;
iov.iov_base = buf;
+ wsp = ws;
do {
- wsp = ws;
nbytes = l->__wcsnrtombs(buf, &wsp, SIZE_T_MAX, sizeof(buf),
&fp->_mbstate);
if (nbytes == (size_t)-1)
@@ -70,7 +70,7 @@ fputws_l(const wchar_t * __restrict ws, FILE * __restrict fp, locale_t locale)
iov.iov_len = uio.uio_resid = nbytes;
if (__sfvwrite(fp, &uio) != 0)
goto error;
- } while (ws != NULL);
+ } while (wsp != NULL);
FUNLOCKFILE(fp);
return (0);
diff --git a/lib/libc/stdio/getline.3 b/lib/libc/stdio/getline.3
index e0dda082ed85..6061bfcd1da6 100644
--- a/lib/libc/stdio/getline.3
+++ b/lib/libc/stdio/getline.3
@@ -78,7 +78,7 @@ and
.Fn getline
functions return the number of characters written, excluding the
terminating
-.Dv NUL
+.Dv NUL
character.
The value \-1 is returned if an error occurs, or if end-of-file is reached.
.Sh EXAMPLES
diff --git a/lib/libc/stdio/mktemp.3 b/lib/libc/stdio/mktemp.3
index 3e02d94fdfd8..b51a177b4cdc 100644
--- a/lib/libc/stdio/mktemp.3
+++ b/lib/libc/stdio/mktemp.3
@@ -28,7 +28,7 @@
.\" @(#)mktemp.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd February 11, 1998
+.Dd March 4, 2012
.Dt MKTEMP 3
.Os
.Sh NAME
@@ -180,12 +180,6 @@ with an argument of
will result in a core dump due to
.Fn mkstemp
attempting to modify the string constant that was given.
-If the program in question makes heavy use of that type
-of function call, you do have the option of compiling the program
-so that it will store string constants in a writable segment of memory.
-See
-.Xr gcc 1
-for more information.
.Sh SEE ALSO
.Xr chmod 2 ,
.Xr getpid 2 ,
@@ -242,10 +236,3 @@ and the return status of the call should be tested for failure.
This will ensure that the program does not continue blindly
in the event that an attacker has already created the file
with the intention of manipulating or reading its contents.
-.Pp
-The implementation of these functions calls
-.Xr arc4random 3 ,
-which is not reentrant.
-You must provide your own locking around this and other consumers of the
-.Xr arc4random 3
-API.
diff --git a/lib/libc/stdio/printf.3 b/lib/libc/stdio/printf.3
index 90a8ed8b02ed..0d9339ea55cc 100644
--- a/lib/libc/stdio/printf.3
+++ b/lib/libc/stdio/printf.3
@@ -113,20 +113,6 @@ string that specifies how subsequent arguments
.Xr stdarg 3 )
are converted for output.
.Pp
-These functions return the number of characters printed
-(not including the trailing
-.Ql \e0
-used to end output to strings) or a negative value if an output error occurs,
-except for
-.Fn snprintf
-and
-.Fn vsnprintf ,
-which return the number of characters that would have been printed if the
-.Fa size
-were unlimited
-(again, not including the final
-.Ql \e0 ) .
-.Pp
The
.Fn asprintf
and
@@ -164,15 +150,19 @@ if the return value is greater than or equal to the
.Fa size
argument, the string was too short
and some of the printed characters were discarded.
-The output is always null-terminated.
+The output is always null-terminated, unless
+.Fa size
+is 0.
.Pp
The
.Fn sprintf
and
.Fn vsprintf
functions
-effectively assume an infinite
-.Fa size .
+effectively assume a
+.Fa size
+of
+.Dv INT_MAX + 1.
.Pp
The format string is composed of zero or more directives:
ordinary
@@ -670,6 +660,21 @@ In no case does a non-existent or small field width cause truncation of
a numeric field; if the result of a conversion is wider than the field
width, the
field is expanded to contain the conversion result.
+.Sh RETURN VALUES
+These functions return the number of characters printed
+(not including the trailing
+.Ql \e0
+used to end output to strings),
+except for
+.Fn snprintf
+and
+.Fn vsnprintf ,
+which return the number of characters that would have been printed if the
+.Fa size
+were unlimited
+(again, not including the final
+.Ql \e0 ) .
+These functions return a negative value if an error occurs.
.Sh EXAMPLES
To print a date and time in the form
.Dq Li "Sunday, July 3, 10:02" ,
@@ -771,6 +776,13 @@ family of functions may fail if:
An invalid wide character code was encountered.
.It Bq Er ENOMEM
Insufficient storage space is available.
+.It Bq Er EOVERFLOW
+The
+.Fa size
+argument exceeds
+.Dv INT_MAX + 1 ,
+or the return value would be too large to be represented by an
+.Vt int .
.El
.Sh SEE ALSO
.Xr printf 1 ,
diff --git a/lib/libc/stdio/snprintf.c b/lib/libc/stdio/snprintf.c
index 74af42de23a7..d0ae5a663103 100644
--- a/lib/libc/stdio/snprintf.c
+++ b/lib/libc/stdio/snprintf.c
@@ -41,6 +41,7 @@ static char sccsid[] = "@(#)snprintf.c 8.1 (Berkeley) 6/4/93";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdarg.h>
@@ -59,8 +60,11 @@ snprintf(char * __restrict str, size_t n, char const * __restrict fmt, ...)
on = n;
if (n != 0)
n--;
- if (n > INT_MAX)
- n = INT_MAX;
+ if (n > INT_MAX) {
+ errno = EOVERFLOW;
+ *str = '\0';
+ return (EOF);
+ }
va_start(ap, fmt);
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *)str;
@@ -84,8 +88,11 @@ snprintf_l(char * __restrict str, size_t n, locale_t locale,
on = n;
if (n != 0)
n--;
- if (n > INT_MAX)
- n = INT_MAX;
+ if (n > INT_MAX) {
+ errno = EOVERFLOW;
+ *str = '\0';
+ return (EOF);
+ }
va_start(ap, fmt);
f._flags = __SWR | __SSTR;
f._bf._base = f._p = (unsigned char *)str;
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
index bfbdc1331d49..4ad0ee16b1ab 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <ctype.h>
+#include <errno.h>
#include <limits.h>
#include <locale.h>
#include <stddef.h>
@@ -480,6 +481,7 @@ __vfprintf(FILE *fp, locale_t locale, const char *fmt0, va_list ap)
if ((n = fmt - cp) != 0) {
if ((unsigned)ret + n > INT_MAX) {
ret = EOF;
+ errno = EOVERFLOW;
goto error;
}
PRINT(cp, n);
@@ -935,6 +937,7 @@ number: if ((dprec = prec) >= 0)
prsize = width > realsz ? width : realsz;
if ((unsigned)ret + prsize > INT_MAX) {
ret = EOF;
+ errno = EOVERFLOW;
goto error;
}
diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c
index 0e7894917416..6a6b19ccb801 100644
--- a/lib/libc/stdio/vfscanf.c
+++ b/lib/libc/stdio/vfscanf.c
@@ -107,6 +107,415 @@ static int parsefloat(FILE *, char *, char *, locale_t);
__weak_reference(__vfscanf, vfscanf);
/*
+ * Conversion functions are passed a pointer to this object instead of
+ * a real parameter to indicate that the assignment-suppression (*)
+ * flag was specified. We could use a NULL pointer to indicate this,
+ * but that would mask bugs in applications that call scanf() with a
+ * NULL pointer.
+ */
+static const int suppress;
+#define SUPPRESS_PTR ((void *)&suppress)
+
+static const mbstate_t initial_mbs;
+
+/*
+ * The following conversion functions return the number of characters consumed,
+ * or -1 on input failure. Character class conversion returns 0 on match
+ * failure.
+ */
+
+static __inline int
+convert_char(FILE *fp, char * __restrict p, int width)
+{
+ int n, nread;
+
+ nread = 0;
+ if (p == SUPPRESS_PTR) {
+ size_t sum = 0;
+ for (;;) {
+ if ((n = fp->_r) < width) {
+ sum += n;
+ width -= n;
+ fp->_p += n;
+ if (__srefill(fp)) {
+ if (sum == 0)
+ return (-1);
+ break;
+ }
+ } else {
+ sum += width;
+ fp->_r -= width;
+ fp->_p += width;
+ break;
+ }
+ }
+ nread += sum;
+ } else {
+ size_t r = __fread(p, 1, width, fp);
+
+ if (r == 0)
+ return (-1);
+ nread += r;
+ }
+ return (nread);
+}
+
+static __inline int
+convert_wchar(FILE *fp, wchar_t *wcp, int width)
+{
+ mbstate_t mbs;
+ size_t nconv;
+ int n, nread;
+ char buf[MB_CUR_MAX];
+
+ nread = 0;
+ n = 0;
+ while (width != 0) {
+ if (n == MB_CUR_MAX) {
+ fp->_flags |= __SERR;
+ return (-1);
+ }
+ buf[n++] = *fp->_p;
+ fp->_p++;
+ fp->_r--;
+ mbs = initial_mbs;
+ nconv = mbrtowc(wcp, buf, n, &mbs);
+ if (nconv == (size_t)-1) {
+ fp->_flags |= __SERR;
+ return (-1);
+ }
+ if (nconv == 0 && wcp != SUPPRESS_PTR)
+ *wcp = L'\0';
+ if (nconv != (size_t)-2) {
+ nread += n;
+ width--;
+ if (wcp != SUPPRESS_PTR)
+ wcp++;
+ n = 0;
+ }
+ if (fp->_r <= 0 && __srefill(fp)) {
+ if (n != 0) {
+ fp->_flags |= __SERR;
+ return (-1);
+ }
+ break;
+ }
+ }
+ return (nread);
+}
+
+static __inline int
+convert_ccl(FILE *fp, char * __restrict p, int width, const char *ccltab)
+{
+ char *p0;
+ int n;
+
+ if (p == SUPPRESS_PTR) {
+ n = 0;
+ while (ccltab[*fp->_p]) {
+ n++, fp->_r--, fp->_p++;
+ if (--width == 0)
+ break;
+ if (fp->_r <= 0 && __srefill(fp)) {
+ if (n == 0)
+ return (-1);
+ break;
+ }
+ }
+ } else {
+ p0 = p;
+ while (ccltab[*fp->_p]) {
+ fp->_r--;
+ *p++ = *fp->_p++;
+ if (--width == 0)
+ break;
+ if (fp->_r <= 0 && __srefill(fp)) {
+ if (p == p0)
+ return (-1);
+ break;
+ }
+ }
+ n = p - p0;
+ if (n == 0)
+ return (0);
+ *p = 0;
+ }
+ return (n);
+}
+
+static __inline int
+convert_wccl(FILE *fp, wchar_t *wcp, int width, const char *ccltab)
+{
+ mbstate_t mbs;
+ wchar_t twc;
+ int n, nchars, nconv;
+ char buf[MB_CUR_MAX];
+
+ if (wcp == SUPPRESS_PTR)
+ wcp = &twc;
+ n = 0;
+ nchars = 0;
+ while (width != 0) {
+ if (n == MB_CUR_MAX) {
+ fp->_flags |= __SERR;
+ return (-1);
+ }
+ buf[n++] = *fp->_p;
+ fp->_p++;
+ fp->_r--;
+ mbs = initial_mbs;
+ nconv = mbrtowc(wcp, buf, n, &mbs);
+ if (nconv == (size_t)-1) {
+ fp->_flags |= __SERR;
+ return (-1);
+ }
+ if (nconv == 0)
+ *wcp = L'\0';
+ if (nconv != (size_t)-2) {
+ if (wctob(*wcp) != EOF && !ccltab[wctob(*wcp)]) {
+ while (n != 0) {
+ n--;
+ __ungetc(buf[n], fp);
+ }
+ break;
+ }
+ width--;
+ if (wcp != &twc)
+ wcp++;
+ nchars++;
+ n = 0;
+ }
+ if (fp->_r <= 0 && __srefill(fp)) {
+ if (n != 0) {
+ fp->_flags |= __SERR;
+ return (-1);
+ }
+ break;
+ }
+ }
+ if (n != 0) {
+ fp->_flags |= __SERR;
+ return (-1);
+ }
+ if (nchars == 0)
+ return (0);
+ *wcp = L'\0';
+ return (nchars);
+}
+
+static __inline int
+convert_string(FILE *fp, char * __restrict p, int width)
+{
+ char *p0;
+ int n;
+
+ if (p == SUPPRESS_PTR) {
+ n = 0;
+ while (!isspace(*fp->_p)) {
+ n++, fp->_r--, fp->_p++;
+ if (--width == 0)
+ break;
+ if (fp->_r <= 0 && __srefill(fp))
+ break;
+ }
+ } else {
+ p0 = p;
+ while (!isspace(*fp->_p)) {
+ fp->_r--;
+ *p++ = *fp->_p++;
+ if (--width == 0)
+ break;
+ if (fp->_r <= 0 && __srefill(fp))
+ break;
+ }
+ *p = 0;
+ n = p - p0;
+ }
+ return (n);
+}
+
+static __inline int
+convert_wstring(FILE *fp, wchar_t *wcp, int width)
+{
+ mbstate_t mbs;
+ wchar_t twc;
+ int n, nconv, nread;
+ char buf[MB_CUR_MAX];
+
+ if (wcp == SUPPRESS_PTR)
+ wcp = &twc;
+ n = nread = 0;
+ while (!isspace(*fp->_p) && width != 0) {
+ if (n == MB_CUR_MAX) {
+ fp->_flags |= __SERR;
+ return (-1);
+ }
+ buf[n++] = *fp->_p;
+ fp->_p++;
+ fp->_r--;
+ mbs = initial_mbs;
+ nconv = mbrtowc(wcp, buf, n, &mbs);
+ if (nconv == (size_t)-1) {
+ fp->_flags |= __SERR;
+ return (-1);
+ }
+ if (nconv == 0)
+ *wcp = L'\0';
+ if (nconv != (size_t)-2) {
+ if (iswspace(*wcp)) {
+ while (n != 0) {
+ n--;
+ __ungetc(buf[n], fp);
+ }
+ break;
+ }
+ nread += n;
+ width--;
+ if (wcp != &twc)
+ wcp++;
+ n = 0;
+ }
+ if (fp->_r <= 0 && __srefill(fp)) {
+ if (n != 0) {
+ fp->_flags |= __SERR;
+ return (-1);
+ }
+ break;
+ }
+ }
+ *wcp = L'\0';
+ return (nread);
+}
+
+/*
+ * Read an integer, storing it in buf. The only relevant bit in the
+ * flags argument is PFXOK.
+ *
+ * Return 0 on a match failure, and the number of characters read
+ * otherwise.
+ */
+static __inline int
+parseint(FILE *fp, char * __restrict buf, int width, int base, int flags)
+{
+ /* `basefix' is used to avoid `if' tests */
+ static const short basefix[17] =
+ { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+ char *p;
+ int c;
+
+ flags |= SIGNOK | NDIGITS | NZDIGITS;
+ for (p = buf; width; width--) {
+ c = *fp->_p;
+ /*
+ * Switch on the character; `goto ok' if we accept it
+ * as a part of number.
+ */
+ switch (c) {
+
+ /*
+ * The digit 0 is always legal, but is special. For
+ * %i conversions, if no digits (zero or nonzero) have
+ * been scanned (only signs), we will have base==0.
+ * In that case, we should set it to 8 and enable 0x
+ * prefixing. Also, if we have not scanned zero
+ * digits before this, do not turn off prefixing
+ * (someone else will turn it off if we have scanned
+ * any nonzero digits).
+ */
+ case '0':
+ if (base == 0) {
+ base = 8;
+ flags |= PFXOK;
+ }
+ if (flags & NZDIGITS)
+ flags &= ~(SIGNOK|NZDIGITS|NDIGITS);
+ else
+ flags &= ~(SIGNOK|PFXOK|NDIGITS);
+ goto ok;
+
+ /* 1 through 7 always legal */
+ case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ base = basefix[base];
+ flags &= ~(SIGNOK | PFXOK | NDIGITS);
+ goto ok;
+
+ /* digits 8 and 9 ok iff decimal or hex */
+ case '8': case '9':
+ base = basefix[base];
+ if (base <= 8)
+ break; /* not legal here */
+ flags &= ~(SIGNOK | PFXOK | NDIGITS);
+ goto ok;
+
+ /* letters ok iff hex */
+ case 'A': case 'B': case 'C':
+ case 'D': case 'E': case 'F':
+ case 'a': case 'b': case 'c':
+ case 'd': case 'e': case 'f':
+ /* no need to fix base here */
+ if (base <= 10)
+ break; /* not legal here */
+ flags &= ~(SIGNOK | PFXOK | NDIGITS);
+ goto ok;
+
+ /* sign ok only as first character */
+ case '+': case '-':
+ if (flags & SIGNOK) {
+ flags &= ~SIGNOK;
+ flags |= HAVESIGN;
+ goto ok;
+ }
+ break;
+
+ /*
+ * x ok iff flag still set & 2nd char (or 3rd char if
+ * we have a sign).
+ */
+ case 'x': case 'X':
+ if (flags & PFXOK && p ==
+ buf + 1 + !!(flags & HAVESIGN)) {
+ base = 16; /* if %i */
+ flags &= ~PFXOK;
+ goto ok;
+ }
+ break;
+ }
+
+ /*
+ * If we got here, c is not a legal character for a
+ * number. Stop accumulating digits.
+ */
+ break;
+ ok:
+ /*
+ * c is legal: store it and look at the next.
+ */
+ *p++ = c;
+ if (--fp->_r > 0)
+ fp->_p++;
+ else if (__srefill(fp))
+ break; /* EOF */
+ }
+ /*
+ * If we had only a sign, it is no good; push back the sign.
+ * If the number ends in `x', it was [sign] '0' 'x', so push
+ * back the x and treat it as [sign] '0'.
+ */
+ if (flags & NDIGITS) {
+ if (p > buf)
+ (void) __ungetc(*(u_char *)--p, fp);
+ return (0);
+ }
+ c = ((u_char *)p)[-1];
+ if (c == 'x' || c == 'X') {
+ --p;
+ (void) __ungetc(c, fp);
+ }
+ return (p - buf);
+}
+
+/*
* __vfscanf - MT-safe version
*/
int
@@ -137,27 +546,18 @@ vfscanf_l(FILE *fp, locale_t locale, char const *fmt0, va_list ap)
int
__svfscanf(FILE *fp, locale_t locale, const char *fmt0, va_list ap)
{
+#define GETARG(type) ((flags & SUPPRESS) ? SUPPRESS_PTR : va_arg(ap, type))
const u_char *fmt = (const u_char *)fmt0;
int c; /* character from format, or conversion */
size_t width; /* field width, or 0 */
- char *p; /* points into all kinds of strings */
- int n; /* handy integer */
int flags; /* flags as defined above */
- char *p0; /* saves original value of p when necessary */
int nassigned; /* number of fields assigned */
int nconversions; /* number of conversions */
+ int nr; /* characters read by the current conversion */
int nread; /* number of characters consumed from fp */
int base; /* base argument to conversion function */
char ccltab[256]; /* character class table for %[...] */
- char buf[BUF]; /* buffer for numeric and mb conversions */
- wchar_t *wcp; /* handy wide character pointer */
- size_t nconv; /* length of multibyte sequence converted */
- static const mbstate_t initial;
- mbstate_t mbs;
-
- /* `basefix' is used to avoid `if' tests in the integer scanner */
- static short basefix[17] =
- { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+ char buf[BUF]; /* buffer for numeric conversions */
ORIENT(fp, -1);
@@ -300,7 +700,6 @@ literal:
break;
case 'n':
- nconversions++;
if (flags & SUPPRESS) /* ??? */
continue;
if (flags & SHORTSHORT)
@@ -366,178 +765,32 @@ literal:
if (width == 0)
width = 1;
if (flags & LONG) {
- if ((flags & SUPPRESS) == 0)
- wcp = va_arg(ap, wchar_t *);
- else
- wcp = NULL;
- n = 0;
- while (width != 0) {
- if (n == MB_CUR_MAX) {
- fp->_flags |= __SERR;
- goto input_failure;
- }
- buf[n++] = *fp->_p;
- fp->_p++;
- fp->_r--;
- mbs = initial;
- nconv = mbrtowc(wcp, buf, n, &mbs);
- if (nconv == (size_t)-1) {
- fp->_flags |= __SERR;
- goto input_failure;
- }
- if (nconv == 0 && !(flags & SUPPRESS))
- *wcp = L'\0';
- if (nconv != (size_t)-2) {
- nread += n;
- width--;
- if (!(flags & SUPPRESS))
- wcp++;
- n = 0;
- }
- if (fp->_r <= 0 && __srefill(fp)) {
- if (n != 0) {
- fp->_flags |= __SERR;
- goto input_failure;
- }
- break;
- }
- }
- if (!(flags & SUPPRESS))
- nassigned++;
- } else if (flags & SUPPRESS) {
- size_t sum = 0;
- for (;;) {
- if ((n = fp->_r) < width) {
- sum += n;
- width -= n;
- fp->_p += n;
- if (__srefill(fp)) {
- if (sum == 0)
- goto input_failure;
- break;
- }
- } else {
- sum += width;
- fp->_r -= width;
- fp->_p += width;
- break;
- }
- }
- nread += sum;
+ nr = convert_wchar(fp, GETARG(wchar_t *),
+ width);
} else {
- size_t r = __fread((void *)va_arg(ap, char *), 1,
- width, fp);
-
- if (r == 0)
- goto input_failure;
- nread += r;
- nassigned++;
+ nr = convert_char(fp, GETARG(char *), width);
}
- nconversions++;
+ if (nr < 0)
+ goto input_failure;
break;
case CT_CCL:
/* scan a (nonempty) character class (sets NOSKIP) */
if (width == 0)
width = (size_t)~0; /* `infinity' */
- /* take only those things in the class */
if (flags & LONG) {
- wchar_t twc;
- int nchars;
-
- if ((flags & SUPPRESS) == 0)
- wcp = va_arg(ap, wchar_t *);
- else
- wcp = &twc;
- n = 0;
- nchars = 0;
- while (width != 0) {
- if (n == MB_CUR_MAX) {
- fp->_flags |= __SERR;
- goto input_failure;
- }
- buf[n++] = *fp->_p;
- fp->_p++;
- fp->_r--;
- mbs = initial;
- nconv = mbrtowc(wcp, buf, n, &mbs);
- if (nconv == (size_t)-1) {
- fp->_flags |= __SERR;
- goto input_failure;
- }
- if (nconv == 0)
- *wcp = L'\0';
- if (nconv != (size_t)-2) {
- if (wctob(*wcp) != EOF &&
- !ccltab[wctob(*wcp)]) {
- while (n != 0) {
- n--;
- __ungetc(buf[n],
- fp);
- }
- break;
- }
- nread += n;
- width--;
- if (!(flags & SUPPRESS))
- wcp++;
- nchars++;
- n = 0;
- }
- if (fp->_r <= 0 && __srefill(fp)) {
- if (n != 0) {
- fp->_flags |= __SERR;
- goto input_failure;
- }
- break;
- }
- }
- if (n != 0) {
- fp->_flags |= __SERR;
- goto input_failure;
- }
- n = nchars;
- if (n == 0)
- goto match_failure;
- if (!(flags & SUPPRESS)) {
- *wcp = L'\0';
- nassigned++;
- }
- } else if (flags & SUPPRESS) {
- n = 0;
- while (ccltab[*fp->_p]) {
- n++, fp->_r--, fp->_p++;
- if (--width == 0)
- break;
- if (fp->_r <= 0 && __srefill(fp)) {
- if (n == 0)
- goto input_failure;
- break;
- }
- }
- if (n == 0)
- goto match_failure;
+ nr = convert_wccl(fp, GETARG(wchar_t *), width,
+ ccltab);
} else {
- p0 = p = va_arg(ap, char *);
- while (ccltab[*fp->_p]) {
- fp->_r--;
- *p++ = *fp->_p++;
- if (--width == 0)
- break;
- if (fp->_r <= 0 && __srefill(fp)) {
- if (p == p0)
- goto input_failure;
- break;
- }
- }
- n = p - p0;
- if (n == 0)
+ nr = convert_ccl(fp, GETARG(char *), width,
+ ccltab);
+ }
+ if (nr <= 0) {
+ if (nr < 0)
+ goto input_failure;
+ else /* nr == 0 */
goto match_failure;
- *p = 0;
- nassigned++;
}
- nread += n;
- nconversions++;
break;
case CT_STRING:
@@ -545,82 +798,14 @@ literal:
if (width == 0)
width = (size_t)~0;
if (flags & LONG) {
- wchar_t twc;
-
- if ((flags & SUPPRESS) == 0)
- wcp = va_arg(ap, wchar_t *);
- else
- wcp = &twc;
- n = 0;
- while (!isspace(*fp->_p) && width != 0) {
- if (n == MB_CUR_MAX) {
- fp->_flags |= __SERR;
- goto input_failure;
- }
- buf[n++] = *fp->_p;
- fp->_p++;
- fp->_r--;
- mbs = initial;
- nconv = mbrtowc(wcp, buf, n, &mbs);
- if (nconv == (size_t)-1) {
- fp->_flags |= __SERR;
- goto input_failure;
- }
- if (nconv == 0)
- *wcp = L'\0';
- if (nconv != (size_t)-2) {
- if (iswspace(*wcp)) {
- while (n != 0) {
- n--;
- __ungetc(buf[n],
- fp);
- }
- break;
- }
- nread += n;
- width--;
- if (!(flags & SUPPRESS))
- wcp++;
- n = 0;
- }
- if (fp->_r <= 0 && __srefill(fp)) {
- if (n != 0) {
- fp->_flags |= __SERR;
- goto input_failure;
- }
- break;
- }
- }
- if (!(flags & SUPPRESS)) {
- *wcp = L'\0';
- nassigned++;
- }
- } else if (flags & SUPPRESS) {
- n = 0;
- while (!isspace(*fp->_p)) {
- n++, fp->_r--, fp->_p++;
- if (--width == 0)
- break;
- if (fp->_r <= 0 && __srefill(fp))
- break;
- }
- nread += n;
+ nr = convert_wstring(fp, GETARG(wchar_t *),
+ width);
} else {
- p0 = p = va_arg(ap, char *);
- while (!isspace(*fp->_p)) {
- fp->_r--;
- *p++ = *fp->_p++;
- if (--width == 0)
- break;
- if (fp->_r <= 0 && __srefill(fp))
- break;
- }
- *p = 0;
- nread += p - p0;
- nassigned++;
+ nr = convert_string(fp, GETARG(char *), width);
}
- nconversions++;
- continue;
+ if (nr < 0)
+ goto input_failure;
+ break;
case CT_INT:
/* scan an integer as if by the conversion function */
@@ -633,122 +818,13 @@ literal:
width = sizeof(buf) - 2;
width++;
#endif
- flags |= SIGNOK | NDIGITS | NZDIGITS;
- for (p = buf; width; width--) {
- c = *fp->_p;
- /*
- * Switch on the character; `goto ok'
- * if we accept it as a part of number.
- */
- switch (c) {
-
- /*
- * The digit 0 is always legal, but is
- * special. For %i conversions, if no
- * digits (zero or nonzero) have been
- * scanned (only signs), we will have
- * base==0. In that case, we should set
- * it to 8 and enable 0x prefixing.
- * Also, if we have not scanned zero digits
- * before this, do not turn off prefixing
- * (someone else will turn it off if we
- * have scanned any nonzero digits).
- */
- case '0':
- if (base == 0) {
- base = 8;
- flags |= PFXOK;
- }
- if (flags & NZDIGITS)
- flags &= ~(SIGNOK|NZDIGITS|NDIGITS);
- else
- flags &= ~(SIGNOK|PFXOK|NDIGITS);
- goto ok;
-
- /* 1 through 7 always legal */
- case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- base = basefix[base];
- flags &= ~(SIGNOK | PFXOK | NDIGITS);
- goto ok;
-
- /* digits 8 and 9 ok iff decimal or hex */
- case '8': case '9':
- base = basefix[base];
- if (base <= 8)
- break; /* not legal here */
- flags &= ~(SIGNOK | PFXOK | NDIGITS);
- goto ok;
-
- /* letters ok iff hex */
- case 'A': case 'B': case 'C':
- case 'D': case 'E': case 'F':
- case 'a': case 'b': case 'c':
- case 'd': case 'e': case 'f':
- /* no need to fix base here */
- if (base <= 10)
- break; /* not legal here */
- flags &= ~(SIGNOK | PFXOK | NDIGITS);
- goto ok;
-
- /* sign ok only as first character */
- case '+': case '-':
- if (flags & SIGNOK) {
- flags &= ~SIGNOK;
- flags |= HAVESIGN;
- goto ok;
- }
- break;
-
- /*
- * x ok iff flag still set & 2nd char (or
- * 3rd char if we have a sign).
- */
- case 'x': case 'X':
- if (flags & PFXOK && p ==
- buf + 1 + !!(flags & HAVESIGN)) {
- base = 16; /* if %i */
- flags &= ~PFXOK;
- goto ok;
- }
- break;
- }
-
- /*
- * If we got here, c is not a legal character
- * for a number. Stop accumulating digits.
- */
- break;
- ok:
- /*
- * c is legal: store it and look at the next.
- */
- *p++ = c;
- if (--fp->_r > 0)
- fp->_p++;
- else if (__srefill(fp))
- break; /* EOF */
- }
- /*
- * If we had only a sign, it is no good; push
- * back the sign. If the number ends in `x',
- * it was [sign] '0' 'x', so push back the x
- * and treat it as [sign] '0'.
- */
- if (flags & NDIGITS) {
- if (p > buf)
- (void) __ungetc(*(u_char *)--p, fp);
+ nr = parseint(fp, buf, width, base, flags);
+ if (nr == 0)
goto match_failure;
- }
- c = ((u_char *)p)[-1];
- if (c == 'x' || c == 'X') {
- --p;
- (void) __ungetc(c, fp);
- }
if ((flags & SUPPRESS) == 0) {
uintmax_t res;
- *p = 0;
+ buf[nr] = '\0';
if ((flags & UNSIGNED) == 0)
res = strtoimax_l(buf, (char **)NULL, base, locale);
else
@@ -772,10 +848,7 @@ literal:
*va_arg(ap, size_t *) = res;
else
*va_arg(ap, int *) = res;
- nassigned++;
}
- nread += p - buf;
- nconversions++;
break;
#ifndef NO_FLOATING_POINT
@@ -783,26 +856,30 @@ literal:
/* scan a floating point number as if by strtod */
if (width == 0 || width > sizeof(buf) - 1)
width = sizeof(buf) - 1;
- if ((width = parsefloat(fp, buf, buf + width, locale)) == 0)
+ nr = parsefloat(fp, buf, buf + width, locale);
+ if (nr == 0)
goto match_failure;
if ((flags & SUPPRESS) == 0) {
if (flags & LONGDBL) {
- long double res = strtold_l(buf, &p, locale);
+ long double res = strtold_l(buf, NULL,
+ locale);
*va_arg(ap, long double *) = res;
} else if (flags & LONG) {
- double res = strtod_l(buf, &p, locale);
+ double res = strtod_l(buf, NULL,
+ locale);
*va_arg(ap, double *) = res;
} else {
- float res = strtof_l(buf, &p, locale);
+ float res = strtof_l(buf, NULL, locale);
*va_arg(ap, float *) = res;
}
- nassigned++;
}
- nread += width;
- nconversions++;
break;
#endif /* !NO_FLOATING_POINT */
}
+ if (!(flags & SUPPRESS))
+ nassigned++;
+ nread += nr;
+ nconversions++;
}
input_failure:
return (nconversions != 0 ? nassigned : EOF);
diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c
index 73e37c914c5c..cc96b63bd1e4 100644
--- a/lib/libc/stdio/vfwprintf.c
+++ b/lib/libc/stdio/vfwprintf.c
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <ctype.h>
+#include <errno.h>
#include <limits.h>
#include <locale.h>
#include <stdarg.h>
@@ -553,6 +554,7 @@ __vfwprintf(FILE *fp, locale_t locale, const wchar_t *fmt0, va_list ap)
if ((n = fmt - cp) != 0) {
if ((unsigned)ret + n > INT_MAX) {
ret = EOF;
+ errno = EOVERFLOW;
goto error;
}
PRINT(cp, n);
@@ -1003,6 +1005,7 @@ number: if ((dprec = prec) >= 0)
prsize = width > realsz ? width : realsz;
if ((unsigned)ret + prsize > INT_MAX) {
ret = EOF;
+ errno = EOVERFLOW;
goto error;
}
diff --git a/lib/libc/stdio/vfwscanf.c b/lib/libc/stdio/vfwscanf.c
index 22b08270897c..6b4d8c59b49c 100644
--- a/lib/libc/stdio/vfwscanf.c
+++ b/lib/libc/stdio/vfwscanf.c
@@ -101,13 +101,359 @@ __FBSDID("$FreeBSD$");
static int parsefloat(FILE *, wchar_t *, wchar_t *, locale_t);
#endif
-#define INCCL(_c) \
- (cclcompl ? (wmemchr(ccls, (_c), ccle - ccls) == NULL) : \
- (wmemchr(ccls, (_c), ccle - ccls) != NULL))
+struct ccl {
+ const wchar_t *start; /* character class start */
+ const wchar_t *end; /* character class end */
+ int compl; /* ccl is complemented? */
+};
+
+static __inline int
+inccl(const struct ccl *ccl, wint_t wi)
+{
+
+ if (ccl->compl) {
+ return (wmemchr(ccl->start, wi, ccl->end - ccl->start)
+ == NULL);
+ } else {
+ return (wmemchr(ccl->start, wi, ccl->end - ccl->start) != NULL);
+ }
+}
+
+/*
+ * Conversion functions are passed a pointer to this object instead of
+ * a real parameter to indicate that the assignment-suppression (*)
+ * flag was specified. We could use a NULL pointer to indicate this,
+ * but that would mask bugs in applications that call scanf() with a
+ * NULL pointer.
+ */
+static const int suppress;
+#define SUPPRESS_PTR ((void *)&suppress)
static const mbstate_t initial_mbs;
/*
+ * The following conversion functions return the number of characters consumed,
+ * or -1 on input failure. Character class conversion returns 0 on match
+ * failure.
+ */
+
+static __inline int
+convert_char(FILE *fp, char * __restrict mbp, int width, locale_t locale)
+{
+ mbstate_t mbs;
+ size_t nconv;
+ wint_t wi;
+ int n;
+ char mbbuf[MB_LEN_MAX];
+
+ n = 0;
+ mbs = initial_mbs;
+ while (width != 0 && (wi = __fgetwc(fp, locale)) != WEOF) {
+ if (width >= MB_CUR_MAX && mbp != SUPPRESS_PTR) {
+ nconv = wcrtomb(mbp, wi, &mbs);
+ if (nconv == (size_t)-1)
+ return (-1);
+ } else {
+ nconv = wcrtomb(mbbuf, wi, &mbs);
+ if (nconv == (size_t)-1)
+ return (-1);
+ if (nconv > width) {
+ __ungetwc(wi, fp, locale);
+ break;
+ }
+ if (mbp != SUPPRESS_PTR)
+ memcpy(mbp, mbbuf, nconv);
+ }
+ if (mbp != SUPPRESS_PTR)
+ mbp += nconv;
+ width -= nconv;
+ n++;
+ }
+ if (n == 0)
+ return (-1);
+ return (n);
+}
+
+static __inline int
+convert_wchar(FILE *fp, wchar_t *wcp, int width, locale_t locale)
+{
+ wint_t wi;
+ int n;
+
+ n = 0;
+ while (width-- != 0 && (wi = __fgetwc(fp, locale)) != WEOF) {
+ if (wcp != SUPPRESS_PTR)
+ *wcp++ = (wchar_t)wi;
+ n++;
+ }
+ if (n == 0)
+ return (-1);
+ return (n);
+}
+
+static __inline int
+convert_ccl(FILE *fp, char * __restrict mbp, int width, const struct ccl *ccl,
+ locale_t locale)
+{
+ mbstate_t mbs;
+ size_t nconv;
+ wint_t wi;
+ int n;
+ char mbbuf[MB_LEN_MAX];
+
+ n = 0;
+ mbs = initial_mbs;
+ while ((wi = __fgetwc(fp, locale)) != WEOF &&
+ width != 0 && inccl(ccl, wi)) {
+ if (width >= MB_CUR_MAX && mbp != SUPPRESS_PTR) {
+ nconv = wcrtomb(mbp, wi, &mbs);
+ if (nconv == (size_t)-1)
+ return (-1);
+ } else {
+ nconv = wcrtomb(mbbuf, wi, &mbs);
+ if (nconv == (size_t)-1)
+ return (-1);
+ if (nconv > width)
+ break;
+ if (mbp != SUPPRESS_PTR)
+ memcpy(mbp, mbbuf, nconv);
+ }
+ if (mbp != SUPPRESS_PTR)
+ mbp += nconv;
+ width -= nconv;
+ n++;
+ }
+ if (wi != WEOF)
+ __ungetwc(wi, fp, locale);
+ if (mbp != SUPPRESS_PTR)
+ *mbp = 0;
+ return (n);
+}
+
+static __inline int
+convert_wccl(FILE *fp, wchar_t *wcp, int width, const struct ccl *ccl,
+ locale_t locale)
+{
+ wchar_t *wcp0;
+ wint_t wi;
+ int n;
+
+ if (wcp == SUPPRESS_PTR) {
+ n = 0;
+ while ((wi = __fgetwc(fp, locale)) != WEOF &&
+ width-- != 0 && inccl(ccl, wi))
+ n++;
+ if (wi != WEOF)
+ __ungetwc(wi, fp, locale);
+ } else {
+ wcp0 = wcp;
+ while ((wi = __fgetwc(fp, locale)) != WEOF &&
+ width-- != 0 && inccl(ccl, wi))
+ *wcp++ = (wchar_t)wi;
+ if (wi != WEOF)
+ __ungetwc(wi, fp, locale);
+ n = wcp - wcp0;
+ if (n == 0)
+ return (0);
+ *wcp = 0;
+ }
+ return (n);
+}
+
+static __inline int
+convert_string(FILE *fp, char * __restrict mbp, int width, locale_t locale)
+{
+ mbstate_t mbs;
+ size_t nconv;
+ wint_t wi;
+ int nread;
+ char mbbuf[MB_LEN_MAX];
+
+ mbs = initial_mbs;
+ nread = 0;
+ while ((wi = __fgetwc(fp, locale)) != WEOF && width != 0 &&
+ !iswspace(wi)) {
+ if (width >= MB_CUR_MAX && mbp != SUPPRESS_PTR) {
+ nconv = wcrtomb(mbp, wi, &mbs);
+ if (nconv == (size_t)-1)
+ return (-1);
+ } else {
+ nconv = wcrtomb(mbbuf, wi, &mbs);
+ if (nconv == (size_t)-1)
+ return (-1);
+ if (nconv > width)
+ break;
+ if (mbp != SUPPRESS_PTR)
+ memcpy(mbp, mbbuf, nconv);
+ }
+ if (mbp != SUPPRESS_PTR)
+ mbp += nconv;
+ width -= nconv;
+ nread++;
+ }
+ if (wi != WEOF)
+ __ungetwc(wi, fp, locale);
+ if (mbp != SUPPRESS_PTR)
+ *mbp = 0;
+ return (nread);
+}
+
+static __inline int
+convert_wstring(FILE *fp, wchar_t *wcp, int width, locale_t locale)
+{
+ wchar_t *wcp0;
+ wint_t wi;
+ int nread;
+
+ nread = 0;
+ if (wcp == SUPPRESS_PTR) {
+ while ((wi = __fgetwc(fp, locale)) != WEOF &&
+ width-- != 0 && !iswspace(wi))
+ nread++;
+ if (wi != WEOF)
+ __ungetwc(wi, fp, locale);
+ } else {
+ wcp0 = wcp;
+ while ((wi = __fgetwc(fp, locale)) != WEOF &&
+ width-- != 0 && !iswspace(wi)) {
+ *wcp++ = (wchar_t)wi;
+ nread++;
+ }
+ if (wi != WEOF)
+ __ungetwc(wi, fp, locale);
+ *wcp = '\0';
+ }
+ return (nread);
+}
+
+/*
+ * Read an integer, storing it in buf. The only relevant bit in the
+ * flags argument is PFXOK.
+ *
+ * Return 0 on a match failure, and the number of characters read
+ * otherwise.
+ */
+static __inline int
+parseint(FILE *fp, wchar_t *buf, int width, int base, int flags,
+ locale_t locale)
+{
+ /* `basefix' is used to avoid `if' tests */
+ static const short basefix[17] =
+ { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
+ wchar_t *wcp;
+ int c;
+
+ flags |= SIGNOK | NDIGITS | NZDIGITS;
+ for (wcp = buf; width; width--) {
+ c = __fgetwc(fp, locale);
+ /*
+ * Switch on the character; `goto ok' if we accept it
+ * as a part of number.
+ */
+ switch (c) {
+
+ /*
+ * The digit 0 is always legal, but is special. For
+ * %i conversions, if no digits (zero or nonzero) have
+ * been scanned (only signs), we will have base==0.
+ * In that case, we should set it to 8 and enable 0x
+ * prefixing. Also, if we have not scanned zero
+ * digits before this, do not turn off prefixing
+ * (someone else will turn it off if we have scanned
+ * any nonzero digits).
+ */
+ case '0':
+ if (base == 0) {
+ base = 8;
+ flags |= PFXOK;
+ }
+ if (flags & NZDIGITS)
+ flags &= ~(SIGNOK|NZDIGITS|NDIGITS);
+ else
+ flags &= ~(SIGNOK|PFXOK|NDIGITS);
+ goto ok;
+
+ /* 1 through 7 always legal */
+ case '1': case '2': case '3':
+ case '4': case '5': case '6': case '7':
+ base = basefix[base];
+ flags &= ~(SIGNOK | PFXOK | NDIGITS);
+ goto ok;
+
+ /* digits 8 and 9 ok iff decimal or hex */
+ case '8': case '9':
+ base = basefix[base];
+ if (base <= 8)
+ break; /* not legal here */
+ flags &= ~(SIGNOK | PFXOK | NDIGITS);
+ goto ok;
+
+ /* letters ok iff hex */
+ case 'A': case 'B': case 'C':
+ case 'D': case 'E': case 'F':
+ case 'a': case 'b': case 'c':
+ case 'd': case 'e': case 'f':
+ /* no need to fix base here */
+ if (base <= 10)
+ break; /* not legal here */
+ flags &= ~(SIGNOK | PFXOK | NDIGITS);
+ goto ok;
+
+ /* sign ok only as first character */
+ case '+': case '-':
+ if (flags & SIGNOK) {
+ flags &= ~SIGNOK;
+ flags |= HAVESIGN;
+ goto ok;
+ }
+ break;
+
+ /*
+ * x ok iff flag still set & 2nd char (or 3rd char if
+ * we have a sign).
+ */
+ case 'x': case 'X':
+ if (flags & PFXOK && wcp ==
+ buf + 1 + !!(flags & HAVESIGN)) {
+ base = 16; /* if %i */
+ flags &= ~PFXOK;
+ goto ok;
+ }
+ break;
+ }
+
+ /*
+ * If we got here, c is not a legal character for a
+ * number. Stop accumulating digits.
+ */
+ if (c != WEOF)
+ __ungetwc(c, fp, locale);
+ break;
+ ok:
+ /*
+ * c is legal: store it and look at the next.
+ */
+ *wcp++ = (wchar_t)c;
+ }
+ /*
+ * If we had only a sign, it is no good; push back the sign.
+ * If the number ends in `x', it was [sign] '0' 'x', so push
+ * back the x and treat it as [sign] '0'.
+ */
+ if (flags & NDIGITS) {
+ if (wcp > buf)
+ __ungetwc(*--wcp, fp, locale);
+ return (0);
+ }
+ c = wcp[-1];
+ if (c == 'x' || c == 'X') {
+ --wcp;
+ __ungetwc(c, fp, locale);
+ }
+ return (wcp - buf);
+}
+
+/*
* MT-safe version.
*/
int
@@ -136,34 +482,23 @@ int
__vfwscanf(FILE * __restrict fp, locale_t locale,
const wchar_t * __restrict fmt, va_list ap)
{
+#define GETARG(type) ((flags & SUPPRESS) ? SUPPRESS_PTR : va_arg(ap, type))
wint_t c; /* character from format, or conversion */
size_t width; /* field width, or 0 */
- wchar_t *p; /* points into all kinds of strings */
- int n; /* handy integer */
int flags; /* flags as defined above */
- wchar_t *p0; /* saves original value of p when necessary */
int nassigned; /* number of fields assigned */
int nconversions; /* number of conversions */
+ int nr; /* characters read by the current conversion */
int nread; /* number of characters consumed from fp */
int base; /* base argument to conversion function */
+ struct ccl ccl; /* character class info */
wchar_t buf[BUF]; /* buffer for numeric conversions */
- const wchar_t *ccls; /* character class start */
- const wchar_t *ccle; /* character class end */
- int cclcompl; /* ccl is complemented? */
wint_t wi; /* handy wint_t */
- char *mbp; /* multibyte string pointer for %c %s %[ */
- size_t nconv; /* number of bytes in mb. conversion */
- char mbbuf[MB_LEN_MAX]; /* temporary mb. character buffer */
- mbstate_t mbs;
-
- /* `basefix' is used to avoid `if' tests in the integer scanner */
- static short basefix[17] =
- { 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
nassigned = 0;
nconversions = 0;
nread = 0;
- ccls = ccle = NULL;
+ ccl.start = ccl.end = NULL;
for (;;) {
c = *fmt++;
if (c == 0)
@@ -171,7 +506,7 @@ __vfwscanf(FILE * __restrict fp, locale_t locale,
if (iswspace(c)) {
while ((c = __fgetwc(fp, locale)) != WEOF &&
iswspace_l(c, locale))
- ;
+ nread++;
if (c != WEOF)
__ungetwc(c, fp, locale);
continue;
@@ -283,17 +618,17 @@ literal:
break;
case '[':
- ccls = fmt;
+ ccl.start = fmt;
if (*fmt == '^') {
- cclcompl = 1;
+ ccl.compl = 1;
fmt++;
} else
- cclcompl = 0;
+ ccl.compl = 0;
if (*fmt == ']')
fmt++;
while (*fmt != '\0' && *fmt != ']')
fmt++;
- ccle = fmt;
+ ccl.end = fmt;
fmt++;
flags |= NOSKIP;
c = CT_CCL;
@@ -315,7 +650,6 @@ literal:
break;
case 'n':
- nconversions++;
if (flags & SUPPRESS) /* ??? */
continue;
if (flags & SHORTSHORT)
@@ -368,57 +702,14 @@ literal:
if (width == 0)
width = 1;
if (flags & LONG) {
- if (!(flags & SUPPRESS))
- p = va_arg(ap, wchar_t *);
- n = 0;
- while (width-- != 0 &&
- (wi = __fgetwc(fp, locale)) != WEOF) {
- if (!(flags & SUPPRESS))
- *p++ = (wchar_t)wi;
- n++;
- }
- if (n == 0)
- goto input_failure;
- nread += n;
- if (!(flags & SUPPRESS))
- nassigned++;
+ nr = convert_wchar(fp, GETARG(wchar_t *), width,
+ locale);
} else {
- if (!(flags & SUPPRESS))
- mbp = va_arg(ap, char *);
- n = 0;
- mbs = initial_mbs;
- while (width != 0 &&
- (wi = __fgetwc(fp, locale)) != WEOF) {
- if (width >= MB_CUR_MAX &&
- !(flags & SUPPRESS)) {
- nconv = wcrtomb(mbp, wi, &mbs);
- if (nconv == (size_t)-1)
- goto input_failure;
- } else {
- nconv = wcrtomb(mbbuf, wi,
- &mbs);
- if (nconv == (size_t)-1)
- goto input_failure;
- if (nconv > width) {
- __ungetwc(wi, fp, locale);
- break;
- }
- if (!(flags & SUPPRESS))
- memcpy(mbp, mbbuf,
- nconv);
- }
- if (!(flags & SUPPRESS))
- mbp += nconv;
- width -= nconv;
- n++;
- }
- if (n == 0)
- goto input_failure;
- nread += n;
- if (!(flags & SUPPRESS))
- nassigned++;
+ nr = convert_char(fp, GETARG(char *), width,
+ locale);
}
- nconversions++;
+ if (nr < 0)
+ goto input_failure;
break;
case CT_CCL:
@@ -426,246 +717,49 @@ literal:
if (width == 0)
width = (size_t)~0; /* `infinity' */
/* take only those things in the class */
- if ((flags & SUPPRESS) && (flags & LONG)) {
- n = 0;
- while ((wi = __fgetwc(fp, locale)) != WEOF &&
- width-- != 0 && INCCL(wi))
- n++;
- if (wi != WEOF)
- __ungetwc(wi, fp, locale);
- if (n == 0)
- goto match_failure;
- } else if (flags & LONG) {
- p0 = p = va_arg(ap, wchar_t *);
- while ((wi = __fgetwc(fp, locale)) != WEOF &&
- width-- != 0 && INCCL(wi))
- *p++ = (wchar_t)wi;
- if (wi != WEOF)
- __ungetwc(wi, fp, locale);
- n = p - p0;
- if (n == 0)
- goto match_failure;
- *p = 0;
- nassigned++;
+ if (flags & LONG) {
+ nr = convert_wccl(fp, GETARG(wchar_t *), width,
+ &ccl, locale);
} else {
- if (!(flags & SUPPRESS))
- mbp = va_arg(ap, char *);
- n = 0;
- mbs = initial_mbs;
- while ((wi = __fgetwc(fp, locale)) != WEOF &&
- width != 0 && INCCL(wi)) {
- if (width >= MB_CUR_MAX &&
- !(flags & SUPPRESS)) {
- nconv = wcrtomb(mbp, wi, &mbs);
- if (nconv == (size_t)-1)
- goto input_failure;
- } else {
- nconv = wcrtomb(mbbuf, wi,
- &mbs);
- if (nconv == (size_t)-1)
- goto input_failure;
- if (nconv > width)
- break;
- if (!(flags & SUPPRESS))
- memcpy(mbp, mbbuf,
- nconv);
- }
- if (!(flags & SUPPRESS))
- mbp += nconv;
- width -= nconv;
- n++;
- }
- if (wi != WEOF)
- __ungetwc(wi, fp, locale);
- if (!(flags & SUPPRESS)) {
- *mbp = 0;
- nassigned++;
- }
+ nr = convert_ccl(fp, GETARG(char *), width,
+ &ccl, locale);
+ }
+ if (nr <= 0) {
+ if (nr < 0)
+ goto input_failure;
+ else /* nr == 0 */
+ goto match_failure;
}
- nread += n;
- nconversions++;
break;
case CT_STRING:
/* like CCL, but zero-length string OK, & no NOSKIP */
if (width == 0)
width = (size_t)~0;
- if ((flags & SUPPRESS) && (flags & LONG)) {
- while ((wi = __fgetwc(fp, locale)) != WEOF &&
- width-- != 0 &&
- !iswspace(wi))
- nread++;
- if (wi != WEOF)
- __ungetwc(wi, fp, locale);
- } else if (flags & LONG) {
- p0 = p = va_arg(ap, wchar_t *);
- while ((wi = __fgetwc(fp, locale)) != WEOF &&
- width-- != 0 &&
- !iswspace(wi)) {
- *p++ = (wchar_t)wi;
- nread++;
- }
- if (wi != WEOF)
- __ungetwc(wi, fp, locale);
- *p = '\0';
- nassigned++;
+ if (flags & LONG) {
+ nr = convert_wstring(fp, GETARG(wchar_t *),
+ width, locale);
} else {
- if (!(flags & SUPPRESS))
- mbp = va_arg(ap, char *);
- mbs = initial_mbs;
- while ((wi = __fgetwc(fp, locale)) != WEOF &&
- width != 0 &&
- !iswspace(wi)) {
- if (width >= MB_CUR_MAX &&
- !(flags & SUPPRESS)) {
- nconv = wcrtomb(mbp, wi, &mbs);
- if (nconv == (size_t)-1)
- goto input_failure;
- } else {
- nconv = wcrtomb(mbbuf, wi,
- &mbs);
- if (nconv == (size_t)-1)
- goto input_failure;
- if (nconv > width)
- break;
- if (!(flags & SUPPRESS))
- memcpy(mbp, mbbuf,
- nconv);
- }
- if (!(flags & SUPPRESS))
- mbp += nconv;
- width -= nconv;
- nread++;
- }
- if (wi != WEOF)
- __ungetwc(wi, fp, locale);
- if (!(flags & SUPPRESS)) {
- *mbp = 0;
- nassigned++;
- }
+ nr = convert_string(fp, GETARG(char *), width,
+ locale);
}
- nconversions++;
- continue;
+ if (nr < 0)
+ goto input_failure;
+ break;
case CT_INT:
/* scan an integer as if by the conversion function */
if (width == 0 || width > sizeof(buf) /
sizeof(*buf) - 1)
width = sizeof(buf) / sizeof(*buf) - 1;
- flags |= SIGNOK | NDIGITS | NZDIGITS;
- for (p = buf; width; width--) {
- c = __fgetwc(fp, locale);
- /*
- * Switch on the character; `goto ok'
- * if we accept it as a part of number.
- */
- switch (c) {
-
- /*
- * The digit 0 is always legal, but is
- * special. For %i conversions, if no
- * digits (zero or nonzero) have been
- * scanned (only signs), we will have
- * base==0. In that case, we should set
- * it to 8 and enable 0x prefixing.
- * Also, if we have not scanned zero digits
- * before this, do not turn off prefixing
- * (someone else will turn it off if we
- * have scanned any nonzero digits).
- */
- case '0':
- if (base == 0) {
- base = 8;
- flags |= PFXOK;
- }
- if (flags & NZDIGITS)
- flags &= ~(SIGNOK|NZDIGITS|NDIGITS);
- else
- flags &= ~(SIGNOK|PFXOK|NDIGITS);
- goto ok;
-
- /* 1 through 7 always legal */
- case '1': case '2': case '3':
- case '4': case '5': case '6': case '7':
- base = basefix[base];
- flags &= ~(SIGNOK | PFXOK | NDIGITS);
- goto ok;
-
- /* digits 8 and 9 ok iff decimal or hex */
- case '8': case '9':
- base = basefix[base];
- if (base <= 8)
- break; /* not legal here */
- flags &= ~(SIGNOK | PFXOK | NDIGITS);
- goto ok;
-
- /* letters ok iff hex */
- case 'A': case 'B': case 'C':
- case 'D': case 'E': case 'F':
- case 'a': case 'b': case 'c':
- case 'd': case 'e': case 'f':
- /* no need to fix base here */
- if (base <= 10)
- break; /* not legal here */
- flags &= ~(SIGNOK | PFXOK | NDIGITS);
- goto ok;
-
- /* sign ok only as first character */
- case '+': case '-':
- if (flags & SIGNOK) {
- flags &= ~SIGNOK;
- flags |= HAVESIGN;
- goto ok;
- }
- break;
-
- /*
- * x ok iff flag still set & 2nd char (or
- * 3rd char if we have a sign).
- */
- case 'x': case 'X':
- if (flags & PFXOK && p ==
- buf + 1 + !!(flags & HAVESIGN)) {
- base = 16; /* if %i */
- flags &= ~PFXOK;
- goto ok;
- }
- break;
- }
- /*
- * If we got here, c is not a legal character
- * for a number. Stop accumulating digits.
- */
- if (c != WEOF)
- __ungetwc(c, fp, locale);
- break;
- ok:
- /*
- * c is legal: store it and look at the next.
- */
- *p++ = (wchar_t)c;
- }
- /*
- * If we had only a sign, it is no good; push
- * back the sign. If the number ends in `x',
- * it was [sign] '0' 'x', so push back the x
- * and treat it as [sign] '0'.
- */
- if (flags & NDIGITS) {
- if (p > buf)
- __ungetwc(*--p, fp, locale);
+ nr = parseint(fp, buf, width, base, flags, locale);
+ if (nr == 0)
goto match_failure;
- }
- c = p[-1];
- if (c == 'x' || c == 'X') {
- --p;
- __ungetwc(c, fp, locale);
- }
if ((flags & SUPPRESS) == 0) {
uintmax_t res;
- *p = 0;
+ buf[nr] = L'\0';
if ((flags & UNSIGNED) == 0)
res = wcstoimax(buf, NULL, base);
else
@@ -689,10 +783,7 @@ literal:
*va_arg(ap, size_t *) = res;
else
*va_arg(ap, int *) = res;
- nassigned++;
}
- nread += p - buf;
- nconversions++;
break;
#ifndef NO_FLOATING_POINT
@@ -701,26 +792,28 @@ literal:
if (width == 0 || width > sizeof(buf) /
sizeof(*buf) - 1)
width = sizeof(buf) / sizeof(*buf) - 1;
- if ((width = parsefloat(fp, buf, buf + width, locale)) == 0)
+ nr = parsefloat(fp, buf, buf + width, locale);
+ if (nr == 0)
goto match_failure;
if ((flags & SUPPRESS) == 0) {
if (flags & LONGDBL) {
- long double res = wcstold(buf, &p);
+ long double res = wcstold(buf, NULL);
*va_arg(ap, long double *) = res;
} else if (flags & LONG) {
- double res = wcstod(buf, &p);
+ double res = wcstod(buf, NULL);
*va_arg(ap, double *) = res;
} else {
- float res = wcstof(buf, &p);
+ float res = wcstof(buf, NULL);
*va_arg(ap, float *) = res;
}
- nassigned++;
}
- nread += width;
- nconversions++;
break;
#endif /* !NO_FLOATING_POINT */
}
+ if (!(flags & SUPPRESS))
+ nassigned++;
+ nread += nr;
+ nconversions++;
}
input_failure:
return (nconversions != 0 ? nassigned : EOF);
diff --git a/lib/libc/stdio/vsnprintf.c b/lib/libc/stdio/vsnprintf.c
index d2bad0f09aa7..82959d1d082c 100644
--- a/lib/libc/stdio/vsnprintf.c
+++ b/lib/libc/stdio/vsnprintf.c
@@ -41,6 +41,7 @@ static char sccsid[] = "@(#)vsnprintf.c 8.1 (Berkeley) 6/4/93";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include "local.h"
@@ -59,8 +60,11 @@ vsnprintf_l(char * __restrict str, size_t n, locale_t locale,
on = n;
if (n != 0)
n--;
- if (n > INT_MAX)
- n = INT_MAX;
+ if (n > INT_MAX) {
+ errno = EOVERFLOW;
+ *str = '\0';
+ return (EOF);
+ }
/* Stdio internals do not deal correctly with zero length buffer */
if (n == 0) {
if (on > 0)
diff --git a/lib/libc/stdio/vswprintf.c b/lib/libc/stdio/vswprintf.c
index 023c53750f2d..2585888cfbca 100644
--- a/lib/libc/stdio/vswprintf.c
+++ b/lib/libc/stdio/vswprintf.c
@@ -39,6 +39,7 @@ __FBSDID("FreeBSD: src/lib/libc/stdio/vasprintf.c,v 1.16 2002/08/21 16:19:57 mik
__FBSDID("$FreeBSD$");
#include <errno.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>
@@ -61,11 +62,17 @@ vswprintf_l(wchar_t * __restrict s, size_t n, locale_t locale,
errno = EINVAL;
return (-1);
}
+ if (n - 1 > INT_MAX) {
+ errno = EOVERFLOW;
+ *s = L'\0';
+ return (-1);
+ }
f._flags = __SWR | __SSTR | __SALC;
f._bf._base = f._p = (unsigned char *)malloc(128);
if (f._bf._base == NULL) {
errno = ENOMEM;
+ *s = L'\0';
return (-1);
}
f._bf._size = f._w = 127; /* Leave room for the NUL */
@@ -74,6 +81,7 @@ vswprintf_l(wchar_t * __restrict s, size_t n, locale_t locale,
sverrno = errno;
free(f._bf._base);
errno = sverrno;
+ *s = L'\0';
return (-1);
}
*f._p = '\0';
@@ -87,6 +95,7 @@ vswprintf_l(wchar_t * __restrict s, size_t n, locale_t locale,
free(f._bf._base);
if (nwc == (size_t)-1) {
errno = EILSEQ;
+ *s = L'\0';
return (-1);
}
if (nwc == n) {
diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc
index 7db0f6063fd7..7fdb6e42dd7f 100644
--- a/lib/libc/stdlib/Makefile.inc
+++ b/lib/libc/stdlib/Makefile.inc
@@ -7,7 +7,7 @@
MISRCS+=_Exit.c a64l.c abort.c abs.c atexit.c atof.c atoi.c atol.c atoll.c \
bsearch.c div.c exit.c getenv.c getopt.c getopt_long.c \
getsubopt.c hcreate.c heapsort.c imaxabs.c imaxdiv.c \
- insque.c l64a.c labs.c ldiv.c llabs.c lldiv.c lsearch.c malloc.c \
+ insque.c l64a.c labs.c ldiv.c llabs.c lldiv.c lsearch.c \
merge.c ptsname.c qsort.c qsort_r.c quick_exit.c radixsort.c rand.c \
random.c reallocf.c realpath.c remque.c strfmon.c strtoimax.c \
strtol.c strtoll.c strtoq.c strtoul.c strtonum.c strtoull.c \
@@ -18,13 +18,13 @@ SYM_MAPS+= ${.CURDIR}/stdlib/Symbol.map
# machine-dependent stdlib sources
.sinclude "${.CURDIR}/${LIBC_ARCH}/stdlib/Makefile.inc"
-MAN+= a64l.3 abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 \
- at_quick_exit.3 bsearch.3 \
+MAN+= a64l.3 abort.3 abs.3 alloca.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 \
- lsearch.3 malloc.3 memory.3 posix_memalign.3 ptsname.3 qsort.3 \
+ lsearch.3 memory.3 ptsname.3 qsort.3 \
quick_exit.3 \
- radixsort.3 rand.3 random.3 \
+ radixsort.3 rand.3 random.3 reallocf.3 \
realpath.3 strfmon.3 strtod.3 strtol.3 strtonum.3 strtoul.3 system.3 \
tsearch.3
@@ -45,11 +45,4 @@ MLINKS+=radixsort.3 sradixsort.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+=malloc.3 calloc.3 malloc.3 free.3 malloc.3 malloc.conf.5 \
- malloc.3 realloc.3 malloc.3 reallocf.3 malloc.3 malloc_usable_size.3
MLINKS+=tsearch.3 tdelete.3 tsearch.3 tfind.3 tsearch.3 twalk.3
-
-.if defined(MALLOC_PRODUCTION)
-CFLAGS+= -DMALLOC_PRODUCTION
-.endif
-
diff --git a/lib/libc/stdlib/Symbol.map b/lib/libc/stdlib/Symbol.map
index 897bccd75411..6a1798f88eab 100644
--- a/lib/libc/stdlib/Symbol.map
+++ b/lib/libc/stdlib/Symbol.map
@@ -47,14 +47,6 @@ FBSD_1.0 {
lldiv;
lsearch;
lfind;
- _malloc_options;
- _malloc_message;
- malloc;
- posix_memalign;
- calloc;
- realloc;
- free;
- malloc_usable_size;
mergesort;
putenv;
qsort_r;
@@ -93,18 +85,18 @@ FBSD_1.0 {
};
FBSD_1.3 {
+ at_quick_exit;
atof_l;
atoi_l;
atol_l;
atoll_l;
- at_quick_exit;
quick_exit;
strtod_l;
- strtol_l;
- strtoll_l;
strtof_l;
strtoimax_l;
+ strtol_l;
strtold_l;
+ strtoll_l;
strtoq_l;
strtoul_l;
strtoull_l;
@@ -113,9 +105,6 @@ FBSD_1.3 {
};
FBSDprivate_1.0 {
- _malloc_thread_cleanup;
- _malloc_prefork;
- _malloc_postfork;
__system;
_system;
};
diff --git a/lib/libc/stdlib/at_quick_exit.3 b/lib/libc/stdlib/at_quick_exit.3
index 7f989637a40c..a75c0c0a3b12 100644
--- a/lib/libc/stdlib/at_quick_exit.3
+++ b/lib/libc/stdlib/at_quick_exit.3
@@ -1,6 +1,6 @@
.\" Copyright (c) 2011 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:
@@ -9,7 +9,7 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this 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
@@ -21,7 +21,7 @@
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
-.\"
+.\"
.\" $FreeBSD$
.\"
.Dd December 7, 2011
@@ -40,16 +40,16 @@
The
.Fn at_quick_exit
function registers a cleanup function to be called when the program exits as a
-result of calling
+result of calling
.Xr quick_exit 3 .
The cleanup functions are called in the reverse order and will not be called if
-the program exits by calling
+the program exits by calling
.Xr exit 3 ,
.Xr _Exit 3 ,
or
.Xr abort 3 .
.Sh RETURN VALUES
-The
+The
.Fn at_quick_exit
function returns the value 0 if successful and a non-zero value on failure.
.Sh SEE ALSO
diff --git a/lib/libc/stdlib/getenv.3 b/lib/libc/stdlib/getenv.3
index fd7d856f0481..bc87b9d54cbb 100644
--- a/lib/libc/stdlib/getenv.3
+++ b/lib/libc/stdlib/getenv.3
@@ -201,7 +201,7 @@ function appeared in
Until
.Fx 7.0 ,
.Fn putenv
-would make a copy of
+would make a copy of
.Fa string
and insert it into the environment using
.Fn setenv .
diff --git a/lib/libc/stdlib/jemalloc/Makefile.inc b/lib/libc/stdlib/jemalloc/Makefile.inc
new file mode 100644
index 000000000000..971867638494
--- /dev/null
+++ b/lib/libc/stdlib/jemalloc/Makefile.inc
@@ -0,0 +1,46 @@
+# $FreeBSD$
+
+.PATH: ${.CURDIR}/stdlib/jemalloc
+
+JEMALLOCSRCS:= jemalloc.c arena.c atomic.c base.c bitmap.c chunk.c \
+ chunk_dss.c chunk_mmap.c ckh.c ctl.c extent.c hash.c huge.c mb.c \
+ mutex.c prof.c quarantine.c rtree.c stats.c tcache.c util.c tsd.c
+
+SYM_MAPS+=${.CURDIR}/stdlib/jemalloc/Symbol.map
+
+CFLAGS+=-I${.CURDIR}/../../contrib/jemalloc/include
+
+.for src in ${JEMALLOCSRCS}
+MISRCS+=jemalloc_${src}
+CLEANFILES+=jemalloc_${src}
+jemalloc_${src}:
+ ln -sf ${.CURDIR}/../../contrib/jemalloc/src/${src} ${.TARGET}
+.endfor
+
+MAN+=jemalloc.3
+CLEANFILES+=jemalloc.3
+jemalloc.3:
+ ln -sf ${.CURDIR}/../../contrib/jemalloc/doc/jemalloc.3 ${.TARGET}
+
+MLINKS+= \
+ jemalloc.3 malloc.3 \
+ jemalloc.3 calloc.3 \
+ jemalloc.3 posix_memalign.3 \
+ jemalloc.3 aligned_alloc.3 \
+ jemalloc.3 realloc.3 \
+ jemalloc.3 free.3 \
+ jemalloc.3 malloc_usable_size.3 \
+ jemalloc.3 malloc_stats_print.3 \
+ jemalloc.3 mallctl.3 \
+ jemalloc.3 mallctlnametomib.3 \
+ jemalloc.3 mallctlbymib.3 \
+ jemalloc.3 allocm.3 \
+ jemalloc.3 rallocm.3 \
+ jemalloc.3 sallocm.3 \
+ jemalloc.3 dallocm.3 \
+ jemalloc.3 nallocm.3 \
+ jemalloc.3 malloc.conf.5
+
+.if defined(MALLOC_PRODUCTION)
+CFLAGS+= -DMALLOC_PRODUCTION
+.endif
diff --git a/lib/libc/stdlib/jemalloc/Symbol.map b/lib/libc/stdlib/jemalloc/Symbol.map
new file mode 100644
index 000000000000..b98d37ae5bf0
--- /dev/null
+++ b/lib/libc/stdlib/jemalloc/Symbol.map
@@ -0,0 +1,35 @@
+/*
+ * $FreeBSD$
+ */
+
+FBSD_1.0 {
+ _malloc_options;
+ _malloc_message;
+ malloc;
+ posix_memalign;
+ calloc;
+ realloc;
+ free;
+ malloc_usable_size;
+};
+
+FBSD_1.3 {
+ malloc_conf;
+ malloc_message;
+ aligned_alloc;
+ malloc_stats_print;
+ mallctl;
+ mallctlnametomib;
+ mallctlbymib;
+ allocm;
+ rallocm;
+ sallocm;
+ dallocm;
+ nallocm;
+};
+
+FBSDprivate_1.0 {
+ _malloc_thread_cleanup;
+ _malloc_prefork;
+ _malloc_postfork;
+};
diff --git a/lib/libc/stdlib/malloc.3 b/lib/libc/stdlib/malloc.3
deleted file mode 100644
index 5f097333b86a..000000000000
--- a/lib/libc/stdlib/malloc.3
+++ /dev/null
@@ -1,591 +0,0 @@
-.\" Copyright (c) 1980, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" the American National Standards Committee X3, on Information
-.\" Processing Systems.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" @(#)malloc.3 8.1 (Berkeley) 6/4/93
-.\" $FreeBSD$
-.\"
-.Dd January 31, 2010
-.Dt MALLOC 3
-.Os
-.Sh NAME
-.Nm malloc , calloc , realloc , free , reallocf , malloc_usable_size
-.Nd general purpose memory allocation functions
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In stdlib.h
-.Ft void *
-.Fn malloc "size_t size"
-.Ft void *
-.Fn calloc "size_t number" "size_t size"
-.Ft void *
-.Fn realloc "void *ptr" "size_t size"
-.Ft void *
-.Fn reallocf "void *ptr" "size_t size"
-.Ft void
-.Fn free "void *ptr"
-.Ft const char *
-.Va _malloc_options ;
-.Ft void
-.Fn \*(lp*_malloc_message\*(rp "const char *p1" "const char *p2" "const char *p3" "const char *p4"
-.In malloc_np.h
-.Ft size_t
-.Fn malloc_usable_size "const void *ptr"
-.Sh DESCRIPTION
-The
-.Fn malloc
-function allocates
-.Fa size
-bytes of uninitialized memory.
-The allocated space is suitably aligned (after possible pointer coercion)
-for storage of any type of object.
-.Pp
-The
-.Fn calloc
-function allocates space for
-.Fa number
-objects,
-each
-.Fa size
-bytes in length.
-The result is identical to calling
-.Fn malloc
-with an argument of
-.Dq "number * size" ,
-with the exception that the allocated memory is explicitly initialized
-to zero bytes.
-.Pp
-The
-.Fn realloc
-function changes the size of the previously allocated memory referenced by
-.Fa ptr
-to
-.Fa size
-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
-.Fa ptr
-is freed and a pointer to the newly allocated memory is returned.
-Note that
-.Fn realloc
-and
-.Fn reallocf
-may move the memory allocation, resulting in a different return value than
-.Fa ptr .
-If
-.Fa ptr
-is
-.Dv NULL ,
-the
-.Fn realloc
-function behaves identically to
-.Fn malloc
-for the specified size.
-.Pp
-The
-.Fn reallocf
-function is identical to the
-.Fn realloc
-function, except that it
-will free the passed pointer when the requested memory cannot be allocated.
-This is a
-.Fx
-specific API designed to ease the problems with traditional coding styles
-for
-.Fn realloc
-causing memory leaks in libraries.
-.Pp
-The
-.Fn free
-function causes the allocated memory referenced by
-.Fa ptr
-to be made available for future allocations.
-If
-.Fa ptr
-is
-.Dv NULL ,
-no action occurs.
-.Pp
-The
-.Fn malloc_usable_size
-function returns the usable size of the allocation pointed to by
-.Fa ptr .
-The return value may be larger than the size that was requested during
-allocation.
-The
-.Fn malloc_usable_size
-function is not a mechanism for in-place
-.Fn realloc ;
-rather it is provided solely as a tool for introspection purposes.
-Any discrepancy between the requested allocation size and the size reported by
-.Fn malloc_usable_size
-should not be depended on, since such behavior is entirely
-implementation-dependent.
-.Sh TUNING
-Once, when the first call is made to one of these memory allocation
-routines, various flags will be set or reset, which affects the
-workings of this allocator implementation.
-.Pp
-The
-.Dq name
-of the file referenced by the symbolic link named
-.Pa /etc/malloc.conf ,
-the value of the environment variable
-.Ev MALLOC_OPTIONS ,
-and the string pointed to by the global variable
-.Va _malloc_options
-will be interpreted, in that order, from left to right as flags.
-.Pp
-Each flag is a single letter, optionally prefixed by a non-negative base 10
-integer repetition count.
-For example,
-.Dq 3N
-is equivalent to
-.Dq NNN .
-Some flags control parameter magnitudes, where uppercase increases the
-magnitude, and lowercase decreases the magnitude.
-Other flags control boolean parameters, where uppercase indicates that a
-behavior is set, or on, and lowercase means that a behavior is not set, or off.
-.Bl -tag -width indent
-.It A
-All warnings (except for the warning about unknown
-flags being set) become fatal.
-The process will call
-.Xr abort 3
-in these cases.
-.It C
-Double/halve the size of the maximum size class that is a multiple of the
-cacheline size (64).
-Above this size, subpage spacing (256 bytes) is used for size classes.
-The default value is 512 bytes.
-.It D
-Use
-.Xr sbrk 2
-to acquire memory in the data storage segment (DSS).
-This option is enabled by default.
-See the
-.Dq M
-option for related information and interactions.
-.It E
-Double/halve the size of the maximum medium size class.
-The valid range is from one page to one half chunk.
-The default value is 32 KiB.
-.It F
-Halve/double the per-arena minimum ratio of active to dirty pages.
-Some dirty unused pages may be allowed to accumulate, within the limit set by
-the ratio, before informing the kernel about at least half of those pages via
-.Xr madvise 2 .
-This provides the kernel with sufficient information to recycle dirty pages if
-physical memory becomes scarce and the pages remain unused.
-The default minimum ratio is 32:1;
-.Ev MALLOC_OPTIONS=6F
-will disable dirty page purging.
-.It G
-Double/halve the approximate interval (counted in terms of
-thread-specific cache allocation/deallocation events) between full
-thread-specific cache garbage collection sweeps.
-Garbage collection is actually performed incrementally, one size
-class at a time, in order to avoid large collection pauses.
-The default sweep interval is 8192;
-.Ev MALLOC_OPTIONS=14g
-will disable garbage collection.
-.It H
-Double/halve the number of thread-specific cache slots per size
-class.
-When there are multiple threads, each thread uses a
-thread-specific cache for small and medium objects.
-Thread-specific caching allows many allocations to be satisfied
-without performing any thread synchronization, at the cost of
-increased memory use.
-See the
-.Dq G
-option for related tuning information.
-The default number of cache slots is 128;
-.Ev MALLOC_OPTIONS=7h
-will disable thread-specific caching.
-Note that one cache slot per size class is not a valid
-configuration due to implementation details.
-.It J
-Each byte of new memory allocated by
-.Fn malloc ,
-.Fn realloc ,
-or
-.Fn reallocf
-will be initialized to 0xa5.
-All memory returned by
-.Fn free ,
-.Fn realloc ,
-or
-.Fn reallocf
-will be initialized to 0x5a.
-This is intended for debugging and will impact performance negatively.
-.It K
-Double/halve the virtual memory chunk size.
-The default chunk size is 4 MiB.
-.It M
-Use
-.Xr mmap 2
-to acquire anonymously mapped memory.
-This option is enabled by default.
-If both the
-.Dq D
-and
-.Dq M
-options are enabled, the allocator prefers anonymous mappings over the DSS,
-but allocation only fails if memory cannot be acquired via either method.
-If neither option is enabled, then the
-.Dq M
-option is implicitly enabled in order to assure that there is a method for
-acquiring memory.
-.It N
-Double/halve the number of arenas.
-The default number of arenas is two times the number of CPUs, or one if there
-is a single CPU.
-.It P
-Various statistics are printed at program exit via an
-.Xr atexit 3
-function.
-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.
-Therefore, this option should only be used with care; it is primarily intended
-as a performance tuning aid during application development.
-.It Q
-Double/halve the size of the maximum size class that is a multiple of the
-quantum (8 or 16 bytes, depending on architecture).
-Above this size, cacheline spacing is used for size classes.
-The default value is 128 bytes.
-.It U
-Generate
-.Dq utrace
-entries for
-.Xr ktrace 1 ,
-for all operations.
-Consult the source for details on this option.
-.It V
-Attempting to allocate zero bytes will return a
-.Dv NULL
-pointer instead of a valid pointer.
-(The default behavior is to make a minimal allocation and return a
-pointer to it.)
-This option is provided for System V compatibility.
-This option is incompatible with the
-.Dq X
-option.
-.It X
-Rather than return failure for any allocation function, display a diagnostic
-message on
-.Dv STDERR_FILENO
-and cause the program to drop core (using
-.Xr abort 3 ) .
-This option should be set at compile time by including the following in the
-source code:
-.Bd -literal -offset indent
-_malloc_options = "X";
-.Ed
-.It Z
-Each byte of new memory allocated by
-.Fn malloc ,
-.Fn realloc ,
-or
-.Fn reallocf
-will be initialized to 0.
-Note that this initialization only happens once for each byte, so
-.Fn realloc
-and
-.Fn reallocf
-calls do not zero memory that was previously allocated.
-This is intended for debugging and will impact performance negatively.
-.El
-.Pp
-The
-.Dq J
-and
-.Dq Z
-options are intended for testing and debugging.
-An application which changes its behavior when these options are used
-is flawed.
-.Sh IMPLEMENTATION NOTES
-Traditionally, allocators have used
-.Xr sbrk 2
-to obtain memory, which is suboptimal for several reasons, including race
-conditions, increased fragmentation, and artificial limitations on maximum
-usable memory.
-This allocator uses both
-.Xr sbrk 2
-and
-.Xr mmap 2
-by default, but it can be configured at run time to use only one or the other.
-If resource limits are not a primary concern, the preferred configuration is
-.Ev MALLOC_OPTIONS=dM
-or
-.Ev MALLOC_OPTIONS=DM .
-When so configured, the
-.Ar datasize
-resource limit has little practical effect for typical applications; use
-.Ev MALLOC_OPTIONS=Dm
-if that is a concern.
-Regardless of allocator configuration, the
-.Ar vmemoryuse
-resource limit can be used to bound the total virtual memory used by a
-process, as described in
-.Xr limits 1 .
-.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
-for small and medium objects, in order to make it possible to completely avoid
-synchronization for most small and medium 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 equal-sized chunks, where the chunk size is
-a power of two that is greater than the page size.
-Chunks are always aligned to multiples of the chunk size.
-This alignment makes it possible to find metadata for user objects very
-quickly.
-.Pp
-User objects are broken into four categories according to size: small, medium,
-large, and huge.
-Small objects are smaller than one page.
-Medium objects range from one page to an upper limit determined at run time (see
-the
-.Dq E
-option).
-Large objects are smaller than the chunk size.
-Huge objects are a multiple of the chunk size.
-Small, medium, and large objects are managed by arenas; huge objects are managed
-separately in a single data structure that is shared by all threads.
-Huge objects are used by applications infrequently enough that this single
-data structure is not a scalability issue.
-.Pp
-Each chunk that is managed by an arena tracks its contents as runs of
-contiguous pages (unused, backing a set of small or medium objects, or backing
-one large object).
-The combination of chunk alignment and chunk page maps makes it possible to
-determine all metadata regarding small and large allocations in constant time.
-.Pp
-Small and medium objects are managed in groups by page runs.
-Each run maintains a bitmap that tracks 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.
-Allocation requests that are more than half the quantum, but no more than the
-minimum cacheline-multiple size class (see the
-.Dq Q
-option) are rounded up to the nearest multiple of the quantum.
-Allocation requests that are more than the minimum cacheline-multiple size
-class, but no more than the minimum subpage-multiple size class (see the
-.Dq C
-option) are rounded up to the nearest multiple of the cacheline size (64).
-Allocation requests that are more than the minimum subpage-multiple size class,
-but no more than the maximum subpage-multiple size class are rounded up to the
-nearest multiple of the subpage size (256).
-Allocation requests that are more than the maximum subpage-multiple size class,
-but no more than the maximum medium size class (see the
-.Dq M
-option) are rounded up to the nearest medium size class; spacing is an
-automatically determined power of two and ranges from the subpage size to the
-page size.
-Allocation requests that are more than the maximum medium size class, but small
-enough to fit in an arena-managed chunk (see the
-.Dq K
-option), are rounded up to the nearest run size.
-Allocation requests that are too large to fit in an arena-managed chunk are
-rounded up to the nearest multiple of the chunk size.
-.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.
-.Sh DEBUGGING MALLOC PROBLEMS
-The first thing to do is to set the
-.Dq A
-option.
-This option forces a coredump (if possible) at the first sign of trouble,
-rather than the normal policy of trying to continue if at all possible.
-.Pp
-It is probably also a good idea to recompile the program with suitable
-options and symbols for debugger support.
-.Pp
-If the program starts to give unusual results, coredump or generally behave
-differently without emitting any of the messages mentioned in the next
-section, it is likely because it depends on the storage being filled with
-zero bytes.
-Try running it with the
-.Dq Z
-option set;
-if that improves the situation, this diagnosis has been confirmed.
-If the program still misbehaves,
-the likely problem is accessing memory outside the allocated area.
-.Pp
-Alternatively, if the symptoms are not easy to reproduce, setting the
-.Dq J
-option may help provoke the problem.
-.Pp
-In truly difficult cases, the
-.Dq U
-option, if supported by the kernel, can provide a detailed trace of
-all calls made to these functions.
-.Pp
-Unfortunately this implementation does not provide much detail about
-the problems it detects; the performance impact for storing such information
-would be prohibitive.
-There are a number of allocator implementations available on the Internet
-which focus on detecting and pinpointing problems by trading performance for
-extra sanity checks and detailed diagnostics.
-.Sh DIAGNOSTIC MESSAGES
-If any of the memory allocation/deallocation functions detect an error or
-warning condition, a message will be printed to file descriptor
-.Dv STDERR_FILENO .
-Errors will result in the process dumping core.
-If the
-.Dq A
-option is set, all warnings are treated as errors.
-.Pp
-The
-.Va _malloc_message
-variable allows the programmer to override the function which emits the text
-strings forming the errors and warnings if for some reason the
-.Dv STDERR_FILENO
-file descriptor is not suitable for this.
-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
-.Dq Ao Ar progname Ac Ns Li : (malloc) .
-.Sh RETURN VALUES
-The
-.Fn malloc
-and
-.Fn calloc
-functions return a pointer to the allocated memory if successful; otherwise
-a
-.Dv NULL
-pointer is returned and
-.Va errno
-is set to
-.Er ENOMEM .
-.Pp
-The
-.Fn realloc
-and
-.Fn reallocf
-functions return a pointer, possibly identical to
-.Fa ptr ,
-to the allocated memory
-if successful; otherwise a
-.Dv NULL
-pointer is returned, and
-.Va errno
-is set to
-.Er ENOMEM
-if the error was the result of an allocation failure.
-The
-.Fn realloc
-function always leaves the original buffer intact
-when an error occurs, whereas
-.Fn reallocf
-deallocates it in this case.
-.Pp
-The
-.Fn free
-function returns no value.
-.Pp
-The
-.Fn malloc_usable_size
-function returns the usable size of the allocation pointed to by
-.Fa ptr .
-.Sh ENVIRONMENT
-The following environment variables affect the execution of the allocation
-functions:
-.Bl -tag -width ".Ev MALLOC_OPTIONS"
-.It Ev MALLOC_OPTIONS
-If the environment variable
-.Ev MALLOC_OPTIONS
-is set, the characters it contains will be interpreted as flags to the
-allocation functions.
-.El
-.Sh EXAMPLES
-To dump core whenever a problem occurs:
-.Bd -literal -offset indent
-ln -s 'A' /etc/malloc.conf
-.Ed
-.Pp
-To specify in the source that a program does no return value checking
-on calls to these functions:
-.Bd -literal -offset indent
-_malloc_options = "X";
-.Ed
-.Sh SEE ALSO
-.Xr limits 1 ,
-.Xr madvise 2 ,
-.Xr mmap 2 ,
-.Xr sbrk 2 ,
-.Xr alloca 3 ,
-.Xr atexit 3 ,
-.Xr getpagesize 3 ,
-.Xr getpagesizes 3 ,
-.Xr memory 3 ,
-.Xr posix_memalign 3
-.Sh STANDARDS
-The
-.Fn malloc ,
-.Fn calloc ,
-.Fn realloc
-and
-.Fn free
-functions conform to
-.St -isoC .
-.Sh HISTORY
-The
-.Fn reallocf
-function first appeared in
-.Fx 3.0 .
-.Pp
-The
-.Fn malloc_usable_size
-function first appeared in
-.Fx 7.0 .
diff --git a/lib/libc/stdlib/posix_memalign.3 b/lib/libc/stdlib/posix_memalign.3
deleted file mode 100644
index b092cedd0598..000000000000
--- a/lib/libc/stdlib/posix_memalign.3
+++ /dev/null
@@ -1,96 +0,0 @@
-.\" Copyright (C) 2006 Jason Evans <jasone@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.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd January 11, 2006
-.Dt POSIX_MEMALIGN 3
-.Os
-.Sh NAME
-.Nm posix_memalign
-.Nd aligned memory allocation
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.In stdlib.h
-.Ft int
-.Fn posix_memalign "void **ptr" "size_t alignment" "size_t size"
-.Sh DESCRIPTION
-The
-.Fn posix_memalign
-function allocates
-.Fa size
-bytes of memory such that the allocation's base address is an even multiple of
-.Fa alignment ,
-and returns the allocation in the value pointed to by
-.Fa ptr .
-.Pp
-The requested
-.Fa alignment
-must be a power of 2 at least as large as
-.Fn sizeof "void *" .
-.Pp
-Memory that is allocated via
-.Fn posix_memalign
-can be used as an argument in subsequent calls to
-.Xr realloc 3 ,
-.Xr reallocf 3 ,
-and
-.Xr free 3 .
-.Sh RETURN VALUES
-The
-.Fn posix_memalign
-function returns the value 0 if successful; otherwise it returns an error value.
-.Sh ERRORS
-The
-.Fn posix_memalign
-function will fail if:
-.Bl -tag -width Er
-.It Bq Er EINVAL
-The
-.Fa alignment
-parameter is not a power of 2 at least as large as
-.Fn sizeof "void *" .
-.It Bq Er ENOMEM
-Memory allocation error.
-.El
-.Sh SEE ALSO
-.Xr free 3 ,
-.Xr malloc 3 ,
-.Xr realloc 3 ,
-.Xr reallocf 3 ,
-.Xr valloc 3
-.Sh STANDARDS
-The
-.Fn posix_memalign
-function conforms to
-.St -p1003.1-2001 .
-.Sh HISTORY
-The
-.Fn posix_memalign
-function first appeared in
-.Fx 7.0 .
diff --git a/lib/libc/stdlib/ql.h b/lib/libc/stdlib/ql.h
deleted file mode 100644
index a1bc3abc238f..000000000000
--- a/lib/libc/stdlib/ql.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 2002 Jason Evans <jasone@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
- * unmodified other than the allowable 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.
- *
- ******************************************************************************/
-
-#ifndef QL_H_
-#define QL_H_
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * List definitions.
- */
-#define ql_head(a_type) \
-struct { \
- a_type *qlh_first; \
-}
-
-#define ql_head_initializer(a_head) {NULL}
-
-#define ql_elm(a_type) qr(a_type)
-
-/* List functions. */
-#define ql_new(a_head) do { \
- (a_head)->qlh_first = NULL; \
-} while (0)
-
-#define ql_elm_new(a_elm, a_field) qr_new((a_elm), a_field)
-
-#define ql_first(a_head) ((a_head)->qlh_first)
-
-#define ql_last(a_head, a_field) \
- ((ql_first(a_head) != NULL) \
- ? qr_prev(ql_first(a_head), a_field) : NULL)
-
-#define ql_next(a_head, a_elm, a_field) \
- ((ql_last(a_head, a_field) != (a_elm)) \
- ? qr_next((a_elm), a_field) : NULL)
-
-#define ql_prev(a_head, a_elm, a_field) \
- ((ql_first(a_head) != (a_elm)) ? qr_prev((a_elm), a_field) \
- : NULL)
-
-#define ql_before_insert(a_head, a_qlelm, a_elm, a_field) do { \
- qr_before_insert((a_qlelm), (a_elm), a_field); \
- if (ql_first(a_head) == (a_qlelm)) { \
- ql_first(a_head) = (a_elm); \
- } \
-} while (0)
-
-#define ql_after_insert(a_qlelm, a_elm, a_field) \
- qr_after_insert((a_qlelm), (a_elm), a_field)
-
-#define ql_head_insert(a_head, a_elm, a_field) do { \
- if (ql_first(a_head) != NULL) { \
- qr_before_insert(ql_first(a_head), (a_elm), a_field); \
- } \
- ql_first(a_head) = (a_elm); \
-} while (0)
-
-#define ql_tail_insert(a_head, a_elm, a_field) do { \
- if (ql_first(a_head) != NULL) { \
- qr_before_insert(ql_first(a_head), (a_elm), a_field); \
- } \
- ql_first(a_head) = qr_next((a_elm), a_field); \
-} while (0)
-
-#define ql_remove(a_head, a_elm, a_field) do { \
- if (ql_first(a_head) == (a_elm)) { \
- ql_first(a_head) = qr_next(ql_first(a_head), a_field); \
- } \
- if (ql_first(a_head) != (a_elm)) { \
- qr_remove((a_elm), a_field); \
- } else { \
- ql_first(a_head) = NULL; \
- } \
-} while (0)
-
-#define ql_head_remove(a_head, a_type, a_field) do { \
- a_type *t = ql_first(a_head); \
- ql_remove((a_head), t, a_field); \
-} while (0)
-
-#define ql_tail_remove(a_head, a_type, a_field) do { \
- a_type *t = ql_last(a_head, a_field); \
- ql_remove((a_head), t, a_field); \
-} while (0)
-
-#define ql_foreach(a_var, a_head, a_field) \
- qr_foreach((a_var), ql_first(a_head), a_field)
-
-#define ql_reverse_foreach(a_var, a_head, a_field) \
- qr_reverse_foreach((a_var), ql_first(a_head), a_field)
-
-#endif /* QL_H_ */
diff --git a/lib/libc/stdlib/qr.h b/lib/libc/stdlib/qr.h
deleted file mode 100644
index 6e02321be55c..000000000000
--- a/lib/libc/stdlib/qr.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/******************************************************************************
- *
- * Copyright (C) 2002 Jason Evans <jasone@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
- * unmodified other than the allowable 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.
- *
- ******************************************************************************/
-
-#ifndef QR_H_
-#define QR_H_
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/* Ring definitions. */
-#define qr(a_type) \
-struct { \
- a_type *qre_next; \
- a_type *qre_prev; \
-}
-
-/* Ring functions. */
-#define qr_new(a_qr, a_field) do { \
- (a_qr)->a_field.qre_next = (a_qr); \
- (a_qr)->a_field.qre_prev = (a_qr); \
-} while (0)
-
-#define qr_next(a_qr, a_field) ((a_qr)->a_field.qre_next)
-
-#define qr_prev(a_qr, a_field) ((a_qr)->a_field.qre_prev)
-
-#define qr_before_insert(a_qrelm, a_qr, a_field) do { \
- (a_qr)->a_field.qre_prev = (a_qrelm)->a_field.qre_prev; \
- (a_qr)->a_field.qre_next = (a_qrelm); \
- (a_qr)->a_field.qre_prev->a_field.qre_next = (a_qr); \
- (a_qrelm)->a_field.qre_prev = (a_qr); \
-} while (0)
-
-#define qr_after_insert(a_qrelm, a_qr, a_field) \
- do \
- { \
- (a_qr)->a_field.qre_next = (a_qrelm)->a_field.qre_next; \
- (a_qr)->a_field.qre_prev = (a_qrelm); \
- (a_qr)->a_field.qre_next->a_field.qre_prev = (a_qr); \
- (a_qrelm)->a_field.qre_next = (a_qr); \
- } while (0)
-
-#define qr_meld(a_qr_a, a_qr_b, a_field) do { \
- void *t; \
- (a_qr_a)->a_field.qre_prev->a_field.qre_next = (a_qr_b); \
- (a_qr_b)->a_field.qre_prev->a_field.qre_next = (a_qr_a); \
- t = (a_qr_a)->a_field.qre_prev; \
- (a_qr_a)->a_field.qre_prev = (a_qr_b)->a_field.qre_prev; \
- (a_qr_b)->a_field.qre_prev = t; \
-} while (0)
-
-/* qr_meld() and qr_split() are functionally equivalent, so there's no need to
- * have two copies of the code. */
-#define qr_split(a_qr_a, a_qr_b, a_field) \
- qr_meld((a_qr_a), (a_qr_b), a_field)
-
-#define qr_remove(a_qr, a_field) do { \
- (a_qr)->a_field.qre_prev->a_field.qre_next \
- = (a_qr)->a_field.qre_next; \
- (a_qr)->a_field.qre_next->a_field.qre_prev \
- = (a_qr)->a_field.qre_prev; \
- (a_qr)->a_field.qre_next = (a_qr); \
- (a_qr)->a_field.qre_prev = (a_qr); \
-} while (0)
-
-#define qr_foreach(var, a_qr, a_field) \
- for ((var) = (a_qr); \
- (var) != NULL; \
- (var) = (((var)->a_field.qre_next != (a_qr)) \
- ? (var)->a_field.qre_next : NULL))
-
-#define qr_reverse_foreach(var, a_qr, a_field) \
- for ((var) = ((a_qr) != NULL) ? qr_prev(a_qr, a_field) : NULL; \
- (var) != NULL; \
- (var) = (((var) != (a_qr)) \
- ? (var)->a_field.qre_prev : NULL))
-
-#endif /* QR_H_ */
diff --git a/lib/libc/stdlib/rb.h b/lib/libc/stdlib/rb.h
deleted file mode 100644
index baaec7f29c77..000000000000
--- a/lib/libc/stdlib/rb.h
+++ /dev/null
@@ -1,1002 +0,0 @@
-/*-
- *******************************************************************************
- *
- * Copyright (C) 2008-2010 Jason Evans <jasone@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
- * unmodified other than the allowable 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.
- *
- ******************************************************************************
- *
- * cpp macro implementation of left-leaning 2-3 red-black trees. Parent
- * pointers are not used, and color bits are stored in the least significant
- * bit of right-child pointers (if RB_COMPACT is defined), thus making node
- * linkage as compact as is possible for red-black trees.
- *
- * Usage:
- *
- * #include <stdint.h>
- * #include <stdbool.h>
- * #define NDEBUG // (Optional, see assert(3).)
- * #include <assert.h>
- * #define RB_COMPACT // (Optional, embed color bits in right-child pointers.)
- * #include <rb.h>
- * ...
- *
- *******************************************************************************
- */
-
-#ifndef RB_H_
-#define RB_H_
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#ifdef RB_COMPACT
-/* Node structure. */
-#define rb_node(a_type) \
-struct { \
- a_type *rbn_left; \
- a_type *rbn_right_red; \
-}
-#else
-#define rb_node(a_type) \
-struct { \
- a_type *rbn_left; \
- a_type *rbn_right; \
- bool rbn_red; \
-}
-#endif
-
-/* Root structure. */
-#define rb_tree(a_type) \
-struct { \
- a_type *rbt_root; \
- a_type rbt_nil; \
-}
-
-/* Left accessors. */
-#define rbtn_left_get(a_type, a_field, a_node) \
- ((a_node)->a_field.rbn_left)
-#define rbtn_left_set(a_type, a_field, a_node, a_left) do { \
- (a_node)->a_field.rbn_left = a_left; \
-} while (0)
-
-#ifdef RB_COMPACT
-/* Right accessors. */
-#define rbtn_right_get(a_type, a_field, a_node) \
- ((a_type *) (((intptr_t) (a_node)->a_field.rbn_right_red) \
- & ((ssize_t)-2)))
-#define rbtn_right_set(a_type, a_field, a_node, a_right) do { \
- (a_node)->a_field.rbn_right_red = (a_type *) (((uintptr_t) a_right) \
- | (((uintptr_t) (a_node)->a_field.rbn_right_red) & ((size_t)1))); \
-} while (0)
-
-/* Color accessors. */
-#define rbtn_red_get(a_type, a_field, a_node) \
- ((bool) (((uintptr_t) (a_node)->a_field.rbn_right_red) \
- & ((size_t)1)))
-#define rbtn_color_set(a_type, a_field, a_node, a_red) do { \
- (a_node)->a_field.rbn_right_red = (a_type *) ((((intptr_t) \
- (a_node)->a_field.rbn_right_red) & ((ssize_t)-2)) \
- | ((ssize_t)a_red)); \
-} while (0)
-#define rbtn_red_set(a_type, a_field, a_node) do { \
- (a_node)->a_field.rbn_right_red = (a_type *) (((uintptr_t) \
- (a_node)->a_field.rbn_right_red) | ((size_t)1)); \
-} while (0)
-#define rbtn_black_set(a_type, a_field, a_node) do { \
- (a_node)->a_field.rbn_right_red = (a_type *) (((intptr_t) \
- (a_node)->a_field.rbn_right_red) & ((ssize_t)-2)); \
-} while (0)
-#else
-/* Right accessors. */
-#define rbtn_right_get(a_type, a_field, a_node) \
- ((a_node)->a_field.rbn_right)
-#define rbtn_right_set(a_type, a_field, a_node, a_right) do { \
- (a_node)->a_field.rbn_right = a_right; \
-} while (0)
-
-/* Color accessors. */
-#define rbtn_red_get(a_type, a_field, a_node) \
- ((a_node)->a_field.rbn_red)
-#define rbtn_color_set(a_type, a_field, a_node, a_red) do { \
- (a_node)->a_field.rbn_red = (a_red); \
-} while (0)
-#define rbtn_red_set(a_type, a_field, a_node) do { \
- (a_node)->a_field.rbn_red = true; \
-} while (0)
-#define rbtn_black_set(a_type, a_field, a_node) do { \
- (a_node)->a_field.rbn_red = false; \
-} while (0)
-#endif
-
-/* Node initializer. */
-#define rbt_node_new(a_type, a_field, a_rbt, a_node) do { \
- rbtn_left_set(a_type, a_field, (a_node), &(a_rbt)->rbt_nil); \
- rbtn_right_set(a_type, a_field, (a_node), &(a_rbt)->rbt_nil); \
- rbtn_red_set(a_type, a_field, (a_node)); \
-} while (0)
-
-/* Tree initializer. */
-#define rb_new(a_type, a_field, a_rbt) do { \
- (a_rbt)->rbt_root = &(a_rbt)->rbt_nil; \
- rbt_node_new(a_type, a_field, a_rbt, &(a_rbt)->rbt_nil); \
- rbtn_black_set(a_type, a_field, &(a_rbt)->rbt_nil); \
-} while (0)
-
-/* Internal utility macros. */
-#define rbtn_first(a_type, a_field, a_rbt, a_root, r_node) do { \
- (r_node) = (a_root); \
- if ((r_node) != &(a_rbt)->rbt_nil) { \
- for (; \
- rbtn_left_get(a_type, a_field, (r_node)) != &(a_rbt)->rbt_nil;\
- (r_node) = rbtn_left_get(a_type, a_field, (r_node))) { \
- } \
- } \
-} while (0)
-
-#define rbtn_last(a_type, a_field, a_rbt, a_root, r_node) do { \
- (r_node) = (a_root); \
- if ((r_node) != &(a_rbt)->rbt_nil) { \
- for (; rbtn_right_get(a_type, a_field, (r_node)) != \
- &(a_rbt)->rbt_nil; (r_node) = rbtn_right_get(a_type, a_field, \
- (r_node))) { \
- } \
- } \
-} while (0)
-
-#define rbtn_rotate_left(a_type, a_field, a_node, r_node) do { \
- (r_node) = rbtn_right_get(a_type, a_field, (a_node)); \
- rbtn_right_set(a_type, a_field, (a_node), \
- rbtn_left_get(a_type, a_field, (r_node))); \
- rbtn_left_set(a_type, a_field, (r_node), (a_node)); \
-} while (0)
-
-#define rbtn_rotate_right(a_type, a_field, a_node, r_node) do { \
- (r_node) = rbtn_left_get(a_type, a_field, (a_node)); \
- rbtn_left_set(a_type, a_field, (a_node), \
- rbtn_right_get(a_type, a_field, (r_node))); \
- rbtn_right_set(a_type, a_field, (r_node), (a_node)); \
-} while (0)
-
-/*
- * The rb_proto() macro generates function prototypes that correspond to the
- * functions generated by an equivalently parameterized call to rb_gen().
- */
-
-#define rb_proto(a_attr, a_prefix, a_rbt_type, a_type) \
-a_attr void \
-a_prefix##new(a_rbt_type *rbtree); \
-a_attr a_type * \
-a_prefix##first(a_rbt_type *rbtree); \
-a_attr a_type * \
-a_prefix##last(a_rbt_type *rbtree); \
-a_attr a_type * \
-a_prefix##next(a_rbt_type *rbtree, a_type *node); \
-a_attr a_type * \
-a_prefix##prev(a_rbt_type *rbtree, a_type *node); \
-a_attr a_type * \
-a_prefix##search(a_rbt_type *rbtree, a_type *key); \
-a_attr a_type * \
-a_prefix##nsearch(a_rbt_type *rbtree, a_type *key); \
-a_attr a_type * \
-a_prefix##psearch(a_rbt_type *rbtree, a_type *key); \
-a_attr void \
-a_prefix##insert(a_rbt_type *rbtree, a_type *node); \
-a_attr void \
-a_prefix##remove(a_rbt_type *rbtree, a_type *node); \
-a_attr a_type * \
-a_prefix##iter(a_rbt_type *rbtree, a_type *start, a_type *(*cb)( \
- a_rbt_type *, a_type *, void *), void *arg); \
-a_attr a_type * \
-a_prefix##reverse_iter(a_rbt_type *rbtree, a_type *start, \
- a_type *(*cb)(a_rbt_type *, a_type *, void *), void *arg);
-
-/*
- * The rb_gen() macro generates a type-specific red-black tree implementation,
- * based on the above cpp macros.
- *
- * Arguments:
- *
- * a_attr : Function attribute for generated functions (ex: static).
- * a_prefix : Prefix for generated functions (ex: extree_).
- * a_rb_type : Type for red-black tree data structure (ex: extree_t).
- * a_type : Type for red-black tree node data structure (ex:
- * extree_node_t).
- * a_field : Name of red-black tree node linkage (ex: extree_link).
- * a_cmp : Node comparison function name, with the following prototype:
- * int (a_cmp *)(a_type *a_node, a_type *a_other);
- * ^^^^^^
- * or a_key
- * Interpretation of comparision function return values:
- * -1 : a_node < a_other
- * 0 : a_node == a_other
- * 1 : a_node > a_other
- * In all cases, the a_node or a_key macro argument is the first
- * argument to the comparison function, which makes it possible
- * to write comparison functions that treat the first argument
- * specially.
- *
- * Assuming the following setup:
- *
- * typedef struct ex_node_s ex_node_t;
- * struct ex_node_s {
- * rb_node(ex_node_t) ex_link;
- * };
- * typedef rb(ex_node_t) ex_t;
- * rb_gen(static, ex_, ex_t, ex_node_t, ex_link, ex_cmp, 1297, 1301)
- *
- * The following API is generated:
- *
- * static void
- * ex_new(ex_t *extree);
- * Description: Initialize a red-black tree structure.
- * Args:
- * extree: Pointer to an uninitialized red-black tree object.
- *
- * static ex_node_t *
- * ex_first(ex_t *extree);
- * static ex_node_t *
- * ex_last(ex_t *extree);
- * Description: Get the first/last node in extree.
- * Args:
- * extree: Pointer to an initialized red-black tree object.
- * Ret: First/last node in extree, or NULL if extree is empty.
- *
- * static ex_node_t *
- * ex_next(ex_t *extree, ex_node_t *node);
- * static ex_node_t *
- * ex_prev(ex_t *extree, ex_node_t *node);
- * Description: Get node's successor/predecessor.
- * Args:
- * extree: Pointer to an initialized red-black tree object.
- * node : A node in extree.
- * Ret: node's successor/predecessor in extree, or NULL if node is
- * last/first.
- *
- * static ex_node_t *
- * ex_search(ex_t *extree, ex_node_t *key);
- * Description: Search for node that matches key.
- * Args:
- * extree: Pointer to an initialized red-black tree object.
- * key : Search key.
- * Ret: Node in extree that matches key, or NULL if no match.
- *
- * static ex_node_t *
- * ex_nsearch(ex_t *extree, ex_node_t *key);
- * static ex_node_t *
- * ex_psearch(ex_t *extree, ex_node_t *key);
- * Description: Search for node that matches key. If no match is found,
- * return what would be key's successor/predecessor, were
- * key in extree.
- * Args:
- * extree: Pointer to an initialized red-black tree object.
- * key : Search key.
- * Ret: Node in extree that matches key, or if no match, hypothetical
- * node's successor/predecessor (NULL if no successor/predecessor).
- *
- * static void
- * ex_insert(ex_t *extree, ex_node_t *node);
- * Description: Insert node into extree.
- * Args:
- * extree: Pointer to an initialized red-black tree object.
- * node : Node to be inserted into extree.
- *
- * static void
- * ex_remove(ex_t *extree, ex_node_t *node);
- * Description: Remove node from extree.
- * Args:
- * extree: Pointer to an initialized red-black tree object.
- * node : Node in extree to be removed.
- *
- * static ex_node_t *
- * ex_iter(ex_t *extree, ex_node_t *start, ex_node_t *(*cb)(ex_t *,
- * ex_node_t *, void *), void *arg);
- * static ex_node_t *
- * ex_reverse_iter(ex_t *extree, ex_node_t *start, ex_node *(*cb)(ex_t *,
- * ex_node_t *, void *), void *arg);
- * Description: Iterate forward/backward over extree, starting at node.
- * If extree is modified, iteration must be immediately
- * terminated by the callback function that causes the
- * modification.
- * Args:
- * extree: Pointer to an initialized red-black tree object.
- * start : Node at which to start iteration, or NULL to start at
- * first/last node.
- * cb : Callback function, which is called for each node during
- * iteration. Under normal circumstances the callback function
- * should return NULL, which causes iteration to continue. If a
- * callback function returns non-NULL, iteration is immediately
- * terminated and the non-NULL return value is returned by the
- * iterator. This is useful for re-starting iteration after
- * modifying extree.
- * arg : Opaque pointer passed to cb().
- * Ret: NULL if iteration completed, or the non-NULL callback return value
- * that caused termination of the iteration.
- */
-#define rb_gen(a_attr, a_prefix, a_rbt_type, a_type, a_field, a_cmp) \
-a_attr void \
-a_prefix##new(a_rbt_type *rbtree) { \
- rb_new(a_type, a_field, rbtree); \
-} \
-a_attr a_type * \
-a_prefix##first(a_rbt_type *rbtree) { \
- a_type *ret; \
- rbtn_first(a_type, a_field, rbtree, rbtree->rbt_root, ret); \
- if (ret == &rbtree->rbt_nil) { \
- ret = NULL; \
- } \
- return (ret); \
-} \
-a_attr a_type * \
-a_prefix##last(a_rbt_type *rbtree) { \
- a_type *ret; \
- rbtn_last(a_type, a_field, rbtree, rbtree->rbt_root, ret); \
- if (ret == &rbtree->rbt_nil) { \
- ret = NULL; \
- } \
- return (ret); \
-} \
-a_attr a_type * \
-a_prefix##next(a_rbt_type *rbtree, a_type *node) { \
- a_type *ret; \
- if (rbtn_right_get(a_type, a_field, node) != &rbtree->rbt_nil) { \
- rbtn_first(a_type, a_field, rbtree, rbtn_right_get(a_type, \
- a_field, node), ret); \
- } else { \
- a_type *tnode = rbtree->rbt_root; \
- assert(tnode != &rbtree->rbt_nil); \
- ret = &rbtree->rbt_nil; \
- while (true) { \
- int cmp = (a_cmp)(node, tnode); \
- if (cmp < 0) { \
- ret = tnode; \
- tnode = rbtn_left_get(a_type, a_field, tnode); \
- } else if (cmp > 0) { \
- tnode = rbtn_right_get(a_type, a_field, tnode); \
- } else { \
- break; \
- } \
- assert(tnode != &rbtree->rbt_nil); \
- } \
- } \
- if (ret == &rbtree->rbt_nil) { \
- ret = (NULL); \
- } \
- return (ret); \
-} \
-a_attr a_type * \
-a_prefix##prev(a_rbt_type *rbtree, a_type *node) { \
- a_type *ret; \
- if (rbtn_left_get(a_type, a_field, node) != &rbtree->rbt_nil) { \
- rbtn_last(a_type, a_field, rbtree, rbtn_left_get(a_type, \
- a_field, node), ret); \
- } else { \
- a_type *tnode = rbtree->rbt_root; \
- assert(tnode != &rbtree->rbt_nil); \
- ret = &rbtree->rbt_nil; \
- while (true) { \
- int cmp = (a_cmp)(node, tnode); \
- if (cmp < 0) { \
- tnode = rbtn_left_get(a_type, a_field, tnode); \
- } else if (cmp > 0) { \
- ret = tnode; \
- tnode = rbtn_right_get(a_type, a_field, tnode); \
- } else { \
- break; \
- } \
- assert(tnode != &rbtree->rbt_nil); \
- } \
- } \
- if (ret == &rbtree->rbt_nil) { \
- ret = (NULL); \
- } \
- return (ret); \
-} \
-a_attr a_type * \
-a_prefix##search(a_rbt_type *rbtree, a_type *key) { \
- a_type *ret; \
- int cmp; \
- ret = rbtree->rbt_root; \
- while (ret != &rbtree->rbt_nil \
- && (cmp = (a_cmp)(key, ret)) != 0) { \
- if (cmp < 0) { \
- ret = rbtn_left_get(a_type, a_field, ret); \
- } else { \
- ret = rbtn_right_get(a_type, a_field, ret); \
- } \
- } \
- if (ret == &rbtree->rbt_nil) { \
- ret = (NULL); \
- } \
- return (ret); \
-} \
-a_attr a_type * \
-a_prefix##nsearch(a_rbt_type *rbtree, a_type *key) { \
- a_type *ret; \
- a_type *tnode = rbtree->rbt_root; \
- ret = &rbtree->rbt_nil; \
- while (tnode != &rbtree->rbt_nil) { \
- int cmp = (a_cmp)(key, tnode); \
- if (cmp < 0) { \
- ret = tnode; \
- tnode = rbtn_left_get(a_type, a_field, tnode); \
- } else if (cmp > 0) { \
- tnode = rbtn_right_get(a_type, a_field, tnode); \
- } else { \
- ret = tnode; \
- break; \
- } \
- } \
- if (ret == &rbtree->rbt_nil) { \
- ret = (NULL); \
- } \
- return (ret); \
-} \
-a_attr a_type * \
-a_prefix##psearch(a_rbt_type *rbtree, a_type *key) { \
- a_type *ret; \
- a_type *tnode = rbtree->rbt_root; \
- ret = &rbtree->rbt_nil; \
- while (tnode != &rbtree->rbt_nil) { \
- int cmp = (a_cmp)(key, tnode); \
- if (cmp < 0) { \
- tnode = rbtn_left_get(a_type, a_field, tnode); \
- } else if (cmp > 0) { \
- ret = tnode; \
- tnode = rbtn_right_get(a_type, a_field, tnode); \
- } else { \
- ret = tnode; \
- break; \
- } \
- } \
- if (ret == &rbtree->rbt_nil) { \
- ret = (NULL); \
- } \
- return (ret); \
-} \
-a_attr void \
-a_prefix##insert(a_rbt_type *rbtree, a_type *node) { \
- struct { \
- a_type *node; \
- int cmp; \
- } path[sizeof(void *) << 4], *pathp; \
- rbt_node_new(a_type, a_field, rbtree, node); \
- /* Wind. */ \
- path->node = rbtree->rbt_root; \
- for (pathp = path; pathp->node != &rbtree->rbt_nil; pathp++) { \
- int cmp = pathp->cmp = a_cmp(node, pathp->node); \
- assert(cmp != 0); \
- if (cmp < 0) { \
- pathp[1].node = rbtn_left_get(a_type, a_field, \
- pathp->node); \
- } else { \
- pathp[1].node = rbtn_right_get(a_type, a_field, \
- pathp->node); \
- } \
- } \
- pathp->node = node; \
- /* Unwind. */ \
- for (pathp--; (uintptr_t)pathp >= (uintptr_t)path; pathp--) { \
- a_type *cnode = pathp->node; \
- if (pathp->cmp < 0) { \
- a_type *left = pathp[1].node; \
- rbtn_left_set(a_type, a_field, cnode, left); \
- if (rbtn_red_get(a_type, a_field, left)) { \
- a_type *leftleft = rbtn_left_get(a_type, a_field, left);\
- if (rbtn_red_get(a_type, a_field, leftleft)) { \
- /* Fix up 4-node. */ \
- a_type *tnode; \
- rbtn_black_set(a_type, a_field, leftleft); \
- rbtn_rotate_right(a_type, a_field, cnode, tnode); \
- cnode = tnode; \
- } \
- } else { \
- return; \
- } \
- } else { \
- a_type *right = pathp[1].node; \
- rbtn_right_set(a_type, a_field, cnode, right); \
- if (rbtn_red_get(a_type, a_field, right)) { \
- a_type *left = rbtn_left_get(a_type, a_field, cnode); \
- if (rbtn_red_get(a_type, a_field, left)) { \
- /* Split 4-node. */ \
- rbtn_black_set(a_type, a_field, left); \
- rbtn_black_set(a_type, a_field, right); \
- rbtn_red_set(a_type, a_field, cnode); \
- } else { \
- /* Lean left. */ \
- a_type *tnode; \
- bool tred = rbtn_red_get(a_type, a_field, cnode); \
- rbtn_rotate_left(a_type, a_field, cnode, tnode); \
- rbtn_color_set(a_type, a_field, tnode, tred); \
- rbtn_red_set(a_type, a_field, cnode); \
- cnode = tnode; \
- } \
- } else { \
- return; \
- } \
- } \
- pathp->node = cnode; \
- } \
- /* Set root, and make it black. */ \
- rbtree->rbt_root = path->node; \
- rbtn_black_set(a_type, a_field, rbtree->rbt_root); \
-} \
-a_attr void \
-a_prefix##remove(a_rbt_type *rbtree, a_type *node) { \
- struct { \
- a_type *node; \
- int cmp; \
- } *pathp, *nodep, path[sizeof(void *) << 4]; \
- /* Wind. */ \
- nodep = NULL; /* Silence compiler warning. */ \
- path->node = rbtree->rbt_root; \
- for (pathp = path; pathp->node != &rbtree->rbt_nil; pathp++) { \
- int cmp = pathp->cmp = a_cmp(node, pathp->node); \
- if (cmp < 0) { \
- pathp[1].node = rbtn_left_get(a_type, a_field, \
- pathp->node); \
- } else { \
- pathp[1].node = rbtn_right_get(a_type, a_field, \
- pathp->node); \
- if (cmp == 0) { \
- /* Find node's successor, in preparation for swap. */ \
- pathp->cmp = 1; \
- nodep = pathp; \
- for (pathp++; pathp->node != &rbtree->rbt_nil; \
- pathp++) { \
- pathp->cmp = -1; \
- pathp[1].node = rbtn_left_get(a_type, a_field, \
- pathp->node); \
- } \
- break; \
- } \
- } \
- } \
- assert(nodep->node == node); \
- pathp--; \
- if (pathp->node != node) { \
- /* Swap node with its successor. */ \
- bool tred = rbtn_red_get(a_type, a_field, pathp->node); \
- rbtn_color_set(a_type, a_field, pathp->node, \
- rbtn_red_get(a_type, a_field, node)); \
- rbtn_left_set(a_type, a_field, pathp->node, \
- rbtn_left_get(a_type, a_field, node)); \
- /* If node's successor is its right child, the following code */\
- /* will do the wrong thing for the right child pointer. */\
- /* However, it doesn't matter, because the pointer will be */\
- /* properly set when the successor is pruned. */\
- rbtn_right_set(a_type, a_field, pathp->node, \
- rbtn_right_get(a_type, a_field, node)); \
- rbtn_color_set(a_type, a_field, node, tred); \
- /* The pruned leaf node's child pointers are never accessed */\
- /* again, so don't bother setting them to nil. */\
- nodep->node = pathp->node; \
- pathp->node = node; \
- if (nodep == path) { \
- rbtree->rbt_root = nodep->node; \
- } else { \
- if (nodep[-1].cmp < 0) { \
- rbtn_left_set(a_type, a_field, nodep[-1].node, \
- nodep->node); \
- } else { \
- rbtn_right_set(a_type, a_field, nodep[-1].node, \
- nodep->node); \
- } \
- } \
- } else { \
- a_type *left = rbtn_left_get(a_type, a_field, node); \
- if (left != &rbtree->rbt_nil) { \
- /* node has no successor, but it has a left child. */\
- /* Splice node out, without losing the left child. */\
- assert(rbtn_red_get(a_type, a_field, node) == false); \
- assert(rbtn_red_get(a_type, a_field, left)); \
- rbtn_black_set(a_type, a_field, left); \
- if (pathp == path) { \
- rbtree->rbt_root = left; \
- } else { \
- if (pathp[-1].cmp < 0) { \
- rbtn_left_set(a_type, a_field, pathp[-1].node, \
- left); \
- } else { \
- rbtn_right_set(a_type, a_field, pathp[-1].node, \
- left); \
- } \
- } \
- return; \
- } else if (pathp == path) { \
- /* The tree only contained one node. */ \
- rbtree->rbt_root = &rbtree->rbt_nil; \
- return; \
- } \
- } \
- if (rbtn_red_get(a_type, a_field, pathp->node)) { \
- /* Prune red node, which requires no fixup. */ \
- assert(pathp[-1].cmp < 0); \
- rbtn_left_set(a_type, a_field, pathp[-1].node, \
- &rbtree->rbt_nil); \
- return; \
- } \
- /* The node to be pruned is black, so unwind until balance is */\
- /* restored. */\
- pathp->node = &rbtree->rbt_nil; \
- for (pathp--; (uintptr_t)pathp >= (uintptr_t)path; pathp--) { \
- assert(pathp->cmp != 0); \
- if (pathp->cmp < 0) { \
- rbtn_left_set(a_type, a_field, pathp->node, \
- pathp[1].node); \
- assert(rbtn_red_get(a_type, a_field, pathp[1].node) \
- == false); \
- if (rbtn_red_get(a_type, a_field, pathp->node)) { \
- a_type *right = rbtn_right_get(a_type, a_field, \
- pathp->node); \
- a_type *rightleft = rbtn_left_get(a_type, a_field, \
- right); \
- a_type *tnode; \
- if (rbtn_red_get(a_type, a_field, rightleft)) { \
- /* In the following diagrams, ||, //, and \\ */\
- /* indicate the path to the removed node. */\
- /* */\
- /* || */\
- /* pathp(r) */\
- /* // \ */\
- /* (b) (b) */\
- /* / */\
- /* (r) */\
- /* */\
- rbtn_black_set(a_type, a_field, pathp->node); \
- rbtn_rotate_right(a_type, a_field, right, tnode); \
- rbtn_right_set(a_type, a_field, pathp->node, tnode);\
- rbtn_rotate_left(a_type, a_field, pathp->node, \
- tnode); \
- } else { \
- /* || */\
- /* pathp(r) */\
- /* // \ */\
- /* (b) (b) */\
- /* / */\
- /* (b) */\
- /* */\
- rbtn_rotate_left(a_type, a_field, pathp->node, \
- tnode); \
- } \
- /* Balance restored, but rotation modified subtree */\
- /* root. */\
- assert((uintptr_t)pathp > (uintptr_t)path); \
- if (pathp[-1].cmp < 0) { \
- rbtn_left_set(a_type, a_field, pathp[-1].node, \
- tnode); \
- } else { \
- rbtn_right_set(a_type, a_field, pathp[-1].node, \
- tnode); \
- } \
- return; \
- } else { \
- a_type *right = rbtn_right_get(a_type, a_field, \
- pathp->node); \
- a_type *rightleft = rbtn_left_get(a_type, a_field, \
- right); \
- if (rbtn_red_get(a_type, a_field, rightleft)) { \
- /* || */\
- /* pathp(b) */\
- /* // \ */\
- /* (b) (b) */\
- /* / */\
- /* (r) */\
- a_type *tnode; \
- rbtn_black_set(a_type, a_field, rightleft); \
- rbtn_rotate_right(a_type, a_field, right, tnode); \
- rbtn_right_set(a_type, a_field, pathp->node, tnode);\
- rbtn_rotate_left(a_type, a_field, pathp->node, \
- tnode); \
- /* Balance restored, but rotation modified */\
- /* subree root, which may actually be the tree */\
- /* root. */\
- if (pathp == path) { \
- /* Set root. */ \
- rbtree->rbt_root = tnode; \
- } else { \
- if (pathp[-1].cmp < 0) { \
- rbtn_left_set(a_type, a_field, \
- pathp[-1].node, tnode); \
- } else { \
- rbtn_right_set(a_type, a_field, \
- pathp[-1].node, tnode); \
- } \
- } \
- return; \
- } else { \
- /* || */\
- /* pathp(b) */\
- /* // \ */\
- /* (b) (b) */\
- /* / */\
- /* (b) */\
- a_type *tnode; \
- rbtn_red_set(a_type, a_field, pathp->node); \
- rbtn_rotate_left(a_type, a_field, pathp->node, \
- tnode); \
- pathp->node = tnode; \
- } \
- } \
- } else { \
- a_type *left; \
- rbtn_right_set(a_type, a_field, pathp->node, \
- pathp[1].node); \
- left = rbtn_left_get(a_type, a_field, pathp->node); \
- if (rbtn_red_get(a_type, a_field, left)) { \
- a_type *tnode; \
- a_type *leftright = rbtn_right_get(a_type, a_field, \
- left); \
- a_type *leftrightleft = rbtn_left_get(a_type, a_field, \
- leftright); \
- if (rbtn_red_get(a_type, a_field, leftrightleft)) { \
- /* || */\
- /* pathp(b) */\
- /* / \\ */\
- /* (r) (b) */\
- /* \ */\
- /* (b) */\
- /* / */\
- /* (r) */\
- a_type *unode; \
- rbtn_black_set(a_type, a_field, leftrightleft); \
- rbtn_rotate_right(a_type, a_field, pathp->node, \
- unode); \
- rbtn_rotate_right(a_type, a_field, pathp->node, \
- tnode); \
- rbtn_right_set(a_type, a_field, unode, tnode); \
- rbtn_rotate_left(a_type, a_field, unode, tnode); \
- } else { \
- /* || */\
- /* pathp(b) */\
- /* / \\ */\
- /* (r) (b) */\
- /* \ */\
- /* (b) */\
- /* / */\
- /* (b) */\
- assert(leftright != &rbtree->rbt_nil); \
- rbtn_red_set(a_type, a_field, leftright); \
- rbtn_rotate_right(a_type, a_field, pathp->node, \
- tnode); \
- rbtn_black_set(a_type, a_field, tnode); \
- } \
- /* Balance restored, but rotation modified subtree */\
- /* root, which may actually be the tree root. */\
- if (pathp == path) { \
- /* Set root. */ \
- rbtree->rbt_root = tnode; \
- } else { \
- if (pathp[-1].cmp < 0) { \
- rbtn_left_set(a_type, a_field, pathp[-1].node, \
- tnode); \
- } else { \
- rbtn_right_set(a_type, a_field, pathp[-1].node, \
- tnode); \
- } \
- } \
- return; \
- } else if (rbtn_red_get(a_type, a_field, pathp->node)) { \
- a_type *leftleft = rbtn_left_get(a_type, a_field, left);\
- if (rbtn_red_get(a_type, a_field, leftleft)) { \
- /* || */\
- /* pathp(r) */\
- /* / \\ */\
- /* (b) (b) */\
- /* / */\
- /* (r) */\
- a_type *tnode; \
- rbtn_black_set(a_type, a_field, pathp->node); \
- rbtn_red_set(a_type, a_field, left); \
- rbtn_black_set(a_type, a_field, leftleft); \
- rbtn_rotate_right(a_type, a_field, pathp->node, \
- tnode); \
- /* Balance restored, but rotation modified */\
- /* subtree root. */\
- assert((uintptr_t)pathp > (uintptr_t)path); \
- if (pathp[-1].cmp < 0) { \
- rbtn_left_set(a_type, a_field, pathp[-1].node, \
- tnode); \
- } else { \
- rbtn_right_set(a_type, a_field, pathp[-1].node, \
- tnode); \
- } \
- return; \
- } else { \
- /* || */\
- /* pathp(r) */\
- /* / \\ */\
- /* (b) (b) */\
- /* / */\
- /* (b) */\
- rbtn_red_set(a_type, a_field, left); \
- rbtn_black_set(a_type, a_field, pathp->node); \
- /* Balance restored. */ \
- return; \
- } \
- } else { \
- a_type *leftleft = rbtn_left_get(a_type, a_field, left);\
- if (rbtn_red_get(a_type, a_field, leftleft)) { \
- /* || */\
- /* pathp(b) */\
- /* / \\ */\
- /* (b) (b) */\
- /* / */\
- /* (r) */\
- a_type *tnode; \
- rbtn_black_set(a_type, a_field, leftleft); \
- rbtn_rotate_right(a_type, a_field, pathp->node, \
- tnode); \
- /* Balance restored, but rotation modified */\
- /* subtree root, which may actually be the tree */\
- /* root. */\
- if (pathp == path) { \
- /* Set root. */ \
- rbtree->rbt_root = tnode; \
- } else { \
- if (pathp[-1].cmp < 0) { \
- rbtn_left_set(a_type, a_field, \
- pathp[-1].node, tnode); \
- } else { \
- rbtn_right_set(a_type, a_field, \
- pathp[-1].node, tnode); \
- } \
- } \
- return; \
- } else { \
- /* || */\
- /* pathp(b) */\
- /* / \\ */\
- /* (b) (b) */\
- /* / */\
- /* (b) */\
- rbtn_red_set(a_type, a_field, left); \
- } \
- } \
- } \
- } \
- /* Set root. */ \
- rbtree->rbt_root = path->node; \
- assert(rbtn_red_get(a_type, a_field, rbtree->rbt_root) == false); \
-} \
-a_attr a_type * \
-a_prefix##iter_recurse(a_rbt_type *rbtree, a_type *node, \
- a_type *(*cb)(a_rbt_type *, a_type *, void *), void *arg) { \
- if (node == &rbtree->rbt_nil) { \
- return (&rbtree->rbt_nil); \
- } else { \
- a_type *ret; \
- if ((ret = a_prefix##iter_recurse(rbtree, rbtn_left_get(a_type, \
- a_field, node), cb, arg)) != &rbtree->rbt_nil \
- || (ret = cb(rbtree, node, arg)) != NULL) { \
- return (ret); \
- } \
- return (a_prefix##iter_recurse(rbtree, rbtn_right_get(a_type, \
- a_field, node), cb, arg)); \
- } \
-} \
-a_attr a_type * \
-a_prefix##iter_start(a_rbt_type *rbtree, a_type *start, a_type *node, \
- a_type *(*cb)(a_rbt_type *, a_type *, void *), void *arg) { \
- int cmp = a_cmp(start, node); \
- if (cmp < 0) { \
- a_type *ret; \
- if ((ret = a_prefix##iter_start(rbtree, start, \
- rbtn_left_get(a_type, a_field, node), cb, arg)) != \
- &rbtree->rbt_nil || (ret = cb(rbtree, node, arg)) != NULL) { \
- return (ret); \
- } \
- return (a_prefix##iter_recurse(rbtree, rbtn_right_get(a_type, \
- a_field, node), cb, arg)); \
- } else if (cmp > 0) { \
- return (a_prefix##iter_start(rbtree, start, \
- rbtn_right_get(a_type, a_field, node), cb, arg)); \
- } else { \
- a_type *ret; \
- if ((ret = cb(rbtree, node, arg)) != NULL) { \
- return (ret); \
- } \
- return (a_prefix##iter_recurse(rbtree, rbtn_right_get(a_type, \
- a_field, node), cb, arg)); \
- } \
-} \
-a_attr a_type * \
-a_prefix##iter(a_rbt_type *rbtree, a_type *start, a_type *(*cb)( \
- a_rbt_type *, a_type *, void *), void *arg) { \
- a_type *ret; \
- if (start != NULL) { \
- ret = a_prefix##iter_start(rbtree, start, rbtree->rbt_root, \
- cb, arg); \
- } else { \
- ret = a_prefix##iter_recurse(rbtree, rbtree->rbt_root, cb, arg);\
- } \
- if (ret == &rbtree->rbt_nil) { \
- ret = NULL; \
- } \
- return (ret); \
-} \
-a_attr a_type * \
-a_prefix##reverse_iter_recurse(a_rbt_type *rbtree, a_type *node, \
- a_type *(*cb)(a_rbt_type *, a_type *, void *), void *arg) { \
- if (node == &rbtree->rbt_nil) { \
- return (&rbtree->rbt_nil); \
- } else { \
- a_type *ret; \
- if ((ret = a_prefix##reverse_iter_recurse(rbtree, \
- rbtn_right_get(a_type, a_field, node), cb, arg)) != \
- &rbtree->rbt_nil || (ret = cb(rbtree, node, arg)) != NULL) { \
- return (ret); \
- } \
- return (a_prefix##reverse_iter_recurse(rbtree, \
- rbtn_left_get(a_type, a_field, node), cb, arg)); \
- } \
-} \
-a_attr a_type * \
-a_prefix##reverse_iter_start(a_rbt_type *rbtree, a_type *start, \
- a_type *node, a_type *(*cb)(a_rbt_type *, a_type *, void *), \
- void *arg) { \
- int cmp = a_cmp(start, node); \
- if (cmp > 0) { \
- a_type *ret; \
- if ((ret = a_prefix##reverse_iter_start(rbtree, start, \
- rbtn_right_get(a_type, a_field, node), cb, arg)) != \
- &rbtree->rbt_nil || (ret = cb(rbtree, node, arg)) != NULL) { \
- return (ret); \
- } \
- return (a_prefix##reverse_iter_recurse(rbtree, \
- rbtn_left_get(a_type, a_field, node), cb, arg)); \
- } else if (cmp < 0) { \
- return (a_prefix##reverse_iter_start(rbtree, start, \
- rbtn_left_get(a_type, a_field, node), cb, arg)); \
- } else { \
- a_type *ret; \
- if ((ret = cb(rbtree, node, arg)) != NULL) { \
- return (ret); \
- } \
- return (a_prefix##reverse_iter_recurse(rbtree, \
- rbtn_left_get(a_type, a_field, node), cb, arg)); \
- } \
-} \
-a_attr a_type * \
-a_prefix##reverse_iter(a_rbt_type *rbtree, a_type *start, \
- a_type *(*cb)(a_rbt_type *, a_type *, void *), void *arg) { \
- a_type *ret; \
- if (start != NULL) { \
- ret = a_prefix##reverse_iter_start(rbtree, start, \
- rbtree->rbt_root, cb, arg); \
- } else { \
- ret = a_prefix##reverse_iter_recurse(rbtree, rbtree->rbt_root, \
- cb, arg); \
- } \
- if (ret == &rbtree->rbt_nil) { \
- ret = NULL; \
- } \
- return (ret); \
-}
-
-#endif /* RB_H_ */
diff --git a/lib/libc/stdlib/reallocf.3 b/lib/libc/stdlib/reallocf.3
new file mode 100644
index 000000000000..cc9ef3d8f41e
--- /dev/null
+++ b/lib/libc/stdlib/reallocf.3
@@ -0,0 +1,82 @@
+.\" Copyright (c) 1980, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" This code is derived from software contributed to Berkeley by
+.\" the American National Standards Committee X3, on Information
+.\" Processing Systems.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)malloc.3 8.1 (Berkeley) 6/4/93
+.\" $FreeBSD$
+.\"
+.Dd January 31, 2010
+.Dt MALLOC 3
+.Os
+.Sh NAME
+.Nm reallocf
+.Nd memory reallocation function
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In stdlib.h
+.Ft void *
+.Fn reallocf "void *ptr" "size_t size"
+.Sh DESCRIPTION
+The
+.Fn reallocf
+function is identical to the
+.Fn realloc
+function, except that it
+will free the passed pointer when the requested memory cannot be allocated.
+This is a
+.Fx
+specific API designed to ease the problems with traditional coding styles
+for
+.Fn realloc
+causing memory leaks in libraries.
+.Sh RETURN VALUES
+The
+.Fn reallocf
+function returns a pointer, possibly identical to
+.Fa ptr ,
+to the allocated memory
+if successful; otherwise a
+.Dv NULL
+pointer is returned, and
+.Va errno
+is set to
+.Er ENOMEM
+if the error was the result of an allocation failure.
+The
+.Fn reallocf
+function deletes the original buffer when an error occurs.
+.Sh SEE ALSO
+.Xr realloc 3
+.Sh HISTORY
+The
+.Fn reallocf
+function first appeared in
+.Fx 3.0 .
diff --git a/lib/libc/string/memchr.3 b/lib/libc/string/memchr.3
index 6e33aef98380..9f31fd156639 100644
--- a/lib/libc/string/memchr.3
+++ b/lib/libc/string/memchr.3
@@ -94,7 +94,7 @@ conforms to
.St -isoC .
.Pp
The
-.Fn memrchr
+.Fn memrchr
function is a GNU extension and conforms to no standard.
.Sh HISTORY
The
diff --git a/lib/libc/string/strchr.c b/lib/libc/string/strchr.c
index 481cb20711a8..1245f136b7ef 100644
--- a/lib/libc/string/strchr.c
+++ b/lib/libc/string/strchr.c
@@ -51,4 +51,4 @@ strchr(const char *p, int ch)
/* NOTREACHED */
}
-__strong_reference(strchr, index);
+__weak_reference(strchr, index);
diff --git a/lib/libc/string/strerror.3 b/lib/libc/string/strerror.3
index 0ec6cb0af406..5961a84a9d83 100644
--- a/lib/libc/string/strerror.3
+++ b/lib/libc/string/strerror.3
@@ -147,6 +147,7 @@ or
should be used instead.
.Sh SEE ALSO
.Xr intro 2 ,
+.Xr err 3 ,
.Xr psignal 3
.Sh STANDARDS
The
diff --git a/lib/libc/string/strerror.c b/lib/libc/string/strerror.c
index 57d253db4611..bfca871ad31a 100644
--- a/lib/libc/string/strerror.c
+++ b/lib/libc/string/strerror.c
@@ -121,6 +121,6 @@ strerror(int num)
static char ebuf[NL_TEXTMAX];
if (strerror_r(num, ebuf, sizeof(ebuf)) != 0)
- errno = EINVAL;
+ errno = EINVAL;
return (ebuf);
}
diff --git a/lib/libc/string/strrchr.c b/lib/libc/string/strrchr.c
index 160c4b5459ab..be9f9781f6e9 100644
--- a/lib/libc/string/strrchr.c
+++ b/lib/libc/string/strrchr.c
@@ -52,4 +52,4 @@ strrchr(const char *p, int ch)
/* NOTREACHED */
}
-__strong_reference(strrchr, rindex);
+__weak_reference(strrchr, rindex);
diff --git a/lib/libc/string/swab.3 b/lib/libc/string/swab.3
index f8ef34ee3f3b..0c9deea8463b 100644
--- a/lib/libc/string/swab.3
+++ b/lib/libc/string/swab.3
@@ -28,7 +28,7 @@
.\" @(#)swab.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd December 10, 2004
+.Dd March 4, 2012
.Dt SWAB 3
.Os
.Sh NAME
@@ -54,6 +54,9 @@ swapping adjacent bytes.
The argument
.Fa len
must be an even number.
+If
+.Fa len
+is less than zero, nothing will be done.
.Sh SEE ALSO
.Xr bzero 3 ,
.Xr memset 3
diff --git a/lib/libc/string/swab.c b/lib/libc/string/swab.c
index 1db7d1fab00b..ec6cbf0f536f 100644
--- a/lib/libc/string/swab.c
+++ b/lib/libc/string/swab.c
@@ -45,6 +45,8 @@ swab(const void * __restrict from, void * __restrict to, ssize_t len)
int n;
char *fp, *tp;
+ if (len <= 0)
+ return;
n = len >> 1;
fp = (char *)from;
tp = (char *)to;
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index 073220e35fcc..61d1713193e1 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -165,7 +165,7 @@ MLINKS+=jail.2 jail_attach.2 \
jail.2 jail_remove.2 \
jail.2 jail_set.2
MLINKS+=kldunload.2 kldunloadf.2
-MLINKS+=kqueue.2 kevent.2
+MLINKS+=kqueue.2 kevent.2 kqueue.2 EV_SET.3
MLINKS+=link.2 linkat.2
MLINKS+=madvise.2 posix_madvise.2
MLINKS+=mkdir.2 mkdirat.2
diff --git a/lib/libc/sys/cap_enter.2 b/lib/libc/sys/cap_enter.2
index a3ea710b53a8..5454ec94862f 100644
--- a/lib/libc/sys/cap_enter.2
+++ b/lib/libc/sys/cap_enter.2
@@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 11, 2009
+.Dd February 25, 2012
.Dt CAP_ENTER 2
.Os
.Sh NAME
@@ -68,7 +68,7 @@ appropriately-crafted applications or application components may be run.
returns a flag indicating whether or not the process is in a capability mode
sandbox.
.Sh CAVEAT
-Creating effecive process sandboxes is a tricky process that involves
+Creating effective process sandboxes is a tricky process that involves
identifying the least possible rights required by the process and then
passing those rights into the process in a safe manner.
See the CAVEAT
diff --git a/lib/libc/sys/cap_new.2 b/lib/libc/sys/cap_new.2
index 362be5c15de2..a18fd3bf69f5 100644
--- a/lib/libc/sys/cap_new.2
+++ b/lib/libc/sys/cap_new.2
@@ -462,14 +462,14 @@ argument is not a capability.
Support for capabilities and capabilities mode was developed as part of the
.Tn TrustedBSD
Project.
+.Sh AUTHORS
+These functions and the capability facility were created by
+.An "Robert N. M. Watson"
+at the University of Cambridge Computer Laboratory with support from a grant
+from Google, Inc.
.Sh BUGS
This man page should list the set of permitted system calls more specifically
for each capability right.
.Pp
Capability rights sometimes have unclear indirect impacts, which should be
documented, or at least hinted at.
-.Sh AUTHORS
-These functions and the capability facility were created by
-.An "Robert N. M. Watson"
-at the University of Cambridge Computer Laboratory with support from a grant
-from Google, Inc.
diff --git a/lib/libc/sys/chflags.2 b/lib/libc/sys/chflags.2
index 79f2fe0cc22c..1c2eb7865de0 100644
--- a/lib/libc/sys/chflags.2
+++ b/lib/libc/sys/chflags.2
@@ -28,7 +28,7 @@
.\" @(#)chflags.2 8.3 (Berkeley) 5/2/95
.\" $FreeBSD$
.\"
-.Dd Oct 29, 2010
+.Dd Apr 13, 2012
.Dt CHFLAGS 2
.Os
.Sh NAME
@@ -114,8 +114,7 @@ The
and
.Dv SF_ARCHIVED
flags may only be set or unset by the super-user.
-Attempts to set these flags by non-super-users are rejected, attempts by
-non-superusers to clear flags that are already unset are silently ignored.
+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
@@ -124,7 +123,7 @@ for details.)
.Pp
The
.Dv SF_SNAPSHOT
-flag is maintained by the system and cannot be changed by any user.
+flag is maintained by the system and cannot be toggled.
.Sh RETURN VALUES
.Rv -std
.Sh ERRORS
@@ -154,12 +153,12 @@ or
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 tries to set one of
+A non-super-user attempted to toggle one of
.Dv SF_ARCHIVED , SF_IMMUTABLE , SF_APPEND ,
or
.Dv SF_NOUNLINK .
.It Bq Er EPERM
-User tries to set or remove the
+An attempt was made to toggle the
.Dv SF_SNAPSHOT
flag.
.It Bq Er EROFS
@@ -174,7 +173,9 @@ An
.Tn I/O
error occurred while reading from or writing to the file system.
.It Bq Er EOPNOTSUPP
-The underlying file system does not support file flags.
+The underlying file system does not support file flags, or
+does not support all of the flags set in
+.Fa flags .
.El
.Pp
The
@@ -199,12 +200,12 @@ or
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 tries to set one of
+A non-super-user attempted to toggle one of
.Dv SF_ARCHIVED , SF_IMMUTABLE , SF_APPEND ,
or
.Dv SF_NOUNLINK .
.It Bq Er EPERM
-User tries to set or remove the
+An attempt was made to toggle the
.Dv SF_SNAPSHOT
flag.
.It Bq Er EROFS
@@ -214,7 +215,9 @@ An
.Tn I/O
error occurred while reading from or writing to the file system.
.It Bq Er EOPNOTSUPP
-The underlying file system does not support file flags.
+The underlying file system does not support file flags, or
+does not support all of the flags set in
+.Fa flags .
.El
.Sh SEE ALSO
.Xr chflags 1 ,
diff --git a/lib/libc/sys/chroot.2 b/lib/libc/sys/chroot.2
index ecf2eb54fbc8..060d0648e53e 100644
--- a/lib/libc/sys/chroot.2
+++ b/lib/libc/sys/chroot.2
@@ -28,7 +28,7 @@
.\" @(#)chroot.2 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd June 4, 1993
+.Dd January 3, 2012
.Dt CHROOT 2
.Os
.Sh NAME
@@ -134,9 +134,27 @@ The
.Fn chroot
system call appeared in
.Bx 4.2 .
+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 have many hardcoded paths to files where 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.
diff --git a/lib/libc/sys/close.2 b/lib/libc/sys/close.2
index 524322b1517b..c3a09725e34c 100644
--- a/lib/libc/sys/close.2
+++ b/lib/libc/sys/close.2
@@ -28,7 +28,7 @@
.\" @(#)close.2 8.2 (Berkeley) 4/19/94
.\" $FreeBSD$
.\"
-.Dd December 4, 2006
+.Dd January 22, 2012
.Dt CLOSE 2
.Os
.Sh NAME
@@ -118,6 +118,10 @@ The underlying object did not fit, cached data was lost.
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 ,
diff --git a/lib/libc/sys/cpuset.2 b/lib/libc/sys/cpuset.2
index 1cdff680f0d9..652d3aea7738 100644
--- a/lib/libc/sys/cpuset.2
+++ b/lib/libc/sys/cpuset.2
@@ -77,7 +77,7 @@ while application developers will manipulate anonymous sets using
To select the correct set a value of type
.Ft cpulevel_t
is used.
-The following values for
+The following values for
.Fa level
are supported:
.Bl -column CPU_LEVEL_CPUSET -offset indent
@@ -137,7 +137,7 @@ Children inherit this set after a call to
.Xr fork 2 .
.Pp
.Fn cpuset_setid
-attempts to set the id of the object specified by the
+attempts to set the id of the object specified by the
.Fa which
argument.
Currently
@@ -149,12 +149,12 @@ Upon successful completion all of the threads in the target process will
be running on CPUs permitted by the set.
.Pp
.Fn cpuset_getid
-retrieves a set id from the object indicated by
+retrieves a set id from the object indicated by
.Fa which
and stores it in the space pointed to by
.Fa setid .
The retrieved id may be that of either the root or assigned set
-depending on the value of
+depending on the value of
.Fa level .
.Fa level
should be
diff --git a/lib/libc/sys/cpuset_getaffinity.2 b/lib/libc/sys/cpuset_getaffinity.2
index 5c75b92a7dcc..4fbbc4e851e2 100644
--- a/lib/libc/sys/cpuset_getaffinity.2
+++ b/lib/libc/sys/cpuset_getaffinity.2
@@ -45,7 +45,7 @@
.Fn cpuset_getaffinity
and
.Fn cpuset_setaffinity
-allow the manipulation of sets of CPUs available to processes, threads,
+allow the manipulation of sets of CPUs available to processes, threads,
interrupts, jails and other resources.
These functions may manipulate sets of CPUs that contain many processes
or per-object anonymous masks that effect only a single object.
@@ -108,7 +108,6 @@ and
.Fa id
to the value in
.Fa mask .
-.Pp
.Sh RETURN VALUES
.Rv -std
.Sh ERRORS
diff --git a/lib/libc/sys/dup.2 b/lib/libc/sys/dup.2
index f6f6f46b2a43..d2a4b7e2454a 100644
--- a/lib/libc/sys/dup.2
+++ b/lib/libc/sys/dup.2
@@ -128,20 +128,27 @@ indicates the cause of the error.
.Sh ERRORS
The
.Fn dup
-and
-.Fn dup2
-system calls fail if:
+system call fails if:
.Bl -tag -width Er
.It Bq Er EBADF
The
.Fa oldd
-or
-.Fa newd
argument
is not a valid active descriptor
.It Bq Er EMFILE
Too many descriptors are active.
.El
+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 cap_new 2 ,
diff --git a/lib/libc/sys/fcntl.2 b/lib/libc/sys/fcntl.2
index a801b60dc1fa..beceb72539fa 100644
--- a/lib/libc/sys/fcntl.2
+++ b/lib/libc/sys/fcntl.2
@@ -28,7 +28,7 @@
.\" @(#)fcntl.2 8.2 (Berkeley) 1/12/94
.\" $FreeBSD$
.\"
-.Dd September 28, 2009
+.Dd January 28, 2012
.Dt FCNTL 2
.Os
.Sh NAME
@@ -143,6 +143,22 @@ process groups are specified by supplying
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.
+.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.
.El
.Pp
The flags for the
@@ -241,22 +257,6 @@ will be interrupted if the signal handler has not specified the
.Dv SA_RESTART
(see
.Xr sigaction 2 ) .
-.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.
-.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.
.El
.Pp
When a shared lock has been set on a segment of a file,
@@ -539,8 +539,6 @@ The argument
.Fa cmd
is
.Dv F_DUPFD
-or
-.Dv F_DUP2FD
and the maximum number of file descriptors permitted for the
process are already in use,
or no file descriptors greater than or equal to
diff --git a/lib/libc/sys/getdirentries.2 b/lib/libc/sys/getdirentries.2
index e16e7f2a77f8..3fe16327ed32 100644
--- a/lib/libc/sys/getdirentries.2
+++ b/lib/libc/sys/getdirentries.2
@@ -71,10 +71,10 @@ The data in the buffer is a series of
.Vt dirent
structures each containing the following entries:
.Bd -literal -offset indent
-u_int32_t d_fileno;
-u_int16_t d_reclen;
-u_int8_t d_type;
-u_int8_t d_namlen;
+uint32_t d_fileno;
+uint16_t d_reclen;
+uint8_t d_type;
+uint8_t d_namlen;
char d_name[MAXNAMELEN + 1]; /* see below */
.Ed
.Pp
diff --git a/lib/libc/sys/getsockopt.2 b/lib/libc/sys/getsockopt.2
index edd92c35907c..1e0d3f9180cf 100644
--- a/lib/libc/sys/getsockopt.2
+++ b/lib/libc/sys/getsockopt.2
@@ -28,7 +28,7 @@
.\" @(#)getsockopt.2 8.4 (Berkeley) 5/2/95
.\" $FreeBSD$
.\"
-.Dd November 21, 2011
+.Dd February 26, 2012
.Dt GETSOCKOPT 2
.Os
.Sh NAME
@@ -172,6 +172,8 @@ for the socket
.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_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_SETFIB Ta "set the associated FIB (routing table) for the socket (set only)"
.El
@@ -449,7 +451,10 @@ and for
.Ed
.Pp
.Dv SO_ACCEPTCONN ,
-.Dv SO_TYPE
+.Dv SO_TYPE ,
+.Dv SO_PROTOCOL
+(and its alias
+.Dv SO_PROTOTYPE )
and
.Dv SO_ERROR
are options used only with
@@ -463,6 +468,12 @@ system call was invoked on the socket.
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.
diff --git a/lib/libc/sys/jail.2 b/lib/libc/sys/jail.2
index bf6218ceff38..b0619a042337 100644
--- a/lib/libc/sys/jail.2
+++ b/lib/libc/sys/jail.2
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 23, 2009
+.Dd February 8, 2012
.Dt JAIL 2
.Os
.Sh NAME
@@ -59,7 +59,7 @@ system call sets up a jail and locks the current process in it.
The argument is a pointer to a structure describing the prison:
.Bd -literal -offset indent
struct jail {
- u_int32_t version;
+ uint32_t version;
char *path;
char *hostname;
char *jailname;
@@ -334,7 +334,7 @@ flag is not set.
The jail referred to by a
.Va jid
is not accessible by the process, because the process is in a different
-jail.
+jail.
.It Bq Er EEXIST
The jail referred to by a
.Va jid
@@ -382,7 +382,7 @@ parameter does not exist.
The jail referred to by a
.Va jid
is not accessible by the process, because the process is in a different
-jail.
+jail.
.It Bq Er ENOENT
The
.Va lastjid
@@ -400,6 +400,8 @@ and
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
diff --git a/lib/libc/sys/kill.2 b/lib/libc/sys/kill.2
index d46dc1f42775..03895590edbf 100644
--- a/lib/libc/sys/kill.2
+++ b/lib/libc/sys/kill.2
@@ -28,7 +28,7 @@
.\" @(#)kill.2 8.3 (Berkeley) 4/19/94
.\" $FreeBSD$
.\"
-.Dd April 19, 1994
+.Dd March 15, 2012
.Dt KILL 2
.Os
.Sh NAME
@@ -121,11 +121,8 @@ The
argument
is not a valid signal number.
.It Bq Er ESRCH
-No process can be found corresponding to that specified by
+No process or process group can be found corresponding to that specified by
.Fa pid .
-.It Bq Er ESRCH
-The process id was given as 0
-but the sending process does not have a process group.
.It Bq Er EPERM
The sending process is not the super-user and its effective
user id does not match the effective user-id of the receiving process.
@@ -137,6 +134,7 @@ of the group could not be signaled.
.Xr getpid 2 ,
.Xr killpg 2 ,
.Xr sigaction 2 ,
+.Xr sigqueue 2 ,
.Xr raise 3 ,
.Xr init 8
.Sh STANDARDS
diff --git a/lib/libc/sys/kldstat.2 b/lib/libc/sys/kldstat.2
index 7a48296479a6..8b4e5320dd75 100644
--- a/lib/libc/sys/kldstat.2
+++ b/lib/libc/sys/kldstat.2
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 23, 2011
+.Dd March 28, 2012
.Dt KLDSTAT 2
.Os
.Sh NAME
@@ -47,7 +47,7 @@ into
.Fa stat .
.Bd -literal
struct kld_file_stat {
- int version; /* set to sizeof(linker_file_stat) */
+ int version; /* set to sizeof(struct kld_file_stat) */
char name[MAXPATHLEN];
int refs;
int id;
diff --git a/lib/libc/sys/kqueue.2 b/lib/libc/sys/kqueue.2
index 74824056957a..63a662fd678e 100644
--- a/lib/libc/sys/kqueue.2
+++ b/lib/libc/sys/kqueue.2
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 7, 2011
+.Dd February 15, 2012
.Dt KQUEUE 2
.Os
.Sh NAME
@@ -203,7 +203,7 @@ will not return it.
The filter itself is not disabled.
.It EV_DISPATCH
Disable the event source immediately after delivery of an event.
-See
+See
.Dv EV_DISABLE
above.
.It EV_DELETE
@@ -217,7 +217,7 @@ any pending events.
When passed as input, it forces
.Dv EV_ERROR
to always be returned.
-When a filter is successfully added the
+When a filter is successfully added the
.Va data
field will be zero.
.It EV_ONESHOT
@@ -322,6 +322,9 @@ The sigevent portion of the AIO request is filled in, with
.Va sigev_notify_kqueue
containing the descriptor of the kqueue that the event should
be attached to,
+.Va sigev_notify_kevent_flags
+containing the kevent flags which should be EV_ONESHOT, EV_CLEAR or
+EV_DISPATCH,
.Va sigev_value
containing the udata value, and
.Va sigev_notify
@@ -446,10 +449,10 @@ 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
+The lower 24 bits of the
.Va fflags
may be used for user defined flags and manipulated using the following:
-.Bl -tag -width XXNOTE_FFLAGSMASK
+.Bl -tag -width XXNOTE_FFLAGSMASK
.It Dv NOTE_FFNOP
Ignore the input
.Va fflags .
diff --git a/lib/libc/sys/kse.2 b/lib/libc/sys/kse.2
index 92c1de2b4998..41fcc373ea88 100644
--- a/lib/libc/sys/kse.2
+++ b/lib/libc/sys/kse.2
@@ -676,4 +676,4 @@ This manual page was written by
.An "Archie Cobbs" Aq archie@FreeBSD.org .
.Sh BUGS
The KSE code is
-.Ud .
+.Ud
diff --git a/lib/libc/sys/ktrace.2 b/lib/libc/sys/ktrace.2
index 8ab4a33a2112..1740d75057d8 100644
--- a/lib/libc/sys/ktrace.2
+++ b/lib/libc/sys/ktrace.2
@@ -67,12 +67,12 @@ The
argument specifies the requested ktrace operation.
The defined operations are:
.Bl -column KTRFLAG_DESCENDXXX -offset indent
-.It "KTROP_SET Enable trace points specified in"
+.It KTROP_SET Ta "Enable trace points specified in"
.Fa trpoints .
-.It "KTROP_CLEAR Disable trace points specified in"
+.It KTROP_CLEAR Ta "Disable trace points specified in"
.Fa trpoints .
-.It "KTROP_CLEARFILE Stop all tracing."
-.It "KTRFLAG_DESCEND The tracing change should apply to the"
+.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
@@ -81,20 +81,20 @@ The
argument specifies the trace points of interest.
The defined trace points are:
.Bl -column KTRFAC_PROCCTORXXX -offset indent
-.It "KTRFAC_SYSCALL Trace system calls."
-.It "KTRFAC_SYSRET Trace return values from system calls."
-.It "KTRFAC_NAMEI Trace name lookup operations."
-.It "KTRFAC_GENIO Trace all I/O (note that this option can"
+.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 Trace posted signals."
-.It "KTRFAC_CSW Trace context switch points."
-.It "KTRFAC_USER Trace application-specific events."
-.It "KTRFAC_STRUCT Trace certain data structures."
-.It "KTRFAC_SYSCTL Trace sysctls."
-.It "KTRFAC_PROCCTOR Trace process construction."
-.It "KTRFAC_PROCDTOR Trace process destruction."
-.It "KTRFAC_CAPFAIL Trace capability failures."
-.It "KTRFAC_INHERIT Inherit tracing to future children."
+.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_INHERIT Ta "Inherit tracing to future children."
.El
.Pp
Each tracing event outputs a record composed of a generic header
diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2
index 5e0c22664564..73ffb2ead67b 100644
--- a/lib/libc/sys/mmap.2
+++ b/lib/libc/sys/mmap.2
@@ -28,7 +28,7 @@
.\" @(#)mmap.2 8.4 (Berkeley) 5/11/95
.\" $FreeBSD$
.\"
-.Dd August 28, 2010
+.Dd March 18, 2012
.Dt MMAP 2
.Os
.Sh NAME
@@ -205,7 +205,7 @@ command and
system call generally do not flush dirty NOSYNC VM data.
The
.Xr msync 2
-system call is obsolete since
+system call is usually not needed since
.Bx
implements a coherent file system buffer cache.
However, it may be
@@ -356,8 +356,7 @@ was specified and insufficient memory was available.
.Xr msync 2 ,
.Xr munlock 2 ,
.Xr munmap 2 ,
-.Xr getpagesize 3 ,
-.Xr make.conf 5
+.Xr getpagesize 3
.Sh BUGS
The
.Fa len
diff --git a/lib/libc/sys/msync.2 b/lib/libc/sys/msync.2
index cb1592575b5d..42d8005418d1 100644
--- a/lib/libc/sys/msync.2
+++ b/lib/libc/sys/msync.2
@@ -28,7 +28,7 @@
.\" @(#)msync.2 8.2 (Berkeley) 6/21/94
.\" $FreeBSD$
.\"
-.Dd June 21, 1994
+.Dd March 18, 2012
.Dt MSYNC 2
.Os
.Sh NAME
@@ -98,6 +98,9 @@ The
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 ,
@@ -113,7 +116,7 @@ system call first appeared in
.Sh BUGS
The
.Fn msync
-system call is obsolete since
+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
diff --git a/lib/libc/sys/nfssvc.2 b/lib/libc/sys/nfssvc.2
index cf52187cdbd0..f816231ef0a1 100644
--- a/lib/libc/sys/nfssvc.2
+++ b/lib/libc/sys/nfssvc.2
@@ -143,14 +143,14 @@ and a pointer to a
struct nfsd_srvargs {
struct nfsd *nsd_nfsd; /* Pointer to in kernel nfsd struct */
uid_t nsd_uid; /* Effective uid mapped to cred */
- u_int32_t nsd_haddr; /* Ip address of client */
+ 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 */
- u_int32_t nsd_ttl; /* credential ttl (sec) */
+ uint32_t nsd_ttl; /* credential ttl (sec) */
NFSKERBKEY_T nsd_key; /* Session key */
};
.Ed
diff --git a/lib/libc/sys/pathconf.2 b/lib/libc/sys/pathconf.2
index 3cfcdbc99b7e..8bdd5b8acf9e 100644
--- a/lib/libc/sys/pathconf.2
+++ b/lib/libc/sys/pathconf.2
@@ -87,7 +87,6 @@ while
returns information about the file the link references.
.Pp
The available values are as follows:
-.Pp
.Bl -tag -width 6n
.It Li _PC_LINK_MAX
The maximum file link count.
@@ -174,7 +173,7 @@ 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.
+hole size but still reports holes.
.El
.Sh RETURN VALUES
If the call to
diff --git a/lib/libc/sys/pdfork.2 b/lib/libc/sys/pdfork.2
index 3f36e881ec9e..0808fbc91076 100644
--- a/lib/libc/sys/pdfork.2
+++ b/lib/libc/sys/pdfork.2
@@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 16, 2011
+.Dd February 25, 2012
.Dt PDFORK 2
.Os
.Sh NAME
@@ -87,7 +87,7 @@ except that it accepts a process descriptor,
rather than a PID.
.Pp
.Fn pdwait4
-behaves identially to
+behaves identically to
.Xr wait4 2 ,
but operates with respect to a process descriptor argument rather than a PID.
.Pp
@@ -101,7 +101,8 @@ queries status of a process descriptor; currently only the
.Fa st_ctime
and
.Fa st_mtime
-fields are defined. If the owner read, write, and execute bits are set then the
+fields are defined.
+If the owner read, write, and execute bits are set then the
process represented by the process descriptor is still alive.
.Pp
.Xr poll 2
diff --git a/lib/libc/sys/posix_fadvise.2 b/lib/libc/sys/posix_fadvise.2
index bdf321fe2191..37453ff10d96 100644
--- a/lib/libc/sys/posix_fadvise.2
+++ b/lib/libc/sys/posix_fadvise.2
@@ -28,7 +28,7 @@
.\" @(#)madvise.2 8.1 (Berkeley) 6/9/93
.\" $FreeBSD$
.\"
-.Dd October 26, 2011
+.Dd February 25, 2012
.Dt POSIX_FADVISE 2
.Os
.Sh NAME
@@ -74,7 +74,7 @@ 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 asychronous read of the data if it is not already
+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
@@ -89,7 +89,6 @@ descriptor has the
.Dv O_DIRECT
flag enabled.
.El
-.Pp
.Sh RETURN VALUES
.Rv -std posix_fadvise
.Sh ERRORS
diff --git a/lib/libc/sys/posix_fallocate.2 b/lib/libc/sys/posix_fallocate.2
index f7cbd49c4338..087c68c2ecad 100644
--- a/lib/libc/sys/posix_fallocate.2
+++ b/lib/libc/sys/posix_fallocate.2
@@ -28,7 +28,7 @@
.\" @(#)open.2 8.2 (Berkeley) 11/16/93
.\" $FreeBSD$
.\"
-.Dd April 13, 2011
+.Dd February 25, 2012
.Dt POSIX_FALLOCATE 2
.Os
.Sh NAME
@@ -48,7 +48,7 @@ to
.Fa len
in the file referenced by
.Fa fd
-is guarateed to be allocated upon successful return.
+is guaranteed to be allocated upon successful return.
That is, if
.Fn posix_fallocate
returns successfully, subsequent writes to the specified file data
@@ -79,7 +79,6 @@ may be freed by a successful call to
that reduces the file size to a size smaller than
.Fa offset +
.Fa len .
-.Pp
.Sh RETURN VALUES
If successful,
.Fn posix_fallocate
diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2
index 43592283a93e..9dda8ee1b41c 100644
--- a/lib/libc/sys/ptrace.2
+++ b/lib/libc/sys/ptrace.2
@@ -2,7 +2,7 @@
.\" $NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $
.\"
.\" This file is in the public domain.
-.Dd October 5, 2011
+.Dd February 19, 2012
.Dt PTRACE 2
.Os
.Sh NAME
@@ -355,6 +355,11 @@ The process identifier of the new process is available in the
.Va pl_child_pid
member of
.Vt "struct ptrace_lwpinfo" .
+.It PL_FLAG_CHILD
+The flag is set for first event reported from a new child, which is
+automatically attached due to
+.Dv PT_FOLLOW_FORK
+enabled.
.El
.It pl_sigmask
The current signal mask of the LWP
@@ -436,7 +441,7 @@ 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
+argument specifies a pointer to a
.Vt "struct ptrace_vm_entry" ,
which is defined as follows:
.Bd -literal
diff --git a/lib/libc/sys/quotactl.2 b/lib/libc/sys/quotactl.2
index ff3cb4b1756b..6dabff0ec30c 100644
--- a/lib/libc/sys/quotactl.2
+++ b/lib/libc/sys/quotactl.2
@@ -113,7 +113,7 @@ 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
+Possible values are 32 for the old-style quota file
and 64 for the new-style quota file.
The
.Fa addr
@@ -199,7 +199,7 @@ The
.Fa id
argument to
.Dv Q_GETQUOTA ,
-.Dv Q_SETQUOTA
+.Dv Q_SETQUOTA
or
.Dv Q_SETUSE
is a negative value.
diff --git a/lib/libc/sys/read.2 b/lib/libc/sys/read.2
index 19e4ffe7087b..06e0ef10229f 100644
--- a/lib/libc/sys/read.2
+++ b/lib/libc/sys/read.2
@@ -28,7 +28,7 @@
.\" @(#)read.2 8.4 (Berkeley) 2/26/94
.\" $FreeBSD$
.\"
-.Dd October 11, 2006
+.Dd January 22, 2012
.Dt READ 2
.Os
.Sh NAME
@@ -41,12 +41,12 @@
.Lb libc
.Sh SYNOPSIS
.In sys/types.h
-.In sys/uio.h
.In unistd.h
.Ft ssize_t
.Fn read "int d" "void *buf" "size_t nbytes"
.Ft ssize_t
.Fn pread "int d" "void *buf" "size_t nbytes" "off_t offset"
+.In sys/uio.h
.Ft ssize_t
.Fn readv "int d" "const struct iovec *iov" "int iovcnt"
.Ft ssize_t
diff --git a/lib/libc/sys/sctp_generic_sendmsg.2 b/lib/libc/sys/sctp_generic_sendmsg.2
index fee4211a9e69..1a2b12866d97 100644
--- a/lib/libc/sys/sctp_generic_sendmsg.2
+++ b/lib/libc/sys/sctp_generic_sendmsg.2
@@ -54,7 +54,7 @@ and
.Fn sctp_generic_sendmsg_iov
are the true system calls used by the
.Xr sctp_sendmsg 3
-and
+and
.Xr sctp_send 3
function calls.
These are more efficient since they are
@@ -68,7 +68,7 @@ For detailed usage please see either the
.Xr sctp_send 3
or
.Xr sctp_sendmsg 3
-function calls.
+function calls.
.Sh RETURN VALUES
The call returns the number of bytes written on success and -1 upon failure.
.Sh ERRORS
diff --git a/lib/libc/sys/sctp_peeloff.2 b/lib/libc/sys/sctp_peeloff.2
index d94f2800cc33..40a026d8139d 100644
--- a/lib/libc/sys/sctp_peeloff.2
+++ b/lib/libc/sys/sctp_peeloff.2
@@ -51,7 +51,6 @@ The
system call attempts detach the association specified by
.Fa id
into its own separate socket.
-.Pp
.Sh RETURN VALUES
The call returns -1 on failure and the new socket descriptor
upon success.
@@ -61,7 +60,7 @@ The
system call can return the following errors:
.Bl -tag -width Er
.It Bq Er ENOTCONN
-The
+The
.Fa id
given to the call does not map to a valid
association.
diff --git a/lib/libc/sys/select.2 b/lib/libc/sys/select.2
index 2435e3701f12..59a79984f546 100644
--- a/lib/libc/sys/select.2
+++ b/lib/libc/sys/select.2
@@ -222,6 +222,6 @@ Thus, it is unwise to assume that the timeout value will be unmodified
by the
.Fn select
system call.
-.Fx
+.Fx
does not modify the return value, which can cause problems for applications
ported from other systems.
diff --git a/lib/libc/sys/sendfile.2 b/lib/libc/sys/sendfile.2
index d9f8cab56730..9d1fba55409d 100644
--- a/lib/libc/sys/sendfile.2
+++ b/lib/libc/sys/sendfile.2
@@ -104,7 +104,7 @@ variable pointed to by
The
.Fa flags
argument is a bitmap of these values:
-.Bl -item -offset indent
+.Bl -item -offset indent
.It
.Dv SF_NODISKIO .
This flag causes any
diff --git a/lib/libc/sys/setfib.2 b/lib/libc/sys/setfib.2
index a65a064e2f63..ef561d28e72c 100644
--- a/lib/libc/sys/setfib.2
+++ b/lib/libc/sys/setfib.2
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 8, 2008
+.Dd March 19, 2012
.Dt SETFIB 2
.Os
.Sh NAME
@@ -45,11 +45,30 @@ subsequent to the call, to be that of the argument
The
.Fa fib
argument
-may be between 0 and the current system maximum which
-may be retrieved by the
+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 default fib of the process will be applied to all protocol families
+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.
+However, this maximum is capped at 16 due to the implementation storing
+the fib number in a 4-bit field in
+.Xr mbuf 9
+flags.
+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
diff --git a/lib/libc/sys/setuid.2 b/lib/libc/sys/setuid.2
index 4bb4a68ff8a5..4c7d5ad0c67a 100644
--- a/lib/libc/sys/setuid.2
+++ b/lib/libc/sys/setuid.2
@@ -170,7 +170,7 @@ 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 is set:
+call, be sure to set the close-on-exec flag:
.Bd -literal
void
pseudocode(void)
diff --git a/lib/libc/sys/shm_open.2 b/lib/libc/sys/shm_open.2
index a2fa502ce9a8..cc12132247a7 100644
--- a/lib/libc/sys/shm_open.2
+++ b/lib/libc/sys/shm_open.2
@@ -139,7 +139,6 @@ The
.Fn shm_unlink
system call removes a shared memory object named
.Fa path .
-.Pp
.Sh RETURN VALUES
If successful,
.Fn shm_open
diff --git a/lib/libc/sys/sigqueue.2 b/lib/libc/sys/sigqueue.2
index 780b6a03c5b2..9e6a4c520087 100644
--- a/lib/libc/sys/sigqueue.2
+++ b/lib/libc/sys/sigqueue.2
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 11, 2005
+.Dd March 10, 2012
.Dt SIGQUEUE 2
.Os
.Sh NAME
@@ -126,6 +126,7 @@ The process
does not exist.
.El
.Sh SEE ALSO
+.Xr kill 2 ,
.Xr sigaction 2 ,
.Xr sigpending 2 ,
.Xr sigqueue 2 ,
diff --git a/lib/libc/sys/write.2 b/lib/libc/sys/write.2
index 6d608353226d..d22b9854efe3 100644
--- a/lib/libc/sys/write.2
+++ b/lib/libc/sys/write.2
@@ -28,7 +28,7 @@
.\" @(#)write.2 8.5 (Berkeley) 4/2/94
.\" $FreeBSD$
.\"
-.Dd July 7, 2005
+.Dd January 22, 2012
.Dt WRITE 2
.Os
.Sh NAME
@@ -41,12 +41,12 @@
.Lb libc
.Sh SYNOPSIS
.In sys/types.h
-.In sys/uio.h
.In unistd.h
.Ft ssize_t
.Fn write "int d" "const void *buf" "size_t nbytes"
.Ft ssize_t
.Fn pwrite "int d" "const void *buf" "size_t nbytes" "off_t offset"
+.In sys/uio.h
.Ft ssize_t
.Fn writev "int d" "const struct iovec *iov" "int iovcnt"
.Ft ssize_t
diff --git a/lib/libc/uuid/uuid.3 b/lib/libc/uuid/uuid.3
index 4d1020471eab..4fa41dec98bd 100644
--- a/lib/libc/uuid/uuid.3
+++ b/lib/libc/uuid/uuid.3
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 13, 2008
+.Dd March 1, 2012
.Dt UUID 3
.Os
.Sh NAME
@@ -84,6 +84,15 @@ A 16-bit hash value can be obtained by calling
.Fn uuid_hash .
.Pp
The
+.Fn uuid_to_string
+function set
+.Fa *str
+to be a pointer to a buffer sufficiently large to hold the string.
+This pointer should be passed to
+.Xr free 3
+to release the allocated storage when it is no longer needed.
+.Pp
+The
.Fn uuid_enc_le
and
.Fn uuid_enc_be
@@ -116,7 +125,7 @@ The UUID does not have a known version.
.It Dv uuid_s_invalid_string_uuid
The string representation of an UUID is not valid.
.It Dv uuid_s_no_memory
-The meaning of the code escaped the writers mind.
+The function can not allocate memory to store an UUID representation.
.El
.Sh SEE ALSO
.Xr uuidgen 1 ,
diff --git a/lib/libc/yp/Makefile.inc b/lib/libc/yp/Makefile.inc
index 842e63eb08da..6faa9a54175d 100644
--- a/lib/libc/yp/Makefile.inc
+++ b/lib/libc/yp/Makefile.inc
@@ -10,7 +10,7 @@ CLEANFILES+= yp.h yp_xdr.c
SYM_MAPS+= ${.CURDIR}/yp/Symbol.map
RPCSRC= ${DESTDIR}/usr/include/rpcsvc/yp.x
-RPCGEN= rpcgen -C
+RPCGEN= RPCGEN_CPP=${CPP:Q} rpcgen -C
yp_xdr.c: ${RPCSRC}
${RPCGEN} -c -o ${.TARGET} ${RPCSRC}
diff --git a/lib/libcam/cam.3 b/lib/libcam/cam.3
index c11d8fdb21ac..4f918d2c09f9 100644
--- a/lib/libcam/cam.3
+++ b/lib/libcam/cam.3
@@ -145,7 +145,7 @@ struct cam_device {
* Device name given by
* the user.
*/
- u_int32_t given_unit_number; /*
+ uint32_t given_unit_number; /*
* Unit number given by
* the user.
*/
@@ -153,7 +153,7 @@ struct cam_device {
* Name of the device,
* e.g. 'pass'
*/
- u_int32_t dev_unit_num; /* Unit number of the passthrough
+ uint32_t dev_unit_num; /* Unit number of the passthrough
* device associated with this
* particular device.
*/
@@ -161,18 +161,18 @@ struct cam_device {
char sim_name[SIM_IDLEN+1];/*
* Controller name, e.g.'ahc'
*/
- u_int32_t sim_unit_number; /* Controller unit number */
- u_int32_t bus_id; /* Controller bus number */
+ uint32_t sim_unit_number; /* Controller unit number */
+ uint32_t bus_id; /* Controller bus number */
lun_id_t target_lun; /* Logical Unit Number */
target_id_t target_id; /* Target ID */
path_id_t path_id; /* System SCSI bus number */
- u_int16_t pd_type; /* type of peripheral device */
+ uint16_t pd_type; /* type of peripheral device */
struct scsi_inquiry_data inq_data; /* SCSI Inquiry data */
- u_int8_t serial_num[252]; /* device serial number */
- u_int8_t serial_num_len; /* length of the serial number */
- u_int8_t sync_period; /* Negotiated sync period */
- u_int8_t sync_offset; /* Negotiated sync offset */
- u_int8_t bus_width; /* Negotiated bus width */
+ uint8_t serial_num[252]; /* device serial number */
+ uint8_t serial_num_len; /* length of the serial number */
+ uint8_t sync_period; /* Negotiated sync period */
+ uint8_t sync_offset; /* Negotiated sync offset */
+ uint8_t bus_width; /* Negotiated bus width */
int fd; /* file descriptor for device */
};
.Ed
diff --git a/lib/libcam/cam_cdbparse.3 b/lib/libcam/cam_cdbparse.3
index 0dfa6c8c8903..d0f267fa9a17 100644
--- a/lib/libcam/cam_cdbparse.3
+++ b/lib/libcam/cam_cdbparse.3
@@ -83,9 +83,9 @@
.Ft int
.Fo csio_build
.Fa "struct ccb_scsiio *csio"
-.Fa "u_int8_t *data_ptr"
-.Fa "u_int32_t dxfer_len"
-.Fa "u_int32_t flags"
+.Fa "uint8_t *data_ptr"
+.Fa "uint32_t dxfer_len"
+.Fa "uint32_t flags"
.Fa "int retry_count"
.Fa "int timeout"
.Fa "const char *cmd_spec"
@@ -94,9 +94,9 @@
.Ft int
.Fo csio_build_visit
.Fa "struct ccb_scsiio *csio"
-.Fa "u_int8_t *data_ptr"
-.Fa "u_int32_t dxfer_len"
-.Fa "u_int32_t flags"
+.Fa "uint8_t *data_ptr"
+.Fa "uint32_t dxfer_len"
+.Fa "uint32_t flags"
.Fa "int retry_count"
.Fa "int timeout"
.Fa "const char *cmd_spec"
@@ -122,14 +122,14 @@
.Fc
.Ft int
.Fo buff_decode
-.Fa "u_int8_t *buff"
+.Fa "uint8_t *buff"
.Fa "size_t len"
.Fa "const char *fmt"
.Fa "..."
.Fc
.Ft int
.Fo buff_decode_visit
-.Fa "u_int8_t *buff"
+.Fa "uint8_t *buff"
.Fa "size_t len"
.Fa "const char *fmt"
.Fa "void (*arg_put)(void *, int, void *, int, char *)"
@@ -150,7 +150,7 @@
.Fc
.Ft int
.Fo buff_encode_visit
-.Fa "u_int8_t *buff"
+.Fa "uint8_t *buff"
.Fa "size_t len"
.Fa "const char *fmt"
.Fa "int (*arg_get)(void *hook, char *field_name)"
diff --git a/lib/libcam/camlib.c b/lib/libcam/camlib.c
index 525ad2fc653f..ae35fb969c17 100644
--- a/lib/libcam/camlib.c
+++ b/lib/libcam/camlib.c
@@ -121,7 +121,8 @@ cam_get_device(const char *path, char *dev_name, int devnamelen, int *unit)
if (path == NULL) {
- sprintf(cam_errbuf, "%s: device pathname was NULL", func_name);
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: device pathname was NULL", func_name);
return(-1);
}
@@ -143,7 +144,8 @@ cam_get_device(const char *path, char *dev_name, int devnamelen, int *unit)
}
if (*tmpstr == '\0') {
- sprintf(cam_errbuf, "%s: no text after slash", func_name);
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: no text after slash", func_name);
free(newpath);
return(-1);
}
@@ -170,9 +172,9 @@ cam_get_device(const char *path, char *dev_name, int devnamelen, int *unit)
* If we only have 1, we don't have a valid device name.
*/
if (strlen(tmpstr) < 2) {
- sprintf(cam_errbuf,
- "%s: must have both device name and unit number",
- func_name);
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: must have both device name and unit number",
+ func_name);
free(newpath);
return(-1);
}
@@ -182,9 +184,9 @@ cam_get_device(const char *path, char *dev_name, int devnamelen, int *unit)
* has probably given us all numbers. Point out the error.
*/
if (isdigit(*tmpstr)) {
- sprintf(cam_errbuf,
- "%s: device name cannot begin with a number",
- func_name);
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: device name cannot begin with a number",
+ func_name);
free(newpath);
return(-1);
}
@@ -195,8 +197,8 @@ cam_get_device(const char *path, char *dev_name, int devnamelen, int *unit)
* or he gave us a device name/number format we don't recognize.
*/
if (!isdigit(tmpstr[strlen(tmpstr) - 1])) {
- sprintf(cam_errbuf, "%s: unable to find device unit number",
- func_name);
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: unable to find device unit number", func_name);
free(newpath);
return(-1);
}
@@ -324,8 +326,9 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun,
PERIPH_MATCH_LUN | PERIPH_MATCH_NAME;
if (ioctl(fd, CAMIOCOMMAND, &ccb) == -1) {
- sprintf(cam_errbuf, "%s: CAMIOCOMMAND ioctl failed\n"
- "%s: %s", func_name, func_name, strerror(errno));
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: CAMIOCOMMAND ioctl failed\n"
+ "%s: %s", func_name, func_name, strerror(errno));
goto btl_bailout;
}
@@ -335,23 +338,26 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun,
if ((ccb.ccb_h.status != CAM_REQ_CMP)
|| ((ccb.cdm.status != CAM_DEV_MATCH_LAST)
&& (ccb.cdm.status != CAM_DEV_MATCH_MORE))) {
- sprintf(cam_errbuf, "%s: CAM error %#x, CDM error %d "
- "returned from XPT_DEV_MATCH ccb", func_name,
- ccb.ccb_h.status, ccb.cdm.status);
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: CAM error %#x, CDM error %d "
+ "returned from XPT_DEV_MATCH ccb", func_name,
+ ccb.ccb_h.status, ccb.cdm.status);
goto btl_bailout;
}
if (ccb.cdm.status == CAM_DEV_MATCH_MORE) {
- sprintf(cam_errbuf, "%s: CDM reported more than one"
- " passthrough device at %d:%d:%d!!\n",
- func_name, path_id, target_id, target_lun);
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: CDM reported more than one"
+ " passthrough device at %d:%d:%d!!\n",
+ func_name, path_id, target_id, target_lun);
goto btl_bailout;
}
if (ccb.cdm.num_matches == 0) {
- sprintf(cam_errbuf, "%s: no passthrough device found at"
- " %d:%d:%d", func_name, path_id, target_id,
- target_lun);
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: no passthrough device found at"
+ " %d:%d:%d", func_name, path_id, target_id,
+ target_lun);
goto btl_bailout;
}
@@ -372,8 +378,9 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun,
break; /* NOTREACHED */
}
default:
- sprintf(cam_errbuf, "%s: asked for a peripheral match, but"
- " got a bus or device match", func_name);
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: asked for a peripheral match, but"
+ " got a bus or device match", func_name);
goto btl_bailout;
break; /* NOTREACHED */
}
@@ -446,7 +453,7 @@ cam_lookup_pass(const char *dev_name, int unit, int flags,
"your kernel\n%s: or %s%d doesn't exist",
func_name, func_name, dev_name, unit);
}
- snprintf(cam_errbuf, sizeof(cam_errbuf),
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
"%s: CAMGETPASSTHRU ioctl failed\n"
"%s: %s%s", func_name, func_name, strerror(errno),
(errno == ENOENT) ? tmpstr : "");
@@ -464,8 +471,9 @@ cam_lookup_pass(const char *dev_name, int unit, int flags,
* the device the user gave us.
*/
if (ccb.cgdl.status == CAM_GDEVLIST_ERROR) {
- sprintf(cam_errbuf, "%s: device %s%d does not exist!",
- func_name, dev_name, unit);
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: device %s%d does not exist!",
+ func_name, dev_name, unit);
return(NULL);
}
@@ -495,9 +503,10 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
if (device == NULL) {
if ((device = (struct cam_device *)malloc(
sizeof(struct cam_device))) == NULL) {
- sprintf(cam_errbuf, "%s: device structure malloc"
- " failed\n%s: %s", func_name, func_name,
- strerror(errno));
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: device structure malloc"
+ " failed\n%s: %s", func_name, func_name,
+ strerror(errno));
return(NULL);
}
device->fd = -1;
@@ -553,8 +562,9 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
* because we just opened it above. The only way this
* ioctl can fail is if the ccb size is wrong.
*/
- sprintf(cam_errbuf, "%s: CAMGETPASSTHRU ioctl failed\n"
- "%s: %s", func_name, func_name, strerror(errno));
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: CAMGETPASSTHRU ioctl failed\n"
+ "%s: %s", func_name, func_name, strerror(errno));
goto crod_bailout;
}
@@ -565,8 +575,8 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
* the device the user gave us.
*/
if (ccb.cgdl.status == CAM_GDEVLIST_ERROR) {
- sprintf(cam_errbuf, "%s: passthrough device does not exist!",
- func_name);
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: passthrough device does not exist!", func_name);
goto crod_bailout;
}
@@ -579,8 +589,9 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
ccb.ccb_h.func_code = XPT_PATH_INQ;
if (ioctl(fd, CAMIOCOMMAND, &ccb) == -1) {
- sprintf(cam_errbuf, "%s: Path Inquiry CCB failed\n"
- "%s: %s", func_name, func_name, strerror(errno));
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: Path Inquiry CCB failed\n"
+ "%s: %s", func_name, func_name, strerror(errno));
goto crod_bailout;
}
strlcpy(device->sim_name, ccb.cpi.dev_name, sizeof(device->sim_name));
@@ -593,8 +604,9 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
*/
ccb.ccb_h.func_code = XPT_GDEV_TYPE;
if (ioctl(fd, CAMIOCOMMAND, &ccb) == -1) {
- sprintf(cam_errbuf, "%s: Get Device Type CCB failed\n"
- "%s: %s", func_name, func_name, strerror(errno));
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: Get Device Type CCB failed\n"
+ "%s: %s", func_name, func_name, strerror(errno));
goto crod_bailout;
}
device->pd_type = SID_TYPE(&ccb.cgd.inq_data);
@@ -616,8 +628,9 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
ccb.cts.type = CTS_TYPE_CURRENT_SETTINGS;
if (ioctl(fd, CAMIOCOMMAND, &ccb) == -1) {
- sprintf(cam_errbuf, "%s: Get Transfer Settings CCB failed\n"
- "%s: %s", func_name, func_name, strerror(errno));
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: Get Transfer Settings CCB failed\n"
+ "%s: %s", func_name, func_name, strerror(errno));
goto crod_bailout;
}
if (ccb.cts.protocol == XPORT_SPI) {
@@ -696,7 +709,8 @@ cam_device_dup(struct cam_device *device)
struct cam_device *newdev;
if (device == NULL) {
- sprintf(cam_errbuf, "%s: device is NULL", func_name);
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: device is NULL", func_name);
return(NULL);
}
@@ -721,14 +735,14 @@ cam_device_copy(struct cam_device *src, struct cam_device *dst)
char *func_name = "cam_device_copy";
if (src == NULL) {
- sprintf(cam_errbuf, "%s: source device struct was NULL",
- func_name);
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: source device struct was NULL", func_name);
return;
}
if (dst == NULL) {
- sprintf(cam_errbuf, "%s: destination device struct was NULL",
- func_name);
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ "%s: destination device struct was NULL", func_name);
return;
}
diff --git a/lib/libcom_err/Makefile b/lib/libcom_err/Makefile
index 65a3ffd212ad..78014ade5b15 100644
--- a/lib/libcom_err/Makefile
+++ b/lib/libcom_err/Makefile
@@ -7,6 +7,9 @@ MAN= com_err.3
COM_ERRDIR= ${.CURDIR}/../../contrib/com_err
CFLAGS+= -I${COM_ERRDIR}
+LDFLAGS= -Wl,--no-undefined
+VERSION_MAP= ${COM_ERRDIR}/version-script.map
+
SUBDIR= doc
.include <bsd.lib.mk>
diff --git a/lib/libcrypt/crypt.3 b/lib/libcrypt/crypt.3
index d3f89e20076f..949a7a70e46f 100644
--- a/lib/libcrypt/crypt.3
+++ b/lib/libcrypt/crypt.3
@@ -107,7 +107,6 @@ A brief test on a
crypt to do approximately 2640 crypts
a CPU second and MD5 to do about 62 crypts a CPU second.
.Ss DES Extended Format:
-.Pp
The
.Ar key
is divided into groups of 8 characters (the last group is null-padded)
@@ -163,7 +162,6 @@ string, 20 or 13 bytes (plus null) in length, consisting of the
.Ar salt
followed by the encoded 64-bit encryption.
.Ss "Modular" crypt:
-.Pp
If the salt begins with the string
.Fa $digit$
then the Modular Crypt Format is used.
@@ -189,6 +187,8 @@ Blowfish
.It
NT-Hash
.It
+(unused)
+.It
SHA-256
.It
SHA-512
@@ -199,9 +199,7 @@ An example salt would be:
.Bl -tag -offset indent
.It Cm "$4$thesalt$rest"
.El
-.Pp
.Ss "Traditional" crypt:
-.Pp
The algorithm used will depend upon whether
.Fn crypt_set_format
has been called and whether a global default format has been specified.
diff --git a/lib/libcxxrt/Makefile b/lib/libcxxrt/Makefile
index f1dd957c81a2..e7105460352c 100644
--- a/lib/libcxxrt/Makefile
+++ b/lib/libcxxrt/Makefile
@@ -21,5 +21,6 @@ SRCS+= libelftc_dem_gnu3.c\
WARNS= 0
CFLAGS+= -I${SRCDIR}
+VERSION_MAP= ${.CURDIR}/Version.map
.include <bsd.lib.mk>
diff --git a/lib/libcxxrt/Version.map b/lib/libcxxrt/Version.map
new file mode 100644
index 000000000000..b5be60e5ac21
--- /dev/null
+++ b/lib/libcxxrt/Version.map
@@ -0,0 +1,323 @@
+# $FreeBSD$
+# 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_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;
+ __cxa_guard_abort;
+ __cxa_guard_acquire;
+ __cxa_guard_release;
+ __cxa_pure_virtual;
+ __cxa_rethrow;
+ __cxa_throw;
+ __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.
+ "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::type_info(std::type_info const&)";
+ "std::type_info::~type_info()";
+ "std::type_info::~type_info()";
+ "std::type_info::~type_info()";
+ "std::type_info::operator=(std::type_info const&)";
+ "std::unexpected()";
+ "std::get_terminate()";
+ "std::set_terminate(void (*)())";
+ "std::get_unexpected()";
+ "std::set_unexpected(void (*)())";
+ "std::set_new_handler(void (*)())";
+ "std::uncaught_exception()";
+ "std::terminate()";
+
+
+ # Extensions
+ "pathscale::set_terminate(void (*)())";
+ "pathscale::set_unexpected(void (*)())";
+ "pathscale::set_use_thread_local_handlers(bool)";
+
+
+ };
+
+ local:
+ *;
+};
+
+CXXABI_1.3.1 {
+ __cxa_get_exception_ptr;
+} CXXABI_1.3;
+
+
+CXXRT_1.0 {
+
+ extern "C++" {
+ "std::bad_cast::what() const";
+ "std::bad_typeid::what() const";
+ "std::bad_alloc::what() const";
+ "std::exception::what() const";
+ "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_typeid::bad_typeid(std::bad_typeid const&)";
+ "std::bad_typeid::bad_typeid()";
+ "std::bad_typeid::bad_typeid(std::bad_typeid const&)";
+ "std::bad_typeid::bad_typeid()";
+ "std::bad_typeid::~bad_typeid()";
+ "std::bad_typeid::~bad_typeid()";
+ "std::bad_typeid::~bad_typeid()";
+ "std::bad_typeid::operator=(std::bad_typeid const&)";
+ "std::bad_cast::bad_cast(std::bad_cast const&)";
+ "std::bad_cast::bad_cast()";
+ "std::bad_cast::bad_cast(std::bad_cast const&)";
+ "std::bad_cast::bad_cast()";
+ "std::bad_cast::~bad_cast()";
+ "std::bad_cast::~bad_cast()";
+ "std::bad_cast::~bad_cast()";
+ "std::bad_cast::operator=(std::bad_cast const&)";
+ "std::bad_alloc::bad_alloc(std::bad_alloc const&)";
+ "std::bad_alloc::bad_alloc()";
+ "std::bad_alloc::bad_alloc(std::bad_alloc const&)";
+ "std::bad_alloc::bad_alloc()";
+ "std::bad_alloc::~bad_alloc()";
+ "std::bad_alloc::~bad_alloc()";
+ "std::bad_alloc::~bad_alloc()";
+ "std::bad_alloc::operator=(std::bad_alloc const&)";
+ "std::exception::exception(std::exception const&)";
+ "std::exception::exception()";
+ "std::exception::exception(std::exception const&)";
+ "std::exception::exception()";
+ "std::exception::~exception()";
+ "std::exception::~exception()";
+ "std::exception::~exception()";
+ "std::exception::operator=(std::exception const&)";
+
+
+ "vtable for std::bad_typeid";
+ "vtable for std::bad_cast";
+ "vtable for std::bad_alloc";
+ "vtable for std::exception";
+ "vtable for std::type_info";
+ "typeinfo for std::bad_typeid";
+ "typeinfo for std::bad_cast";
+ "typeinfo for std::bad_alloc";
+ "typeinfo for std::exception";
+ "typeinfo for std::type_info";
+ "typeinfo name for std::bad_typeid";
+ "typeinfo name for std::bad_cast";
+ "typeinfo name for std::bad_alloc";
+ "typeinfo name for std::exception";
+ "typeinfo name for std::type_info";
+
+ "std::type_info::__is_function_p() const";
+ "std::type_info::__do_upcast(__cxxabiv1::__class_type_info const*, void**) const";
+ "std::type_info::__is_pointer_p() const";
+
+
+ "operator delete[](void*)";
+ "operator delete(void*)";
+ "operator new[](unsigned long)";
+ "operator new(unsigned long)";
+ "operator new(unsigned long, std::nothrow_t 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.1;
diff --git a/lib/libdevstat/devstat.3 b/lib/libdevstat/devstat.3
index fb8214667805..8d0ce4dc0117 100644
--- a/lib/libdevstat/devstat.3
+++ b/lib/libdevstat/devstat.3
@@ -193,7 +193,7 @@ subelement contains the following elements:
.Bd -literal -offset indent
struct devinfo {
struct devstat *devices;
- u_int8_t *mem_ptr;
+ uint8_t *mem_ptr;
long generation;
int numdevs;
};
@@ -472,7 +472,7 @@ structure to calculate statistics over
For each statistics to be calculated, the user should supply the proper
enumerated type (listed below), and a variable of the indicated type.
All statistics are either integer values, for which a
-.Vt u_int64_t
+.Vt uint64_t
is used,
or floating point, for which a
.Vt "long double"
@@ -489,7 +489,7 @@ be the last argument passed to
It is an argument list terminator.
.It Dv DSM_TOTAL_BYTES
type:
-.Vt "u_int64_t *"
+.Vt "uint64_t *"
.Pp
The total number of bytes transferred between the acquisition of
.Fa previous
@@ -499,7 +499,7 @@ and
.It Dv DSM_TOTAL_BYTES_WRITE
.It Dv DSM_TOTAL_BYTES_FREE
type:
-.Vt "u_int64_t *"
+.Vt "uint64_t *"
.Pp
The total number of bytes in transactions of the specified type
between the acquisition of
@@ -508,7 +508,7 @@ and
.Fa current .
.It Dv DSM_TOTAL_TRANSFERS
type:
-.Vt "u_int64_t *"
+.Vt "uint64_t *"
.Pp
The total number of transfers between the acquisition of
.Fa previous
@@ -519,7 +519,7 @@ and
.It Dv DSM_TOTAL_TRANSFERS_WRITE
.It Dv DSM_TOTAL_TRANSFERS_FREE
type:
-.Vt "u_int64_t *"
+.Vt "uint64_t *"
.Pp
The total number of transactions of the specified type between
the acquisition of
@@ -528,7 +528,7 @@ and
.Fa current .
.It Dv DSM_TOTAL_BLOCKS
type:
-.Vt "u_int64_t *"
+.Vt "uint64_t *"
.Pp
The total number of blocks transferred between the acquisition of
.Fa previous
@@ -541,7 +541,7 @@ blocksize of 512 bytes will be used in the calculation.
.It Dv DSM_TOTAL_BLOCKS_WRITE
.It Dv DSM_TOTAL_BLOCKS_FREE
type:
-.Vt "u_int64_t *"
+.Vt "uint64_t *"
.Pp
The total number of blocks of the specified type between the acquisition of
.Fa previous
@@ -665,7 +665,7 @@ and
.Fa current .
.It Dv DSM_QUEUE_LENGTH
type:
-.Vt "u_int64_t *"
+.Vt "uint64_t *"
.Pp
The number of not yet completed transactions at the time when
.Fa current
diff --git a/lib/libdevstat/devstat.c b/lib/libdevstat/devstat.c
index 06d214858318..ff0767a42db6 100644
--- a/lib/libdevstat/devstat.c
+++ b/lib/libdevstat/devstat.c
@@ -365,6 +365,12 @@ devstat_getdevs(kvm_t *kd, struct statinfo *stats)
dssize = (dinfo->numdevs * sizeof(struct devstat)) +
sizeof(long);
dinfo->mem_ptr = (u_int8_t *)malloc(dssize);
+ if (dinfo->mem_ptr == NULL) {
+ snprintf(devstat_errbuf, sizeof(devstat_errbuf),
+ "%s: Cannot allocate memory for mem_ptr element",
+ __func__);
+ return(-1);
+ }
} else
dssize = (dinfo->numdevs * sizeof(struct devstat)) +
sizeof(long);
@@ -567,7 +573,7 @@ devstat_selectdevs(struct device_selection **dev_select, int *num_selected,
* either enlarge or reduce the size of the device selection list.
*/
} else if (*num_selections != numdevs) {
- *dev_select = (struct device_selection *)realloc(*dev_select,
+ *dev_select = (struct device_selection *)reallocf(*dev_select,
numdevs * sizeof(struct device_selection));
*select_generation = current_generation;
init_selections = 1;
@@ -581,6 +587,13 @@ devstat_selectdevs(struct device_selection **dev_select, int *num_selected,
init_selections = 1;
}
+ if (*dev_select == NULL) {
+ snprintf(devstat_errbuf, sizeof(devstat_errbuf),
+ "%s: Cannot (re)allocate memory for dev_select argument",
+ __func__);
+ return(-1);
+ }
+
/*
* If we're in "only" mode, we want to clear out the selected
* variable since we're going to select exactly what the user wants
@@ -608,6 +621,12 @@ devstat_selectdevs(struct device_selection **dev_select, int *num_selected,
|| (perf_select != 0)) && (changed == 0)){
old_dev_select = (struct device_selection *)malloc(
*num_selections * sizeof(struct device_selection));
+ if (old_dev_select == NULL) {
+ snprintf(devstat_errbuf, sizeof(devstat_errbuf),
+ "%s: Cannot allocate memory for selection list backup",
+ __func__);
+ return(-1);
+ }
old_num_selections = *num_selections;
bcopy(*dev_select, old_dev_select,
sizeof(struct device_selection) * *num_selections);
@@ -1028,16 +1047,17 @@ devstat_buildmatch(char *match_str, struct devstat_match **matches,
return(-1);
}
- /*
- * Since you can't realloc a pointer that hasn't been malloced
- * first, we malloc first and then realloc.
- */
if (*num_matches == 0)
- *matches = (struct devstat_match *)malloc(
- sizeof(struct devstat_match));
- else
- *matches = (struct devstat_match *)realloc(*matches,
- sizeof(struct devstat_match) * (*num_matches + 1));
+ *matches = NULL;
+
+ *matches = (struct devstat_match *)reallocf(*matches,
+ sizeof(struct devstat_match) * (*num_matches + 1));
+
+ if (*matches == NULL) {
+ snprintf(devstat_errbuf, sizeof(devstat_errbuf),
+ "%s: Cannot allocate memory for matches list", __func__);
+ return(-1);
+ }
/* Make sure the current entry is clear */
bzero(&matches[0][*num_matches], sizeof(struct devstat_match));
diff --git a/lib/libdisk/libdisk.h b/lib/libdisk/libdisk.h
index 301d0540166e..a302c645b4d1 100644
--- a/lib/libdisk/libdisk.h
+++ b/lib/libdisk/libdisk.h
@@ -293,8 +293,6 @@ int Fixup_Names(struct disk *);
int MakeDevChunk(const struct chunk *, const char *);
__END_DECLS
-#define dprintf printf
-
/* TODO
*
* Need an error string mechanism from the functions instead of warn()
diff --git a/lib/libedit/edit/readline/Makefile b/lib/libedit/edit/readline/Makefile
index 9dc4a5958c10..c36bb686ef9b 100644
--- a/lib/libedit/edit/readline/Makefile
+++ b/lib/libedit/edit/readline/Makefile
@@ -1,8 +1,7 @@
# Copyright (c) 2011 David E O'Brien
# $FreeBSD$
-INCS= readline.h history.h
-INCSLINKS= readline.h ${INCSDIR}/tilde.h
+INCS= readline.h history.h tilde.h
INCSDIR= ${INCLUDEDIR}/edit/readline
diff --git a/lib/libedit/edit/readline/tilde.h b/lib/libedit/edit/readline/tilde.h
new file mode 100644
index 000000000000..1b84338470e7
--- /dev/null
+++ b/lib/libedit/edit/readline/tilde.h
@@ -0,0 +1,32 @@
+/*-
+ * Copyright (c) 2011 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 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <edit/readline/readline.h>
diff --git a/lib/libelf/elf.3 b/lib/libelf/elf.3
index e3e01bc7ac22..609fab60c0a2 100644
--- a/lib/libelf/elf.3
+++ b/lib/libelf/elf.3
@@ -523,7 +523,7 @@ flag on an ELF descriptor using
.Xr elf_flagelf 3 ,
following which the library will use the data offsets and alignments
specified by the application when laying out the file.
-Application control of file layout is described further in the
+Application control of file layout is described further in the
.Xr elf_update 3
manual page.
.Pp
diff --git a/lib/libelf/elf_getdata.3 b/lib/libelf/elf_getdata.3
index 59e0ef6a05ea..9416a2c788f8 100644
--- a/lib/libelf/elf_getdata.3
+++ b/lib/libelf/elf_getdata.3
@@ -174,7 +174,7 @@ These functions return a valid pointer to a data descriptor if successful, or
NULL if an error occurs.
.Sh ERRORS
These functions may fail with the following errors:
-.Bl -tag -width "[ELF_E_RESOURCE]"
+.Bl -tag -width "[ELF_E_RESOURCE]"
.It Bq Er ELF_E_ARGUMENT
Arguments
.Ar scn
diff --git a/lib/libelf/elf_getphdrnum.3 b/lib/libelf/elf_getphdrnum.3
index 290c69ac87a6..9a25bf69e3e3 100644
--- a/lib/libelf/elf_getphdrnum.3
+++ b/lib/libelf/elf_getphdrnum.3
@@ -24,8 +24,8 @@
.\" $FreeBSD$
.\"
.Dd August 5, 2009
-.Os
.Dt ELF_GETPHDRNUM 3
+.Os
.Sh NAME
.Nm elf_getphdrnum
.Nd return the number of program headers in an ELF file
@@ -45,7 +45,6 @@ and stores it into the location pointed to by argument
.Pp
This routine allows applications to uniformly process both normal ELF
objects and ELF objects that use extended numbering.
-.Pp
.Sh RETURN VALUES
Function
.Fn elf_getphdrnum
diff --git a/lib/libelf/elf_getphnum.3 b/lib/libelf/elf_getphnum.3
index abf4b395c4de..174ecb58df4b 100644
--- a/lib/libelf/elf_getphnum.3
+++ b/lib/libelf/elf_getphnum.3
@@ -50,7 +50,6 @@ and stores it into the location pointed to by argument
.Pp
This routine allows applications to uniformly process both normal ELF
objects and ELF objects that use extended numbering.
-.Pp
.Sh RETURN VALUES
Function
.Fn elf_getphnum
diff --git a/lib/libelf/elf_getshdrnum.3 b/lib/libelf/elf_getshdrnum.3
index 0128e0a0268f..42a1194215cd 100644
--- a/lib/libelf/elf_getshdrnum.3
+++ b/lib/libelf/elf_getshdrnum.3
@@ -24,8 +24,8 @@
.\" $FreeBSD$
.\"
.Dd August 4, 2009
-.Os
.Dt ELF_GETSHDRNUM 3
+.Os
.Sh NAME
.Nm elf_getshdrnum
.Nd return the number of sections in an ELF file
@@ -45,7 +45,6 @@ and stores it into the location pointed to by argument
.Pp
This routine allows applications to uniformly process both normal ELF
objects, and ELF objects that use extended section numbering.
-.Pp
.Sh RETURN VALUES
Function
.Fn elf_getshdrnum
diff --git a/lib/libelf/elf_getshdrstrndx.3 b/lib/libelf/elf_getshdrstrndx.3
index 009662ec1bb9..ea4c65c42b03 100644
--- a/lib/libelf/elf_getshdrstrndx.3
+++ b/lib/libelf/elf_getshdrstrndx.3
@@ -24,8 +24,8 @@
.\" $FreeBSD$
.\"
.Dd August 5, 2009
-.Os
.Dt ELF_GETSHDRSTRNDX 3
+.Os
.Sh NAME
.Nm elf_getshdrstrndx
.Nd retrieve the index of the section name string table
@@ -46,7 +46,6 @@ and stores it into the location pointed to by argument
.Pp
This function allow applications to process both normal ELF
objects and ELF objects that use extended section numbering uniformly.
-.Pp
.Sh RETURN VALUES
These functions return zero if successful, or -1 in case of an error.
.Sh ERRORS
diff --git a/lib/libelf/elf_getshnum.3 b/lib/libelf/elf_getshnum.3
index 41b519e29716..41431fed73ba 100644
--- a/lib/libelf/elf_getshnum.3
+++ b/lib/libelf/elf_getshnum.3
@@ -50,7 +50,6 @@ and stores it into the location pointed to by argument
.Pp
This routine allows applications to uniformly process both normal ELF
objects, and ELF objects that use extended section numbering.
-.Pp
.Sh RETURN VALUES
Function
.Fn elf_getshnum
diff --git a/lib/libelf/elf_getshstrndx.3 b/lib/libelf/elf_getshstrndx.3
index f042a6f72393..a7202773b225 100644
--- a/lib/libelf/elf_getshstrndx.3
+++ b/lib/libelf/elf_getshstrndx.3
@@ -60,7 +60,6 @@ sets the index of the section name string table to argument
.Pp
These routines allow applications to process both normal ELF
objects and ELF objects that use extended section numbering uniformly.
-.Pp
.Sh RETURN VALUES
These functions return a non-zero value if successful, or zero in case
of an error.
diff --git a/lib/libelf/libelf_data.c b/lib/libelf/libelf_data.c
index ee2d57a4cb79..3fbb067eaee9 100644
--- a/lib/libelf/libelf_data.c
+++ b/lib/libelf/libelf_data.c
@@ -86,6 +86,10 @@ _libelf_xlate_shtype(uint32_t sht)
#endif
case SHT_MIPS_DWARF:
/* FALLTHROUGH */
+ case SHT_MIPS_REGINFO:
+ /* FALLTHROUGH */
+ case SHT_MIPS_OPTIONS:
+ /* FALLTHROUGH */
case SHT_AMD64_UNWIND: /* == SHT_IA_64_UNWIND */
return (ELF_T_BYTE);
default:
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
index 0d5f2d6448ee..e6f67c30a37c 100644
--- a/lib/libfetch/common.c
+++ b/lib/libfetch/common.c
@@ -404,6 +404,33 @@ fetch_ssl_read(SSL *ssl, char *buf, size_t len)
}
#endif
+/*
+ * Cache some data that was read from a socket but cannot be immediately
+ * returned because of an interrupted system call.
+ */
+static int
+fetch_cache_data(conn_t *conn, char *src, size_t nbytes)
+{
+ char *tmp;
+
+ if (conn->cache.size < nbytes) {
+ tmp = realloc(conn->cache.buf, nbytes);
+ if (tmp == NULL) {
+ fetch_syserr();
+ return (-1);
+ }
+ conn->cache.buf = tmp;
+ conn->cache.size = nbytes;
+ }
+
+ memcpy(conn->cache.buf, src, nbytes);
+ conn->cache.len = nbytes;
+ conn->cache.pos = 0;
+
+ return (0);
+}
+
+
static ssize_t
fetch_socket_read(int sd, char *buf, size_t len)
{
@@ -429,6 +456,7 @@ fetch_read(conn_t *conn, char *buf, size_t len)
fd_set readfds;
ssize_t rlen, total;
int r;
+ char *start;
if (fetchTimeout) {
FD_ZERO(&readfds);
@@ -437,6 +465,24 @@ fetch_read(conn_t *conn, char *buf, size_t len)
}
total = 0;
+ start = buf;
+
+ if (conn->cache.len > 0) {
+ /*
+ * The last invocation of fetch_read was interrupted by a
+ * signal after some data had been read from the socket. Copy
+ * the cached data into the supplied buffer before trying to
+ * read from the socket again.
+ */
+ total = (conn->cache.len < len) ? conn->cache.len : len;
+ memcpy(buf, conn->cache.buf, total);
+
+ conn->cache.len -= total;
+ conn->cache.pos += total;
+ len -= total;
+ buf += total;
+ }
+
while (len > 0) {
/*
* The socket is non-blocking. Instead of the canonical
@@ -472,6 +518,8 @@ fetch_read(conn_t *conn, char *buf, size_t len)
total += rlen;
continue;
} else if (rlen == FETCH_READ_ERROR) {
+ if (errno == EINTR)
+ fetch_cache_data(conn, start, total);
return (-1);
}
// assert(rlen == FETCH_READ_WAIT);
@@ -492,8 +540,12 @@ fetch_read(conn_t *conn, char *buf, size_t len)
errno = 0;
r = select(conn->sd + 1, &readfds, NULL, NULL, &delta);
if (r == -1) {
- if (errno == EINTR && fetchRestartCalls)
- continue;
+ if (errno == EINTR) {
+ if (fetchRestartCalls)
+ continue;
+ /* Save anything that was read. */
+ fetch_cache_data(conn, start, total);
+ }
fetch_syserr();
return (-1);
}
@@ -677,6 +729,7 @@ fetch_close(conn_t *conn)
if (--conn->ref > 0)
return (0);
ret = close(conn->sd);
+ free(conn->cache.buf);
free(conn->buf);
free(conn);
return (ret);
diff --git a/lib/libfetch/common.h b/lib/libfetch/common.h
index 35e0dfd0a7c8..241dbbf8b465 100644
--- a/lib/libfetch/common.h
+++ b/lib/libfetch/common.h
@@ -52,6 +52,13 @@ struct fetchconn {
size_t bufsize; /* buffer size */
size_t buflen; /* length of buffer contents */
int err; /* last protocol reply code */
+ struct { /* data cached after an interrupted
+ read */
+ char *buf;
+ size_t size;
+ size_t pos;
+ size_t len;
+ } cache;
#ifdef WITH_SSL
SSL *ssl; /* SSL handle */
SSL_CTX *ssl_ctx; /* SSL context */
diff --git a/lib/libfetch/fetch.3 b/lib/libfetch/fetch.3
index 40d66bfd59f8..30372f21fdc0 100644
--- a/lib/libfetch/fetch.3
+++ b/lib/libfetch/fetch.3
@@ -375,7 +375,7 @@ If the
(if-modified-since) flag is specified, and
the
.Va ims_time
-field is set in
+field is set in
.Vt "struct url" ,
then
.Fn fetchXGetHTTP
diff --git a/lib/libfetch/fetch.c b/lib/libfetch/fetch.c
index f4c4a707d526..a081520143e5 100644
--- a/lib/libfetch/fetch.c
+++ b/lib/libfetch/fetch.c
@@ -289,6 +289,49 @@ fetchMakeURL(const char *scheme, const char *host, int port, const char *doc,
}
/*
+ * Return value of the given hex digit.
+ */
+static int
+fetch_hexval(char ch)
+{
+
+ if (ch >= '0' && ch <= '9')
+ return (ch - '0');
+ else if (ch >= 'a' && ch <= 'f')
+ return (ch - 'a' + 10);
+ else if (ch >= 'A' && ch <= 'F')
+ return (ch - 'A' + 10);
+ return (-1);
+}
+
+/*
+ * Decode percent-encoded URL component from src into dst, stopping at end
+ * of string, or at @ or : separators. Returns a pointer to the unhandled
+ * part of the input string (null terminator, @, or :). No terminator is
+ * written to dst (it is the caller's responsibility).
+ */
+static const char *
+fetch_pctdecode(char *dst, const char *src, size_t dlen)
+{
+ int d1, d2;
+ char c;
+ const char *s;
+
+ for (s = src; *s != '\0' && *s != '@' && *s != ':'; s++) {
+ if (s[0] == '%' && (d1 = fetch_hexval(s[1])) >= 0 &&
+ (d2 = fetch_hexval(s[2])) >= 0 && (d1 > 0 || d2 > 0)) {
+ c = d1 << 4 | d2;
+ s += 2;
+ } else {
+ c = *s;
+ }
+ if (dlen-- > 0)
+ *dst++ = c;
+ }
+ return (s);
+}
+
+/*
* Split an URL into components. URL syntax is:
* [method:/][/[user[:pwd]@]host[:port]/][document]
* This almost, but not quite, RFC1738 URL syntax.
@@ -329,15 +372,11 @@ fetchParseURL(const char *URL)
p = strpbrk(URL, "/@");
if (p && *p == '@') {
/* username */
- for (q = URL, i = 0; (*q != ':') && (*q != '@'); q++)
- if (i < URL_USERLEN)
- u->user[i++] = *q;
+ q = fetch_pctdecode(u->user, URL, URL_USERLEN);
/* password */
if (*q == ':')
- for (q++, i = 0; (*q != ':') && (*q != '@'); q++)
- if (i < URL_PWDLEN)
- u->pwd[i++] = *q;
+ q = fetch_pctdecode(u->pwd, ++q, URL_PWDLEN);
p++;
} else {
diff --git a/lib/libfetch/http.c b/lib/libfetch/http.c
index b33d6f10dbc7..557ff26ebf94 100644
--- a/lib/libfetch/http.c
+++ b/lib/libfetch/http.c
@@ -196,6 +196,8 @@ http_growbuf(struct httpio *io, size_t len)
static int
http_fillbuf(struct httpio *io, size_t len)
{
+ ssize_t nbytes;
+
if (io->error)
return (-1);
if (io->eof)
@@ -204,10 +206,11 @@ http_fillbuf(struct httpio *io, size_t len)
if (io->chunked == 0) {
if (http_growbuf(io, len) == -1)
return (-1);
- if ((io->buflen = fetch_read(io->conn, io->buf, len)) == -1) {
- io->error = 1;
+ if ((nbytes = fetch_read(io->conn, io->buf, len)) == -1) {
+ io->error = errno;
return (-1);
}
+ io->buflen = nbytes;
io->bufpos = 0;
return (io->buflen);
}
@@ -227,10 +230,11 @@ http_fillbuf(struct httpio *io, size_t len)
len = io->chunksize;
if (http_growbuf(io, len) == -1)
return (-1);
- if ((io->buflen = fetch_read(io->conn, io->buf, len)) == -1) {
- io->error = 1;
+ if ((nbytes = fetch_read(io->conn, io->buf, len)) == -1) {
+ io->error = errno;
return (-1);
}
+ io->buflen = nbytes;
io->chunksize -= io->buflen;
if (io->chunksize == 0) {
@@ -272,8 +276,11 @@ http_readfn(void *v, char *buf, int len)
io->bufpos += l;
}
- if (!pos && io->error)
+ if (!pos && io->error) {
+ if (io->error == EINTR)
+ io->error = 0;
return (-1);
+ }
return (pos);
}
diff --git a/lib/libgpib/gpib.3 b/lib/libgpib/gpib.3
index b587da6682b5..9d80ae0aadc6 100644
--- a/lib/libgpib/gpib.3
+++ b/lib/libgpib/gpib.3
@@ -279,7 +279,6 @@ Device trigger status
Device clear state
.El
.Ss Function Description
-.Pp
The function
.Fn ibdev
is used to open the GPIB device, and establish the parameters to
diff --git a/lib/libgssapi/Symbol.map b/lib/libgssapi/Symbol.map
index 717f1b9e5af1..f90b7ab92ab7 100644
--- a/lib/libgssapi/Symbol.map
+++ b/lib/libgssapi/Symbol.map
@@ -73,4 +73,5 @@ FBSDprivate_1.0 {
_gss_copy_oid;
_gss_copy_buffer;
_gss_free_oid;
+ _gss_mg_collect_error;
};
diff --git a/lib/libgssapi/gss_accept_sec_context.3 b/lib/libgssapi/gss_accept_sec_context.3
index cd80db69d01c..825c28d04b88 100644
--- a/lib/libgssapi/gss_accept_sec_context.3
+++ b/lib/libgssapi/gss_accept_sec_context.3
@@ -39,7 +39,7 @@
.In "gssapi/gssapi.h"
.Ft OM_uint32
.Fo gss_accept_sec_context
-.Fa "OM_uint32 *minor_status
+.Fa "OM_uint32 *minor_status"
.Fa "gss_ctx_id_t *context_handle"
.Fa "const gss_cred_id_t acceptor_cred_handle"
.Fa "const gss_buffer_t input_token_buffer"
diff --git a/lib/libgssapi/gss_display_status.c b/lib/libgssapi/gss_display_status.c
index 0374fbd8053d..b2a22d21fb48 100644
--- a/lib/libgssapi/gss_display_status.c
+++ b/lib/libgssapi/gss_display_status.c
@@ -26,7 +26,7 @@
* $FreeBSD$
*/
/*
- * Copyright (c) 1998 - 2005 Kungliga Tekniska Högskolan
+ * Copyright (c) 1998 - 2005 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -58,7 +58,7 @@
* SUCH DAMAGE.
*/
/*
- * Copyright (c) 1998 - 2005 Kungliga Tekniska Högskolan
+ * Copyright (c) 1998 - 2005 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -173,7 +173,7 @@ supplementary_error(OM_uint32 v)
return msgs[v];
}
-#if defined(__sparc64__) || defined(__arm__) || defined(__mips__)
+#if defined(__NO_TLS)
/*
* These platforms don't support TLS on FreeBSD - threads will just
@@ -338,3 +338,13 @@ gss_display_status(OM_uint32 *minor_status,
_gss_buffer_zero(status_string);
return (GSS_S_BAD_STATUS);
}
+
+void
+_gss_mg_collect_error(gss_OID mech, OM_uint32 maj, OM_uint32 min)
+{
+ struct _gss_mech_switch *m;
+
+ m = _gss_find_mech_switch(mech);
+ if (m != NULL)
+ _gss_mg_error(m, maj, min);
+}
diff --git a/lib/libgssapi/gss_pseudo_random.c b/lib/libgssapi/gss_pseudo_random.c
index 72166099512a..c250d717a62f 100644
--- a/lib/libgssapi/gss_pseudo_random.c
+++ b/lib/libgssapi/gss_pseudo_random.c
@@ -1,5 +1,5 @@
-/*
- * Copyright (c) 2007 Kungliga Tekniska Högskolan
+/*-
+ * Copyright (c) 2007 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
diff --git a/lib/libgssapi/gss_release_buffer.3 b/lib/libgssapi/gss_release_buffer.3
index 259db3ba6b8e..c4acf81faf49 100644
--- a/lib/libgssapi/gss_release_buffer.3
+++ b/lib/libgssapi/gss_release_buffer.3
@@ -53,7 +53,7 @@ field in the descriptor to
.Dv NULL .
Any buffer object returned by a GSS-API routine may be passed to
.Fn gss_release_buffer
-(even if there is no storage associated with the buffer).
+(even if there is no storage associated with the buffer).
.Sh PARAMETERS
.Bl -tag
.It minor_status
diff --git a/lib/libgssapi/gss_release_oid.c b/lib/libgssapi/gss_release_oid.c
index a2e7a61a6678..01d06937f13e 100644
--- a/lib/libgssapi/gss_release_oid.c
+++ b/lib/libgssapi/gss_release_oid.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2006 Kungliga Tekniska Högskolan
+ * Copyright (c) 2006 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
diff --git a/lib/libgssapi/gss_release_oid_set.3 b/lib/libgssapi/gss_release_oid_set.3
index 391ad283c799..7de4e9ae195d 100644
--- a/lib/libgssapi/gss_release_oid_set.3
+++ b/lib/libgssapi/gss_release_oid_set.3
@@ -53,7 +53,7 @@ and the gss_OID_set_desc itself.
.Pp
Implementations are encouraged to set the gss_OID_set parameter to
.Dv GSS_C_NO_OID_SET
-on successful completion of this routine.
+on successful completion of this routine.
.Sh PARAMETERS
.Bl -tag
.It minor_status
diff --git a/lib/libgssapi/mech.5 b/lib/libgssapi/mech.5
index 6078828e97fc..b56565e3d15d 100644
--- a/lib/libgssapi/mech.5
+++ b/lib/libgssapi/mech.5
@@ -62,10 +62,10 @@ This mechanism will be used by
.Xr gss_init_sec_context 3
if the user doesn't specify a specific mechanism.
.Pp
-The
+The
.Pa "/etc/gss/qop"
file contains a list of Quality of Protection values for use with
-GSS-API.
+GSS-API.
Each line of the file either contains a comment if the first character
is '#' or it contains three fields with the following meanings:
.Bl -tag
diff --git a/lib/libgssapi/mech_switch.h b/lib/libgssapi/mech_switch.h
index 99e254e73b6f..e5173df4002e 100644
--- a/lib/libgssapi/mech_switch.h
+++ b/lib/libgssapi/mech_switch.h
@@ -360,3 +360,4 @@ extern void _gss_load_mech(void);
extern struct _gss_mech_switch *_gss_find_mech_switch(gss_OID);
extern void _gss_mg_error(struct _gss_mech_switch *m, OM_uint32 maj,
OM_uint32 min);
+extern void _gss_mg_collect_error(gss_OID mech, OM_uint32 maj, OM_uint32 min);
diff --git a/lib/libipsec/pfkey.c b/lib/libipsec/pfkey.c
index 2dd9d7183c4d..234e7c8bbcea 100644
--- a/lib/libipsec/pfkey.c
+++ b/lib/libipsec/pfkey.c
@@ -662,7 +662,7 @@ pfkey_send_register(so, satype)
{
int len, algno;
- if (satype == PF_UNSPEC) {
+ if (satype == SADB_SATYPE_UNSPEC) {
for (algno = 0;
algno < sizeof(supported_map)/sizeof(supported_map[0]);
algno++) {
@@ -1778,6 +1778,18 @@ pfkey_align(msg, mhp)
case SADB_X_EXT_SA2:
mhp[ext->sadb_ext_type] = (caddr_t)ext;
break;
+ case SADB_X_EXT_NAT_T_TYPE:
+ case SADB_X_EXT_NAT_T_SPORT:
+ case SADB_X_EXT_NAT_T_DPORT:
+ /* case SADB_X_EXT_NAT_T_OA: is OAI */
+ case SADB_X_EXT_NAT_T_OAI:
+ case SADB_X_EXT_NAT_T_OAR:
+ case SADB_X_EXT_NAT_T_FRAG:
+ if (feature_present("ipsec_natt")) {
+ mhp[ext->sadb_ext_type] = (caddr_t)ext;
+ break;
+ }
+ /* FALLTHROUGH */
default:
__ipsec_errcode = EIPSEC_INVAL_EXTTYPE;
return -1;
diff --git a/lib/libjail/jail.c b/lib/libjail/jail.c
index 69386e5118b6..af0e40a0dc45 100644
--- a/lib/libjail/jail.c
+++ b/lib/libjail/jail.c
@@ -885,36 +885,20 @@ jailparam_type(struct jailparam *jp)
* the "no" counterpart to a boolean.
*/
nname = nononame(jp->jp_name);
- if (nname != NULL) {
- snprintf(desc.s, sizeof(desc.s), SJPARAM ".%s", nname);
- free(nname);
- miblen = sizeof(mib) - 2 * sizeof(int);
- if (sysctl(mib, 2, mib + 2, &miblen, desc.s,
- strlen(desc.s)) >= 0) {
- mib[1] = 4;
- desclen = sizeof(desc);
- if (sysctl(mib, (miblen / sizeof(int)) + 2,
- &desc, &desclen, NULL, 0) < 0) {
- snprintf(jail_errmsg,
- JAIL_ERRMSGLEN,
- "sysctl(0.4.%s): %s", desc.s,
- strerror(errno));
- return (-1);
- }
- if ((desc.i & CTLTYPE) == CTLTYPE_INT &&
- desc.s[0] == 'B') {
- jp->jp_ctltype = desc.i;
- jp->jp_flags |= JP_NOBOOL;
- jp->jp_valuelen = sizeof(int);
- return (0);
- }
- }
+ if (nname == NULL) {
+ unknown_parameter:
+ snprintf(jail_errmsg, JAIL_ERRMSGLEN,
+ "unknown parameter: %s", jp->jp_name);
+ errno = ENOENT;
+ return (-1);
}
- unknown_parameter:
- snprintf(jail_errmsg, JAIL_ERRMSGLEN,
- "unknown parameter: %s", jp->jp_name);
- errno = ENOENT;
- return (-1);
+ snprintf(desc.s, sizeof(desc.s), SJPARAM ".%s", nname);
+ free(nname);
+ 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;
}
mib_desc:
mib[1] = 4;
@@ -925,6 +909,16 @@ jailparam_type(struct jailparam *jp)
"sysctl(0.4.%s): %s", jp->jp_name, strerror(errno));
return (-1);
}
+ jp->jp_ctltype = desc.i;
+ /* If this came from removing a "no", it better be a boolean. */
+ if (jp->jp_flags & JP_NOBOOL) {
+ if ((desc.i & CTLTYPE) == CTLTYPE_INT && desc.s[0] == 'B') {
+ jp->jp_valuelen = sizeof(int);
+ return (0);
+ }
+ else if ((desc.i & CTLTYPE) != CTLTYPE_NODE)
+ goto unknown_parameter;
+ }
/* See if this is an array type. */
p = strchr(desc.s, '\0');
isarray = 0;
@@ -935,7 +929,6 @@ jailparam_type(struct jailparam *jp)
p[-2] = 0;
}
/* Look for types we understand. */
- jp->jp_ctltype = desc.i;
switch (desc.i & CTLTYPE) {
case CTLTYPE_INT:
if (desc.s[0] == 'B')
diff --git a/lib/libkse/Makefile b/lib/libkse/Makefile
index 9a7aa1281b58..7d8c5c1c2b2c 100644
--- a/lib/libkse/Makefile
+++ b/lib/libkse/Makefile
@@ -38,7 +38,7 @@ SYMBOL_MAPS=${.CURDIR}/kse.map
PRECIOUSLIB=
-.path: ${.CURDIR}/arch/${MACHINE_CPUARCH}/${MACHINE_CPUARCH}
+.PATH: ${.CURDIR}/arch/${MACHINE_CPUARCH}/${MACHINE_CPUARCH}
.include "${.CURDIR}/arch/${MACHINE_CPUARCH}/Makefile.inc"
.include "${.CURDIR}/support/Makefile.inc"
diff --git a/lib/libkvm/kvm_proc.c b/lib/libkvm/kvm_proc.c
index d32575cd04ae..8fc415c5e8f0 100644
--- a/lib/libkvm/kvm_proc.c
+++ b/lib/libkvm/kvm_proc.c
@@ -474,7 +474,7 @@ struct kinfo_proc *
kvm_getprocs(kvm_t *kd, int op, int arg, int *cnt)
{
int mib[4], st, nprocs;
- size_t size;
+ size_t size, osize;
int temp_op;
if (kd->procbase != 0) {
@@ -524,10 +524,11 @@ kvm_getprocs(kvm_t *kd, int op, int arg, int *cnt)
_kvm_realloc(kd, kd->procbase, size);
if (kd->procbase == 0)
return (0);
+ osize = size;
st = sysctl(mib, temp_op == KERN_PROC_ALL ||
temp_op == KERN_PROC_PROC ? 3 : 4,
kd->procbase, &size, NULL, 0);
- } while (st == -1 && errno == ENOMEM);
+ } while (st == -1 && errno == ENOMEM && size == osize);
if (st == -1) {
_kvm_syserr(kd, kd->program, "kvm_getprocs");
return (0);
@@ -658,30 +659,38 @@ kvm_argv(kvm_t *kd, const struct kinfo_proc *kp, int env, int nchr)
buflen = nchr;
}
}
- if (buf != NULL) {
- oid[0] = CTL_KERN;
- oid[1] = KERN_PROC;
- oid[2] = env ? KERN_PROC_ENV : KERN_PROC_ARGS;
- oid[3] = kp->ki_pid;
- bufsz = buflen;
- i = sysctl(oid, 4, buf, &bufsz, 0, 0);
- if (i == 0 && bufsz > 0) {
- i = 0;
- p = buf;
- do {
- bufp[i++] = p;
- p += strlen(p) + 1;
- if (i >= argc) {
- argc += argc;
- bufp = realloc(bufp,
- sizeof(char *) * argc);
- }
- } while (p < buf + bufsz);
- bufp[i++] = 0;
- return (bufp);
- }
+ oid[0] = CTL_KERN;
+ oid[1] = KERN_PROC;
+ oid[2] = env ? KERN_PROC_ENV : KERN_PROC_ARGS;
+ oid[3] = kp->ki_pid;
+ bufsz = buflen;
+ if (sysctl(oid, 4, buf, &bufsz, 0, 0) == -1) {
+ /*
+ * If the supplied buf is too short to hold the requested
+ * value the sysctl returns with ENOMEM. The buf is filled
+ * with the truncated value and the returned bufsz is equal
+ * to the requested len.
+ */
+ if (errno != ENOMEM || bufsz != (size_t)buflen)
+ return (0);
+ buf[bufsz - 1] = '\0';
+ errno = 0;
+ } else if (bufsz == 0) {
+ return (0);
}
- return (NULL);
+ i = 0;
+ p = buf;
+ do {
+ bufp[i++] = p;
+ p += strlen(p) + 1;
+ if (i >= argc) {
+ argc += argc;
+ bufp = realloc(bufp,
+ sizeof(char *) * argc);
+ }
+ } while (p < buf + bufsz);
+ bufp[i++] = 0;
+ return (bufp);
}
char **
diff --git a/lib/libmagic/Makefile b/lib/libmagic/Makefile
index 4d5ab9d57e0c..59573060afb1 100644
--- a/lib/libmagic/Makefile
+++ b/lib/libmagic/Makefile
@@ -1,5 +1,5 @@
# $FreeBSD$
-# Copyright (c) David E. O'Brien, 2000-2004
+# Copyright (c) David E. O'Brien, 2000-2004, 2006, 2009
CONTRDIR= ${.CURDIR}/../../contrib/file
.PATH: ${CONTRDIR}
diff --git a/lib/libmagic/config.h b/lib/libmagic/config.h
index 8574ddc3582b..c7e38ec761a1 100644
--- a/lib/libmagic/config.h
+++ b/lib/libmagic/config.h
@@ -15,6 +15,14 @@
/* HAVE_DAYLIGHT */
/* #undef HAVE_DAYLIGHT */
+/* 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 HAVE_DECL_TZNAME 1
+
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
@@ -24,9 +32,15 @@
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
+/* Define to 1 if you have the `fork' function. */
+#define HAVE_FORK 1
+
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
#define HAVE_FSEEKO 1
+/* 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
@@ -42,6 +56,9 @@
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
+/* Define to 1 if you have the `gnurx' library (-lgnurx). */
+/* #undef HAVE_LIBGNURX */
+
/* Define to 1 if you have the `z' library (-lz). */
#define HAVE_LIBZ 1
@@ -66,6 +83,9 @@
/* Define to 1 if you have the `mmap' function. */
#define HAVE_MMAP 1
+/* Define to 1 if the system has the type `pid_t'. */
+#define HAVE_PID_T 1
+
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
@@ -99,13 +119,13 @@
/* HAVE_STRUCT_OPTION */
#define HAVE_STRUCT_OPTION 1
-/* Define to 1 if `st_rdev' is 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 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 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/mman.h> header file. */
@@ -174,6 +194,10 @@
/* Define to 1 if you have the <zlib.h> header file. */
#define HAVE_ZLIB_H 1
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#define LT_OBJDIR ".libs/"
+
/* Define to 1 if `major', `minor', and `makedev' are declared in <mkdev.h>.
*/
/* #undef MAJOR_IN_MKDEV */
@@ -195,13 +219,16 @@
#define PACKAGE_NAME "file"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "file 5.03"
+#define PACKAGE_STRING "file 5.11"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "file"
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
/* Define to the version of this package. */
-#define PACKAGE_VERSION "5.03"
+#define PACKAGE_VERSION "5.11"
/* The size of `long long', as computed by sizeof. */
#define SIZEOF_LONG_LONG 8
@@ -212,25 +239,50 @@
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
/* #undef TM_IN_SYS_TIME */
-/* Version number of package */
-#define VERSION "5.03"
-
-/* Number of bits in a file offset, on hosts where this is settable. */
-/* #undef _FILE_OFFSET_BITS */
-
+/* Enable extensions on AIX 3, Interix. */
+#ifndef _ALL_SOURCE
+# define _ALL_SOURCE 1
+#endif
/* Enable GNU extensions on systems that have them. */
-#ifndef __FreeBSD__
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
+/* Enable threading extensions on Solaris. */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# define _POSIX_PTHREAD_SEMANTICS 1
+#endif
+/* Enable extensions on HP NonStop. */
+#ifndef _TANDEM_SOURCE
+# define _TANDEM_SOURCE 1
+#endif
+/* Enable general extensions on Solaris. */
+#ifndef __EXTENSIONS__
+# define __EXTENSIONS__ 1
#endif
+
+/* Version number of package */
+#define VERSION "5.11"
+
+/* 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). */
/* #undef _LARGEFILE_SOURCE */
/* Define for large files, on AIX-style hosts. */
/* #undef _LARGE_FILES */
+/* Define to 1 if on MINIX. */
+/* #undef _MINIX */
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+ this defined. */
+/* #undef _POSIX_1_SOURCE */
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+/* #undef _POSIX_SOURCE */
+
/* Define to empty if `const' does not conform to ANSI C. */
/* #undef const */
@@ -244,6 +296,7 @@
/* #undef size_t */
+#ifdef _FREEBSD_UNUSED_
#ifndef HAVE_UINT8_T
typedef unsigned char uint8_t;
#endif
@@ -270,4 +323,5 @@ typedef long long int64_t;
typedef long int64_t;
#endif
#endif
+#endif /* _FREEBSD_UNUSED_ */
diff --git a/lib/libmemstat/libmemstat.3 b/lib/libmemstat/libmemstat.3
index d7a000c481ca..9b749f053c71 100644
--- a/lib/libmemstat/libmemstat.3
+++ b/lib/libmemstat/libmemstat.3
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 21, 2011
+.Dd February 25, 2012
.Dt LIBMEMSTAT 3
.Os
.Sh NAME
@@ -345,7 +345,7 @@ Return a caller-owned per-CPU pointer for the memory type.
Set a caller-owned per-CPU pointer for the memory type.
.It Fn memstat_get_percpu_caller_uint64
Return a caller-owned per-CPU integer for the memory type.
-.It Fn memsttat_set_percpu_caller_uint64
+.It Fn memstat_set_percpu_caller_uint64
Set a caller-owned per-CPU integer for the memory type.
.It Fn memstat_get_percpu_free
If the memory allocator supports a per-CPU cache, return the number of free
diff --git a/lib/libopie/config.h b/lib/libopie/config.h
index ca0c3383a8bf..b9bc40c06627 100644
--- a/lib/libopie/config.h
+++ b/lib/libopie/config.h
@@ -54,7 +54,7 @@
/* #undef DOANONYMOUS */
/* The default value of the PATH environment variable */
-#define DEFAULT_PATH "/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin"
+#define DEFAULT_PATH "/usr/bin:/bin:/usr/sbin:/sbin"
/* Defined if the file /etc/default/login exists
(and, presumably, should be looked at by login) */
diff --git a/lib/libpam/modules/pam_exec/pam_exec.8 b/lib/libpam/modules/pam_exec/pam_exec.8
index 311d64c492a9..3231228927ed 100644
--- a/lib/libpam/modules/pam_exec/pam_exec.8
+++ b/lib/libpam/modules/pam_exec/pam_exec.8
@@ -32,7 +32,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 1, 2005
+.Dd February 8, 2012
.Dt PAM_EXEC 8
.Os
.Sh NAME
@@ -45,9 +45,25 @@
.Pa pam_exec
.Op Ar arguments
.Sh DESCRIPTION
-The exec service module for PAM executes the program designated by its
-first argument, with its remaining arguments as command-line
-arguments.
+The exec service module for PAM executes the program designated by
+its first argument if no options are specified, with its remaining
+arguments as command-line arguments.
+If options are specified, the program and its arguments follow the last
+option or
+.Cm --
+if the program name conflicts with an option name.
+.Pp
+The following options may be passed before the program and its
+arguments:
+.Bl -tag -width ".Cm return_prog_exit_status"
+.It Cm return_prog_exit_status
+Use the program exit status as the return code of the pam_sm_* function.
+It must be a valid return value for this function.
+.It Cm --
+Stop options parsing;
+program and its arguments follow.
+.El
+.Pp
The child's environment is set to the current PAM environment list,
as returned by
.Xr pam_getenvlist 3 .
@@ -56,13 +72,69 @@ variables:
.Ev PAM_RHOST ,
.Ev PAM_RUSER ,
.Ev PAM_SERVICE ,
-.Ev PAM_TTY ,
+.Ev PAM_SM_FUNC ,
+.Ev PAM_TTY
and
.Ev PAM_USER .
+.Pp
+The
+.Ev PAM_SM_FUNC
+variable contains the name of the PAM service module function being
+called.
+It may be:
+.Bl -dash -offset indent -compact
+.It
+pam_sm_acct_mgmt
+.It
+pam_sm_authenticate
+.It
+pam_sm_chauthtok
+.It
+pam_sm_close_session
+.It
+pam_sm_open_session
+.It
+pam_sm_setcred
+.El
+.Pp
+If
+.Cm return_prog_exit_status
+is not set (default), the
+.Ev PAM_SM_FUNC
+function returns
+.Er PAM_SUCCESS
+if the program exit status is 0,
+.Er PAM_PERM_DENIED
+otherwise.
+.Pp
+If
+.Cm return_prog_exit_status
+is set, the program exit status is used.
+It should be
+.Er PAM_SUCCESS
+or one of the error codes allowed by the calling
+.Ev PAM_SM_FUNC
+function.
+The valid codes are documented in each function man page.
+If the exit status is not a valid return code,
+.Er PAM_SERVICE_ERR
+is returned.
+Each valid codes numerical value is available as an environment variable
+(eg.\&
+.Ev PAM_SUCESS ,
+.Ev PAM_USER_UNKNOWN ,
+etc).
+This is useful in shell scripts for instance.
.Sh SEE ALSO
.Xr pam_get_item 3 ,
.Xr pam.conf 5 ,
-.Xr pam 8
+.Xr pam 8 ,
+.Xr pam_sm_acct_mgmt 8 ,
+.Xr pam_sm_authenticate 8 ,
+.Xr pam_sm_chauthtok 8,
+.Xr pam_sm_close_session 8 ,
+.Xr pam_sm_open_session 8 ,
+.Xr pam_sm_setcred 8 .
.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 b7a870fe3c14..d43d181f31e5 100644
--- a/lib/libpam/modules/pam_exec/pam_exec.c
+++ b/lib/libpam/modules/pam_exec/pam_exec.c
@@ -60,32 +60,86 @@ static struct {
ENV_ITEM(PAM_RUSER),
};
+struct pe_opts {
+ int return_prog_exit_status;
+};
+
+#define PAM_RV_COUNT 24
+
static int
-_pam_exec(pam_handle_t *pamh __unused, int flags __unused,
- int argc, const char *argv[])
+parse_options(const char *func, int *argc, const char **argv[],
+ struct pe_opts *options)
+{
+ int i;
+
+ /*
+ * Parse options:
+ * return_prog_exit_status:
+ * use the program exit status as the return code of pam_exec
+ * --:
+ * stop options parsing; what follows is the command to execute
+ */
+ options->return_prog_exit_status = 0;
+
+ for (i = 0; i < *argc; ++i) {
+ if (strcmp((*argv)[i], "return_prog_exit_status") == 0) {
+ openpam_log(PAM_LOG_DEBUG,
+ "%s: Option \"return_prog_exit_status\" enabled",
+ func);
+ options->return_prog_exit_status = 1;
+ } else {
+ if (strcmp((*argv)[i], "--") == 0) {
+ (*argc)--;
+ (*argv)++;
+ }
+
+ break;
+ }
+ }
+
+ (*argc) -= i;
+ (*argv) += i;
+
+ return (0);
+}
+
+static int
+_pam_exec(pam_handle_t *pamh __unused,
+ const char *func, int flags __unused, int argc, const char *argv[],
+ struct pe_opts *options)
{
int envlen, i, nitems, pam_err, status;
- char *env, **envlist, **tmp;
+ int nitems_rv;
+ char **envlist, **tmp, *envstr;
volatile int childerr;
pid_t pid;
- if (argc < 1)
- return (PAM_SERVICE_ERR);
-
/*
* XXX For additional credit, divert child's stdin/stdout/stderr
* to the conversation function.
*/
+ /* Check there's a program name left after parsing options. */
+ if (argc < 1) {
+ openpam_log(PAM_LOG_ERROR, "%s: No program specified: aborting",
+ func);
+ return (PAM_SERVICE_ERR);
+ }
+
/*
- * Set up the child's environment list. It consists of the PAM
- * environment, plus a few hand-picked PAM items.
+ * Set up the child's environment list. It consists of the PAM
+ * environment, plus a few hand-picked PAM items, the pam_sm_*
+ * function name calling it and, if return_prog_exit_status is
+ * set, the valid return codes numerical values.
*/
envlist = pam_getenvlist(pamh);
for (envlen = 0; envlist[envlen] != NULL; ++envlen)
/* nothing */ ;
nitems = sizeof(env_items) / sizeof(*env_items);
- tmp = realloc(envlist, (envlen + nitems + 1) * sizeof(*envlist));
+ /* Count PAM return values put in the environment. */
+ nitems_rv = options->return_prog_exit_status ? PAM_RV_COUNT : 0;
+ tmp = realloc(envlist, (envlen + nitems + 1 + nitems_rv + 1) *
+ sizeof(*envlist));
if (tmp == NULL) {
openpam_free_envlist(envlist);
return (PAM_BUF_ERR);
@@ -93,12 +147,12 @@ _pam_exec(pam_handle_t *pamh __unused, int flags __unused,
envlist = tmp;
for (i = 0; i < nitems; ++i) {
const void *item;
- char *envstr;
pam_err = pam_get_item(pamh, env_items[i].item, &item);
if (pam_err != PAM_SUCCESS || item == NULL)
continue;
- asprintf(&envstr, "%s=%s", env_items[i].name, item);
+ asprintf(&envstr, "%s=%s", env_items[i].name,
+ (const char *)item);
if (envstr == NULL) {
openpam_free_envlist(envlist);
return (PAM_BUF_ERR);
@@ -107,10 +161,59 @@ _pam_exec(pam_handle_t *pamh __unused, int flags __unused,
envlist[envlen] = NULL;
}
+ /* Add the pam_sm_* function name to the environment. */
+ asprintf(&envstr, "PAM_SM_FUNC=%s", func);
+ if (envstr == NULL) {
+ openpam_free_envlist(envlist);
+ return (PAM_BUF_ERR);
+ }
+ envlist[envlen++] = envstr;
+
+ /* Add the PAM return values to the environment. */
+ if (options->return_prog_exit_status) {
+#define ADD_PAM_RV_TO_ENV(name) \
+ asprintf(&envstr, #name "=%d", name); \
+ if (envstr == NULL) { \
+ openpam_free_envlist(envlist); \
+ return (PAM_BUF_ERR); \
+ } \
+ envlist[envlen++] = envstr
+ /*
+ * CAUTION: When adding/removing an item in the list
+ * below, be sure to update the value of PAM_RV_COUNT.
+ */
+ ADD_PAM_RV_TO_ENV(PAM_ABORT);
+ ADD_PAM_RV_TO_ENV(PAM_ACCT_EXPIRED);
+ ADD_PAM_RV_TO_ENV(PAM_AUTHINFO_UNAVAIL);
+ ADD_PAM_RV_TO_ENV(PAM_AUTHTOK_DISABLE_AGING);
+ ADD_PAM_RV_TO_ENV(PAM_AUTHTOK_ERR);
+ ADD_PAM_RV_TO_ENV(PAM_AUTHTOK_LOCK_BUSY);
+ ADD_PAM_RV_TO_ENV(PAM_AUTHTOK_RECOVERY_ERR);
+ ADD_PAM_RV_TO_ENV(PAM_AUTH_ERR);
+ ADD_PAM_RV_TO_ENV(PAM_BUF_ERR);
+ ADD_PAM_RV_TO_ENV(PAM_CONV_ERR);
+ ADD_PAM_RV_TO_ENV(PAM_CRED_ERR);
+ ADD_PAM_RV_TO_ENV(PAM_CRED_EXPIRED);
+ ADD_PAM_RV_TO_ENV(PAM_CRED_INSUFFICIENT);
+ ADD_PAM_RV_TO_ENV(PAM_CRED_UNAVAIL);
+ ADD_PAM_RV_TO_ENV(PAM_IGNORE);
+ ADD_PAM_RV_TO_ENV(PAM_MAXTRIES);
+ ADD_PAM_RV_TO_ENV(PAM_NEW_AUTHTOK_REQD);
+ ADD_PAM_RV_TO_ENV(PAM_PERM_DENIED);
+ ADD_PAM_RV_TO_ENV(PAM_SERVICE_ERR);
+ ADD_PAM_RV_TO_ENV(PAM_SESSION_ERR);
+ ADD_PAM_RV_TO_ENV(PAM_SUCCESS);
+ ADD_PAM_RV_TO_ENV(PAM_SYSTEM_ERR);
+ ADD_PAM_RV_TO_ENV(PAM_TRY_AGAIN);
+ ADD_PAM_RV_TO_ENV(PAM_USER_UNKNOWN);
+ }
+
+ envlist[envlen] = NULL;
+
/*
* Fork and run the command. By using vfork() instead of fork(),
* we can distinguish between an execve() failure and a non-zero
- * exit code from the command.
+ * exit status from the command.
*/
childerr = 0;
if ((pid = vfork()) == 0) {
@@ -120,81 +223,276 @@ _pam_exec(pam_handle_t *pamh __unused, int flags __unused,
}
openpam_free_envlist(envlist);
if (pid == -1) {
- openpam_log(PAM_LOG_ERROR, "vfork(): %m");
+ openpam_log(PAM_LOG_ERROR, "%s: vfork(): %m", func);
return (PAM_SYSTEM_ERR);
}
- if (waitpid(pid, &status, 0) == -1) {
- openpam_log(PAM_LOG_ERROR, "waitpid(): %m");
+ while (waitpid(pid, &status, 0) == -1) {
+ if (errno == EINTR)
+ continue;
+ openpam_log(PAM_LOG_ERROR, "%s: waitpid(): %m", func);
return (PAM_SYSTEM_ERR);
}
if (childerr != 0) {
- openpam_log(PAM_LOG_ERROR, "execve(): %m");
+ openpam_log(PAM_LOG_ERROR, "%s: execve(): %m", func);
return (PAM_SYSTEM_ERR);
}
if (WIFSIGNALED(status)) {
- openpam_log(PAM_LOG_ERROR, "%s caught signal %d%s",
- argv[0], WTERMSIG(status),
+ openpam_log(PAM_LOG_ERROR, "%s: %s caught signal %d%s",
+ func, argv[0], WTERMSIG(status),
WCOREDUMP(status) ? " (core dumped)" : "");
- return (PAM_SYSTEM_ERR);
+ return (PAM_SERVICE_ERR);
}
if (!WIFEXITED(status)) {
- openpam_log(PAM_LOG_ERROR, "unknown status 0x%x", status);
- return (PAM_SYSTEM_ERR);
+ openpam_log(PAM_LOG_ERROR, "%s: unknown status 0x%x",
+ func, status);
+ return (PAM_SERVICE_ERR);
}
- if (WEXITSTATUS(status) != 0) {
- openpam_log(PAM_LOG_ERROR, "%s returned code %d",
- argv[0], WEXITSTATUS(status));
- return (PAM_SYSTEM_ERR);
+
+ if (options->return_prog_exit_status) {
+ openpam_log(PAM_LOG_DEBUG,
+ "%s: Use program exit status as return value: %d",
+ func, WEXITSTATUS(status));
+ return (WEXITSTATUS(status));
+ } else {
+ return (WEXITSTATUS(status) == 0 ?
+ PAM_SUCCESS : PAM_PERM_DENIED);
}
- return (PAM_SUCCESS);
}
PAM_EXTERN int
pam_sm_authenticate(pam_handle_t *pamh, int flags,
int argc, const char *argv[])
{
+ int ret;
+ struct pe_opts options;
+
+ ret = parse_options(__func__, &argc, &argv, &options);
+ if (ret != 0)
+ return (PAM_SERVICE_ERR);
+
+ ret = _pam_exec(pamh, __func__, flags, argc, argv, &options);
- return (_pam_exec(pamh, flags, argc, argv));
+ /*
+ * We must check that the program returned a valid code for this
+ * function.
+ */
+ switch (ret) {
+ case PAM_SUCCESS:
+ case PAM_ABORT:
+ case PAM_AUTHINFO_UNAVAIL:
+ case PAM_AUTH_ERR:
+ case PAM_BUF_ERR:
+ case PAM_CONV_ERR:
+ case PAM_CRED_INSUFFICIENT:
+ case PAM_IGNORE:
+ case PAM_MAXTRIES:
+ case PAM_PERM_DENIED:
+ case PAM_SERVICE_ERR:
+ case PAM_SYSTEM_ERR:
+ case PAM_USER_UNKNOWN:
+ break;
+ default:
+ openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d",
+ argv[0], ret);
+ ret = PAM_SERVICE_ERR;
+ }
+
+ return (ret);
}
PAM_EXTERN int
pam_sm_setcred(pam_handle_t *pamh, int flags,
int argc, const char *argv[])
{
+ int ret;
+ struct pe_opts options;
+
+ ret = parse_options(__func__, &argc, &argv, &options);
+ if (ret != 0)
+ return (PAM_SERVICE_ERR);
+
+ ret = _pam_exec(pamh, __func__, flags, argc, argv, &options);
+
+ /*
+ * We must check that the program returned a valid code for this
+ * function.
+ */
+ switch (ret) {
+ case PAM_SUCCESS:
+ case PAM_ABORT:
+ case PAM_BUF_ERR:
+ case PAM_CONV_ERR:
+ case PAM_CRED_ERR:
+ case PAM_CRED_EXPIRED:
+ case PAM_CRED_UNAVAIL:
+ case PAM_IGNORE:
+ case PAM_PERM_DENIED:
+ case PAM_SERVICE_ERR:
+ case PAM_SYSTEM_ERR:
+ case PAM_USER_UNKNOWN:
+ break;
+ default:
+ openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d",
+ argv[0], ret);
+ ret = PAM_SERVICE_ERR;
+ }
- return (_pam_exec(pamh, flags, argc, argv));
+ return (ret);
}
PAM_EXTERN int
pam_sm_acct_mgmt(pam_handle_t *pamh, int flags,
int argc, const char *argv[])
{
+ int ret;
+ struct pe_opts options;
+
+ ret = parse_options(__func__, &argc, &argv, &options);
+ if (ret != 0)
+ return (PAM_SERVICE_ERR);
+
+ ret = _pam_exec(pamh, __func__, flags, argc, argv, &options);
+
+ /*
+ * We must check that the program returned a valid code for this
+ * function.
+ */
+ switch (ret) {
+ case PAM_SUCCESS:
+ case PAM_ABORT:
+ case PAM_ACCT_EXPIRED:
+ case PAM_AUTH_ERR:
+ case PAM_BUF_ERR:
+ case PAM_CONV_ERR:
+ case PAM_IGNORE:
+ case PAM_NEW_AUTHTOK_REQD:
+ case PAM_PERM_DENIED:
+ case PAM_SERVICE_ERR:
+ case PAM_SYSTEM_ERR:
+ case PAM_USER_UNKNOWN:
+ break;
+ default:
+ openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d",
+ argv[0], ret);
+ ret = PAM_SERVICE_ERR;
+ }
- return (_pam_exec(pamh, flags, argc, argv));
+ return (ret);
}
PAM_EXTERN int
pam_sm_open_session(pam_handle_t *pamh, int flags,
int argc, const char *argv[])
{
+ int ret;
+ struct pe_opts options;
+
+ ret = parse_options(__func__, &argc, &argv, &options);
+ if (ret != 0)
+ return (PAM_SERVICE_ERR);
- return (_pam_exec(pamh, flags, argc, argv));
+ ret = _pam_exec(pamh, __func__, flags, argc, argv, &options);
+
+ /*
+ * We must check that the program returned a valid code for this
+ * function.
+ */
+ switch (ret) {
+ case PAM_SUCCESS:
+ case PAM_ABORT:
+ case PAM_BUF_ERR:
+ case PAM_CONV_ERR:
+ case PAM_IGNORE:
+ case PAM_PERM_DENIED:
+ case PAM_SERVICE_ERR:
+ case PAM_SESSION_ERR:
+ case PAM_SYSTEM_ERR:
+ break;
+ default:
+ openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d",
+ argv[0], ret);
+ ret = PAM_SERVICE_ERR;
+ }
+
+ return (ret);
}
PAM_EXTERN int
pam_sm_close_session(pam_handle_t *pamh, int flags,
int argc, const char *argv[])
{
+ int ret;
+ struct pe_opts options;
- return (_pam_exec(pamh, flags, argc, argv));
+ ret = parse_options(__func__, &argc, &argv, &options);
+ if (ret != 0)
+ return (PAM_SERVICE_ERR);
+
+ ret = _pam_exec(pamh, __func__, flags, argc, argv, &options);
+
+ /*
+ * We must check that the program returned a valid code for this
+ * function.
+ */
+ switch (ret) {
+ case PAM_SUCCESS:
+ case PAM_ABORT:
+ case PAM_BUF_ERR:
+ case PAM_CONV_ERR:
+ case PAM_IGNORE:
+ case PAM_PERM_DENIED:
+ case PAM_SERVICE_ERR:
+ case PAM_SESSION_ERR:
+ case PAM_SYSTEM_ERR:
+ break;
+ default:
+ openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d",
+ argv[0], ret);
+ ret = PAM_SERVICE_ERR;
+ }
+
+ return (ret);
}
PAM_EXTERN int
pam_sm_chauthtok(pam_handle_t *pamh, int flags,
int argc, const char *argv[])
{
+ int ret;
+ struct pe_opts options;
+
+ ret = parse_options(__func__, &argc, &argv, &options);
+ if (ret != 0)
+ return (PAM_SERVICE_ERR);
+
+ ret = _pam_exec(pamh, __func__, flags, argc, argv, &options);
+
+ /*
+ * We must check that the program returned a valid code for this
+ * function.
+ */
+ switch (ret) {
+ case PAM_SUCCESS:
+ case PAM_ABORT:
+ case PAM_AUTHTOK_DISABLE_AGING:
+ case PAM_AUTHTOK_ERR:
+ case PAM_AUTHTOK_LOCK_BUSY:
+ case PAM_AUTHTOK_RECOVERY_ERR:
+ case PAM_BUF_ERR:
+ case PAM_CONV_ERR:
+ case PAM_IGNORE:
+ case PAM_PERM_DENIED:
+ case PAM_SERVICE_ERR:
+ case PAM_SYSTEM_ERR:
+ case PAM_TRY_AGAIN:
+ break;
+ default:
+ openpam_log(PAM_LOG_ERROR, "%s returned invalid code %d",
+ argv[0], ret);
+ ret = PAM_SERVICE_ERR;
+ }
- return (_pam_exec(pamh, flags, argc, argv));
+ return (ret);
}
PAM_MODULE_ENTRY("pam_exec");
diff --git a/lib/libpam/modules/pam_krb5/pam_krb5.c b/lib/libpam/modules/pam_krb5/pam_krb5.c
index 439fcf9f1a24..602718fdaba6 100644
--- a/lib/libpam/modules/pam_krb5/pam_krb5.c
+++ b/lib/libpam/modules/pam_krb5/pam_krb5.c
@@ -92,6 +92,13 @@ static void compat_free_data_contents(krb5_context, krb5_data *);
#define PAM_OPT_NO_USER_CHECK "no_user_check"
#define PAM_OPT_REUSE_CCACHE "reuse_ccache"
+#define PAM_LOG_KRB5_ERR(ctx, rv, fmt, ...) \
+ do { \
+ const char *krb5msg = krb5_get_error_message(ctx, rv); \
+ PAM_LOG(fmt ": %s", ##__VA_ARGS__, krb5msg); \
+ krb5_free_error_message(ctx, krb5msg); \
+ } while (0)
+
/*
* authentication management
*/
@@ -104,7 +111,7 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused,
krb5_creds creds;
krb5_principal princ;
krb5_ccache ccache;
- krb5_get_init_creds_opt opts;
+ krb5_get_init_creds_opt *opts;
struct passwd *pwd;
int retval;
const void *ccache_data;
@@ -139,13 +146,6 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused,
PAM_LOG("Context initialised");
- krb5_get_init_creds_opt_init(&opts);
-
- if (openpam_get_option(pamh, PAM_OPT_FORWARDABLE))
- krb5_get_init_creds_opt_set_forwardable(&opts, 1);
-
- PAM_LOG("Credentials initialised");
-
krbret = krb5_cc_register(pam_context, &krb5_mcc_ops, FALSE);
if (krbret != 0 && krbret != KRB5_CC_TYPE_EXISTS) {
PAM_VERBOSE_ERROR("Kerberos 5 error");
@@ -166,8 +166,7 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused,
krbret = krb5_parse_name(pam_context, principal, &princ);
free(principal);
if (krbret != 0) {
- PAM_LOG("Error krb5_parse_name(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret, "Error krb5_parse_name()");
PAM_VERBOSE_ERROR("Kerberos 5 error");
retval = PAM_SERVICE_ERR;
goto cleanup3;
@@ -179,8 +178,8 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused,
princ_name = NULL;
krbret = krb5_unparse_name(pam_context, princ, &princ_name);
if (krbret != 0) {
- PAM_LOG("Error krb5_unparse_name(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_unparse_name()");
PAM_VERBOSE_ERROR("Kerberos 5 error");
retval = PAM_SERVICE_ERR;
goto cleanup2;
@@ -206,8 +205,8 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused,
sizeof(luser), luser);
if (krbret != 0) {
PAM_VERBOSE_ERROR("Kerberos 5 error");
- PAM_LOG("Error krb5_aname_to_localname(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_aname_to_localname()");
retval = PAM_USER_UNKNOWN;
goto cleanup2;
}
@@ -228,14 +227,30 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused,
PAM_LOG("Done getpwnam()");
}
+ /* Initialize credentials request options. */
+ krbret = krb5_get_init_creds_opt_alloc(pam_context, &opts);
+ if (krbret != 0) {
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_get_init_creds_opt_alloc()");
+ PAM_VERBOSE_ERROR("Kerberos 5 error");
+ retval = PAM_SERVICE_ERR;
+ goto cleanup2;
+ }
+
+ if (openpam_get_option(pamh, PAM_OPT_FORWARDABLE))
+ krb5_get_init_creds_opt_set_forwardable(opts, 1);
+
+ PAM_LOG("Credential options initialised");
+
/* Get a TGT */
memset(&creds, 0, sizeof(krb5_creds));
krbret = krb5_get_init_creds_password(pam_context, &creds, princ,
- pass, NULL, pamh, 0, NULL, &opts);
+ pass, NULL, pamh, 0, NULL, opts);
+ krb5_get_init_creds_opt_free(pam_context, opts);
if (krbret != 0) {
PAM_VERBOSE_ERROR("Kerberos 5 error");
- PAM_LOG("Error krb5_get_init_creds_password(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_get_init_creds_password()");
retval = PAM_AUTH_ERR;
goto cleanup2;
}
@@ -243,27 +258,27 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused,
PAM_LOG("Got TGT");
/* Generate a temporary cache */
- krbret = krb5_cc_gen_new(pam_context, &krb5_mcc_ops, &ccache);
+ krbret = krb5_cc_new_unique(pam_context, krb5_cc_type_memory, NULL, &ccache);
if (krbret != 0) {
PAM_VERBOSE_ERROR("Kerberos 5 error");
- PAM_LOG("Error krb5_cc_gen_new(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_cc_new_unique()");
retval = PAM_SERVICE_ERR;
goto cleanup;
}
krbret = krb5_cc_initialize(pam_context, ccache, princ);
if (krbret != 0) {
PAM_VERBOSE_ERROR("Kerberos 5 error");
- PAM_LOG("Error krb5_cc_initialize(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_cc_initialize()");
retval = PAM_SERVICE_ERR;
goto cleanup;
}
krbret = krb5_cc_store_cred(pam_context, ccache, &creds);
if (krbret != 0) {
PAM_VERBOSE_ERROR("Kerberos 5 error");
- PAM_LOG("Error krb5_cc_store_cred(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_cc_store_cred()");
krb5_cc_destroy(pam_context, ccache);
retval = PAM_SERVICE_ERR;
goto cleanup;
@@ -406,8 +421,8 @@ pam_sm_setcred(pam_handle_t *pamh, int flags,
}
krbret = krb5_cc_resolve(pam_context, cache_data, &ccache_temp);
if (krbret != 0) {
- PAM_LOG("Error krb5_cc_resolve(\"%s\"): %s", (const char *)cache_data,
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_cc_resolve(\"%s\")", (const char *)cache_data);
retval = PAM_SERVICE_ERR;
goto cleanup3;
}
@@ -479,22 +494,21 @@ pam_sm_setcred(pam_handle_t *pamh, int flags,
/* Initialize the new ccache */
krbret = krb5_cc_get_principal(pam_context, ccache_temp, &princ);
if (krbret != 0) {
- PAM_LOG("Error krb5_cc_get_principal(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_cc_get_principal()");
retval = PAM_SERVICE_ERR;
goto cleanup3;
}
krbret = krb5_cc_resolve(pam_context, cache_name, &ccache_perm);
if (krbret != 0) {
- PAM_LOG("Error krb5_cc_resolve(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret, "Error krb5_cc_resolve()");
retval = PAM_SERVICE_ERR;
goto cleanup2;
}
krbret = krb5_cc_initialize(pam_context, ccache_perm, princ);
if (krbret != 0) {
- PAM_LOG("Error krb5_cc_initialize(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_cc_initialize()");
retval = PAM_SERVICE_ERR;
goto cleanup2;
}
@@ -504,8 +518,8 @@ pam_sm_setcred(pam_handle_t *pamh, int flags,
/* Prepare for iteration over creds */
krbret = krb5_cc_start_seq_get(pam_context, ccache_temp, &cursor);
if (krbret != 0) {
- PAM_LOG("Error krb5_cc_start_seq_get(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_cc_start_seq_get()");
krb5_cc_destroy(pam_context, ccache_perm);
retval = PAM_SERVICE_ERR;
goto cleanup2;
@@ -518,8 +532,8 @@ pam_sm_setcred(pam_handle_t *pamh, int flags,
&cursor, &creds) == 0)) {
krbret = krb5_cc_store_cred(pam_context, ccache_perm, &creds);
if (krbret != 0) {
- PAM_LOG("Error krb5_cc_store_cred(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_cc_store_cred()");
krb5_cc_destroy(pam_context, ccache_perm);
krb5_free_cred_contents(pam_context, &creds);
retval = PAM_SERVICE_ERR;
@@ -620,8 +634,8 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused,
krbret = krb5_cc_resolve(pam_context, (const char *)ccache_name, &ccache);
if (krbret != 0) {
- PAM_LOG("Error krb5_cc_resolve(\"%s\"): %s", (const char *)ccache_name,
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_cc_resolve(\"%s\")", (const char *)ccache_name);
krb5_free_context(pam_context);
return (PAM_PERM_DENIED);
}
@@ -631,8 +645,8 @@ pam_sm_acct_mgmt(pam_handle_t *pamh, int flags __unused,
krbret = krb5_cc_get_principal(pam_context, ccache, &princ);
if (krbret != 0) {
- PAM_LOG("Error krb5_cc_get_principal(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_cc_get_principal()");
retval = PAM_PERM_DENIED;;
goto cleanup;
}
@@ -666,7 +680,7 @@ pam_sm_chauthtok(pam_handle_t *pamh, int flags,
krb5_context pam_context;
krb5_creds creds;
krb5_principal princ;
- krb5_get_init_creds_opt opts;
+ krb5_get_init_creds_opt *opts;
krb5_data result_code_string, result_string;
int result_code, retval;
const char *pass;
@@ -690,15 +704,11 @@ pam_sm_chauthtok(pam_handle_t *pamh, int flags,
PAM_LOG("Context initialised");
- krb5_get_init_creds_opt_init(&opts);
-
- PAM_LOG("Credentials options initialised");
-
/* Get principal name */
krbret = krb5_parse_name(pam_context, (const char *)user, &princ);
if (krbret != 0) {
- PAM_LOG("Error krb5_parse_name(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_parse_name()");
retval = PAM_USER_UNKNOWN;
goto cleanup3;
}
@@ -707,8 +717,8 @@ pam_sm_chauthtok(pam_handle_t *pamh, int flags,
princ_name = NULL;
krbret = krb5_unparse_name(pam_context, princ, &princ_name);
if (krbret != 0) {
- PAM_LOG("Error krb5_unparse_name(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_unparse_name()");
retval = PAM_SERVICE_ERR;
goto cleanup2;
}
@@ -722,12 +732,25 @@ pam_sm_chauthtok(pam_handle_t *pamh, int flags,
PAM_LOG("Got password");
+ /* Initialize credentials request options. */
+ krbret = krb5_get_init_creds_opt_alloc(pam_context, &opts);
+ if (krbret != 0) {
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_get_init_creds_opt_alloc()");
+ PAM_VERBOSE_ERROR("Kerberos 5 error");
+ retval = PAM_SERVICE_ERR;
+ goto cleanup2;
+ }
+
+ PAM_LOG("Credentials options initialised");
+
memset(&creds, 0, sizeof(krb5_creds));
krbret = krb5_get_init_creds_password(pam_context, &creds, princ,
- pass, NULL, pamh, 0, "kadmin/changepw", &opts);
+ pass, NULL, pamh, 0, "kadmin/changepw", opts);
+ krb5_get_init_creds_opt_free(pam_context, opts);
if (krbret != 0) {
- PAM_LOG("Error krb5_get_init_creds_password(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_get_init_creds_password()");
retval = PAM_AUTH_ERR;
goto cleanup2;
}
@@ -752,12 +775,12 @@ pam_sm_chauthtok(pam_handle_t *pamh, int flags,
retval = PAM_BUF_ERR;
goto cleanup;
}
- krbret = krb5_change_password(pam_context, &creds, passdup,
+ krbret = krb5_set_password(pam_context, &creds, passdup, NULL,
&result_code, &result_code_string, &result_string);
free(passdup);
if (krbret != 0) {
- PAM_LOG("Error krb5_change_password(): %s",
- krb5_get_err_text(pam_context, krbret));
+ PAM_LOG_KRB5_ERR(pam_context, krbret,
+ "Error krb5_change_password()");
retval = PAM_AUTHTOK_ERR;
goto cleanup;
}
@@ -840,11 +863,14 @@ verify_krb_v5_tgt(krb5_context context, krb5_ccache ccache,
retval = krb5_sname_to_principal(context, NULL, *service,
KRB5_NT_SRV_HST, &princ);
if (retval != 0) {
- if (debug)
+ if (debug) {
+ const char *msg = krb5_get_error_message(
+ context, retval);
syslog(LOG_DEBUG,
"pam_krb5: verify_krb_v5_tgt(): %s: %s",
- "krb5_sname_to_principal()",
- krb5_get_err_text(context, retval));
+ "krb5_sname_to_principal()", msg);
+ krb5_free_error_message(context, msg);
+ }
return -1;
}
@@ -866,11 +892,14 @@ verify_krb_v5_tgt(krb5_context context, krb5_ccache ccache,
}
if (retval != 0) { /* failed to find key */
/* Keytab or service key does not exist */
- if (debug)
+ if (debug) {
+ const char *msg = krb5_get_error_message(context,
+ retval);
syslog(LOG_DEBUG,
"pam_krb5: verify_krb_v5_tgt(): %s: %s",
- "krb5_kt_read_service_key()",
- krb5_get_err_text(context, retval));
+ "krb5_kt_read_service_key()", msg);
+ krb5_free_error_message(context, msg);
+ }
retval = 0;
goto cleanup;
}
@@ -886,11 +915,14 @@ verify_krb_v5_tgt(krb5_context context, krb5_ccache ccache,
auth_context = NULL; /* setup for rd_req */
}
if (retval) {
- if (debug)
+ if (debug) {
+ const char *msg = krb5_get_error_message(context,
+ retval);
syslog(LOG_DEBUG,
"pam_krb5: verify_krb_v5_tgt(): %s: %s",
- "krb5_mk_req()",
- krb5_get_err_text(context, retval));
+ "krb5_mk_req()", msg);
+ krb5_free_error_message(context, msg);
+ }
retval = -1;
goto cleanup;
}
@@ -899,11 +931,14 @@ verify_krb_v5_tgt(krb5_context context, krb5_ccache ccache,
retval = krb5_rd_req(context, &auth_context, &packet, princ, NULL,
NULL, NULL);
if (retval) {
- if (debug)
+ if (debug) {
+ const char *msg = krb5_get_error_message(context,
+ retval);
syslog(LOG_DEBUG,
"pam_krb5: verify_krb_v5_tgt(): %s: %s",
- "krb5_rd_req()",
- krb5_get_err_text(context, retval));
+ "krb5_rd_req()", msg);
+ krb5_free_error_message(context, msg);
+ }
retval = -1;
}
else
diff --git a/lib/libpam/modules/pam_ksu/pam_ksu.c b/lib/libpam/modules/pam_ksu/pam_ksu.c
index 80a395a8abd9..f8f7fb63ae8b 100644
--- a/lib/libpam/modules/pam_ksu/pam_ksu.c
+++ b/lib/libpam/modules/pam_ksu/pam_ksu.c
@@ -70,8 +70,9 @@ pam_sm_authenticate(pam_handle_t *pamh, int flags __unused,
PAM_LOG("Got ruser: %s", (const char *)ruser);
rv = krb5_init_context(&context);
if (rv != 0) {
- PAM_LOG("krb5_init_context failed: %s",
- krb5_get_err_text(context, rv));
+ const char *msg = krb5_get_error_message(context, rv);
+ PAM_LOG("krb5_init_context failed: %s", msg);
+ krb5_free_error_message(context, msg);
return (PAM_SERVICE_ERR);
}
rv = get_su_principal(context, user, ruser, &su_principal_name, &su_principal);
@@ -112,7 +113,7 @@ auth_krb5(pam_handle_t *pamh, krb5_context context, const char *su_principal_nam
krb5_principal su_principal)
{
krb5_creds creds;
- krb5_get_init_creds_opt gic_opt;
+ krb5_get_init_creds_opt *gic_opt;
krb5_verify_init_creds_opt vic_opt;
const char *pass;
char *prompt;
@@ -120,7 +121,6 @@ auth_krb5(pam_handle_t *pamh, krb5_context context, const char *su_principal_nam
int pamret;
prompt = NULL;
- krb5_get_init_creds_opt_init(&gic_opt);
krb5_verify_init_creds_opt_init(&vic_opt);
if (su_principal_name != NULL)
(void)asprintf(&prompt, "Password for %s:", su_principal_name);
@@ -133,11 +133,20 @@ auth_krb5(pam_handle_t *pamh, krb5_context context, const char *su_principal_nam
free(prompt);
if (pamret != PAM_SUCCESS)
return (pamret);
+ rv = krb5_get_init_creds_opt_alloc(context, &gic_opt);
+ if (rv != 0) {
+ const char *msg = krb5_get_error_message(context, rv);
+ PAM_LOG("krb5_get_init_creds_opt_alloc: %s", msg);
+ krb5_free_error_message(context, msg);
+ return (PAM_AUTH_ERR);
+ }
rv = krb5_get_init_creds_password(context, &creds, su_principal,
- pass, NULL, NULL, 0, NULL, &gic_opt);
+ pass, NULL, NULL, 0, NULL, gic_opt);
+ krb5_get_init_creds_opt_free(context, gic_opt);
if (rv != 0) {
- PAM_LOG("krb5_get_init_creds_password: %s",
- krb5_get_err_text(context, rv));
+ const char *msg = krb5_get_error_message(context, rv);
+ PAM_LOG("krb5_get_init_creds_password: %s", msg);
+ krb5_free_error_message(context, msg);
return (PAM_AUTH_ERR);
}
krb5_verify_init_creds_opt_set_ap_req_nofail(&vic_opt, 1);
@@ -145,8 +154,9 @@ auth_krb5(pam_handle_t *pamh, krb5_context context, const char *su_principal_nam
&vic_opt);
krb5_free_cred_contents(context, &creds);
if (rv != 0) {
- PAM_LOG("krb5_verify_init_creds: %s",
- krb5_get_err_text(context, rv));
+ const char *msg = krb5_get_error_message(context, rv);
+ PAM_LOG("krb5_verify_init_creds: %s", msg);
+ krb5_free_error_message(context, msg);
return (PAM_AUTH_ERR);
}
return (PAM_SUCCESS);
@@ -220,8 +230,9 @@ get_su_principal(krb5_context context, const char *target_user, const char *curr
rv = krb5_unparse_name(context, default_principal, &principal_name);
krb5_free_principal(context, default_principal);
if (rv != 0) {
- PAM_LOG("krb5_unparse_name: %s",
- krb5_get_err_text(context, rv));
+ const char *msg = krb5_get_error_message(context, rv);
+ PAM_LOG("krb5_unparse_name: %s", msg);
+ krb5_free_error_message(context, msg);
return (rv);
}
PAM_LOG("Default principal name: %s", principal_name);
@@ -243,8 +254,9 @@ get_su_principal(krb5_context context, const char *target_user, const char *curr
return (errno);
rv = krb5_parse_name(context, *su_principal_name, &default_principal);
if (rv != 0) {
- PAM_LOG("krb5_parse_name `%s': %s", *su_principal_name,
- krb5_get_err_text(context, rv));
+ const char *msg = krb5_get_error_message(context, rv);
+ PAM_LOG("krb5_parse_name `%s': %s", *su_principal_name, msg);
+ krb5_free_error_message(context, msg);
free(*su_principal_name);
return (rv);
}
diff --git a/lib/libpam/modules/pam_nologin/pam_nologin.8 b/lib/libpam/modules/pam_nologin/pam_nologin.8
index 9448bf245654..cc94be555d68 100644
--- a/lib/libpam/modules/pam_nologin/pam_nologin.8
+++ b/lib/libpam/modules/pam_nologin/pam_nologin.8
@@ -48,7 +48,7 @@ parameter, this is the
feature.
.Ss NoLogin Account Management Module
The NoLogin account management component,
-.Fn pam_sm_acct_mgmt ,
+.Fn pam_sm_acct_mgmt ,
verifies whether logins are administratively disabled via
.Xr nologin 5 .
It returns success if the user's login class has an "ignorenologin"
diff --git a/lib/libpam/modules/pam_unix/Makefile b/lib/libpam/modules/pam_unix/Makefile
index ce66768b225c..4d28cfd6a44b 100644
--- a/lib/libpam/modules/pam_unix/Makefile
+++ b/lib/libpam/modules/pam_unix/Makefile
@@ -40,8 +40,8 @@ LIB= pam_unix
SRCS= pam_unix.c
MAN= pam_unix.8
-DPADD= ${LIBUTIL} ${LIBCRYPT}
-LDADD= -lutil -lcrypt
+DPADD+= ${LIBUTIL} ${LIBCRYPT}
+LDADD+= -lutil -lcrypt
.if ${MK_NIS} != "no"
CFLAGS+= -DYP
diff --git a/lib/libpmc/Makefile b/lib/libpmc/Makefile
index 85ddf0f45a14..5edbfe6419ef 100644
--- a/lib/libpmc/Makefile
+++ b/lib/libpmc/Makefile
@@ -20,6 +20,7 @@ MAN+= pmc_read.3
MAN+= pmc_set.3
MAN+= pmc_start.3
MAN+= pmclog.3
+MAN+= pmc.soft.3
# PMC-dependent manual pages
.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
@@ -35,11 +36,16 @@ MAN+= pmc.p5.3
MAN+= pmc.p6.3
MAN+= pmc.corei7.3
MAN+= pmc.corei7uc.3
+MAN+= pmc.sandybridge.3
+MAN+= pmc.sandybridgeuc.3
MAN+= pmc.westmere.3
MAN+= pmc.westmereuc.3
MAN+= pmc.tsc.3
.elif ${MACHINE_CPUARCH} == "arm" && ${CPUTYPE} == "xscale"
MAN+= pmc.xscale.3
+.elif ${MACHINE_CPUARCH} == "mips"
+MAN+= pmc.mips24k.3
+MAN+= pmc.octeon.3
.endif
MLINKS+= \
diff --git a/lib/libpmc/libpmc.c b/lib/libpmc/libpmc.c
index ba63ace1ff95..3b7dc376ed27 100644
--- a/lib/libpmc/libpmc.c
+++ b/lib/libpmc/libpmc.c
@@ -77,11 +77,12 @@ static int tsc_allocate_pmc(enum pmc_event _pe, char *_ctrspec,
static int xscale_allocate_pmc(enum pmc_event _pe, char *_ctrspec,
struct pmc_op_pmcallocate *_pmc_config);
#endif
-
#if defined(__mips__)
-static int mips24k_allocate_pmc(enum pmc_event _pe, char* ctrspec,
+static int mips_allocate_pmc(enum pmc_event _pe, char* ctrspec,
struct pmc_op_pmcallocate *_pmc_config);
#endif /* __mips__ */
+static int soft_allocate_pmc(enum pmc_event _pe, char *_ctrspec,
+ struct pmc_op_pmcallocate *_pmc_config);
#if defined(__powerpc__)
static int ppc7450_allocate_pmc(enum pmc_event _pe, char* ctrspec,
@@ -152,9 +153,12 @@ PMC_CLASSDEP_TABLE(p5, P5);
PMC_CLASSDEP_TABLE(p6, P6);
PMC_CLASSDEP_TABLE(xscale, XSCALE);
PMC_CLASSDEP_TABLE(mips24k, MIPS24K);
+PMC_CLASSDEP_TABLE(octeon, OCTEON);
PMC_CLASSDEP_TABLE(ucf, UCF);
PMC_CLASSDEP_TABLE(ppc7450, PPC7450);
+static struct pmc_event_descr soft_event_table[PMC_EV_DYN_COUNT];
+
#undef __PMC_EV_ALIAS
#define __PMC_EV_ALIAS(N,CODE) { N, PMC_EV_##CODE },
@@ -179,6 +183,11 @@ static const struct pmc_event_descr corei7_event_table[] =
__PMC_EV_ALIAS_COREI7()
};
+static const struct pmc_event_descr sandybridge_event_table[] =
+{
+ __PMC_EV_ALIAS_SANDYBRIDGE()
+};
+
static const struct pmc_event_descr westmere_event_table[] =
{
__PMC_EV_ALIAS_WESTMERE()
@@ -189,6 +198,11 @@ static const struct pmc_event_descr corei7uc_event_table[] =
__PMC_EV_ALIAS_COREI7UC()
};
+static const struct pmc_event_descr sandybridgeuc_event_table[] =
+{
+ __PMC_EV_ALIAS_SANDYBRIDGEUC()
+};
+
static const struct pmc_event_descr westmereuc_event_table[] =
{
__PMC_EV_ALIAS_WESTMEREUC()
@@ -204,19 +218,22 @@ static const struct pmc_event_descr westmereuc_event_table[] =
PMC_CLASS_##C, __VA_ARGS__ \
}
-PMC_MDEP_TABLE(atom, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC);
-PMC_MDEP_TABLE(core, IAP, PMC_CLASS_TSC);
-PMC_MDEP_TABLE(core2, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC);
-PMC_MDEP_TABLE(corei7, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
-PMC_MDEP_TABLE(westmere, IAP, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
-PMC_MDEP_TABLE(k7, K7, PMC_CLASS_TSC);
-PMC_MDEP_TABLE(k8, K8, PMC_CLASS_TSC);
-PMC_MDEP_TABLE(p4, P4, PMC_CLASS_TSC);
-PMC_MDEP_TABLE(p5, P5, PMC_CLASS_TSC);
-PMC_MDEP_TABLE(p6, P6, PMC_CLASS_TSC);
-PMC_MDEP_TABLE(xscale, XSCALE, PMC_CLASS_XSCALE);
-PMC_MDEP_TABLE(mips24k, MIPS24K, PMC_CLASS_MIPS24K);
-PMC_MDEP_TABLE(ppc7450, PPC7450, PMC_CLASS_PPC7450);
+PMC_MDEP_TABLE(atom, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC);
+PMC_MDEP_TABLE(core, IAP, PMC_CLASS_SOFT, PMC_CLASS_TSC);
+PMC_MDEP_TABLE(core2, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC);
+PMC_MDEP_TABLE(corei7, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
+PMC_MDEP_TABLE(sandybridge, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
+PMC_MDEP_TABLE(westmere, IAP, PMC_CLASS_SOFT, PMC_CLASS_IAF, PMC_CLASS_TSC, PMC_CLASS_UCF, PMC_CLASS_UCP);
+PMC_MDEP_TABLE(k7, K7, PMC_CLASS_SOFT, PMC_CLASS_TSC);
+PMC_MDEP_TABLE(k8, K8, PMC_CLASS_SOFT, PMC_CLASS_TSC);
+PMC_MDEP_TABLE(p4, P4, PMC_CLASS_SOFT, PMC_CLASS_TSC);
+PMC_MDEP_TABLE(p5, P5, PMC_CLASS_SOFT, PMC_CLASS_TSC);
+PMC_MDEP_TABLE(p6, P6, PMC_CLASS_SOFT, PMC_CLASS_TSC);
+PMC_MDEP_TABLE(xscale, XSCALE, PMC_CLASS_SOFT, PMC_CLASS_XSCALE);
+PMC_MDEP_TABLE(mips24k, MIPS24K, PMC_CLASS_SOFT, PMC_CLASS_MIPS24K);
+PMC_MDEP_TABLE(octeon, OCTEON, PMC_CLASS_SOFT, PMC_CLASS_OCTEON);
+PMC_MDEP_TABLE(ppc7450, PPC7450, PMC_CLASS_SOFT, PMC_CLASS_PPC7450);
+PMC_MDEP_TABLE(generic, SOFT, PMC_CLASS_SOFT);
static const struct pmc_event_descr tsc_event_table[] =
{
@@ -242,9 +259,11 @@ PMC_CLASS_TABLE_DESC(atom, IAP, atom, iap);
PMC_CLASS_TABLE_DESC(core, IAP, core, iap);
PMC_CLASS_TABLE_DESC(core2, IAP, core2, iap);
PMC_CLASS_TABLE_DESC(corei7, IAP, corei7, iap);
+PMC_CLASS_TABLE_DESC(sandybridge, IAP, sandybridge, iap);
PMC_CLASS_TABLE_DESC(westmere, IAP, westmere, iap);
PMC_CLASS_TABLE_DESC(ucf, UCF, ucf, ucf);
PMC_CLASS_TABLE_DESC(corei7uc, UCP, corei7uc, ucp);
+PMC_CLASS_TABLE_DESC(sandybridgeuc, UCP, sandybridgeuc, ucp);
PMC_CLASS_TABLE_DESC(westmereuc, UCP, westmereuc, ucp);
#endif
#if defined(__i386__)
@@ -264,15 +283,24 @@ PMC_CLASS_TABLE_DESC(tsc, TSC, tsc, tsc);
#if defined(__XSCALE__)
PMC_CLASS_TABLE_DESC(xscale, XSCALE, xscale, xscale);
#endif
-
#if defined(__mips__)
-PMC_CLASS_TABLE_DESC(mips24k, MIPS24K, mips24k, mips24k);
+PMC_CLASS_TABLE_DESC(mips24k, MIPS24K, mips24k, mips);
+PMC_CLASS_TABLE_DESC(octeon, OCTEON, octeon, mips);
#endif /* __mips__ */
-
#if defined(__powerpc__)
PMC_CLASS_TABLE_DESC(ppc7450, PPC7450, ppc7450, ppc7450);
#endif
+static struct pmc_class_descr soft_class_table_descr =
+{
+ .pm_evc_name = "SOFT-",
+ .pm_evc_name_size = sizeof("SOFT-") - 1,
+ .pm_evc_class = PMC_CLASS_SOFT,
+ .pm_evc_event_table = NULL,
+ .pm_evc_event_table_size = 0,
+ .pm_evc_allocate_pmc = soft_allocate_pmc
+};
+
#undef PMC_CLASS_TABLE_DESC
static const struct pmc_class_descr **pmc_class_table;
@@ -327,9 +355,12 @@ static const char * pmc_state_names[] = {
__PMC_STATES()
};
-static int pmc_syscall = -1; /* filled in by pmc_init() */
-
-static struct pmc_cpuinfo cpu_info; /* filled in by pmc_init() */
+/*
+ * Filled in by pmc_init().
+ */
+static int pmc_syscall = -1;
+static struct pmc_cpuinfo cpu_info;
+static struct pmc_op_getdyneventinfo soft_event_info;
/* Event masks for events */
struct pmc_masks {
@@ -530,6 +561,8 @@ static struct pmc_event_alias core2_aliases_without_iaf[] = {
#define atom_aliases_without_iaf core2_aliases_without_iaf
#define corei7_aliases core2_aliases
#define corei7_aliases_without_iaf core2_aliases_without_iaf
+#define sandybridge_aliases core2_aliases
+#define sandybridge_aliases_without_iaf core2_aliases_without_iaf
#define westmere_aliases core2_aliases
#define westmere_aliases_without_iaf core2_aliases_without_iaf
@@ -2161,6 +2194,25 @@ tsc_allocate_pmc(enum pmc_event pe, char *ctrspec,
}
#endif
+static struct pmc_event_alias generic_aliases[] = {
+ EV_ALIAS("instructions", "SOFT-CLOCK.HARD"),
+ EV_ALIAS(NULL, NULL)
+};
+
+static int
+soft_allocate_pmc(enum pmc_event pe, char *ctrspec,
+ struct pmc_op_pmcallocate *pmc_config)
+{
+ (void)ctrspec;
+ (void)pmc_config;
+
+ if (pe < PMC_EV_SOFT_FIRST || pe > PMC_EV_SOFT_LAST)
+ return (-1);
+
+ pmc_config->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE);
+ return (0);
+}
+
#if defined(__XSCALE__)
static struct pmc_event_alias xscale_aliases[] = {
@@ -2193,12 +2245,19 @@ static struct pmc_event_alias mips24k_aliases[] = {
EV_ALIAS(NULL, NULL)
};
-#define MIPS24K_KW_OS "os"
-#define MIPS24K_KW_USR "usr"
-#define MIPS24K_KW_ANYTHREAD "anythread"
+static struct pmc_event_alias octeon_aliases[] = {
+ EV_ALIAS("instructions", "RET"),
+ EV_ALIAS("branches", "BR"),
+ EV_ALIAS("branch-mispredicts", "BRMIS"),
+ EV_ALIAS(NULL, NULL)
+};
+
+#define MIPS_KW_OS "os"
+#define MIPS_KW_USR "usr"
+#define MIPS_KW_ANYTHREAD "anythread"
static int
-mips24k_allocate_pmc(enum pmc_event pe, char *ctrspec __unused,
+mips_allocate_pmc(enum pmc_event pe, char *ctrspec __unused,
struct pmc_op_pmcallocate *pmc_config __unused)
{
char *p;
@@ -2208,11 +2267,11 @@ mips24k_allocate_pmc(enum pmc_event pe, char *ctrspec __unused,
pmc_config->pm_caps |= (PMC_CAP_READ | PMC_CAP_WRITE);
while ((p = strsep(&ctrspec, ",")) != NULL) {
- if (KWMATCH(p, MIPS24K_KW_OS))
+ if (KWMATCH(p, MIPS_KW_OS))
pmc_config->pm_caps |= PMC_CAP_SYSTEM;
- else if (KWMATCH(p, MIPS24K_KW_USR))
+ else if (KWMATCH(p, MIPS_KW_USR))
pmc_config->pm_caps |= PMC_CAP_USER;
- else if (KWMATCH(p, MIPS24K_KW_ANYTHREAD))
+ else if (KWMATCH(p, MIPS_KW_ANYTHREAD))
pmc_config->pm_caps |= (PMC_CAP_USER | PMC_CAP_SYSTEM);
else
return (-1);
@@ -2220,6 +2279,7 @@ mips24k_allocate_pmc(enum pmc_event pe, char *ctrspec __unused,
return (0);
}
+
#endif /* __mips__ */
#if defined(__powerpc__)
@@ -2562,6 +2622,10 @@ pmc_event_names_of_class(enum pmc_class cl, const char ***eventnames,
ev = corei7_event_table;
count = PMC_EVENT_TABLE_SIZE(corei7);
break;
+ case PMC_CPU_INTEL_SANDYBRIDGE:
+ ev = sandybridge_event_table;
+ count = PMC_EVENT_TABLE_SIZE(sandybridge);
+ break;
case PMC_CPU_INTEL_WESTMERE:
ev = westmere_event_table;
count = PMC_EVENT_TABLE_SIZE(westmere);
@@ -2583,6 +2647,10 @@ pmc_event_names_of_class(enum pmc_class cl, const char ***eventnames,
ev = corei7uc_event_table;
count = PMC_EVENT_TABLE_SIZE(corei7uc);
break;
+ case PMC_CPU_INTEL_SANDYBRIDGE:
+ ev = sandybridgeuc_event_table;
+ count = PMC_EVENT_TABLE_SIZE(sandybridgeuc);
+ break;
case PMC_CPU_INTEL_WESTMERE:
ev = westmereuc_event_table;
count = PMC_EVENT_TABLE_SIZE(westmereuc);
@@ -2621,10 +2689,18 @@ pmc_event_names_of_class(enum pmc_class cl, const char ***eventnames,
ev = mips24k_event_table;
count = PMC_EVENT_TABLE_SIZE(mips24k);
break;
+ case PMC_CLASS_OCTEON:
+ ev = octeon_event_table;
+ count = PMC_EVENT_TABLE_SIZE(octeon);
+ break;
case PMC_CLASS_PPC7450:
ev = ppc7450_event_table;
count = PMC_EVENT_TABLE_SIZE(ppc7450);
break;
+ case PMC_CLASS_SOFT:
+ ev = soft_event_table;
+ count = soft_event_info.pm_nevent;
+ break;
default:
errno = EINVAL;
return (-1);
@@ -2638,6 +2714,7 @@ pmc_event_names_of_class(enum pmc_class cl, const char ***eventnames,
for (;count--; ev++, names++)
*names = ev->pm_ev_name;
+
return (0);
}
@@ -2742,11 +2819,34 @@ pmc_init(void)
pmc_class_table[n] = NULL;
/*
+ * Get soft events list.
+ */
+ soft_event_info.pm_class = PMC_CLASS_SOFT;
+ if (PMC_CALL(GETDYNEVENTINFO, &soft_event_info) < 0)
+ return (pmc_syscall = -1);
+
+ /* Map soft events to static list. */
+ for (n = 0; n < soft_event_info.pm_nevent; n++) {
+ soft_event_table[n].pm_ev_name =
+ soft_event_info.pm_events[n].pm_ev_name;
+ soft_event_table[n].pm_ev_code =
+ soft_event_info.pm_events[n].pm_ev_code;
+ }
+ soft_class_table_descr.pm_evc_event_table_size = \
+ soft_event_info.pm_nevent;
+ soft_class_table_descr.pm_evc_event_table = \
+ soft_event_table;
+
+ /*
* Fill in the class table.
*/
n = 0;
+
+ /* Fill soft events information. */
+ pmc_class_table[n++] = &soft_class_table_descr;
#if defined(__amd64__) || defined(__i386__)
- pmc_class_table[n++] = &tsc_class_table_descr;
+ if (cpu_info.pm_cputype != PMC_CPU_GENERIC)
+ pmc_class_table[n++] = &tsc_class_table_descr;
/*
* Check if this CPU has fixed function counters.
@@ -2814,6 +2914,11 @@ pmc_init(void)
pmc_class_table[n++] = &corei7uc_class_table_descr;
PMC_MDEP_INIT_INTEL_V2(corei7);
break;
+ case PMC_CPU_INTEL_SANDYBRIDGE:
+ pmc_class_table[n++] = &ucf_class_table_descr;
+ pmc_class_table[n++] = &sandybridgeuc_class_table_descr;
+ PMC_MDEP_INIT_INTEL_V2(sandybridge);
+ break;
case PMC_CPU_INTEL_WESTMERE:
pmc_class_table[n++] = &ucf_class_table_descr;
pmc_class_table[n++] = &westmereuc_class_table_descr;
@@ -2824,6 +2929,9 @@ pmc_init(void)
pmc_class_table[n] = &p4_class_table_descr;
break;
#endif
+ case PMC_CPU_GENERIC:
+ PMC_MDEP_INIT(generic);
+ break;
#if defined(__XSCALE__)
case PMC_CPU_INTEL_XSCALE:
PMC_MDEP_INIT(xscale);
@@ -2835,6 +2943,10 @@ pmc_init(void)
PMC_MDEP_INIT(mips24k);
pmc_class_table[n] = &mips24k_class_table_descr;
break;
+ case PMC_CPU_MIPS_OCTEON:
+ PMC_MDEP_INIT(octeon);
+ pmc_class_table[n] = &octeon_class_table_descr;
+ break;
#endif /* __mips__ */
#if defined(__powerpc__)
case PMC_CPU_PPC_7450:
@@ -2937,6 +3049,10 @@ _pmc_name_of_event(enum pmc_event pe, enum pmc_cputype cpu)
ev = corei7_event_table;
evfence = corei7_event_table + PMC_EVENT_TABLE_SIZE(corei7);
break;
+ case PMC_CPU_INTEL_SANDYBRIDGE:
+ ev = sandybridge_event_table;
+ evfence = sandybridge_event_table + PMC_EVENT_TABLE_SIZE(sandybridge);
+ break;
case PMC_CPU_INTEL_WESTMERE:
ev = westmere_event_table;
evfence = westmere_event_table + PMC_EVENT_TABLE_SIZE(westmere);
@@ -2953,6 +3069,10 @@ _pmc_name_of_event(enum pmc_event pe, enum pmc_cputype cpu)
ev = corei7uc_event_table;
evfence = corei7uc_event_table + PMC_EVENT_TABLE_SIZE(corei7uc);
break;
+ case PMC_CPU_INTEL_SANDYBRIDGE:
+ ev = sandybridgeuc_event_table;
+ evfence = sandybridgeuc_event_table + PMC_EVENT_TABLE_SIZE(sandybridgeuc);
+ break;
case PMC_CPU_INTEL_WESTMERE:
ev = westmereuc_event_table;
evfence = westmereuc_event_table + PMC_EVENT_TABLE_SIZE(westmereuc);
@@ -2980,15 +3100,19 @@ _pmc_name_of_event(enum pmc_event pe, enum pmc_cputype cpu)
evfence = xscale_event_table + PMC_EVENT_TABLE_SIZE(xscale);
} else if (pe >= PMC_EV_MIPS24K_FIRST && pe <= PMC_EV_MIPS24K_LAST) {
ev = mips24k_event_table;
- evfence = mips24k_event_table + PMC_EVENT_TABLE_SIZE(mips24k
-);
+ evfence = mips24k_event_table + PMC_EVENT_TABLE_SIZE(mips24k);
+ } else if (pe >= PMC_EV_OCTEON_FIRST && pe <= PMC_EV_OCTEON_LAST) {
+ ev = octeon_event_table;
+ evfence = octeon_event_table + PMC_EVENT_TABLE_SIZE(octeon);
} else if (pe >= PMC_EV_PPC7450_FIRST && pe <= PMC_EV_PPC7450_LAST) {
ev = ppc7450_event_table;
- evfence = ppc7450_event_table + PMC_EVENT_TABLE_SIZE(ppc7450
-);
+ evfence = ppc7450_event_table + PMC_EVENT_TABLE_SIZE(ppc7450);
} else if (pe == PMC_EV_TSC_TSC) {
ev = tsc_event_table;
evfence = tsc_event_table + PMC_EVENT_TABLE_SIZE(tsc);
+ } else if (pe >= PMC_EV_SOFT_FIRST && pe <= PMC_EV_SOFT_LAST) {
+ ev = soft_event_table;
+ evfence = soft_event_table + soft_event_info.pm_nevent;
}
for (; ev != evfence; ev++)
diff --git a/lib/libpmc/pmc.3 b/lib/libpmc/pmc.3
index 2431080a32a9..cf74f321076d 100644
--- a/lib/libpmc/pmc.3
+++ b/lib/libpmc/pmc.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -223,9 +223,10 @@ and
CPUs.
.It Li PMC_CLASS_TSC
The timestamp counter on i386 and amd64 architecture CPUs.
+.It Li PMC_CLASS_SOFT
+Software events.
.El
.Ss PMC Capabilities
-.Pp
Capabilities of performance monitoring hardware are denoted using
the
.Vt "enum pmc_caps"
@@ -526,6 +527,7 @@ API is
.Xr pmc.p4 3 ,
.Xr pmc.p5 3 ,
.Xr pmc.p6 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmclog 3 ,
.Xr hwpmc 4 ,
diff --git a/lib/libpmc/pmc.atom.3 b/lib/libpmc/pmc.atom.3
index a54d1db2b1cd..f61a1415ec43 100644
--- a/lib/libpmc/pmc.atom.3
+++ b/lib/libpmc/pmc.atom.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -1176,6 +1176,7 @@ and the underlying hardware events used on these CPUs.
.Xr pmc.p4 3 ,
.Xr pmc.p5 3 ,
.Xr pmc.p6 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc_cpuinfo 3 ,
.Xr pmclog 3 ,
diff --git a/lib/libpmc/pmc.core.3 b/lib/libpmc/pmc.core.3
index db4c769c3a22..73e8d81d5dc2 100644
--- a/lib/libpmc/pmc.core.3
+++ b/lib/libpmc/pmc.core.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -180,7 +180,7 @@ The default is
The following event names are case insensitive.
Whitespace, hyphens and underscore characters in these names are
ignored.
-.Pp
+.Pp
Core PMCs support the following events:
.Bl -tag -width indent
.It Li BAClears
@@ -193,7 +193,7 @@ produce a prediction.
.It Li Br_BAC_Missp_Exec
.Pq Event 8AH , Umask 00H
The number of branch instructions executed that were mispredicted at
-the front end.
+the front end.
.It Li Br_Bogus
.Pq Event E4H , Umask 00H
The number of bogus branches.
@@ -792,6 +792,7 @@ may not count some transitions.
.Xr pmc.p4 3 ,
.Xr pmc.p5 3 ,
.Xr pmc.p6 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmclog 3 ,
.Xr hwpmc 4
diff --git a/lib/libpmc/pmc.core2.3 b/lib/libpmc/pmc.core2.3
index 3dbc0c850e5f..5c6b533164f9 100644
--- a/lib/libpmc/pmc.core2.3
+++ b/lib/libpmc/pmc.core2.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -1107,6 +1107,7 @@ and the underlying hardware events used.
.Xr pmc.p4 3 ,
.Xr pmc.p5 3 ,
.Xr pmc.p6 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc_cpuinfo 3 ,
.Xr pmclog 3 ,
diff --git a/lib/libpmc/pmc.corei7.3 b/lib/libpmc/pmc.corei7.3
index 679313f218c6..aaf1f022615f 100644
--- a/lib/libpmc/pmc.corei7.3
+++ b/lib/libpmc/pmc.corei7.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -200,10 +200,6 @@ Number of cache load STLB hits
.Pq Event 08H , Umask 20H
Number of DTLB cache load misses where the low part of the linear to
physical address translation was missed.
-.It Li DTLB_LOAD_MISSES.PDP_MISS
-.Pq Event 08H , Umask 40H
-Number of DTLB cache load misses where the high part of the linear to
-physical address translation was missed.
.It Li DTLB_LOAD_MISSES.LARGE_WALK_COMPLETED
.Pq Event 08H , Umask 80H
Counts number of completed large page walks due to load miss in the STLB.
@@ -646,10 +642,6 @@ Counter 0, 1 only
Counts all data reads and writes (speculated and retired) from cacheable
memory, including locked operations.
Counter 0, 1 only
-.It Li L1D_PEND_MISS.LOAD_BUFFERS_FULL
-.Pq Event 48H , Umask 02H
-Counts cycles of L1 data cache load fill buffers full.
-Counter 0, 1 only
.It Li DTLB_MISSES.ANY
.Pq Event 49H , Umask 01H
Counts the number of misses in the STLB which causes a page walk.
@@ -660,6 +652,12 @@ Counts number of misses in the STLB which resulted in a completed page walk.
.Pq Event 49H , Umask 10H
Counts the number of DTLB first level misses that hit in the second level
TLB. This event is only relevant if the core contains multiple DTLB levels.
+.It Li DTLB_MISSES.PDE_MISS
+.Pq Event 49H , Umask 20H
+Number of DTLB misses caused by low part of address, includes references to 2M pages because 2M pages do not use the PDE.
+.It Li DTLB_MISSES.LARGE_WALK_COMPLETED
+.Pq Event 49H , Umask 80H
+Counts number of misses in the STLB which resulted in a completed page walk for large pages.
.It Li LOAD_HIT_PRE
.Pq Event 4CH , Umask 01H
Counts load operations sent to the L1 data cache while a previous SSE
@@ -1205,9 +1203,6 @@ The BPU clear leads to 2 cycle bubble in the Front End.
.Pq Event E8H , Umask 02H
Counts late Branch Prediction Unit clears due to Most Recently Used
conflicts. The PBU clear leads to a 3 cycle bubble in the Front End.
-.It Li BPU_CLEARS.ANY
-.Pq Event E8H , Umask 03H
-Counts all BPU clears.
.It Li L2_TRANSACTIONS.LOAD
.Pq Event F0H , Umask 01H
Counts L2 load operations due to HW prefetch or demand loads.
@@ -1564,6 +1559,7 @@ Counts number of segment register loads.
.Xr pmc.corei7uc 3 ,
.Xr pmc.westmere 3 ,
.Xr pmc.westmereuc 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc_cpuinfo 3 ,
.Xr pmclog 3 ,
diff --git a/lib/libpmc/pmc.corei7uc.3 b/lib/libpmc/pmc.corei7uc.3
index a69eab775880..3114c8ea9f6a 100644
--- a/lib/libpmc/pmc.corei7uc.3
+++ b/lib/libpmc/pmc.corei7uc.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -863,6 +863,7 @@ refreshed or needs to go into a power down mode.
.Xr pmc.corei7 3 ,
.Xr pmc.westmere 3 ,
.Xr pmc.westmereuc 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc_cpuinfo 3 ,
.Xr pmclog 3 ,
diff --git a/lib/libpmc/pmc.h b/lib/libpmc/pmc.h
index 2be88b121d3c..e17a5840b4ea 100644
--- a/lib/libpmc/pmc.h
+++ b/lib/libpmc/pmc.h
@@ -98,7 +98,7 @@ int pmc_npmc(int _cpu);
int pmc_cpuinfo(const struct pmc_cpuinfo **_cpu_info);
int pmc_pmcinfo(int _cpu, struct pmc_pmcinfo **_pmc_info);
-const char *pmc_name_of_capability(uint32_t _c);
+const char *pmc_name_of_capability(enum pmc_caps _c);
const char *pmc_name_of_class(enum pmc_class _pc);
const char *pmc_name_of_cputype(enum pmc_cputype _cp);
const char *pmc_name_of_disposition(enum pmc_disp _pd);
diff --git a/lib/libpmc/pmc.iaf.3 b/lib/libpmc/pmc.iaf.3
index ec9f21cb2761..7e623d6548ac 100644
--- a/lib/libpmc/pmc.iaf.3
+++ b/lib/libpmc/pmc.iaf.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -132,6 +132,7 @@ CPU, use the event specifier
.Xr pmc.p4 3 ,
.Xr pmc.p5 3 ,
.Xr pmc.p6 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc_cpuinfo 3 ,
.Xr pmclog 3 ,
diff --git a/lib/libpmc/pmc.k7.3 b/lib/libpmc/pmc.k7.3
index 2775d4fd922b..646f35275149 100644
--- a/lib/libpmc/pmc.k7.3
+++ b/lib/libpmc/pmc.k7.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -64,7 +64,6 @@ Each K7 CPU contains 4 PMCs with the following capabilities:
.It PMC_CAP_WRITE Ta Yes
.El
.Ss Event Qualifiers
-.Pp
Event specifiers for AMD K7 PMCs can have the following optional
qualifiers:
.Bl -tag -width indent
@@ -250,6 +249,7 @@ and the underlying hardware events used.
.Xr pmc.p4 3 ,
.Xr pmc.p5 3 ,
.Xr pmc.p6 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmclog 3 ,
.Xr hwpmc 4
diff --git a/lib/libpmc/pmc.k8.3 b/lib/libpmc/pmc.k8.3
index 995bfac958a3..628137d7ffaf 100644
--- a/lib/libpmc/pmc.k8.3
+++ b/lib/libpmc/pmc.k8.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -67,7 +67,6 @@ Each CPU contains 4 PMCs with the following capabilities:
.It PMC_CAP_WRITE Ta Yes
.El
.Ss Event Qualifiers
-.Pp
Event specifiers for AMD K8 PMCs can have the following optional
qualifiers:
.Bl -tag -width indent
@@ -784,6 +783,7 @@ and the underlying hardware events used.
.Xr pmc.p4 3 ,
.Xr pmc.p5 3 ,
.Xr pmc.p6 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmclog 3 ,
.Xr hwpmc 4
diff --git a/lib/libpmc/pmc.mips.3 b/lib/libpmc/pmc.mips24k.3
index 46cc4432a51e..4acb0a7eab94 100644
--- a/lib/libpmc/pmc.mips.3
+++ b/lib/libpmc/pmc.mips24k.3
@@ -9,27 +9,27 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall George Neville-Neil be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
-.Dd February 11, 2010
-.Dt PMC.MIPS 3
+.Dd March 24, 2012
+.Dt PMC.MIPS24K 3
.Os
.Sh NAME
-.Nm pmc.mips
+.Nm pmc.mips24k
.Nd measurement events for
-.Tn MIPS
+.Tn MIPS24K
family CPUs
.Sh LIBRARY
.Lb libpmc
@@ -54,16 +54,16 @@ MIPS programmable PMCs support the following events:
.Bl -tag -width indent
.It Li CYCLE
.Pq Event 0, Counter 0/1
-Total number of cycles.
+Total number of cycles.
The performance counters are clocked by the
-top-level gated clock.
+top-level gated clock.
If the core is built with that clock gater
present, none of the counters will increment while the clock is
stopped - due to a WAIT instruction.
.It Li INSTR_EXECUTED
.Pq Event 1, Counter 0/1
Total number of instructions completed.
-.It Li BRANCH_COMPLETED
+.It Li BRANCH_COMPLETED
.Pq Event 2, Counter 0
Total number of branch instructions completed.
.It Li BRANCH_MISPRED
@@ -85,9 +85,9 @@ If RPS use is disabled, JR $31 will not be predicted.
.Pq Event 5, Counter 0
Counts ITLB accesses that are due to fetches showing up in the
instruction fetch stage of the pipeline and which do not use a fixed
-mapping or are not in unmapped space.
+mapping or are not in unmapped space.
If an address is fetched twice from the pipe (as in the case of a
-cache miss), that instruction willcount as 2 ITLB accesses.
+cache miss), that instruction willcount as 2 ITLB accesses.
Since each fetch gets us 2 instructions,there is one access marked per double
word.
.It Li ITLB_MISS
@@ -102,7 +102,8 @@ They are also ignored if there is some form of address error.
Counts DTLB access including those in unmapped address spaces.
.It Li DTLB_MISS
.Pq Event 6, Counter 1
-Counts DTLB misses. Back to back misses that result in only one DTLB
+Counts DTLB misses.
+Back to back misses that result in only one DTLB
entry getting refilled are counted as a single miss.
.It Li JTLB_IACCESS
.Pq Event 7, Counter 0
@@ -119,7 +120,8 @@ Data JTLB accesses.
Counts data JTLB accesses that result in no match or a match on an invalid translation.
.It Li IC_FETCH
.Pq Event 9, Counter 0
-Counts every time the instruction cache is accessed. All replays,
+Counts every time the instruction cache is accessed.
+All replays,
wasted fetches etc. are counted.
For example, following a branch, even though the prediction is taken,
the fall through access is counted.
@@ -166,7 +168,7 @@ This includes all instructions that normally write to a general
purpose register, but where the destination register was set to r0.
.It Li INTEGER_MULDIV_COMPLETED
.Pq Event 17, Counter 1
-Integer multipy and divide instructions completed. (MULxx, DIVx, MADDx, MSUBx).
+Integer multiply and divide instructions completed. (MULxx, DIVx, MADDx, MSUBx).
.It Li RF_STALL
.Pq Event 18, Counter 0
Counts the total number of cycles where no instructions are issued
@@ -179,7 +181,8 @@ when both stalls are active will only be counted once.
replay traps (other than uTLB)
.It Li STORE_COND_COMPLETED
.Pq Event 19, Counter 0
-Conditional stores completed. Counts all events, including failed stores.
+Conditional stores completed.
+Counts all events, including failed stores.
.It Li STORE_COND_FAILED
.Pq Event 19, Counter 1
Conditional store instruction that did not update memory.
@@ -189,7 +192,7 @@ different and the observed operating mode could change between them,
causing some inaccuracy in the measured ratio.
.It Li ICACHE_REQUESTS
.Pq Event 20, Counter 0
-Note that this only counts PREFs that are actually attempted.
+Note that this only counts PREFs that are actually attempted.
PREFs to uncached addresses or ones with translation errors are not counted
.It Li ICACHE_HIT
.Pq Event 20, Counter 1
@@ -214,7 +217,7 @@ Any type of exception taken.
Counts cycles where the LSU is in fixup and cannot accept a new
instruction from the ALU.
Fixups are replays within the LSU that occur when an instruction needs
-to re-access the cache or the DTLB.
+to re-access the cache or the DTLB.
.It Li IFU_CYCLES_STALLED
.Pq Event 25, Counter 0
Counts the number of cycles where the fetch unit is not providing a
@@ -256,7 +259,7 @@ Cycles where the main pipeline is stalled because of an index conflict
in the Fill Store Buffer.
.It Li DMISS_CYCLES
.Pq Event 39, Counter 0
-Data miss is outstanding, but not necessarily stalling the pipeline.
+Data miss is outstanding, but not necessarily stalling the pipeline.
The difference between this and D$ miss stall cycles can show the gain
from non-blocking cache misses.
.It Li L2_MISS_CYCLES
@@ -282,7 +285,8 @@ Counts all cycles where integer pipeline waits on CorExtend return data.
Count all pipeline bubbles that are a result of multicycle ISPRAM
access.
Pipeline bubbles are defined as all cycles that IFU doesn't present an
-instruction to ALU. The four cycles after a redirect are not counted.
+instruction to ALU.
+The four cycles after a redirect are not counted.
.It Li DSPRAM_STALL_CYCLES
.Pq Event 43, Counter 1
Counts stall cycles created by an instruction waiting for access to DSPRAM.
@@ -372,10 +376,10 @@ aliases supported by
.Lb libpmc
and the underlying hardware events used.
.Bl -column "branch-mispredicts" "cpu_clk_unhalted.core_p"
-.It Em Alias Ta Em Event Ta
-.It Li instructions Ta Li INSTR_EXECUTED Ta
-.It Li branches Ta Li BRANCH_COMPLETED Ta
-.It Li branch-mispredicts Ta Li BRANCH_MISPRED Ta
+.It Em Alias Ta Em Event
+.It Li instructions Ta Li INSTR_EXECUTED
+.It Li branches Ta Li BRANCH_COMPLETED
+.It Li branch-mispredicts Ta Li BRANCH_MISPRED
.El
.Sh SEE ALSO
.Xr pmc 3 ,
@@ -384,9 +388,11 @@ and the underlying hardware events used.
.Xr pmc.iaf 3 ,
.Xr pmc.k7 3 ,
.Xr pmc.k8 3 ,
+.Xr pmc.octeon 3 ,
.Xr pmc.p4 3 ,
.Xr pmc.p5 3 ,
.Xr pmc.p6 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc_cpuinfo 3 ,
.Xr pmclog 3 ,
@@ -405,5 +411,3 @@ library was written by
MIPS support was added by
.An "George Neville-Neil"
.Aq gnn@FreeBSD.org .
-.Sh CAVEATS
-The MIPS code does not yet support sampling.
diff --git a/lib/libpmc/pmc.octeon.3 b/lib/libpmc/pmc.octeon.3
new file mode 100644
index 000000000000..be38dd8c5786
--- /dev/null
+++ b/lib/libpmc/pmc.octeon.3
@@ -0,0 +1,253 @@
+.\" Copyright (c) 2010 George Neville-Neil. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd March 24, 2012
+.Dt PMC.OCTEON 3
+.Os
+.Sh NAME
+.Nm pmc.octeon
+.Nd measurement events for
+.Tn Octeon
+family CPUs
+.Sh LIBRARY
+.Lb libpmc
+.Sh SYNOPSIS
+.In pmc.h
+.Sh DESCRIPTION
+There are two counters per core supported by the hardware and each is 64 bits
+wide.
+.Ss Event Specifiers (Programmable PMCs)
+MIPS programmable PMCs support the following events:
+.Bl -tag -width indent
+.It Li CLK
+.Pq Event 1
+Conditionally clocked cycles (as opposed to count/cvm_count which count even with no clocks)
+.It Li ISSUE
+.Pq Event 2
+Instructions issued but not retired
+.It Li RET
+.Pq Event 3
+Instructions retired
+.It Li NISSUE
+.Pq Event 4
+Cycles no issue
+.It Li SISSUE
+.Pq Event 5
+Cycles single issue
+.It Li DISSUE
+.Pq Event 6
+Cycles dual issue
+.It Li IFI
+.Pq Event 7
+Cycle ifetch issued (but not necessarily commit to pp_mem)
+.It Li BR
+.Pq Event 8
+Branches retired
+.It Li BRMIS
+.Pq Event 9
+Branch mispredicts
+.It Li J
+.Pq Event 10
+Jumps retired
+.It Li JMIS
+.Pq Event 11
+Jumps mispredicted
+.It Li REPLAY
+.Pq Event 12
+Mem Replays
+.It Li IUNA
+.Pq Event 13
+Cycles idle due to unaligned_replays
+.It Li TRAP
+.Pq Event 14
+trap_6a signal
+.It Li UULOAD
+.Pq Event 16
+Unexpected unaligned loads (REPUN=1)
+.It Li UUSTORE
+.Pq Event 17
+Unexpected unaligned store (REPUN=1)
+.It Li ULOAD
+.Pq Event 18
+Unaligned loads (REPUN=1 or USEUN=1)
+.It Li USTORE
+.Pq Event 19
+Unaligned store (REPUN=1 or USEUN=1)
+.It Li EC
+.Pq Event 20
+Exec clocks(must set CvmCtl[DISCE] for accurate timing)
+.It Li MC
+.Pq Event 21
+Mul clocks(must set CvmCtl[DISCE] for accurate timing)
+.It Li CC
+.Pq Event 22
+Crypto clocks(must set CvmCtl[DISCE] for accurate timing)
+.It Li CSRC
+.Pq Event 23
+Issue_csr clocks(must set CvmCtl[DISCE] for accurate timing)
+.It Li CFETCH
+.Pq Event 24
+Icache committed fetches (demand+prefetch)
+.It Li CPREF
+.Pq Event 25
+Icache committed prefetches
+.It Li ICA
+.Pq Event 26
+Icache aliases
+.It Li II
+.Pq Event 27
+Icache invalidates
+.It Li IP
+.Pq Event 28
+Icache parity error
+.It Li CIMISS
+.Pq Event 29
+Cycles idle due to imiss (must set CvmCtl[DISCE] for accurate timing)
+.It Li WBUF
+.Pq Event 32
+Number of write buffer entries created
+.It Li WDAT
+.Pq Event 33
+Number of write buffer data cycles used (may need to set CvmCtl[DISCE] for accurate counts)
+.It Li WBUFLD
+.Pq Event 34
+Number of write buffer entries forced out by loads
+.It Li WBUFFL
+.Pq Event 35
+Number of cycles that there was no available write buffer entry (may need to set CvmCtl[DISCE] and CvmMemCtl[MCLK] for accurate counts)
+.It Li WBUFTR
+.Pq Event 36
+Number of stores that found no available write buffer entries
+.It Li BADD
+.Pq Event 37
+Number of address bus cycles used (may need to set CvmCtl[DISCE] for accurate counts)
+.It Li BADDL2
+.Pq Event 38
+Number of address bus cycles not reflected (i.e. destined for L2) (may need to set CvmCtl[DISCE] for accurate counts)
+.It Li BFILL
+.Pq Event 39
+Number of fill bus cycles used (may need to set CvmCtl[DISCE] for accurate counts)
+.It Li DDIDS
+.Pq Event 40
+Number of Dstream DIDs created
+.It Li IDIDS
+.Pq Event 41
+Number of Istream DIDs created
+.It Li DIDNA
+.Pq Event 42
+Number of cycles that no DIDs were available (may need to set CvmCtl[DISCE] and CvmMemCtl[MCLK] for accurate counts)
+.It Li LDS
+.Pq Event 43
+Number of load issues
+.It Li LMLDS
+.Pq Event 44
+Number of local memory load
+.It Li IOLDS
+.Pq Event 45
+Number of I/O load issues
+.It Li DMLDS
+.Pq Event 46
+Number of loads that were not prefetches and missed in the cache
+.It Li STS
+.Pq Event 48
+Number of store issues
+.It Li LMSTS
+.Pq Event 49
+Number of local memory store issues
+.It Li IOSTS
+.Pq Event 50
+Number of I/O store issues
+.It Li IOBDMA
+.Pq Event 51
+Number of IOBDMAs
+.It Li DTLB
+.Pq Event 53
+Number of dstream TLB refill, invalid, or modified exceptions
+.It Li DTLBAD
+.Pq Event 54
+Number of dstream TLB address errors
+.It Li ITLB
+.Pq Event 55
+Number of istream TLB refill, invalid, or address error exceptions
+.It Li SYNC
+.Pq Event 56
+Number of SYNC stall cycles (may need to set CvmCtl[DISCE] for accurate counts)
+.It Li SYNCIOB
+.Pq Event 57
+Number of SYNCIOBDMA stall cycles (may need to set CvmCtl[DISCE] for accurate counts)
+.It Li SYNCW
+.Pq Event 58
+Number of SYNCWs
+.It Li ERETMIS
+.Pq Event 64
+D/eret mispredicts (CN63XX specific)
+.It Li LIKMIS
+.Pq Event 65
+Branch likely mispredicts (CN63XX specific)
+.It Li HAZTR
+.Pq Event 66
+Hazard traps due to *MTC0 to CvmCtl, Perf counter control, EntryHi, or CvmMemCtl registers (CN63XX specific)
+.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" "cpu_clk_unhalted.core_p"
+.It Em Alias Ta Em Event
+.It Li instructions Ta Li RET
+.It Li branches Ta Li BR
+.It Li branch-mispredicts Ta Li BS
+.El
+.Sh SEE ALSO
+.Xr pmc 3 ,
+.Xr pmc.atom 3 ,
+.Xr pmc.core 3 ,
+.Xr pmc.iaf 3 ,
+.Xr pmc.k7 3 ,
+.Xr pmc.k8 3 ,
+.Xr pmc.mips24k 3 ,
+.Xr pmc.p4 3 ,
+.Xr pmc.p5 3 ,
+.Xr pmc.p6 3 ,
+.Xr pmc.soft 3 ,
+.Xr pmc.tsc 3 ,
+.Xr pmc_cpuinfo 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 jkoshy@FreeBSD.org .
+MIPS support was added by
+.An "George Neville-Neil"
+.Aq gnn@FreeBSD.org .
diff --git a/lib/libpmc/pmc.p4.3 b/lib/libpmc/pmc.p4.3
index cd0da4f3d8d1..b273edd8b1e7 100644
--- a/lib/libpmc/pmc.p4.3
+++ b/lib/libpmc/pmc.p4.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -90,7 +90,6 @@ These PMCs support the following capabilities:
.It PMC_CAP_WRITE Ta Yes
.El
.Ss Event Qualifiers
-.Pp
Event specifiers for Intel P4 PMCs can have the following common
qualifiers:
.Bl -tag -width indent
@@ -1209,6 +1208,7 @@ and the underlying hardware events used.
.Xr pmc.k8 3 ,
.Xr pmc.p5 3 ,
.Xr pmc.p6 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmclog 3 ,
.Xr hwpmc 4
diff --git a/lib/libpmc/pmc.p5.3 b/lib/libpmc/pmc.p5.3
index 36ab917dc256..ebdd5054e2d5 100644
--- a/lib/libpmc/pmc.p5.3
+++ b/lib/libpmc/pmc.p5.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -444,6 +444,7 @@ and the underlying hardware events used.
.Xr pmc.k8 3 ,
.Xr pmc.p4 3 ,
.Xr pmc.p6 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmclog 3 ,
.Xr hwpmc 4
diff --git a/lib/libpmc/pmc.p6.3 b/lib/libpmc/pmc.p6.3
index d8cde6427b66..3fa98a75a396 100644
--- a/lib/libpmc/pmc.p6.3
+++ b/lib/libpmc/pmc.p6.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -1010,6 +1010,7 @@ and the underlying hardware events used.
.Xr pmc.k8 3 ,
.Xr pmc.p4 3 ,
.Xr pmc.p5 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmclog 3 ,
.Xr hwpmc 4
diff --git a/lib/libpmc/pmc.sandybridge.3 b/lib/libpmc/pmc.sandybridge.3
new file mode 100644
index 000000000000..e0c7eb9925c8
--- /dev/null
+++ b/lib/libpmc/pmc.sandybridge.3
@@ -0,0 +1,932 @@
+.\" Copyright (c) 2012 Davide Italiano <davide@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 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd February 12, 2012
+.Dt PMC.SANDYBRIDGE 3
+.Os
+.Sh NAME
+.Nm pmc.sandybridge
+.Nd measurement events for
+.Tn Intel
+.Tn Sandy Bridge
+family CPUs
+.Sh LIBRARY
+.Lb libpmc
+.Sh SYNOPSIS
+.In pmc.h
+.Sh DESCRIPTION
+.Tn Intel
+.Tn "Sandy Bridge"
+CPUs contain PMCs conforming to the version 3 of the
+.Tn Intel
+performance measurement architecture.
+These CPUs may contain up to three classes of PMCs:
+.Bl -tag -width "Li PMC_CLASS_IAP"
+.It Li PMC_CLASS_IAF
+Fixed-function counters that count only one hardware event per counter.
+.It Li PMC_CLASS_IAP
+Programmable counters that may be configured to count one of a defined
+set of hardware events.
+.It Li PMC_CLASS_TSC
+These PMCs are documented in
+.Xr pmc.tsc 3 .
+.El
+.Pp
+The number of PMCs available in each class and their widths need to be
+determined at run time by calling
+.Xr pmc_cpuinfo 3 .
+.Pp
+Intel Sandy Bridge PMCs are documented in
+.Rs
+.%B "Intel(R) 64 and IA-32 Architectures Software Developers Manual"
+.%T "Volume 3B: System Programming Guide, Part 2"
+.%N "Order Number: 253669-039US"
+.%D May 2011
+.%Q "Intel Corporation"
+.Re
+.Ss SANDY BRIDGE FIXED FUNCTION PMCS
+These PMCs and their supported events are documented in
+.Xr pmc.iaf 3 .
+.Ss SANDY BRIDGE PROGRAMMABLE PMCS
+The programmable PMCs support 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 these PMCs support the following common
+qualifiers:
+.Bl -tag -width indent
+.It Li rsp= Ns Ar value
+Configure the Off-core Response bits.
+.Bl -tag -width indent
+.It Li DMND_DATA_RD
+Counts the number of demand and DCU prefetch data reads of full
+and partial cachelines as well as demand data page table entry
+cacheline reads.
+Does not count L2 data read prefetches or instruction fetches.
+.It Li DMND_RFO
+Counts the number of demand and DCU prefetch reads for ownership
+(RFO) requests generated by a write to data cacheline.
+Does not count L2 RFO.
+.It Li DMND_IFETCH
+Counts the number of demand and DCU prefetch instruction cacheline
+reads.
+Does not count L2 code read prefetches.
+.It Li WB
+Counts the number of writeback (modified to exclusive) transactions.
+.It Li PF_DATA_RD
+Counts the number of data cacheline reads generated by L2 prefetchers.
+.It Li PF_RFO
+Counts the number of RFO requests generated by L2 prefetchers.
+.It Li PF_IFETCH
+Counts the number of code reads generated by L2 prefetchers.
+.It Li OTHER
+Counts one of the following transaction types, including L3 invalidate,
+I/O, full or partial writes, WC or non-temporal stores, CLFLUSH, Fences,
+lock, unlock, split lock.
+.It Li UNCORE_HIT
+L3 Hit: local or remote home requests that hit L3 cache in the uncore
+with no coherency actions required (snooping).
+.It Li OTHER_CORE_HIT_SNP
+L3 Hit: local or remote home requests that hit L3 cache in the uncore
+and was serviced by another core with a cross core snoop where no modified
+copies were found (clean).
+.It Li OTHER_CORE_HITM
+L3 Hit: local or remote home requests that hit L3 cache in the uncore
+and was serviced by another core with a cross core snoop where modified
+copies were found (HITM).
+.It Li REMOTE_CACHE_FWD
+L3 Miss: local homed requests that missed the L3 cache and was serviced
+by forwarded data following a cross package snoop where no modified
+copies found.
+(Remote home requests are not counted)
+.It Li REMOTE_DRAM
+L3 Miss: remote home requests that missed the L3 cache and were serviced
+by remote DRAM.
+.It Li LOCAL_DRAM
+L3 Miss: local home requests that missed the L3 cache and were serviced
+by local DRAM.
+.It Li NON_DRAM
+Non-DRAM requests that were serviced by IOH.
+.El
+.It Li cmask= Ns Ar value
+Configure the PMC 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 PMC to count the number of de-asserted to asserted
+transitions of the conditions expressed by the other qualifiers.
+If specified, the counter will increment only once whenever a
+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 cmask
+qualifier is present, making the counter increment when the number of
+events per cycle is less than the value specified by the
+.Dq Li cmask
+qualifier.
+.It Li os
+Configure the PMC to count events happening at processor 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 are specified, the default is to enable both.
+.Ss Event Specifiers (Programmable PMCs)
+Sandy Bridge programmable PMCs support the following events:
+.Bl -tag -width indent
+.It Li LD_BLOCKS.DATA_UNKNOWN
+.Pq EVENT_03H, Umask 01H
+Blocked loads due to store buffer blocks with unknown data.
+.It Li LD_BLOCKS.STORE_FORWARD
+.Pq Event 03H, Umask 02H
+Loads blocked by overlapping with store buffer that cannot be forwarded.
+.It Li LD_BLOCKS.NO_SR
+.Pq Event 03H, Umask 08H
+# of Split loads blocked due to resource not available.
+.It Li LD_BLOCKS.ALL_BLOCK
+.Pq EVENT_03H, Umask 10H
+Number of cases where any load is blocked but has no DCU miss.
+.It Li MISALIGN_MEM_REF.LOADS
+.Pq Event 05H, Umask 01H
+Speculative cache-line split load uops dispatched to L1D.
+.It Li MISALIGN_MEM_REF.STORES
+.Pq Event 05H, Umask 02H
+Speculative cache-line split Store-address uops dispatched to L1D.
+.It Li LD_BLOCKS_PARTIAL.ADDRESS_ALIAS
+.Pq Event 07H, Umask 01H
+False dependencies in MOB due to partial compare on address.
+.It Li LD_BLOCKS_PARTIAL.ALL_STA_BLOCK
+.Pq Event 07H, Umask 08H
+The number of times that load operations are temporarily blocked because of
+older stores, with addresses that are not yet known.
+A load operation may incur more than one block of this type.
+.It LI DTLB_LOAD_MISSES.MISS_CAUSES_A_WALK
+.Pq Event 08H, Umask 01H
+Misses in all TLB levels that cause a page walk of any page size.
+.It Li DTLB_LOAD_MISSES.WALK_COMPLETED
+.Pq Event 08H, Umask 02H
+Misses in all TLB levels that caused page walk completed of any size.
+.It Li DTLB_LOAD_MISSES.WALK_DURATION
+.Pq Event 08H, Umask 04H
+Cycle PMH is busy with a walk.
+.It Li DTLB_LOAD_MISSES.STLB_HIT
+.Pq Event 08H, Umask 10H
+Number of cache load STLB hits.
+No page walk.
+.It Li INT_MISC.RECOVERY_CYCLES
+.Pq Event 0DH, Umask 03H
+Cycles waiting to recover after Machine Clears or JEClear.
+Set Cmask = 1.
+Set Edge to count occurrences
+.It Li INT_MISC.RAT_STALL_CYCLES
+.Pq Event 0DH, Umask 40H
+Cycles RAT external stall is sent to IDQ for this thread.
+.It Li UOPS_ISSUED.ANY
+.Pq Event 0EH, Umask 01H
+Increments each cycle the # of Uops issued by the RAT to RS.
+Set Cmask = 1, Inv = 1, Any= 1 to count stalled cycles of this core.
+Set Cmask = 1, Inv = 1 to count stalled cycles
+.It Li FP_COMP_OPS_EXE.X87
+.Pq Event 10H, Umask 01H
+Counts number of X87 uops executed.
+.It Li FP_COMP_OPS_EXE.SSE_FP_PACKED_DOUBLE
+.Pq Event 10H, Umask 10H
+Counts number of SSE* double precision FP packed uops executed.
+.It Li FP_COMP_OPS_EXE.SSE_FP_SCALAR_SINGLE
+.Pq Event 10H, Umask 20H
+Counts number of SSE* single precision FP scalar uops executed.
+.It Li FP_COMP_OPS_EXE.SSE_PACKED_SINGLE
+.Pq Event 10H, Umask 40H
+Counts number of SSE* single precision FP packed uops executed.
+.It LiFP_COMP_OPS_EXE.SSE_SCALAR_DOUBLE
+.Pq Event 10H, Umask 80H
+Counts number of SSE* double precision FP scalar uops executed.
+.It Li SIMD_FP_256.PACKED_SINGLE
+.Pq Event 11H, Umask 01H
+Counts 256-bit packed single-precision floating-point instructions.
+.It Li SIMD_FP_256.PACKED_DOUBLE
+.Pq Event 11H, Umask 02H
+Counts 256-bit packed double-precision floating-point instructions.
+.It Li ARITH.FPU_DIV_ACTIVE
+.Pq Event 14H, Umask 01H
+Cycles that the divider is active, includes INT and FP.
+Set 'edge =1, cmask=1' to count the number of divides.
+.It Li INSTS_WRITTEN_TO_IQ.INSTS
+.Pq Event 17H, Umask 01H
+Counts the number of instructions written into the IQ every cycle.
+.It Li L2_RQSTS.DEMAND_DATA_RD_HIT
+.Pq Event 24H, Umask 01H
+Demand Data Read requests that hit L2 cache.
+.It Li L2_RQSTS.ALL_DEMAND_DATA_RD
+.Pq Event 24H, Umask 03H
+Counts any demand and L1 HW prefetch data load requests to L2.
+.It Li L2_RQSTS.RFO_HITS
+.Pq Event 24H, Umask 04H
+Counts the number of store RFO requests that hit the L2 cache.
+.It Li L2_RQSTS.RFO_MISS
+.Pq Event 24H, Umask 08H
+Counts the number of store RFO requests that miss the L2 cache.
+.It Li L2_RQSTS.ALL_RFO
+.Pq Event 24H, Umask 0CH
+Counts all L2 store RFO requests.
+.It Li L2_RQSTS.CODE_RD_HIT
+.Pq Event 24H, Umask 10H
+Number of instruction fetches that hit the L2 cache.
+.It Li L2_RQSTS.CODE_RD_MISS
+.Pq Event 24H, Umask 20H
+Number of instruction fetches that missed the L2 cache.
+.It Li L2_RQSTS.ALL_CODE_RD
+.Pq Event 24H, Umask 30H
+Counts all L2 code requests.
+.It Li L2_RQSTS.PF_HIT
+.Pq Event 24H, Umask 40H
+Requests from L2 Hardware prefetcher that hit L2.
+.It Li L2_RQSTS.PF_MISS
+.Pq Event 24H, Umask 80H
+Requests from L2 Hardware prefetcher that missed L2.
+.It Li L2_RQSTS.ALL_PF
+.Pq Event 24H, Umask C0H
+Any requests from L2 Hardware prefetchers.
+.It Li L2_STORE_LOCK_RQSTS.MISS
+.Pq Event 27H, Umask 01H
+RFOs that miss cache lines.
+.It Li L2_STORE_LOCK_RQSTS.HIT_E
+.Pq Event 27H, Umask 04H
+RFOs that hit cache lines in E state.
+.It Li L2_STORE_LOCK_RQSTS.HIT_M
+.Pq EVENT_27H, Umask 08H
+RFOs that hit cache lines in M state.
+.It Li L2_STORE_LOCK_RQSTS.ALL
+.Pq EVENT_27H, Umask 0FH
+RFOs that access cache lines in any state.
+.It Li L2_L1D_WB_RQSTS.HIT_E
+.Pq Event 28H, Umask 04H
+Not rejected writebacks from L1D to L2 cache lines in E state.
+.It Li L2_L1D_WB_RQSTS.HIT_M
+.Pq Event 28H, Umask 08H
+Not rejected writebacks from L1D to L2 cache lines in M state.
+.It Li LONGEST_LAT_CACHE.REFERENCE
+.Pq Event 2EH, Umask 4FH
+This event counts requests originating from the core that reference a cache
+line in the last level cache.
+.It Li LONGEST_LAT_CACHE.MISS
+.Pq Event 2EH, Umask 41H
+This event counts each cache miss condition for references to the last level
+cache.
+.It Li CPU_CLK_UNHALTED.THREAD_P
+.Pq Event 3CH, Umask 00H
+Counts the number of thread cycles while the thread is not in a halt state.
+The thread enters the halt state when it is running the HLT instruction.
+The core frequency may change from time to time due to power or thermal
+throttling.
+.It Li CPU_CLK_THREAD_UNHALTED.REF_XCLK
+.Pq Event 3CH, Umask 01H
+Increments at the frequency of XCLK (100 MHz) when not halted.
+.It Li L1D_PEND_MISS.PENDING
+.Pq Event 48H, Umask 01H
+Increments the number of outstanding L1D misses every cycle.
+Set Cmask = 1 and Edge =1 to count occurrences.
+Counter 2 only; Set Cmask = 1 to count cycles.
+.It Li DTLB_STORE_MISSES.MISS_CAUSES_A_WALK
+.Pq Event 49H, Umask 01H Miss in all TLB levels causes an page walk of any
+page size (4K/2M/4M/1G).
+.It Li DTLB_STORE_MISSES.WALK_COMPLETED
+.Pq Event 49H, Umask 02H
+Miss in all TLB levels causes a page walk that completes of any page size
+(4K/2M/4M/1G).
+.It Li DTLB_STORE_MISSES.WALK_DURATION
+.Pq Event 49H, Umask 04H
+Cycles PMH is busy with this walk.
+.It Li DTLB_STORE_MISSES.STLB_HIT
+.Pq Event 49H, Umask 10H
+Store operations that miss the first TLB level but hit the second and do not
+cause page walks.
+.It Li LOAD_HIT_PRE.SW_PF
+.Pq Event 4CH, Umask 01H
+Not SW-prefetch load dispatches that hit fill buffer allocated for S/W prefetch.
+.It Li LOAD_HIT_PER.HW_PF
+.Pq Event 4CH, Umask 02H
+Not SW-prefetch load dispatches that hit fill buffer allocated for H/W prefetch.
+.It Li HW_PRE_REQ.DL1_MISS
+.Pq Event 4EH, Umask 02H
+Hardware Prefetch requests that miss the L1D cache.
+A request is being counted each time it access the cache & miss it, including
+if a block is applicable or if hit the Fill Buffer for example.
+This accounts for both L1 streamer and IP-based (IPP) HW prefetchers.
+.It Li L1D.REPLACEMENT
+.Pq Event 51H, Umask 01H
+Counts the number of lines brought into the L1 data cache.
+.It Li L1D.ALLOCATED_IN_M
+.Pq Event 51H, Umask 02H
+Counts the number of allocations of modified L1D cache lines.
+.It Li L1D.EVICTION
+.Pq Event 51H, Umask 04H
+Counts the number of modified lines evicted from the L1 data cache due to
+replacement.
+.It Li L1D.ALL_M_REPLACEMENT
+.Pq Event 51H, Umask 08H
+Cache lines in M state evicted out of L1D due to Snoop HitM or dirty line
+replacement.
+.It Li PARTIAL_RAT_STALLS.FLAGS_MERGE_UOP
+.Pq Event 59H, Umask 20H
+Increments the number of flags-merge uops in flight each cycle.
+Set Cmask = 1 to count cycles.
+.It Li PARTIAL_RAT_STALLS.SLOW_LEA_WINDOW
+.Pq Event 59H, Umask 40H
+Cycles with at least one slow LEA uop allocated.
+.It Li PARTIAL_RAT_STALLS.MUL_SINGLE_UOP
+.Pq Event 59H, Umask 80H
+Number of Multiply packed/scalar single precision uops allocated.
+.It Li RESOURCE_STALLS2.ALL_FL_EMPTY
+.Pq Event 5BH, Umask 0CH
+Cycles stalled due to free list empty.
+.It Li RESOURCE_STALLS2.ALL_PRF_CONTROL
+.Pq Event 5BH, Umask 0FH
+Cycles stalled due to control structures full for physical registers.
+.It Li RESOURCE_STALLS2.BOB_FULL
+.Pq Event 5BH, Umask 40H
+Cycles Allocator is stalled due to Branch Order Buffer.
+.It Li RESOURCE_STALLS2.OOO_RSRC
+.Pq Event 5BH, Umask 4FH
+Cycles stalled due to out of order resources full.
+.It Li CPL_CYCLES.RING0
+.Pq Event 5CH, Umask 01H
+Unhalted core cycles when the thread is in ring 0.
+Use Edge to count transition
+.It Li CPL_CYCLES.RING123
+.Pq Event 5CH, Umask 02H
+Unhalted core cycles when the thread is not in ring 0.
+.It Li RS_EVENTS.EMPTY_CYCLES
+.Pq Event 5EH, Umask 01H
+Cycles the RS is empty for the thread.
+.It Li OFFCORE_REQUESTS_OUTSTANDING.DEMAND_DATA_RD
+.Pq Event 60H, Umask 01H
+Offcore outstanding Demand Data Read transactions in SQ to uncore.
+Set Cmask=1 to count cycles.
+.It Li OFFCORE_REQUESTS_OUTSTANDING.DEMAND_RFO
+.Pq Event 60H, Umask 04H
+Offcore outstanding RFO store transactions in SQ to uncore.
+Set Cmask=1 to count cycles.
+.It Li OFFCORE_REQUESTS_OUTSTANDING.ALL_DATA_RD
+.Pq Event 60H, Umask 08H
+Offcore outstanding cacheable data read transactions in SQ to uncore.
+Set Cmask=1 to count cycles.
+.It Li LOCK_CYCLES.SPLIT_LOCK_UC_LOCK_DURATION
+.Pq Event 63H, Umask 01H
+Cycles in which the L1D and L2 are locked, due to a UC lock or split lock.
+.It Li LOCK_CYCLES.CACHE_LOCK_DURATION
+.Pq Event 63H, Umask 02H
+Cycles in which the L1D is locked.
+.It Li IDQ.EMPTY
+.Pq Event 79H, Umask 02H
+Counts cycles the IDQ is empty.
+.It Li IQD.MITE_UOPS
+.Pq Event 79H, Umask 04H
+Increment each cycle # of uops delivered to IDQ from MITE path.
+Set Cmask = 1 to count cycles.
+Can combine Umask 04H and 20H
+.It Li IDQ.DSB_UOPS
+.Pq Event 79H, Umask 08H
+Increment each cycle.
+# of uops delivered to IDQ from DSB path.
+Set Cmask = 1 to count cycles.
+Can combine Umask 08H and 10H
+.It Li IDQ.MS_DSB_UOPS
+.Pq Event 79H, Umask 10H
+Increment each cycle # of uops delivered to IDQ when MS busy by DSB.
+Set Cmask = 1 to count cycles MS is busy.
+Set Cmask=1 and Edge=1 to count MS activations.
+Can combine Umask 08H and 10H
+.It Li IDQ.MS_MITE_UOPS
+.Pq Event 79H, Umask 20H
+Increment each cycle # of uops delivered to IDQ when MS is busy by MITE.
+Set Cmask = 1 to count cycles.
+Can combine Umask 04H and 20H
+.It Li IDQ.MS_UOPS
+.Pq Event 79H, Umask 30H
+Increment each cycle # of uops delivered to IDQ from MS by either DSB or MITE.
+Set Cmask = 1 to count cycles.
+Can combine Umask 04H, 08H and 30H
+.It Li ICACHE.MISSES
+.Pq Event 80H, Umask 02H
+Number of Instruction Cache, Streaming Buffer and Victim Cache Misses.
+Includes UC accesses.
+.It Li ITLB_MISSES.MISS_CAUSES_A_WALK
+.Pq Event 85H, Umask 01H
+Misses in all ITLB levels that cause page walks.
+.It Li ITLB_MISSES.WALK_COMPLETED
+.Pq Event 85H, Umask 02H
+Misses in all ITLB levels that cause completed page walks.
+.It Li ITLB_MISSES.WALK_DURATION
+.Pq Event 85H, Umask 04H
+Cycle PMH is busy with a walk.
+.It Li ITLB_MISSES.STLB_HIT
+.Pq Event 85H, Umask 10H
+Number of cache load STLB hits.
+No page walk.
+.It Li ILD_STALL.LCP
+.Pq Event 87H, Umask 01H
+Stalls caused by changing prefix length of the instruction.
+.It Li ILD_STALL.IQ_FULL
+.Pq Event 87H, Umask 04H
+Stall cycles due to IQ is full.
+.It Li BR_INST_EXEC.COND
+.Pq Event 88H, Umask 01H
+Qualify conditional near branch instructions executed, but not necessarily
+retired.
+Must combine with umask 40H, 80H
+.It Li BR_INST_EXEC.DIRECT_JMP
+.Pq Event 88H, Umask 02H
+Qualify all unconditional near branch instructions excluding calls and indirect
+branches.
+Must combine with umask 80H
+.It Li BR_INST_EXEC.INDIRECT_JMP_NON_CALL_RET
+.Pq Event 88H, Umask 04H
+Qualify executed indirect near branch instructions that are not calls nor
+returns.
+Must combine with umask 80H
+.It Li BR_INST_EXEC.RETURN_NEAR
+.Pq Event 88H, Umask 08H
+Qualify indirect near branches that have a return mnemonic.
+Must combine with umask 80H
+.It Li BR_INST_EXEC.DIRECT_NEAR_CALL
+.Pq Event 88H, Umask 10H
+Qualify unconditional near call branch instructions, excluding non call branch,
+executed.
+Must combine with umask 80H
+.It Li BR_INST_EXEC.INDIRECT_NEAR_CALL
+.Pq Event 88H, Umask 20H
+Qualify indirect near calls, including both register and memory indirect,
+executed.
+Must combine with umask 80H
+.It Li BR_INST_EXEC.NONTAKEN
+.Pq Event 88H, Umask 40H
+Qualify non-taken near branches executed.
+Applicable to umask 01H only
+.It Li BR_INST_EXEC.TAKEN
+.Pq Event 88H, Umask 80H
+Qualify taken near branches executed.
+Must combine with 01H,02H, 04H, 08H, 10H, 20H
+.It Li BR_INST_EXE.ALL_BRANCHES
+.Pq Event 88H, Umask FFH
+Counts all near executed branches (not necessarily retired).
+.It Li BR_MISP_EXEC.COND
+.Pq Event 89H, Umask 01H
+Qualify conditional near branch instructions mispredicted.
+Must combine with umask 40H, 80H
+.It Li BR_MISP_EXEC.INDIRECT_JMP_NON_CALL_RET
+.Pq Event 89H, Umask 04H
+Qualify mispredicted indirect near branch instructions that are not calls nor
+returns.
+Must combine with umask 80H
+.It Li BR_MISP_EXEC.RETURN_NEAR
+.Pq Event 89H, Umask 08H
+Qualify mispredicted indirect near branches that have a return mnemonic.
+Must combine with umask 80H
+.It Li BR_MISP_EXEC.DIRECT_NEAR_CALL
+.Pq Event 89H, Umask 10H
+Qualify mispredicted unconditional near call branch instructions, excluding non
+call branch, executed.
+Must combine with umask 80H
+.It Li BR_MISP_EXEC.INDIRECT_NEAR_CALL
+.Pq Event 89H, Umask 20H
+Qualify mispredicted indirect near calls, including both register and memory
+indirect, executed.
+Must combine with umask 80H
+.It Li BR_MISP_EXEC.NONTAKEN
+.Pq Event 89H, Umask 40H
+Qualify mispredicted non-taken near branches executed.
+Applicable to umask 01H only
+.It Li BR_MISP_EXEC.TAKEN
+.Pq Event 89H, Umask 80H
+Qualify mispredicted taken near branches executed.
+Must combine with 01H,02H, 04H, 08H, 10H, 20H
+.It Li BR_MISP_EXEC.ALL_BRANCHES
+.Pq Event 89H, Umask FFH
+Counts all near executed branches (not necessarily retired).
+.It Li IDQ_UOPS_NOT_DELIVERED.CORE
+.Pq Event 9CH, Umask 01H
+Count number of non-delivered uops to RAT per thread.
+Use Cmask to qualify uop b/w
+.It Li UOPS_DISPATCHED_PORT.PORT_0
+.Pq Event A1H, Umask 01H
+Cycles which a Uop is dispatched on port 0.
+.It Li UOPS_DISPATCHED_PORT.PORT_1
+.Pq Event A1H, Umask 02H
+Cycles which a Uop is dispatched on port 1.
+.It Li UOPS_DISPATCHED_PORT.PORT_2_LD
+.Pq Event A1H, Umask 04H
+Cycles which a load uop is dispatched on port 2.
+.It Li UOPS_DISPATCHED_PORT.PORT_2_STA
+.Pq Event A1H, Umask 08H
+Cycles which a store address uop is dispatched on port 2.
+.It Li UOPS_DISPATCHED_PORT.PORT_2
+.Pq Event A1H, Umask 0CH
+Cycles which a Uop is dispatched on port 2.
+.It Li UOPS_DISPATCHED_PORT.PORT_3_LD
+.Pq Event A1H, Umask 10H
+Cycles which a load uop is dispatched on port 3.
+.It Li UOPS_DISPATCHED_PORT.PORT_3_STA
+.Pq Event A1H, Umask 20H
+Cycles which a store address uop is dispatched on port 3.
+.It Li UOPS_DISPATCHED_PORT.PORT_3
+.Pq Event A1H, Umask 30H
+.Pq Cycles which a Uop is dispatched on port 3.
+.It Li UOPS_DISPATCHED_PORT.PORT_4
+.Pq Event A1H, Umask 40H
+Cycles which a Uop is dispatched on port 4.
+.It Li UOPS_DISPATCHED_PORT.PORT_5
+.Pq Event A1H, Umask 80H
+Cycles which a Uop is dispatched on port 5.
+.It Li RESOURCE_STALLS.ANY
+.Pq Event A2H, Umask 01H
+Cycles Allocation is stalled due to Resource Related reason.
+.It Li RESOURCE_STALLS.LB
+.Pq Event A2H, Umask 02H
+Counts the cycles of stall due to lack of load buffers.
+.It Li RESOURCE_STALLS.LB
+.Pq Event A2H, Umask 04H
+Cycles stalled due to no eligible RS entry available.
+.It Li RESOURCE_STALLS.SB
+.Pq Event A2H, Umask 08H
+Cycles stalled due to no store buffers available.
+(not including draining form sync)
+.It Li RESOURCE_STALLS.ROB
+.Pq Event A2H, Umask 10H
+Cycles stalled due to re-order buffer full.
+.It Li RESOURCE_STALLS.FCSW
+.Pq Event A2H, Umask 20H
+Cycles stalled due to writing the FPU control word.
+.It Li RESOURCE_STALLS.MXCSR
+.Pq Event A2H, Umask 40H
+Cycles stalled due to the MXCSR register rename occurring to close to a previous
+MXCSR rename.
+.It Li RESOURCE_STALLS.OTHER
+.Pq Event A2H, Umask 80H
+Cycles stalled while execution was stalled due to other resource issues.
+.It Li DSB2MITE_SWITCHES.COUNT
+.Pq Event ABH, Umask 01H
+Number of DSB to MITE switches.
+.It Li DSB2MITE_SWITCHES.PENALTY_CYCLES
+.Pq Event ABH, Umask 02H
+Cycles DSB to MITE switches caused delay.
+.It Li DSB_FILL.OTHER_CANCEL
+.Pq Event ACH, Umask 02H
+Cases of cancelling valid DSB fill not because of exceeding way limit.
+.It Li DSB_FILL.EXCEED_DSB_LINES
+.Pq Event ACH, Umask 08H
+DSB Fill encountered > 3 DSB lines.
+.It Li DSB_FILL.ALL_CANCEL
+.Pq Event ACH, Umask 0AH
+Cases of cancelling valid Decode Stream Buffer (DSB) fill not because of exceeding
+way limit.
+.It Li ITLB.ITLB_FLUSH
+.Pq Event AEH, Umask 01H
+Counts the number of ITLB flushes, includes 4k/2M/4M pages.
+.It Li OFFCORE_REQUESTS.DEMAND_DATA_RD
+.Pq Event B0H, Umask 01H
+Demand data read requests sent to uncore.
+.It Li OFFCORE_REQUESTS.DEMAND_RFO
+.Pq Event B0H, Umask 04H
+Demand RFO read requests sent to uncore, including regular RFOs, locks, ItoM.
+.It Li OFFCORE_REQUESTS.ALL_DATA_RD
+.Pq Event B0H, Umask 08H
+Data read requests sent to uncore (demand and prefetch).
+.It Li UOPS_DISPATCHED.THREAD
+.Pq Event B1H, Umask 01H
+Counts total number of uops to be dispatched per-thread each cycle.
+Set Cmask = 1, INV =1 to count stall cycles.
+.It Li UOPS_DISPATCHED.CORE
+.Pq Event B1H, Umask 02H
+Counts total number of uops to be dispatched per-core each cycle.
+Do not need to set ANY
+.It Li OFFCORE_REQUESTS_BUFFER.SQ_FULL
+.Pq Event B2H, Umask 01H
+Offcore requests buffer cannot take more entries for this thread core.
+.It Li AGU_BYPASS_CANCEL.COUNT
+.Pq Event B6H, Umask 01H
+Counts executed load operations with all the following traits: 1. addressing
+of the format [base + offset], 2. the offset is between 1 and 2047, 3. the
+address specified in the base register is in one page and the address
+[base+offset] is in another page.
+.It Li OFF_CORE_RESPONSE_0
+.Pq Event B7H, Umask 01H
+Off-core Response Performance Monitoring; PMC0 only.
+Requires programming MSR 01A6H
+.It Li OFF_CORE_RESPONSE_1
+.Pq Event BBH, Umask 01H
+Off-core Response Performance Monitoring. PMC3 only.
+Requires programming MSR 01A7H
+.It Li TLB_FLUSH.DTLB_THREAD
+.Pq Event BDH, Umask 01H
+DTLB flush attempts of the thread-specific entries.
+.It Li TLB_FLUSH.STLB_ANY
+.Pq Event BDH, Umask 20H
+Count number of STLB flush attempts.
+.It Li L1D_BLOCKS.BANK_CONFLICT_CYCLES
+.Pq Event BFH, Umask 05H
+Cycles when dispatched loads are cancelled due to L1D bank conflicts with other
+load ports.
+cmask=1
+.It Li INST_RETIRED.ANY_P
+.Pq Event C0H, Umask 00H
+Number of instructions at retirement.
+.It Li INST_RETIRED.PREC_DIST
+.Pq Event C0H, Umask 01H
+Precise instruction retired event with HW to reduce effect of PEBS shadow in IP
+distribution PMC1 only; Must quiesce other PMCs.
+.It Li INST_RETIRED.X87
+.Pq Event C0H, Umask 02H
+X87 instruction retired event.
+.It Li OTHER_ASSISTS.ITLB_MISS_RETIRED
+.Pq Event C1H, Umask 02H
+Instructions that experienced an ITLB miss.
+.It Li OTHER_ASSISTS.AVX_STORE
+.Pq Event C1H, Umask 08H
+Number of assists associated with 256-bit AVX store operations.
+.It Li OTHER_ASSISTS.AVX_TO_SSE
+.Pq Event C1H, Umask 10H
+Number of transitions from AVX256 to legacy SSE when penalty applicable.
+.It Li OTHER_ASSISTS.SSE_TO_AVX
+.Pq Event C1H, Umask 20H
+Number of transitions from SSE to AVX-256 when penalty applicable.
+.It Li UOPS_RETIRED.ALL
+.Pq Event C2H, Umask 01H
+Counts the number of micro-ops retired.
+Use cmask=1 and invert to count active cycles or stalled cycles.
+.It Li UOPS_RETIRED.RETIRE_SLOTS
+.Pq Event C2H, Umask 02H
+Counts the number of retirement slots used each cycle.
+.It Li MACHINE_CLEARS.MEMORY_ORDERING
+.Pq Event C3H, Umask 02H
+Counts the number of machine clears due to memory order conflicts.
+.It Li MACHINE_CLEARS.SMC
+.Pq Event C3H, Umask 04H
+Counts the number of times that a program writes to a code section.
+.It Li MACHINE_CLEARS.MASKMOV
+.Pq Event C3H, Umask 20H
+Counts the number of executed AVX masked load operations that refer to an
+illegal address range with the mask bits set to 0.
+.It Li BR_INST_RETIRED.ALL_BRANCH
+.Pq Event C4H, Umask 00H
+Branch instructions at retirement.
+.It Li BR_INST_RETIRED.CONDITIONAL
+.Pq Event C4H, Umask 01H
+Counts the number of conditional branch instructions retired.
+.It Li BR_INST_RETIRED.NEAR_CALL
+.Pq Event C4H, Umask 02H
+Direct and indirect near call instructions retired.
+.It Li BR_INST_RETIRED.ALL_BRANCHES
+.Pq Event C4H, Umask 04H
+Counts the number of branch instructions retired.
+.It Li BR_INST_RETIRED.NEAR_RETURN
+.Pq Event C4H, Umask 08H
+Counts the number of near return instructions retired.
+.It Li BR_INST_RETIRED.NOT_TAKEN
+.Pq Event C4H, Umask 10H
+Counts the number of not taken branch instructions retired.
+.It Li BR_INST_RETIRED.NEAR_TAKEN
+.Pq Event C4H, Umask 20H
+Number of near taken branches retired.
+.It Li BR_INST_RETIRED.FAR_BRANCH
+.Pq Event C4H, Umask 40H
+Number of far branches retired.
+.It Li BR_MISP_RETIRED.ALL_BRANCHES
+.Pq Event C5H, Umask 00H
+Mispredicted branch instructions at retirement.
+.It Li BR_MISP_RETIRED.CONDITIONAL
+.Pq Event C5H, Umask 01H
+Mispredicted conditional branch instructions retired.
+.It Li BR_MISP_RETIRED.NEAR_CALL
+.Pq Event C5H, Umask 02H
+Direct and indirect mispredicted near call instructions retired.
+.It Li BR_MISP_RETIRED.ALL_BRANCH
+.Pq Event C5H, Umask 04H
+Mispredicted macro branch instructions retired.
+.It Li BR_MISP_RETIRED.NOT_TAKEN
+.Pq Event C5H, Umask 10H
+Mispredicted not taken branch instructions retired.
+.It Li BR_MISP_RETIRED.TAKEN
+.Pq Event C5H, Umask 20H
+Mispredicted taken branch instructions retired.
+.It Li FP_ASSIST.X87_OUTPUT
+.Pq Event CAH, Umask 02H
+Number of X87 assists due to output value.
+.It Li FP_ASSIST.X87_INPUT
+.Pq Event CAH, Umask 04H
+Number of X87 assists due to input value.
+.It Li FP_ASSIST.SIMD_OUTPUT
+.Pq Event CAH, Umask 08H
+Number of SIMD FP assists due to Output values.
+.It Li FP_ASSIST.SIMD_INPUT
+.Pq Event CAH, Umask 10H
+Number of SIMD FP assists due to input values.
+.It Li FP_ASSIST.ANY
+.Pq Event CAH, Umask 1EH
+Cycles with any input/output SSE* or FP assists.
+.It Li ROB_MISC_EVENTS.LBR_INSERTS
+.Pq Event CCH, Umask 20H
+Count cases of saving new LBR records by hardware.
+.It Li MEM_TRANS_RETIRED.LOAD_LATENCY
+.Pq Event CDH, Umask 01H
+Sample loads with specified latency threshold.
+PMC3 only.
+Specify threshold in MSR 0x3F6.
+.It Li MEM_TRANS_RETIRED.PRECISE_STORE
+.Pq Event CDH, Umask 02H
+Sample stores and collect precise store operation via PEBS record.
+PMC3 only.
+.It Li MEM_UOP_RETIRED.LOADS
+.Pq Event D0H, Umask 01H
+Qualify retired memory uops that are loads.
+Combine with umask 10H, 20H, 40H, 80H.
+.It Li MEM_UOP_RETIRED.STORES
+.Pq Event D0H, Umask 02H
+Qualify retired memory uops that are stores.
+Combine with umask 10H, 20H, 40H, 80H.
+.It Li MEM_UOP_RETIRED.STLB_MISS
+.Pq Event D0H, Umask 10H
+Qualify retired memory uops with STLB miss.
+Must combine with umask 01H, 02H, to produce counts.
+.It Li MEM_UOP_RETIRED.LOCK
+.Pq Event D0H, Umask 20H
+Qualify retired memory uops with lock.
+Must combine with umask 01H, 02H, to produce counts.
+.It Li MEM_UOP_RETIRED.SPLIT
+.Pq Event D0H, Umask 40H
+Qualify retired memory uops with line split.
+Must combine with umask 01H, 02H, to produce counts.
+.It Li MEM_UOP_RETIRED_ALL
+.Pq Event D0H, Umask 80H
+Qualify any retired memory uops.
+Must combine with umask 01H, 02H, to produce counts.
+.It Li MEM_LOAD_UOPS_RETIRED.L1_HIT
+.Pq Event D1H, Umask 01H
+Retired load uops with L1 cache hits as data sources.
+Must combine with umask 01H, 02H, to produce counts.
+.It Li MEM_LOAD_UOPS_RETIRED.L2_HIT
+.Pq Event D1H, Umask 02H
+Retired load uops with L2 cache hits as data sources.
+.It Li MEM_LOAD_UOPS_RETIRED.LLC_HIT
+.Pq Event D1H, Umask 04H
+Retired load uops which data sources were data hits in LLC without snoops
+required.
+.It Li MEM_LOAD_UOPS_RETIRED.HIT_LFB
+.Pq Event D1H, Umask 40H
+Retired load uops which data sources were load uops missed L1 but hit FB due
+to preceding miss to the same cache line with data not ready.
+.It Li MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_MISS
+.Pq Event D2H, Umask 01H
+Retired load uops which data sources were LLC hit and cross-core snoop missed in
+on-pkg core cache.
+.It Li MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HIT
+.Pq Event D2H, Umask 02H
+Retired load uops which data sources were LLC and cross-core snoop hits in
+on-pkg core cache.
+.It Li MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_HITM
+.Pq Event D2H, Umask 04H
+Retired load uops which data sources were HitM responses from shared LLC.
+.It Li MEM_LOAD_UOPS_LLC_HIT_RETIRED.XSNP_NONE
+.Pq Event D2H, Umask 08H
+Retired load uops which data sources were hits in LLC without snoops required.
+.It Li MEM_LOAD_UOPS_LLC_HIT_RETIRED.LLC_MISS
+.Pq Event D4H, Umask 02H
+Retired load uops with unknown information as data source in cache serviced the load.
+.It Li L2_TRANS.DEMAND_DATA_RD
+.Pq Event F0H, Umask 01H
+Demand Data Read requests that access L2 cache.
+.It Li L2_TRANS.RF0
+.Pq Event F0H, Umask 02H
+RFO requests that access L2 cache.
+.It Li L2_TRANS.CODE_RD
+.Pq Event F0H, Umask 04H
+L2 cache accesses when fetching instructions.
+.It Li L2_TRANS.ALL_PF
+.Pq Event F0H, Umask 08H
+L2 or LLC HW prefetches that access L2 cache.
+.It Li L2_TRANS.L1D_WB
+.Pq Event F0H, Umask 10H
+L1D writebacks that access L2 cache.
+.It Li L2_TRANS.L2_FILL
+.Pq Event F0H, Umask 20H
+L2 fill requests that access L2 cache.
+.It Li L2_TRANS.L2_WB
+.Pq Event F0H, Umask 40H
+L2 writebacks that access L2 cache.
+.It Li L2_TRANS.ALL_REQUESTS
+.Pq Event F0H, Umask 80H
+Transactions accessing L2 pipe.
+.It Li L2_LINES_IN.I
+.Pq Event F1H, Umask 01H
+L2 cache lines in I state filling L2.
+Counting does not cover rejects.
+.It Li L2_LINES_IN.S
+.Pq Event F1H, Umask 02H
+L2 cache lines in S state filling L2.
+Counting does not cover rejects.
+.It Li L2_LINES_IN.E
+.Pq Event F1H, Umask 04H
+L2 cache lines in E state filling L2.
+Counting does not cover rejects.
+.It Li L2_LINES-IN.ALL
+.Pq Event F1H, Umask 07H
+L2 cache lines filling L2.
+Counting does not cover rejects.
+.It Li L2_LINES_OUT.DEMAND_CLEAN
+.Pq Event F2H, Umask 01H
+Clean L2 cache lines evicted by demand.
+.It Li L2_LINES_OUT.DEMAND_DIRTY
+.Pq Event F2H, Umask 02H
+Dirty L2 cache lines evicted by demand.
+.It Li L2_LINES_OUT.PF_CLEAN
+.Pq Event F2H, Umask 04H
+Clean L2 cache lines evicted by L2 prefetch.
+.It Li L2_LINES_OUT.PF_DIRTY
+.Pq Event F2H, Umask 08H
+Dirty L2 cache lines evicted by L2 prefetch.
+.It Li L2_LINES_OUT.DIRTY_ALL
+.Pq Event F2H, Umask 0AH
+Dirty L2 cache lines filling the L2.
+Counting does not cover rejects.
+.It Li SQ_MISC.SPLIT_LOCK
+.Pq Event F4H, Umask 10H
+Split locks in SQ.
+.El
+.Sh SEE ALSO
+.Xr pmc 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.p4 3 ,
+.Xr pmc.p5 3 ,
+.Xr pmc.p6 3 ,
+.Xr pmc.sandybridgeuc 3 ,
+.Xr pmc.soft 3 ,
+.Xr pmc.tsc 3 ,
+.Xr pmc.ucf 3 ,
+.Xr pmc.westmere 3 ,
+.Xr pmc.westmereuc 3 ,
+.Xr pmc_cpuinfo 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 jkoshy@FreeBSD.org.
+The support for the Sandy Bridge
+microarchitecture was written by
+.An "Davide Italiano"
+.Aq davide@FreeBSD.org .
diff --git a/lib/libpmc/pmc.sandybridgeuc.3 b/lib/libpmc/pmc.sandybridgeuc.3
new file mode 100644
index 000000000000..207848238732
--- /dev/null
+++ b/lib/libpmc/pmc.sandybridgeuc.3
@@ -0,0 +1,233 @@
+.\" Copyright (c) 2012 Davide Italiano <davide@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 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd February 12, 2012
+.Dt PMC.SANDYBRIDGEUC 3
+.Os
+.Sh NAME
+.Nm pmc.sandybridgeuc
+.Nd uncore measurement events for
+.Tn Intel
+.Tn Sandy Bridge
+family CPUs
+.Sh LIBRARY
+.Lb libpmc
+.Sh SYNOPSIS
+.In pmc.h
+.Sh DESCRIPTION
+.Tn Intel
+.Tn "Sandy Bridge"
+CPUs contain PMCs conforming to version 3 of the
+.Tn Intel
+performance measurement architecture.
+These CPUs contain two classes of PMCs:
+.Bl -tag -width "Li PMC_CLASS_UCP"
+.It Li PMC_CLASS_UCF
+Fixed-function counters that count only one hardware event per counter.
+.It Li PMC_CLASS_UCP
+Programmable counters that may be configured to count one of a defined
+set of hardware events.
+.El
+.Pp
+The number of PMCs available in each class and their widths need to be
+determined at run time by calling
+.Xr pmc_cpuinfo 3 .
+.Pp
+Intel Sandy Bridge PMCs are documented in
+.Rs
+.%B "Intel(R) 64 and IA-32 Architectures Software Developers Manual"
+.%T "Volume 3B: System Programming Guide, Part 2"
+.%N "Order Number: 253669-039US"
+.%D May 2011
+.%Q "Intel Corporation"
+.Re
+.Ss SANDYBRIDGE UNCORE FIXED FUNCTION PMCS
+These PMCs and their supported events are documented in
+.Xr pmc.ucf 3 .
+Not all CPUs in this family implement fixed-function counters.
+.Ss SANDYBRIDGE UNCORE PROGRAMMABLE PMCS
+The programmable PMCs support 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 \&No
+.It PMC_CAP_INVERT Ta Yes
+.It PMC_CAP_READ Ta Yes
+.It PMC_CAP_PRECISE Ta \&No
+.It PMC_CAP_SYSTEM Ta \&No
+.It PMC_CAP_TAGGING Ta \&No
+.It PMC_CAP_THRESHOLD Ta Yes
+.It PMC_CAP_USER Ta \&No
+.It PMC_CAP_WRITE Ta Yes
+.El
+.Ss Event Qualifiers
+Event specifiers for these PMCs support the following common
+qualifiers:
+.Bl -tag -width indent
+.It Li cmask= Ns Ar value
+Configure the PMC 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 PMC to count the number of de-asserted to asserted
+transitions of the conditions expressed by the other qualifiers.
+If specified, the counter will increment only once whenever a
+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 cmask
+qualifier is present, making the counter increment when the number of
+events per cycle is less than the value specified by the
+.Dq Li cmask
+qualifier.
+.El
+.Ss Event Specifiers (Programmable PMCs)
+Sandy Bridge programmable PMCs support the following events:
+.Bl -tag -width indent
+.It Li CBO_XSNP_RESPONSE.RSPIHITI
+.Pq Event 22H, Umask 01H
+Snoop responses received from processor cores to requests initiated by this
+Cbox.
+Must combine with one of the umask values of 20H, 40H, 80H
+.It Li CBO_XSNP_RESPONSE.RSPIHITFSE
+.Pq Event 22H, Umask 02H
+Must combine with one of the umask values of 20H, 40H, 80H
+.It Li CBO_XSNP_RESPONSE.RSPSHITFSE
+.Pq Event 22H, Umask 04H
+Must combine with one of the umask values of 20H, 40H, 80H
+.It Li CBO_XSNP_RESPONSE.RSPSFWDM
+.Pq Event 22H, Umask 08H
+.It Li CBO_XSNP_RESPONSE.RSPIFWDM
+.Pq Event 22H, Umask 01H
+.It Li CBO_XSNP_RESPONSE.AND_EXTERNAL
+.Pq Event 22H, Umask 20H
+Filter on cross-core snoops resulted in external snoop request.
+Must combine with at least one of 01H, 02H, 04H, 08H, 10H
+.It Li CBO_XSNP_RESPONSE.AND_XCORE
+.Pq Event 22H, Umask 40H
+Filter on cross-core snoops resulted in core request.
+Must combine with at least one of 01H, 02H, 04H, 08H, 10H
+.It Li CBO_XSNP_RESPONSE.AND_XCORE
+.Pq Event 22H, Umask 80H
+Filter on cross-core snoops resulted in LLC evictions.
+Must combine with at least one of 01H, 02H, 04H, 08H, 10H
+.It Li CBO_CACHE_LOOKUP.M
+.Pq Event 34H, Umask 01H
+LLC lookup request that access cache and found line in M-state.
+Must combine with one of the umask values of 10H, 20H, 40H, 80H
+.It Li CBO_CACHE_LOOKUP.E
+.Pq Event 34H, Umask 02H
+LLC lookup request that access cache and found line in E-state.
+Must combine with one of the umask values of 10H, 20H, 40H, 80H
+.It Li CBO_CACHE_LOOKUP.S
+.Pq Event 34H, Umask 04H
+LLC lookup request that access cache and found line in S-state.
+Must combine with one of the umask values of 10H, 20H, 40H, 80H
+.It Li CBO_CACHE_LOOKUP.I
+.Pq Event 34H, Umask 08H
+LLC lookup request that access cache and found line in I-state.
+Must combine with one of the umask values of 10H, 20H, 40H, 80H
+.It Li CBO_CACHE_LOOKUP.AND_READ
+.Pq Event 34H, Umask 10H
+Filter on processor core initiated cacheable read requests.
+Must combine with at least one of 01H, 02H, 04H, 08H
+.It Li CBO_CACHE_LOOKUP_AND_READ2
+.Pq Event 34H, Umask 20H
+Filter on processor core initiated cacheable write requests.
+Must combine with at least one of 01H, 02H, 04H, 08H
+.It Li CBO_CACHE_LOOKUP.AND_EXTSNP
+.Pq Event 34H, Umask 40H
+Filter on external snoop requests.
+Must combine with at least one of 01H, 02H, 04H, 08H
+.It Li CBO_CACHE_LOOKUP.AND_ANY
+.Pq Event 34H, Umask 80H
+Filter on any IRQ or IPQ initiated requests including uncacheable,
+noncoherent requests.
+Must combine with at least one of 01H, 02H, 04H, 08H
+.It Li IMPH_CBO_TRK_OCCUPANCY.ALL
+.Pq Event 80H, Umask 01H
+Counts cycles weighted by the number of core-outgoing valid entries.
+Valid entries are between allocation to the first of IDIO or DRSO messages.
+Accounts for coherent and incoherent traffic.
+Counter 0 only
+.It Li IMPH_CBO_TRK_REQUEST.ALL
+.Pq Event 81H, Umask 01H
+Counts the number of core-outgoing entries.
+Accounts for coherent and incoherent traffic.
+.It Li IMPH_CBO_TRK_REQUEST.WRITES
+.Pq Event 81H, Umask 20H
+Counts the number of allocated write entries, include full, partial, and
+evictions.
+.It Li IMPH_CBO_TRK_REQUEST.EVICTIONS
+.Pq Event 81H, Umask 80H
+Counts the number of evictions allocated.
+.It Li IMPH_COH_TRK_OCCUPANCY.ALL
+.Pq Event 83H, Umask 01H
+Counts cycles weighted by the
+number of core-outgoing valid entries in the coherent tracker queue.
+Counter 0 only
+.It Li IMPH_COH_TRK_REQUEST.ALL
+.Pq Event 84H, Umask 01H
+Counts the number of core-outgoing entries in the coherent tracker queue.
+.El
+.Sh SEE ALSO
+.Xr pmc 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.p4 3 ,
+.Xr pmc.p5 3 ,
+.Xr pmc.p6 3 ,
+.Xr pmc.sandybridge 3 ,
+.Xr pmc.soft 3 ,
+.Xr pmc.tsc 3 ,
+.Xr pmc.ucf 3 ,
+.Xr pmc.westmere 3 ,
+.Xr pmc.westmereuc 3 ,
+.Xr pmc_cpuinfo 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 jkoshy@FreeBSD.org .
+The support for the Sandy Bridge
+microarchitecture was added by
+.An "Davide Italiano"
+.Aq davide@FreeBSD.org .
diff --git a/lib/libpmc/pmc.soft.3 b/lib/libpmc/pmc.soft.3
new file mode 100644
index 000000000000..a8674ba8b6fd
--- /dev/null
+++ b/lib/libpmc/pmc.soft.3
@@ -0,0 +1,104 @@
+.\" Copyright (c) 2012 Fabien Thomas. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this 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.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd March 28, 2012
+.Dt PMC.SOFT 3
+.Os
+.Sh NAME
+.Nm pmc.soft
+.Nd measurements using software based events
+.Sh LIBRARY
+.Lb libpmc
+.Sh SYNOPSIS
+.In pmc.h
+.Sh DESCRIPTION
+Software events are used to collect various source of software events.
+.Ss PMC Features
+16 sampling counters using software events based on various sources.
+These PMCs support 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 \&No
+.It PMC_CAP_INTERRUPT Ta Yes
+.It PMC_CAP_INVERT Ta \&No
+.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 \&No
+.It PMC_CAP_USER Ta Yes
+.It PMC_CAP_WRITE Ta Yes
+.El
+.Ss Event Qualifiers
+There is no supported event qualifier.
+.Pp
+The event specifiers supported by software are:
+.Bl -tag -width indent
+.It Li CLOCK.HARD
+Hard clock ticks.
+.It Li CLOCK.STAT
+Stat clock ticks.
+.It Li LOCK.FAILED
+Lock acquisition failed.
+.It Li PAGE_FAULT.ALL
+All page fault type.
+.It Li PAGE_FAULT.READ
+Read page fault.
+.It Li PAGE_FAULT.WRITE
+Write page fault.
+.El
+.Sh SEE ALSO
+.Xr pmc 3 ,
+.Xr pmc.atom 3 ,
+.Xr pmc.core 3 ,
+.Xr pmc.iaf 3 ,
+.Xr pmc.ucf 3 ,
+.Xr pmc.k7 3 ,
+.Xr pmc.k8 3 ,
+.Xr pmc.p4 3 ,
+.Xr pmc.p5 3 ,
+.Xr pmc.p6 3 ,
+.Xr pmc.corei7 3 ,
+.Xr pmc.corei7uc 3 ,
+.Xr pmc.westmereuc 3 ,
+.Xr pmc.tsc 3 ,
+.Xr pmc_cpuinfo 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 jkoshy@FreeBSD.org .
+Software PMC was written by
+.An "Fabien Thomas"
+.Aq fabient@FreeBSD.org .
diff --git a/lib/libpmc/pmc.tsc.3 b/lib/libpmc/pmc.tsc.3
index 144ff35c3f05..269200549d69 100644
--- a/lib/libpmc/pmc.tsc.3
+++ b/lib/libpmc/pmc.tsc.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -68,6 +68,7 @@ maps to the TSC.
.Xr pmc.p4 3 ,
.Xr pmc.p5 3 ,
.Xr pmc.p6 3 ,
+.Xr pmc.soft 3 ,
.Xr pmclog 3 ,
.Xr hwpmc 4
.Sh HISTORY
diff --git a/lib/libpmc/pmc.ucf.3 b/lib/libpmc/pmc.ucf.3
index 5155eb663e65..15399e43d02e 100644
--- a/lib/libpmc/pmc.ucf.3
+++ b/lib/libpmc/pmc.ucf.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -96,6 +96,7 @@ offset C0H under device number 0 and Function 0.
.Xr pmc.corei7uc 3 ,
.Xr pmc.westmere 3 ,
.Xr pmc.westmereuc 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc_cpuinfo 3 ,
.Xr pmclog 3 ,
diff --git a/lib/libpmc/pmc.westmere.3 b/lib/libpmc/pmc.westmere.3
index 8128a9c26605..547ee71eff0f 100644
--- a/lib/libpmc/pmc.westmere.3
+++ b/lib/libpmc/pmc.westmere.3
@@ -9,21 +9,21 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
-.Dd March 24, 2010
+.Dd February 25, 2012
.Dt PMC.WESTMERE 3
.Os
.Sh NAME
@@ -92,15 +92,17 @@ Configure the Off-core Response bits.
.It Li DMND_DATA_RD
Counts the number of demand and DCU prefetch data reads of full
and partial cachelines as well as demand data page table entry
-cacheline reads. Does not count L2 data read prefetches or
+cacheline reads.
+Does not count L2 data read prefetches or
instruction fetches.
.It Li DMND_RFO
Counts the number of demand and DCU prefetch reads for ownership
-(RFO) requests generated by a write to data cacheline. Does not
-count L2 RFO.
+(RFO) requests generated by a write to data cacheline.
+Does not count L2 RFO.
.It Li DMND_IFETCH
Counts the number of demand and DCU prefetch instruction cacheline
-reads. Does not count L2 code read prefetches.
+reads.
+Does not count L2 code read prefetches.
WB
Counts the number of writeback (modified to exclusive) transactions.
.It Li PF_DATA_RD
@@ -181,7 +183,8 @@ All Store buffer stall cycles
All store referenced with misaligned address
.It Li STORE_BLOCKS.AT_RET
.Pq Event 06H , Umask 04H
-Counts number of loads delayed with at-Retirement block code. The following
+Counts number of loads delayed with at-Retirement block code.
+The following
loads need to be executed at retirement and wait for all senior stores on
the same thread to be drained: load splitting across 4K boundary (page
split), load accessing uncacheable (UC or USWC) memory, load lock, and load
@@ -225,9 +228,10 @@ ld_lat facility.
In conjunction with ld_lat facility
.It Li MEM_STORE_RETIRED.DTLB_MISS
.Pq Event 0CH , Umask 01H
-The event counts the number of retired stores that missed the DTLB. The DTLB
-miss is not counted if the store operation causes a fault. Does not counter
-prefetches. Counts both primary and secondary misses to the TLB
+The event counts the number of retired stores that missed the DTLB.
+The DTLB miss is not counted if the store operation causes a fault.
+Does not counter prefetches.
+Counts both primary and secondary misses to the TLB
.It Li UOPS_ISSUED.ANY
.Pq Event 0EH , Umask 01H
Counts the number of Uops issued by the Register Allocation Table to the
@@ -264,9 +268,11 @@ Load instructions retired remote DRAM and remote home-remote cache HITM
Load instructions retired I/O (Precise Event)
.It Li FP_COMP_OPS_EXE.X87
.Pq Event 10H , Umask 01H
-Counts the number of FP Computational Uops Executed. The number of FADD,
+Counts the number of FP Computational Uops Executed.
+The number of FADD,
FSUB, FCOM, FMULs, integer MULsand IMULs, FDIVs, FPREMs, FSQRTS, integer
-DIVs, and IDIVs. This event does not distinguish an FADD used in the middle
+DIVs, and IDIVs.
+This event does not distinguish an FADD used in the middle
of a transcendental flow from a separate FADD instruction.
.It Li FP_COMP_OPS_EXE.MMX
.Pq Event 10H , Umask 02H
@@ -316,9 +322,9 @@ Counts number of loads dispatched from the Reservation Station that bypass
the Memory Order Buffer.
.It Li LOAD_DISPATCH.RS_DELAYED
.Pq Event 13H , Umask 02H
-Counts the number of delayed RS dispatches at the stage latch. If an RS
-dispatch can not bypass to LB, it has another chance to dispatch from the
-one-cycle delayed staging latch before it is written into the LB.
+Counts the number of delayed RS dispatches at the stage latch.
+If an RS dispatch can not bypass to LB, it has another chance to dispatch
+from the one-cycle delayed staging latch before it is written into the LB.
.It Li LOAD_DISPATCH.MOB
.Pq Event 13H , Umask 04H
Counts the number of loads dispatched from the Reservation Station to the
@@ -329,13 +335,15 @@ Counts all loads dispatched from the Reservation Station.
.It Li ARITH.CYCLES_DIV_BUSY
.Pq Event 14H , Umask 01H
Counts the number of cycles the divider is busy executing divide or square
-root operations. The divide can be integer, X87 or Streaming SIMD Extensions
-(SSE). The square root operation can be either X87 or SSE.
+root operations.
+The divide can be integer, X87 or Streaming SIMD Extensions (SSE).
+The square root operation can be either X87 or SSE.
Set 'edge =1, invert=1, cmask=1' to count the number of divides.
Count may be incorrect When SMT is on
.It Li ARITH.MUL
.Pq Event 14H , Umask 02H
-Counts the number of multiply operations executed. This includes integer as
+Counts the number of multiply operations executed.
+This includes integer as
well as floating point multiply operations but excludes DPPS mul and MPSAD.
Count may be incorrect When SMT is on
.It Li INST_QUEUE_WRITES
@@ -344,64 +352,72 @@ Counts the number of instructions written into the instruction queue every
cycle.
.It Li INST_DECODED.DEC0
.Pq Event 18H , Umask 01H
-Counts number of instructions that require decoder 0 to be decoded. Usually,
-this means that the instruction maps to more than 1 uop
+Counts number of instructions that require decoder 0 to be decoded.
+Usually, this means that the instruction maps to more than 1 uop
.It Li TWO_UOP_INSTS_DECODED
.Pq Event 19H , Umask 01H
An instruction that generates two uops was decoded
.It Li INST_QUEUE_WRITE_CYCLES
.Pq Event 1EH , Umask 01H
This event counts the number of cycles during which instructions are written
-to the instruction queue. Dividing this counter by the number of
+to the instruction queue.
+Dividing this counter by the number of
instructions written to the instruction queue (INST_QUEUE_WRITES) yields the
-average number of instructions decoded each cycle. If this number is less
+average number of instructions decoded each cycle.
+If this number is less
than four and the pipe stalls, this indicates that the decoder is failing to
decode enough instructions per cycle to sustain the 4-wide pipeline.
If SSE* instructions that are 6 bytes or longer arrive one after another,
-then front end throughput may limit execution speed. In such case,
+then front end throughput may limit execution speed.
+In such case,
.It Li LSD_OVERFLOW
.Pq Event 20H , Umask 01H
Number of loops that can not stream from the instruction queue.
.It Li L2_RQSTS.LD_HIT
.Pq Event 24H , Umask 01H
-Counts number of loads that hit the L2 cache. L2 loads include both L1D
-demand misses as well as L1D prefetches. L2 loads can be rejected for
-various reasons. Only non rejected loads are counted.
+Counts number of loads that hit the L2 cache.
+L2 loads include both L1D demand misses as well as L1D prefetches.
+L2 loads can be rejected for various reasons.
+Only non rejected loads are counted.
.It Li L2_RQSTS.LD_MISS
.Pq Event 24H , Umask 02H
-Counts the number of loads that miss the L2 cache. L2 loads include both L1D
-demand misses as well as L1D prefetches.
+Counts the number of loads that miss the L2 cache.
+L2 loads include both L1D demand misses as well as L1D prefetches.
.It Li L2_RQSTS.LOADS
.Pq Event 24H , Umask 03H
-Counts all L2 load requests. L2 loads include both L1D demand misses as well
-as L1D prefetches.
+Counts all L2 load requests.
+L2 loads include both L1D demand misses as well as L1D prefetches.
.It Li L2_RQSTS.RFO_HIT
.Pq Event 24H , Umask 04H
-Counts the number of store RFO requests that hit the L2 cache. L2 RFO
-requests include both L1D demand RFO misses as well as L1D RFO prefetches.
+Counts the number of store RFO requests that hit the L2 cache.
+L2 RFO requests include both L1D demand RFO misses as well as L1D RFO
+prefetches.
Count includes WC memory requests, where the data is not fetched but the
permission to write the line is required.
.It Li L2_RQSTS.RFO_MISS
.Pq Event 24H , Umask 08H
-Counts the number of store RFO requests that miss the L2 cache. L2 RFO
-requests include both L1D demand RFO misses as well as L1D RFO prefetches.
+Counts the number of store RFO requests that miss the L2 cache.
+L2 RFO requests include both L1D demand RFO misses as well as L1D RFO
+prefetches.
.It Li L2_RQSTS.RFOS
.Pq Event 24H , Umask 0CH
-Counts all L2 store RFO requests. L2 RFO requests include both L1D demand
+Counts all L2 store RFO requests.
+L2 RFO requests include both L1D demand
RFO misses as well as L1D RFO prefetches.
.It Li L2_RQSTS.IFETCH_HIT
.Pq Event 24H , Umask 10H
-Counts number of instruction fetches that hit the L2 cache. L2 instruction
-fetches include both L1I demand misses as well as L1I instruction
-prefetches.
+Counts number of instruction fetches that hit the L2 cache.
+L2 instruction fetches include both L1I demand misses as well as L1I
+instruction prefetches.
.It Li L2_RQSTS.IFETCH_MISS
.Pq Event 24H , Umask 20H
-Counts number of instruction fetches that miss the L2 cache. L2 instruction
-fetches include both L1I demand misses as well as L1I instruction
-prefetches.
+Counts number of instruction fetches that miss the L2 cache.
+L2 instruction fetches include both L1I demand misses as well as L1I
+instruction prefetches.
.It Li L2_RQSTS.IFETCHES
.Pq Event 24H , Umask 30H
-Counts all instruction fetches. L2 instruction fetches include both L1I
+Counts all instruction fetches.
+L2 instruction fetches include both L1I
demand misses as well as L1I instruction prefetches.
.It Li L2_RQSTS.PREFETCH_HIT
.Pq Event 24H , Umask 40H
@@ -421,26 +437,30 @@ Counts all L2 requests for both code and data.
.It Li L2_DATA_RQSTS.DEMAND.I_STATE
.Pq Event 26H , Umask 01H
Counts number of L2 data demand loads where the cache line to be loaded is
-in the I (invalid) state, i.e. a cache miss. L2 demand loads are both L1D
-demand misses and L1D prefetches.
+in the I (invalid) state, i.e. a cache miss.
+L2 demand loads are both L1D demand misses and L1D prefetches.
.It Li L2_DATA_RQSTS.DEMAND.S_STATE
.Pq Event 26H , Umask 02H
Counts number of L2 data demand loads where the cache line to be loaded is
-in the S (shared) state. L2 demand loads are both L1D demand misses and L1D
+in the S (shared) state.
+L2 demand loads are both L1D demand misses and L1D
prefetches.
.It Li L2_DATA_RQSTS.DEMAND.E_STATE
.Pq Event 26H , Umask 04H
Counts number of L2 data demand loads where the cache line to be loaded is
-in the E (exclusive) state. L2 demand loads are both L1D demand misses and
+in the E (exclusive) state.
+L2 demand loads are both L1D demand misses and
L1D prefetches.
.It Li L2_DATA_RQSTS.DEMAND.M_STATE
.Pq Event 26H , Umask 08H
Counts number of L2 data demand loads where the cache line to be loaded is
-in the M (modified) state. L2 demand loads are both L1D demand misses and
+in the M (modified) state.
+L2 demand loads are both L1D demand misses and
L1D prefetches.
.It Li L2_DATA_RQSTS.DEMAND.MESI
.Pq Event 26H , Umask 0FH
-Counts all L2 data demand requests. L2 demand loads are both L1D demand
+Counts all L2 data demand requests.
+L2 demand loads are both L1D demand
misses and L1D prefetches.
.It Li L2_DATA_RQSTS.PREFETCH.I_STATE
.Pq Event 26H , Umask 10H
@@ -449,7 +469,8 @@ in the I (invalid) state, i.e. a cache miss.
.It Li L2_DATA_RQSTS.PREFETCH.S_STATE
.Pq Event 26H , Umask 20H
Counts number of L2 prefetch data loads where the cache line to be loaded is
-in the S (shared) state. A prefetch RFO will miss on an S state line, while
+in the S (shared) state.
+A prefetch RFO will miss on an S state line, while
a prefetch read will hit on an S state line.
.It Li L2_DATA_RQSTS.PREFETCH.E_STATE
.Pq Event 26H , Umask 40H
@@ -468,23 +489,27 @@ Counts all L2 data requests.
.It Li L2_WRITE.RFO.I_STATE
.Pq Event 27H , Umask 01H
Counts number of L2 demand store RFO requests where the cache line to be
-loaded is in the I (invalid) state, i.e, a cache miss. The L1D prefetcher
+loaded is in the I (invalid) state, i.e, a cache miss.
+The L1D prefetcher
does not issue a RFO prefetch.
This is a demand RFO request
.It Li L2_WRITE.RFO.S_STATE
.Pq Event 27H , Umask 02H
Counts number of L2 store RFO requests where the cache line to be loaded is
-in the S (shared) state. The L1D prefetcher does not issue a RFO prefetch.
+in the S (shared) state.
+The L1D prefetcher does not issue a RFO prefetch.
This is a demand RFO request.
.It Li L2_WRITE.RFO.M_STATE
.Pq Event 27H , Umask 08H
Counts number of L2 store RFO requests where the cache line to be loaded is
-in the M (modified) state. The L1D prefetcher does not issue a RFO prefetch.
+in the M (modified) state.
+The L1D prefetcher does not issue a RFO prefetch.
This is a demand RFO request.
.It Li L2_WRITE.RFO.HIT
.Pq Event 27H , Umask 0EH
Counts number of L2 store RFO requests where the cache line to be loaded is
-in either the S, E or M states. The L1D prefetcher does not issue a RFO
+in either the S, E or M states.
+The L1D prefetcher does not issue a RFO
prefetch.
This is a demand RFO request
.It Li L2_WRITE.RFO.MESI
@@ -536,21 +561,23 @@ is in the M (modified) state.
Counts all L1 writebacks to the L2.
.It Li L3_LAT_CACHE.REFERENCE
.Pq Event 2EH , Umask 02H
-Counts uncore Last Level Cache references. Because cache hierarchy, cache
+Counts uncore Last Level Cache references.
+Because cache hierarchy, cache
sizes and other implementation-specific characteristics; value comparison to
estimate performance differences is not recommended.
See Table A-1.
.It Li L3_LAT_CACHE.MISS
.Pq Event 2EH , Umask 01H
-Counts uncore Last Level Cache misses. Because cache hierarchy, cache sizes
+Counts uncore Last Level Cache misses.
+Because cache hierarchy, cache sizes
and other implementation-specific characteristics; value comparison to
estimate performance differences is not recommended.
See Table A-1.
.It Li CPU_CLK_UNHALTED.THREAD_P
.Pq Event 3CH , Umask 00H
Counts the number of thread cycles while the thread is not in a halt state.
-The thread enters the halt state when it is running the HLT instruction. The
-core frequency may change from time to time due to power or thermal
+The thread enters the halt state when it is running the HLT instruction.
+The core frequency may change from time to time due to power or thermal
throttling.
see Table A-1
.It Li CPU_CLK_UNHALTED.REF_P
@@ -569,7 +596,8 @@ Counts cycles of page walk due to misses in the STLB.
.It Li DTLB_MISSES.STLB_HIT
.Pq Event 49H , Umask 10H
Counts the number of DTLB first level misses that hit in the second level
-TLB. This event is only relevant if the core contains multiple DTLB levels.
+TLB.
+This event is only relevant if the core contains multiple DTLB levels.
.It Li DTLB_MISSES.LARGE_WALK_COMPLETED
.Pq Event 49H , Umask 80H
Counts number of completed large page walks due to misses in the STLB.
@@ -584,17 +612,22 @@ Counts number of hardware prefetch requests dispatched out of the prefetch
FIFO.
.It Li L1D_PREFETCH.MISS
.Pq Event 4EH , Umask 02H
-Counts number of hardware prefetch requests that miss the L1D. There are two
-prefetchers in the L1D. A streamer, which predicts lines sequentially after
+Counts number of hardware prefetch requests that miss the L1D.
+There are two
+prefetchers in the L1D.
+A streamer, which predicts lines sequentially after
this one should be fetched, and the IP prefetcher that remembers access
-patterns for the current instruction. The streamer prefetcher stops on an
+patterns for the current instruction.
+The streamer prefetcher stops on an
L1D hit, while the IP prefetcher does not.
.It Li L1D_PREFETCH.TRIGGERS
.Pq Event 4EH , Umask 04H
Counts number of prefetch requests triggered by the Finite State Machine and
-pushed into the prefetch FIFO. Some of the prefetch requests are dropped due
+pushed into the prefetch FIFO.
+Some of the prefetch requests are dropped due
to overwrites or competition between the IP index prefetcher and streamer
-prefetcher. The prefetch FIFO contains 4 entries.
+prefetcher.
+The prefetch FIFO contains 4 entries.
.It Li EPT.WALK_CYCLES
.Pq Event 4FH , Umask 10H
Counts Extended Page walk cycles.
@@ -626,31 +659,33 @@ Counts the number of cacheable load lock speculated or retired instructions
accepted into the fill buffer.
.It Li OFFCORE_REQUESTS_OUTSTANDING.DEMAND.READ_DATA
.Pq Event 60H , Umask 01H
-Counts weighted cycles of offcore demand data read requests. Does not
-include L2 prefetch requests.
+Counts weighted cycles of offcore demand data read requests.
+Does not include L2 prefetch requests.
Counter 0.
.It Li OFFCORE_REQUESTS_OUTSTANDING.DEMAND.READ_CODE
.Pq Event 60H , Umask 02H
-Counts weighted cycles of offcore demand code read requests. Does not
-include L2 prefetch requests.
+Counts weighted cycles of offcore demand code read requests.
+Does not include L2 prefetch requests.
Counter 0.
.It Li OFFCORE_REQUESTS_OUTSTANDING.DEMAND.RFO
.Pq Event 60H , Umask 04H
-Counts weighted cycles of offcore demand RFO requests. Does not include L2
-prefetch requests.
+Counts weighted cycles of offcore demand RFO requests.
+Does not include L2 prefetch requests.
Counter 0.
.It Li OFFCORE_REQUESTS_OUTSTANDING.ANY.READ
.Pq Event 60H , Umask 08H
-Counts weighted cycles of offcore read requests of any kind. Include L2
-prefetch requests.
-Ccounter 0.
+Counts weighted cycles of offcore read requests of any kind.
+Include L2 prefetch requests.
+Counter 0.
.It Li CACHE_LOCK_CYCLES.L1D_L2
.Pq Event 63H , Umask 01H
-Cycle count during which the L1D and L2 are locked. A lock is asserted when
+Cycle count during which the L1D and L2 are locked.
+A lock is asserted when
there is a locked memory access, due to uncacheable memory, a locked
operation that spans two cache lines, or a page walk from an uncacheable
page table.
-Counter 0, 1 only. L1D and L2 locks have a very high performance penalty and
+Counter 0, 1 only.
+L1D and L2 locks have a very high performance penalty and
it is highly recommended to avoid such accesses.
.It Li CACHE_LOCK_CYCLES.L1D
.Pq Event 63H , Umask 02H
@@ -665,9 +700,11 @@ Counts the number of completed I/O transactions.
Counts all instruction fetches that hit the L1 instruction cache.
.It Li L1I.MISSES
.Pq Event 80H , Umask 02H
-Counts all instruction fetches that miss the L1I cache. This includes
+Counts all instruction fetches that miss the L1I cache.
+This includes
instruction cache misses, streaming buffer misses, victim cache misses and
-uncacheable fetches. An instruction fetch miss is counted only once and not
+uncacheable fetches.
+An instruction fetch miss is counted only once and not
once for every cycle it is outstanding.
.It Li L1I.READS
.Pq Event 80H , Umask 03H
@@ -747,10 +784,10 @@ Counts all near call branches executed, but not necessarily retired.
Counts taken near branches executed, but not necessarily retired.
.It Li BR_INST_EXEC.ANY
.Pq Event 88H , Umask 7FH
-Counts all near executed branches (not necessarily retired). This includes
-only instructions and not micro-op branches. Frequent branching is not
-necessarily a major performance issue. However frequent branch
-mispredictions may be a problem.
+Counts all near executed branches (not necessarily retired).
+This includes only instructions and not micro-op branches.
+Frequent branching is not necessarily a major performance issue.
+However frequent branch mispredictions may be a problem.
.It Li BR_MISP_EXEC.COND
.Pq Event 89H , Umask 01H
Counts the number of mispredicted conditional near branch instructions
@@ -791,9 +828,10 @@ Counts the number of mispredicted near branch instructions that were
executed, but not necessarily retired.
.It Li RESOURCE_STALLS.ANY
.Pq Event A2H , Umask 01H
-Counts the number of Allocator resource related stalls. Includes register
-renaming buffer entries, memory buffer entries. In addition to resource
-related stalls, this event counts some other events. Includes stalls arising
+Counts the number of Allocator resource related stalls.
+Includes register renaming buffer entries, memory buffer entries.
+In addition to resource related stalls, this event counts some other events.
+Includes stalls arising
during branch misprediction recovery, such as if retirement of the
mispredicted branch is delayed and stalls arising while store buffer is
draining from synchronizing operations.
@@ -806,7 +844,8 @@ Counts the cycles of stall due to lack of load buffer for load operation.
.Pq Event A2H , Umask 04H
This event counts the number of cycles when the number of instructions in
the pipeline waiting for execution reaches the limit the processor can
-handle. A high count of this event indicates that there are long latency
+handle.
+A high count of this event indicates that there are long latency
operations in the pipe (possibly load and store operations that miss the L2
cache, or instructions dependent upon instructions further down the pipeline
that have yet to retire.
@@ -816,7 +855,8 @@ start execution.
.Pq Event A2H , Umask 08H
This event counts the number of cycles that a resource related stall will
occur due to the number of store instructions reaching the limit of the
-pipeline, (i.e. all store buffers are used). The stall ends when a store
+pipeline, (i.e. all store buffers are used).
+The stall ends when a store
instruction commits its data to the cache or memory.
.It Li RESOURCE_STALLS.ROB_FULL
.Pq Event A2H , Umask 10H
@@ -828,7 +868,8 @@ floating-point unit (FPU) control word.
.It Li RESOURCE_STALLS.MXCSR
.Pq Event A2H , Umask 40H
Stalls due to the MXCSR register rename occurring to close to a previous
-MXCSR rename. The MXCSR provides control and status for the MMX registers.
+MXCSR rename.
+The MXCSR provides control and status for the MMX registers.
.It Li RESOURCE_STALLS.OTHER
.Pq Event A2H , Umask 80H
Counts the number of cycles while execution was stalled due to other
@@ -839,12 +880,14 @@ Counts the number of instructions decoded that are macro-fused but not
necessarily executed or retired.
.It Li BACLEAR_FORCE_IQ
.Pq Event A7H , Umask 01H
-Counts number of times a BACLEAR was forced by the Instruction Queue. The IQ
-is also responsible for providing conditional branch prediction direction
-based on a static scheme and dynamic data provided by the L2 Branch
-Prediction Unit. If the conditional branch target is not found in the Target
+Counts number of times a BACLEAR was forced by the Instruction Queue.
+The IQ is also responsible for providing conditional branch prediction
+direction based on a static scheme and dynamic data provided by the L2
+Branch Prediction Unit.
+If the conditional branch target is not found in the Target
Array and the IQ predicts that the branch is taken, then the IQ will force
-the Branch Address Calculator to issue a BACLEAR. Each BACLEAR asserted by
+the Branch Address Calculator to issue a BACLEAR.
+Each BACLEAR asserted by
the BAC generates approximately an 8 cycle bubble in the instruction fetch
pipeline.
.It Li LSD.UOPS
@@ -856,22 +899,24 @@ Use cmask=1 and invert to count cycles
Counts the number of ITLB flushes
.It Li OFFCORE_REQUESTS.DEMAND.READ_DATA
.Pq Event B0H , Umask 01H
-Counts number of offcore demand data read requests. Does not count L2
-prefetch requests.
+Counts number of offcore demand data read requests.
+Does not count L2 prefetch requests.
.It Li OFFCORE_REQUESTS.DEMAND.READ_CODE
.Pq Event B0H , Umask 02H
-Counts number of offcore demand code read requests. Does not count L2
-prefetch requests.
+Counts number of offcore demand code read requests.
+Does not count L2 prefetch requests.
.It Li OFFCORE_REQUESTS.DEMAND.RFO
.Pq Event B0H , Umask 04H
-Counts number of offcore demand RFO requests. Does not count L2 prefetch
-requests.
+Counts number of offcore demand RFO requests.
+Does not count L2 prefetch requests.
.It Li OFFCORE_REQUESTS.ANY.READ
.Pq Event B0H , Umask 08H
-Counts number of offcore read requests. Includes L2 prefetch requests.
+Counts number of offcore read requests.
+Includes L2 prefetch requests.
.It Li OFFCORE_REQUESTS.ANY.RFO
.Pq Event 80H , Umask 10H
-Counts number of offcore RFO requests. Includes L2 prefetch requests.
+Counts number of offcore RFO requests.
+Includes L2 prefetch requests.
.It Li OFFCORE_REQUESTS.L1D_WRITEBACK
.Pq Event B0H , Umask 40H
Counts number of L1D writebacks to the uncore.
@@ -880,38 +925,42 @@ Counts number of L1D writebacks to the uncore.
Counts all offcore requests.
.It Li UOPS_EXECUTED.PORT0
.Pq Event B1H , Umask 01H
-Counts number of Uops executed that were issued on port 0. Port 0 handles
-integer arithmetic, SIMD and FP add Uops.
+Counts number of Uops executed that were issued on port 0.
+Port 0 handles integer arithmetic, SIMD and FP add Uops.
.It Li UOPS_EXECUTED.PORT1
.Pq Event B1H , Umask 02H
-Counts number of Uops executed that were issued on port 1. Port 1 handles
-integer arithmetic, SIMD, integer shift, FP multiply and FP divide Uops.
+Counts number of Uops executed that were issued on port 1.
+Port 1 handles integer arithmetic, SIMD, integer shift, FP multiply and
+FP divide Uops.
.It Li UOPS_EXECUTED.PORT2_CORE
.Pq Event B1H , Umask 04H
-Counts number of Uops executed that were issued on port 2. Port 2 handles
-the load Uops. This is a core count only and can not be collected per
+Counts number of Uops executed that were issued on port 2.
+Port 2 handles the load Uops.
+This is a core count only and can not be collected per
thread.
.It Li UOPS_EXECUTED.PORT3_CORE
.Pq Event B1H , Umask 08H
-Counts number of Uops executed that were issued on port 3. Port 3 handles
-store Uops. This is a core count only and can not be collected per thread.
+Counts number of Uops executed that were issued on port 3.
+Port 3 handles store Uops.
+This is a core count only and can not be collected per thread.
.It Li UOPS_EXECUTED.PORT4_CORE
.Pq Event B1H , Umask 10H
-Counts number of Uops executed that where issued on port 4. Port 4 handles
-the value to be stored for the store Uops issued on port 3. This is a core
-count only and can not be collected per thread.
+Counts number of Uops executed that where issued on port 4.
+Port 4 handles the value to be stored for the store Uops issued on port 3.
+This is a core count only and can not be collected per thread.
.It Li UOPS_EXECUTED.CORE_ACTIVE_CYCLES_NO_PORT5
.Pq Event B1H , Umask 1FH
Counts number of cycles there are one or more uops being executed and were
-issued on ports 0-4. This is a core count only and can not be collected per
-thread.
+issued on ports 0-4.
+This is a core count only and can not be collected per thread.
.It Li UOPS_EXECUTED.PORT5
.Pq Event B1H , Umask 20H
Counts number of Uops executed that where issued on port 5.
.It Li UOPS_EXECUTED.CORE_ACTIVE_CYCLES
.Pq Event B1H , Umask 3FH
Counts number of cycles there are one or more uops being executed on any
-ports. This is a core count only and can not be collected per thread.
+ports.
+This is a core count only and can not be collected per thread.
.It Li UOPS_EXECUTED.PORT015
.Pq Event B1H , Umask 40H
Counts number of Uops executed that where issued on port 0, 1, or 5.
@@ -924,15 +973,18 @@ Counts number of Uops executed that where issued on port 2, 3, or 4.
Counts number of cycles the SQ is full to handle off-core requests.
.It Li SNOOPQ_REQUESTS_OUTSTANDING.DATA
.Pq Event B3H , Umask 01H
-Counts weighted cycles of snoopq requests for data. Counter 0 only
+Counts weighted cycles of snoopq requests for data.
+Counter 0 only
Use cmask=1 to count cycles not empty.
.It Li SNOOPQ_REQUESTS_OUTSTANDING.INVALIDATE
.Pq Event B3H , Umask 02H
-Counts weighted cycles of snoopq invalidate requests. Counter 0 only.
+Counts weighted cycles of snoopq invalidate requests.
+Counter 0 only.
Use cmask=1 to count cycles not empty.
.It Li SNOOPQ_REQUESTS_OUTSTANDING.CODE
.Pq Event B3H , Umask 04H
-Counts weighted cycles of snoopq requests for code. Counter 0 only.
+Counts weighted cycles of snoopq requests for code.
+Counter 0 only.
Use cmask=1 to count cycles not empty.
.It Li SNOOPQ_REQUESTS.CODE
.Pq Event B4H , Umask 01H
@@ -970,7 +1022,8 @@ Use MSR 01A7H.
See Table A-1
Notes: INST_RETIRED.ANY is counted by a designated fixed counter.
INST_RETIRED.ANY_P is counted by a programmable counter and is an
-architectural performance event. Event is supported if CPUID.A.EBX[1] = 0.
+architectural performance event.
+Event is supported if CPUID.A.EBX[1] = 0.
Counting: Faulting executions of GETSEC/VM entry/VM Exit/MWait will not
count as retired instructions.
.It Li INST_RETIRED.X87
@@ -985,8 +1038,9 @@ Counts the number of retired: MMX instructions.
.It Li UOPS_RETIRED.ANY
.Pq Event C2H , Umask 01H
Counts the number of micro-ops retired, (macro-fused=1, micro- fused=2,
-others=1; maximum count of 8 per cycle). Most instructions are composed of
-one or two micro-ops. Some instructions are decoded into longer sequences
+others=1; maximum count of 8 per cycle).
+Most instructions are composed of one or two micro-ops.
+Some instructions are decoded into longer sequences
such as repeat instructions, floating point transcendental instructions, and
assists.
Use cmask=1 and invert to count active cycles or stalled cycles
@@ -1006,7 +1060,8 @@ Counts the number of machine clears due to memory order conflicts.
.Pq Event C3H , Umask 04H
Counts the number of times that a program writes to a code section.
Self-modifying code causes a sever penalty in all Intel 64 and IA-32
-processors. The modified cache line is written back to the L2 and L3caches.
+processors.
+The modified cache line is written back to the L2 and L3caches.
.It Li BR_INST_RETIRED.ANY_P
.Pq Event C4H , Umask 00H
See Table A-1.
@@ -1063,23 +1118,25 @@ cache.
.It Li MEM_LOAD_RETIRED.OTHER_CORE_L2_HIT_HITM
.Pq Event CBH , Umask 08H
Counts number of retired loads that hit in a sibling core's L2 (on die
-core). Since the L3 is inclusive of all cores on the package, this is an L3
-hit. This counts both clean or modified hits.
+core).
+Since the L3 is inclusive of all cores on the package, this is an L3 hit.
+This counts both clean or modified hits.
.It Li MEM_LOAD_RETIRED.L3_MISS
.Pq Event CBH , Umask 10H
-Counts number of retired loads that miss the L3 cache. The load was
-satisfied by a remote socket, local memory or an IOH.
+Counts number of retired loads that miss the L3 cache.
+The load was satisfied by a remote socket, local memory or an IOH.
.It Li MEM_LOAD_RETIRED.HIT_LFB
.Pq Event CBH , Umask 40H
Counts number of retired loads that miss the L1D and the address is located
-in an allocated line fill buffer and will soon be committed to cache. This
-is counting secondary L1D misses.
+in an allocated line fill buffer and will soon be committed to cache.
+This is counting secondary L1D misses.
.It Li MEM_LOAD_RETIRED.DTLB_MISS
.Pq Event CBH , Umask 80H
-Counts the number of retired loads that missed the DTLB. The DTLB miss is
-not counted if the load operation causes a fault. This event counts loads
-from cacheable memory only. The event does not count loads by software
-prefetches. Counts both primary and secondary misses to the TLB.
+Counts the number of retired loads that missed the DTLB.
+The DTLB miss is not counted if the load operation causes a fault.
+This event counts loads from cacheable memory only.
+The event does not count loads by software prefetches.
+Counts both primary and secondary misses to the TLB.
.It Li FP_MMX_TRANS.TO_FP
.Pq Event CCH , Umask 01H
Counts the first floating-point instruction following any MMX instruction.
@@ -1087,15 +1144,15 @@ You can use this event to estimate the penalties for the transitions between
floating-point and MMX technology states.
.It Li FP_MMX_TRANS.TO_MMX
.Pq Event CCH , Umask 02H
-Counts the first MMX instruction following a floating-point instruction. You
-can use this event to estimate the penalties for the transitions between
+Counts the first MMX instruction following a floating-point instruction.
+You can use this event to estimate the penalties for the transitions between
floating-point and MMX technology states.
.It Li FP_MMX_TRANS.ANY
.Pq Event CCH , Umask 03H
Counts all transitions from floating point to MMX instructions and from MMX
-instructions to floating point instructions. You can use this event to
-estimate the penalties for the transitions between floating-point and MMX
-technology states.
+instructions to floating point instructions.
+You can use this event to estimate the penalties for the transitions between
+floating-point and MMX technology states.
.It Li MACRO_INSTS.DECODED
.Pq Event D0H , Umask 01H
Counts the number of instructions decoded, (but not necessarily executed or
@@ -1105,14 +1162,15 @@ retired).
Counts the cycles of decoder stalls.
.It Li UOPS_DECODED.MS
.Pq Event D1H , Umask 02H
-Counts the number of Uops decoded by the Microcode Sequencer, MS. The MS
-delivers uops when the instruction is more than 4 uops long or a microcode
-assist is occurring.
+Counts the number of Uops decoded by the Microcode Sequencer, MS.
+The MS delivers uops when the instruction is more than 4 uops long or a
+microcode assist is occurring.
.It Li UOPS_DECODED.ESP_FOLDING
.Pq Event D1H , Umask 04H
Counts number of stack pointer (ESP) instructions decoded: push , pop , call
, ret, etc. ESP instructions do not generate a Uop to increment or decrement
-ESP. Instead, they update an ESP_Offset register that keeps track of the
+ESP.
+Instead, they update an ESP_Offset register that keeps track of the
delta to the current value of the ESP register.
.It Li UOPS_DECODED.ESP_SYNC
.Pq Event D1H , Umask 08H
@@ -1122,7 +1180,8 @@ value of the ESP register.
.It Li RAT_STALLS.FLAGS
.Pq Event D2H , Umask 01H
Counts the number of cycles during which execution stalled due to several
-reasons, one of which is a partial flag register stall. A partial register
+reasons, one of which is a partial flag register stall.
+A partial register
stall may occur when two conditions are met: 1) an instruction modifies
some, but not all, of the flags in the flag register and 2) the next
instruction, which depends on flags, depends on flags that were not modified
@@ -1135,28 +1194,34 @@ was partially written by previous instruction.
.It Li RAT_STALLS.ROB_READ_PORT
.Pq Event D2H , Umask 04H
Counts the number of cycles when ROB read port stalls occurred, which did
-not allow new micro-ops to enter the out-of-order pipeline. Note that, at
+not allow new micro-ops to enter the out-of-order pipeline.
+Note that, at
this stage in the pipeline, additional stalls may occur at the same cycle
-and prevent the stalled micro-ops from entering the pipe. In such a case,
+and prevent the stalled micro-ops from entering the pipe.
+In such a case,
micro-ops retry entering the execution pipe in the next cycle and the
ROB-read port stall is counted again.
.It Li RAT_STALLS.SCOREBOARD
.Pq Event D2H , Umask 08H
Counts the cycles where we stall due to microarchitecturally required
-serialization. Microcode scoreboarding stalls.
+serialization.
+Microcode scoreboarding stalls.
.It Li RAT_STALLS.ANY
.Pq Event D2H , Umask 0FH
Counts all Register Allocation Table stall cycles due to: Cycles when ROB
read port stalls occurred, which did not allow new micro-ops to enter the
-execution pipe. Cycles when partial register stalls occurred Cycles when
+execution pipe.
+Cycles when partial register stalls occurred Cycles when
flag stalls occurred Cycles floating-point unit (FPU) status word stalls
-occurred. To count each of these conditions separately use the events:
+occurred.
+To count each of these conditions separately use the events:
RAT_STALLS.ROB_READ_PORT, RAT_STALLS.PARTIAL, RAT_STALLS.FLAGS, and
RAT_STALLS.FPSW.
.It Li SEG_RENAME_STALLS
.Pq Event D4H , Umask 01H
Counts the number of stall cycles due to the lack of renaming resources for
-the ES, DS, FS, and GS segment registers. If a segment is renamed but not
+the ES, DS, FS, and GS segment registers.
+If a segment is renamed but not
retired and a second update to the same segment occurs, a stall occurs in
the front- end of the pipeline until the renamed segment retires.
.It Li ES_REG_RENAMES
@@ -1176,16 +1241,18 @@ or return branch.
.Pq Event E6H , Umask 01H
Counts the number of times the front end is resteered, mainly when the
Branch Prediction Unit cannot provide a correct prediction and this is
-corrected by the Branch Address Calculator at the front end. This can occur
+corrected by the Branch Address Calculator at the front end.
+This can occur
if the code has many branches such that they cannot be consumed by the BPU.
Each BACLEAR asserted by the BAC generates approximately an 8 cycle bubble
-in the instruction fetch pipeline. The effect on total execution time
-depends on the surrounding code.
+in the instruction fetch pipeline.
+The effect on total execution time depends on the surrounding code.
.It Li BACLEAR.BAD_TARGET
.Pq Event E6H , Umask 02H
Counts number of Branch Address Calculator clears (BACLEAR) asserted due to
conditional branch instructions in which there was a target hit but the
-direction was wrong. Each BACLEAR asserted by the BAC generates
+direction was wrong.
+Each BACLEAR asserted by the BAC generates
approximately an 8 cycle bubble in the instruction fetch pipeline.
.It Li BPU_CLEARS.EARLY
.Pq Event E8H , Umask 01H
@@ -1195,7 +1262,8 @@ The BPU clear leads to 2 cycle bubble in the Front End.
.It Li BPU_CLEARS.LATE
.Pq Event E8H , Umask 02H
Counts late Branch Prediction Unit clears due to Most Recently Used
-conflicts. The PBU clear leads to a 3 cycle bubble in the Front End.
+conflicts.
+The PBU clear leads to a 3 cycle bubble in the Front End.
.It Li THREAD_ACTIVE
.Pq Event ECH , Umask 01H
Counts cycles threads are active.
@@ -1258,12 +1326,13 @@ Counts number of Super Queue LRU hints sent to L3.
Counts the number of SQ lock splits across a cache line.
.It Li SQ_FULL_STALL_CYCLES
.Pq Event F6H , Umask 01H
-Counts cycles the Super Queue is full. Neither of the threads on this core
-will be able to access the uncore.
+Counts cycles the Super Queue is full.
+Neither of the threads on this core will be able to access the uncore.
.It Li FP_ASSIST.ALL
.Pq Event F7H , Umask 01H
Counts the number of floating point operations executed that required
-micro-code assist intervention. Assists are required in the following cases:
+micro-code assist intervention.
+Assists are required in the following cases:
SSE instructions, (Denormal input when the DAZ flag is off or Underflow
result when the FTZ flag is off): x87 instructions, (NaN or denormal are
loaded to a register or used as input from memory, Division by 0 or
@@ -1312,6 +1381,7 @@ Counts number of SID integer 64 bit shift or move operations.
.Xr pmc.corei7 3 ,
.Xr pmc.corei7uc 3 ,
.Xr pmc.westmereuc 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc_cpuinfo 3 ,
.Xr pmclog 3 ,
diff --git a/lib/libpmc/pmc.westmereuc.3 b/lib/libpmc/pmc.westmereuc.3
index 525c05f989bf..517c470fbe7d 100644
--- a/lib/libpmc/pmc.westmereuc.3
+++ b/lib/libpmc/pmc.westmereuc.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -1066,6 +1066,7 @@ disabled.
.Xr pmc.corei7 3 ,
.Xr pmc.corei7uc 3 ,
.Xr pmc.westmere 3 ,
+.Xr pmc.soft 3 ,
.Xr pmc.tsc 3 ,
.Xr pmc_cpuinfo 3 ,
.Xr pmclog 3 ,
diff --git a/lib/libpmc/pmc.xscale.3 b/lib/libpmc/pmc.xscale.3
index 8a01dc5c69e3..965ea741203d 100644
--- a/lib/libpmc/pmc.xscale.3
+++ b/lib/libpmc/pmc.xscale.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Rui Paulo ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -45,7 +45,7 @@ have 4 counters.
Third generation cores also have an increased number of PMC events.
.Pp
.Tn Intel XScale
-PMCs are documented in
+PMCs are documented in
.Rs
.%B "3rd Generation Intel XScale Microarchitecture Developer's Manual"
.%D May 2007
@@ -117,23 +117,24 @@ Self initiated address bus transaction.
.It Li DATA_BUS_TRANS
Data bus transaction.
.El
-.Ss Event Name Aliases
+.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" "BRANCH_MISPRED"
-.It Em Alias Ta Em Event Ta
-.It Li branches Ta Li BRANCH_RETIRED Ta
-.It Li branch-mispredicts Ta Li BRANCH_MISPRED Ta
-.It Li dc-misses Ta Li DC_MISS Ta
-.It Li ic-misses Ta Li IC_MISS Ta
-.It Li instructions Ta Li INSTR_RETIRED Ta
+.It Em Alias Ta Em Event
+.It Li branches Ta Li BRANCH_RETIRED
+.It Li branch-mispredicts Ta Li BRANCH_MISPRED
+.It Li dc-misses Ta Li DC_MISS
+.It Li ic-misses Ta Li IC_MISS
+.It Li instructions Ta Li INSTR_RETIRED
.El
.Sh SEE ALSO
.Xr pmc 3 ,
.Xr pmc_cpuinfo 3 ,
.Xr pmclog 3 ,
+.Xr pmc.soft 3 ,
.Xr hwpmc 4
.Sh HISTORY
The
diff --git a/lib/libpmc/pmc_allocate.3 b/lib/libpmc/pmc_allocate.3
index 6a2a6c0d0f07..291ca8ac0113 100644
--- a/lib/libpmc/pmc_allocate.3
+++ b/lib/libpmc/pmc_allocate.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
diff --git a/lib/libpmc/pmc_attach.3 b/lib/libpmc/pmc_attach.3
index ca725112b0b3..b53e78b85a87 100644
--- a/lib/libpmc/pmc_attach.3
+++ b/lib/libpmc/pmc_attach.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
diff --git a/lib/libpmc/pmc_capabilities.3 b/lib/libpmc/pmc_capabilities.3
index 6aee17f8bfb6..8c5916e38a8e 100644
--- a/lib/libpmc/pmc_capabilities.3
+++ b/lib/libpmc/pmc_capabilities.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
@@ -51,7 +51,7 @@
.Ft int
.Fn pmc_width "pmc_id_t pmc" "uint32_t *width"
.Sh DESCRIPTION
-These functions retrieve information about performance monitoring
+These functions retrieve information about performance monitoring
hardware.
.Pp
Function
diff --git a/lib/libpmc/pmc_configure_logfile.3 b/lib/libpmc/pmc_configure_logfile.3
index 399f21a7c542..4549b80d0741 100644
--- a/lib/libpmc/pmc_configure_logfile.3
+++ b/lib/libpmc/pmc_configure_logfile.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
diff --git a/lib/libpmc/pmc_disable.3 b/lib/libpmc/pmc_disable.3
index a6902ffd463f..96eb6df90d10 100644
--- a/lib/libpmc/pmc_disable.3
+++ b/lib/libpmc/pmc_disable.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
diff --git a/lib/libpmc/pmc_event_names_of_class.3 b/lib/libpmc/pmc_event_names_of_class.3
index 183f03f8967b..b38acf5808c8 100644
--- a/lib/libpmc/pmc_event_names_of_class.3
+++ b/lib/libpmc/pmc_event_names_of_class.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
diff --git a/lib/libpmc/pmc_get_driver_stats.3 b/lib/libpmc/pmc_get_driver_stats.3
index fa214b321a30..7d09cecceafe 100644
--- a/lib/libpmc/pmc_get_driver_stats.3
+++ b/lib/libpmc/pmc_get_driver_stats.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
diff --git a/lib/libpmc/pmc_get_msr.3 b/lib/libpmc/pmc_get_msr.3
index 6361d3adab2d..80add1800e45 100644
--- a/lib/libpmc/pmc_get_msr.3
+++ b/lib/libpmc/pmc_get_msr.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
diff --git a/lib/libpmc/pmc_init.3 b/lib/libpmc/pmc_init.3
index 655bfb6f78b0..2bc7c819ad95 100644
--- a/lib/libpmc/pmc_init.3
+++ b/lib/libpmc/pmc_init.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
diff --git a/lib/libpmc/pmc_name_of_capability.3 b/lib/libpmc/pmc_name_of_capability.3
index 78efeafd6ac7..ff02a15cf56d 100644
--- a/lib/libpmc/pmc_name_of_capability.3
+++ b/lib/libpmc/pmc_name_of_capability.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
diff --git a/lib/libpmc/pmc_read.3 b/lib/libpmc/pmc_read.3
index d091716936aa..f10885fb0352 100644
--- a/lib/libpmc/pmc_read.3
+++ b/lib/libpmc/pmc_read.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
diff --git a/lib/libpmc/pmc_set.3 b/lib/libpmc/pmc_set.3
index e8d65971dd29..99f5ebeeec4d 100644
--- a/lib/libpmc/pmc_set.3
+++ b/lib/libpmc/pmc_set.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
diff --git a/lib/libpmc/pmc_start.3 b/lib/libpmc/pmc_start.3
index 2272122dd19b..978c57e362e1 100644
--- a/lib/libpmc/pmc_start.3
+++ b/lib/libpmc/pmc_start.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
diff --git a/lib/libpmc/pmclog.3 b/lib/libpmc/pmclog.3
index 4438f106d0bc..91c7222da7f2 100644
--- a/lib/libpmc/pmclog.3
+++ b/lib/libpmc/pmclog.3
@@ -9,17 +9,17 @@
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
-.\" This software is provided by Joseph Koshy ``as is'' and
-.\" any express or implied warranties, including, but not limited to, the
-.\" implied warranties of merchantability and fitness for a particular purpose
-.\" are disclaimed. in no event shall Joseph Koshy be liable
-.\" for any direct, indirect, incidental, special, exemplary, or consequential
-.\" damages (including, but not limited to, procurement of substitute goods
-.\" or services; loss of use, data, or profits; or business interruption)
-.\" however caused and on any theory of liability, whether in contract, strict
-.\" liability, or tort (including negligence or otherwise) arising in any way
-.\" out of the use of this software, even if advised of the possibility of
-.\" such damage.
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED 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.
.\"
.\" $FreeBSD$
.\"
diff --git a/lib/libpmc/pmclog.c b/lib/libpmc/pmclog.c
index d9ebc674ab65..26ec9ddaab02 100644
--- a/lib/libpmc/pmclog.c
+++ b/lib/libpmc/pmclog.c
@@ -369,6 +369,12 @@ pmclog_get_event(void *cookie, char **data, ssize_t *len,
== NULL)
goto error;
break;
+ case PMCLOG_TYPE_PMCALLOCATEDYN:
+ PMCLOG_READ32(le,ev->pl_u.pl_ad.pl_pmcid);
+ PMCLOG_READ32(le,ev->pl_u.pl_ad.pl_event);
+ PMCLOG_READ32(le,ev->pl_u.pl_ad.pl_flags);
+ PMCLOG_READSTRING(le,ev->pl_u.pl_ad.pl_evname,PMC_NAME_MAX);
+ break;
case PMCLOG_TYPE_PMCATTACH:
PMCLOG_GET_PATHLEN(pathlen,evlen,pmclog_pmcattach);
PMCLOG_READ32(le,ev->pl_u.pl_t.pl_pmcid);
diff --git a/lib/libpmc/pmclog.h b/lib/libpmc/pmclog.h
index b7c9c847628c..2a50945e372e 100644
--- a/lib/libpmc/pmclog.h
+++ b/lib/libpmc/pmclog.h
@@ -88,6 +88,13 @@ struct pmclog_ev_pmcallocate {
pmc_id_t pl_pmcid;
};
+struct pmclog_ev_pmcallocatedyn {
+ uint32_t pl_event;
+ char pl_evname[PMC_NAME_MAX];
+ uint32_t pl_flags;
+ pmc_id_t pl_pmcid;
+};
+
struct pmclog_ev_pmcattach {
pmc_id_t pl_pmcid;
pid_t pl_pid;
@@ -146,6 +153,7 @@ struct pmclog_ev {
struct pmclog_ev_map_out pl_mo;
struct pmclog_ev_pcsample pl_s;
struct pmclog_ev_pmcallocate pl_a;
+ struct pmclog_ev_pmcallocatedyn pl_ad;
struct pmclog_ev_pmcattach pl_t;
struct pmclog_ev_pmcdetach pl_d;
struct pmclog_ev_proccsw pl_c;
diff --git a/lib/libproc/proc_bkpt.c b/lib/libproc/proc_bkpt.c
index c4264717fb65..e16b0fcf80a3 100644
--- a/lib/libproc/proc_bkpt.c
+++ b/lib/libproc/proc_bkpt.c
@@ -44,6 +44,9 @@ __FBSDID("$FreeBSD$");
#if defined(__i386__) || defined(__amd64__)
#define BREAKPOINT_INSTR 0xcc /* int 0x3 */
#define BREAKPOINT_INSTR_SZ 1
+#elif defined(__mips__)
+#define BREAKPOINT_INSTR 0xd /* break */
+#define BREAKPOINT_INSTR_SZ 4
#else
#error "Add support for your architecture"
#endif
diff --git a/lib/libproc/proc_regs.c b/lib/libproc/proc_regs.c
index 3450e98acf74..c299b9b49203 100644
--- a/lib/libproc/proc_regs.c
+++ b/lib/libproc/proc_regs.c
@@ -58,6 +58,8 @@ proc_regget(struct proc_handle *phdl, proc_reg_t reg, unsigned long *regvalue)
*regvalue = regs.r_rip;
#elif defined(__i386__)
*regvalue = regs.r_eip;
+#elif defined(__mips__)
+ *regvalue = regs.r_regs[PC];
#endif
break;
case REG_SP:
@@ -65,6 +67,8 @@ proc_regget(struct proc_handle *phdl, proc_reg_t reg, unsigned long *regvalue)
*regvalue = regs.r_rsp;
#elif defined(__i386__)
*regvalue = regs.r_esp;
+#elif defined(__mips__)
+ *regvalue = regs.r_regs[SP];
#endif
break;
default:
@@ -93,6 +97,8 @@ proc_regset(struct proc_handle *phdl, proc_reg_t reg, unsigned long regvalue)
regs.r_rip = regvalue;
#elif defined(__i386__)
regs.r_eip = regvalue;
+#elif defined(__mips__)
+ regs.r_regs[PC] = regvalue;
#endif
break;
case REG_SP:
@@ -100,6 +106,8 @@ proc_regset(struct proc_handle *phdl, proc_reg_t reg, unsigned long regvalue)
regs.r_rsp = regvalue;
#elif defined(__i386__)
regs.r_esp = regvalue;
+#elif defined(__mips__)
+ regs.r_regs[PC] = regvalue;
#endif
break;
default:
diff --git a/lib/libprocstat/Symbol.map b/lib/libprocstat/Symbol.map
index b5d64d0ff78e..0509066369f0 100644
--- a/lib/libprocstat/Symbol.map
+++ b/lib/libprocstat/Symbol.map
@@ -14,3 +14,7 @@ FBSD_1.2 {
procstat_open_kvm;
procstat_open_sysctl;
};
+
+FBSD_1.3 {
+ procstat_get_shm_info;
+};
diff --git a/lib/libprocstat/Versions.def b/lib/libprocstat/Versions.def
index d69f5c996f75..ed958db0635d 100644
--- a/lib/libprocstat/Versions.def
+++ b/lib/libprocstat/Versions.def
@@ -3,3 +3,8 @@
# This version was first added to 9.0-current.
FBSD_1.2 {
};
+
+# This version was first added to 10.0-current.
+FBSD_1.3 {
+} FBSD_1.2;
+
diff --git a/lib/libprocstat/common_kvm.c b/lib/libprocstat/common_kvm.c
index 1ff181c8077a..63302bc4f6ed 100644
--- a/lib/libprocstat/common_kvm.c
+++ b/lib/libprocstat/common_kvm.c
@@ -80,7 +80,7 @@ kdevtoname(kvm_t *kd, struct cdev *dev, char *buf)
assert(buf);
if (!kvm_read_all(kd, (unsigned long)dev, &si, sizeof(si)))
return (1);
- strlcpy(buf, si.__si_namebuf, SPECNAMELEN + 1);
+ strlcpy(buf, si.si_name, SPECNAMELEN + 1);
return (0);
}
diff --git a/lib/libprocstat/libprocstat.3 b/lib/libprocstat/libprocstat.3
index 49799f5e6ff8..07fffb24001a 100644
--- a/lib/libprocstat/libprocstat.3
+++ b/lib/libprocstat/libprocstat.3
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 12, 2011
+.Dd April 1, 2012
.Dt LIBPROCSTAT 3
.Os
.Sh NAME
@@ -37,6 +37,7 @@
.Nm procstat_freeprocs ,
.Nm procstat_get_pipe_info ,
.Nm procstat_get_pts_info ,
+.Nm procstat_get_shm_info ,
.Nm procstat_get_socket_info ,
.Nm procstat_get_vnode_info
.Nd library interface for file and process information retrieval
@@ -70,6 +71,13 @@
.Fa "char *errbuf"
.Fc
.Ft int
+.Fo procstat_get_shm_info
+.Fa "struct procstat *procstat"
+.Fa "struct filestat *fst"
+.Fa "struct shmstat *shm"
+.Fa "char *errbuf"
+.Fc
+.Ft int
.Fo procstat_get_socket_info
.Fa "struct procstat *procstat"
.Fa "struct filestat *fst"
@@ -191,10 +199,12 @@ function call.
The
.Fn procstat_get_pipe_info ,
.Fn procstat_get_pts_info ,
+.Fn procstat_get_shm_info ,
.Fn procstat_get_socket_info
and
.Fn procstat_get_vnode_info
functions are used to retrive information about pipes, pseudo-terminals,
+shared memory objects,
sockets, and vnodes, respectively.
Each of them have a similar interface API.
The
@@ -231,11 +241,14 @@ argument indicates an actual error message in case of failure.
.Nm procstat_get_pipe_info
.It Li PS_FST_TYPE_PTS
.Nm procstat_get_pts_info
+.It Li PS_FST_TYPE_SHM
+.Nm procstat_get_shm_info
.El
.Sh SEE ALSO
.Xr fstat 1 ,
.Xr fuser 1 ,
.Xr pipe 2 ,
+.Xr shm_open 2 ,
.Xr socket 2 ,
.Xr kvm 3 ,
.Xr queue 3 ,
diff --git a/lib/libprocstat/libprocstat.c b/lib/libprocstat/libprocstat.c
index facce1136f46..167d91aba933 100644
--- a/lib/libprocstat/libprocstat.c
+++ b/lib/libprocstat/libprocstat.c
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
#define _WANT_FILE
#include <sys/file.h>
#include <sys/conf.h>
+#include <sys/mman.h>
#define _KERNEL
#include <sys/mount.h>
#include <sys/pipe.h>
@@ -114,6 +115,10 @@ static int procstat_get_pts_info_sysctl(struct filestat *fst,
struct ptsstat *pts, char *errbuf);
static int procstat_get_pts_info_kvm(kvm_t *kd, struct filestat *fst,
struct ptsstat *pts, char *errbuf);
+static int procstat_get_shm_info_sysctl(struct filestat *fst,
+ struct shmstat *shm, char *errbuf);
+static int procstat_get_shm_info_kvm(kvm_t *kd, struct filestat *fst,
+ struct shmstat *shm, char *errbuf);
static int procstat_get_socket_info_sysctl(struct filestat *fst,
struct sockstat *sock, char *errbuf);
static int procstat_get_socket_info_kvm(kvm_t *kd, struct filestat *fst,
@@ -469,6 +474,10 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
data = file.f_data;
break;
#endif
+ case DTYPE_SHM:
+ type = PS_FST_TYPE_SHM;
+ data = file.f_data;
+ break;
default:
continue;
}
@@ -849,6 +858,69 @@ procstat_get_pts_info_sysctl(struct filestat *fst, struct ptsstat *pts,
}
int
+procstat_get_shm_info(struct procstat *procstat, struct filestat *fst,
+ struct shmstat *shm, char *errbuf)
+{
+
+ assert(shm);
+ if (procstat->type == PROCSTAT_KVM) {
+ return (procstat_get_shm_info_kvm(procstat->kd, fst, shm,
+ errbuf));
+ } else if (procstat->type == PROCSTAT_SYSCTL) {
+ return (procstat_get_shm_info_sysctl(fst, shm, errbuf));
+ } else {
+ warnx("unknown access method: %d", procstat->type);
+ snprintf(errbuf, _POSIX2_LINE_MAX, "error");
+ return (1);
+ }
+}
+
+static int
+procstat_get_shm_info_kvm(kvm_t *kd, struct filestat *fst,
+ struct shmstat *shm, char *errbuf)
+{
+ struct shmfd shmfd;
+ void *shmfdp;
+
+ assert(kd);
+ assert(shm);
+ assert(fst);
+ bzero(shm, sizeof(*shm));
+ shmfdp = fst->fs_typedep;
+ if (shmfdp == NULL)
+ goto fail;
+ if (!kvm_read_all(kd, (unsigned long)shmfdp, &shmfd,
+ sizeof(struct shmfd))) {
+ warnx("can't read shmfd at %p", (void *)shmfdp);
+ goto fail;
+ }
+ shm->mode = S_IFREG | shmfd.shm_mode;
+ shm->size = shmfd.shm_size;
+ return (0);
+
+fail:
+ snprintf(errbuf, _POSIX2_LINE_MAX, "error");
+ return (1);
+}
+
+static int
+procstat_get_shm_info_sysctl(struct filestat *fst, struct shmstat *shm,
+ char *errbuf __unused)
+{
+ struct kinfo_file *kif;
+
+ assert(shm);
+ assert(fst);
+ bzero(shm, sizeof(*shm));
+ kif = fst->fs_typedep;
+ if (kif == NULL)
+ return (0);
+ shm->size = kif->kf_un.kf_file.kf_file_size;
+ shm->mode = kif->kf_un.kf_file.kf_file_mode;
+ return (0);
+}
+
+int
procstat_get_vnode_info(struct procstat *procstat, struct filestat *fst,
struct vnstat *vn, char *errbuf)
{
diff --git a/lib/libprocstat/libprocstat.h b/lib/libprocstat/libprocstat.h
index f1ca109afcbb..c00a179dae54 100644
--- a/lib/libprocstat/libprocstat.h
+++ b/lib/libprocstat/libprocstat.h
@@ -123,6 +123,10 @@ struct pipestat {
uint64_t addr;
uint64_t peer;
};
+struct shmstat {
+ uint64_t size;
+ uint16_t mode;
+};
struct sockstat {
uint64_t inp_ppcb;
uint64_t so_addr;
@@ -152,6 +156,8 @@ 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,
struct ptsstat *pts, char *errbuf);
+int procstat_get_shm_info(struct procstat *procstat, struct filestat *fst,
+ struct shmstat *shm, char *errbuf);
int procstat_get_socket_info(struct procstat *procstat, struct filestat *fst,
struct sockstat *sock, char *errbuf);
int procstat_get_vnode_info(struct procstat *procstat, struct filestat *fst,
diff --git a/lib/libradius/libradius.3 b/lib/libradius/libradius.3
index dca38ca009ee..da60d52474bb 100644
--- a/lib/libradius/libradius.3
+++ b/lib/libradius/libradius.3
@@ -51,14 +51,14 @@
.Fn rad_create_response "struct rad_handle *h" "int code"
.Ft "struct in_addr"
.Fn rad_cvt_addr "const void *data"
-.Ft u_int32_t
+.Ft uint32_t
.Fn rad_cvt_int "const void *data"
.Ft char *
.Fn rad_cvt_string "const void *data" "size_t len"
.Ft int
.Fn rad_get_attr "struct rad_handle *h" "const void **data" "size_t *len"
.Ft int
-.Fn rad_get_vendor_attr "u_int32_t *vendor" "const void **data" "size_t *len"
+.Fn rad_get_vendor_attr "uint32_t *vendor" "const void **data" "size_t *len"
.Ft int
.Fn rad_init_send_request "struct rad_handle *h" "int *fd" "struct timeval *tv"
.Ft int
@@ -66,7 +66,7 @@
.Ft int
.Fn rad_put_attr "struct rad_handle *h" "int type" "const void *data" "size_t len"
.Ft int
-.Fn rad_put_int "struct rad_handle *h" "int type" "u_int32_t value"
+.Fn rad_put_int "struct rad_handle *h" "int type" "uint32_t value"
.Ft int
.Fn rad_put_string "struct rad_handle *h" "int type" "const char *str"
.Ft int
@@ -76,7 +76,7 @@
.Ft int
.Fn rad_put_vendor_attr "struct rad_handle *h" "int vendor" "int type" "const void *data" "size_t len"
.Ft int
-.Fn rad_put_vendor_int "struct rad_handle *h" "int vendor" "int type" "u_int32_t value"
+.Fn rad_put_vendor_int "struct rad_handle *h" "int vendor" "int type" "uint32_t value"
.Ft int
.Fn rad_put_vendor_string "struct rad_handle *h" "int vendor" "int type" "const char *str"
.Ft ssize_t
diff --git a/lib/librpcsec_gss/rpc_gss_seccreate.3 b/lib/librpcsec_gss/rpc_gss_seccreate.3
index 7a5a0cd73d8a..63978a5801a0 100644
--- a/lib/librpcsec_gss/rpc_gss_seccreate.3
+++ b/lib/librpcsec_gss/rpc_gss_seccreate.3
@@ -70,7 +70,7 @@ The default - typically the same as
RPC headers only are integrity protected by a checksum.
.It rpc_gss_svc_integrity
RPC headers and data are integrity protected by a checksum.
-.It rpc_gss_svc_privacy
+.It rpc_gss_svc_privacy
RPC headers are integrity protected by a checksum and data is encrypted.
.El
.It qop
diff --git a/lib/librpcsvc/Makefile b/lib/librpcsvc/Makefile
index 8bb745882984..9c9e3ae04d53 100644
--- a/lib/librpcsvc/Makefile
+++ b/lib/librpcsvc/Makefile
@@ -18,7 +18,7 @@ SECRPCSRCS= secretkey.c xcrypt.c
OTHERSRCS+= yp_passwd.c yp_update.c
.endif
-RPCCOM = rpcgen -C
+RPCCOM= RPCGEN_CPP=${CPP:Q} rpcgen -C
INCDIRS= -I${DESTDIR}/usr/include/rpcsvc
diff --git a/lib/librt/sigev_thread.c b/lib/librt/sigev_thread.c
index 227733069b9b..0246c0c339cb 100644
--- a/lib/librt/sigev_thread.c
+++ b/lib/librt/sigev_thread.c
@@ -224,11 +224,11 @@ __sigev_get_sigevent(struct sigev_node *sn, struct sigevent *newevp,
sigev_id_t id)
{
/*
- * Build a new sigevent, and tell kernel to deliver SIGSERVICE
+ * Build a new sigevent, and tell kernel to deliver SIGLIBRT
* signal to the new thread.
*/
newevp->sigev_notify = SIGEV_THREAD_ID;
- newevp->sigev_signo = SIGSERVICE;
+ newevp->sigev_signo = SIGLIBRT;
newevp->sigev_notify_thread_id = (lwpid_t)sn->sn_tn->tn_lwpid;
newevp->sigev_value.sival_ptr = (void *)id;
}
@@ -279,7 +279,7 @@ __sigev_delete_node(struct sigev_node *sn)
LIST_REMOVE(sn, sn_link);
if (--sn->sn_tn->tn_refcount == 0)
- _pthread_kill(sn->sn_tn->tn_thread, SIGSERVICE);
+ _pthread_kill(sn->sn_tn->tn_thread, SIGLIBRT);
if (sn->sn_flags & SNF_WORKING)
sn->sn_flags |= SNF_REMOVED;
else
@@ -326,7 +326,7 @@ sigev_thread_create(int usedefault)
LIST_INSERT_HEAD(&sigev_threads, tn, tn_link);
__sigev_list_unlock();
- sigfillset(&set); /* SIGSERVICE is masked. */
+ sigfillset(&set); /* SIGLIBRT is masked. */
sigdelset(&set, SIGBUS);
sigdelset(&set, SIGILL);
sigdelset(&set, SIGFPE);
@@ -378,7 +378,7 @@ sigev_service_loop(void *arg)
__sigev_list_unlock();
sigemptyset(&set);
- sigaddset(&set, SIGSERVICE);
+ sigaddset(&set, SIGLIBRT);
for (;;) {
ret = sigwaitinfo(&set, &si);
diff --git a/lib/librt/sigev_thread.h b/lib/librt/sigev_thread.h
index 7e30c2a16fd5..f94afa5461af 100644
--- a/lib/librt/sigev_thread.h
+++ b/lib/librt/sigev_thread.h
@@ -67,8 +67,6 @@ struct sigev_thread {
#define SNF_REMOVED 0x02
#define SNF_SYNC 0x04
-#define SIGSERVICE (SIGTHR+1)
-
int __sigev_check_init();
struct sigev_node *__sigev_alloc(int, const struct sigevent *,
struct sigev_node *, int);
diff --git a/lib/libsm/Makefile b/lib/libsm/Makefile
index 661e87a6e7aa..f2f19fb4cf4a 100644
--- a/lib/libsm/Makefile
+++ b/lib/libsm/Makefile
@@ -18,12 +18,10 @@ CFLAGS+=${SENDMAIL_CFLAGS}
WARNS?= 2
-.if ${CC:T:Mclang} == "clang"
# Unfortunately, clang gives warnings about sendmail code that cannot
# be turned off yet. Since this is contrib code, and we don't really
# care about the warnings, just make them non-fatal for now.
-NO_WERROR=
-.endif
+NO_WERROR.clang=
LIB= sm
diff --git a/lib/libstdthreads/thrd_create.3 b/lib/libstdthreads/thrd_create.3
index ede0d7f2d8fd..5cd960890f2c 100644
--- a/lib/libstdthreads/thrd_create.3
+++ b/lib/libstdthreads/thrd_create.3
@@ -110,7 +110,7 @@
.Fn tss_set "tss_t key" "void *val"
.Sh DESCRIPTION
As of
-.St -isoC-11 ,
+.St -isoC-2011 ,
the C standard includes an API for writing multithreaded applications.
Since POSIX.1 already includes a threading API that is used by virtually
any multithreaded application, the interface provided by the C standard
@@ -252,7 +252,7 @@ code
.Xr pthread 3
.Sh STANDARDS
These functions are expected to conform to
-.St -isoC-11 .
+.St -isoC-2011 .
.Sh HISTORY
These functions appeared in
.Fx 10.0 .
diff --git a/lib/libtacplus/libtacplus.3 b/lib/libtacplus/libtacplus.3
index d74e1e145ea0..f247a280da62 100644
--- a/lib/libtacplus/libtacplus.3
+++ b/lib/libtacplus/libtacplus.3
@@ -380,7 +380,7 @@ the request, and waits for a reply.
On failure,
.Fn tac_send_acct
returns \-1.
-Otherwise, it returns the TACACS+ status code
+Otherwise, it returns the TACACS+ status code
Possible status codes, defined in
.In taclib.h ,
include:
@@ -393,7 +393,6 @@ include:
.It
.Dv TAC_ACCT_STATUS_FOLLOW
.El
-.Pp
.Sh EXTRACTING INFORMATION FROM THE SERVER'S AUTHORIZATION RESPONSE
Like an authentication response packet, an authorization
response packet from the
diff --git a/lib/libthr/arch/arm/arm/pthread_md.c b/lib/libthr/arch/arm/arm/pthread_md.c
index 7ca2b25dcf9c..028f06c17933 100644
--- a/lib/libthr/arch/arm/arm/pthread_md.c
+++ b/lib/libthr/arch/arm/arm/pthread_md.c
@@ -37,14 +37,17 @@ _tcb_ctor(struct pthread *thread, int initial)
{
struct tcb *tcb;
- tcb = malloc(sizeof(struct tcb));
+ tcb = _rtld_allocate_tls((initial) ? _tcb_get() : NULL,
+ sizeof(struct tcb), 16);
if (tcb)
tcb->tcb_thread = thread;
+
return (tcb);
}
void
_tcb_dtor(struct tcb *tcb)
{
- free(tcb);
+
+ _rtld_free_tls(tcb, sizeof(struct tcb), 16);
}
diff --git a/lib/libthr/arch/arm/include/pthread_md.h b/lib/libthr/arch/arm/include/pthread_md.h
index e799c542feb3..83ddf7f85951 100644
--- a/lib/libthr/arch/arm/include/pthread_md.h
+++ b/lib/libthr/arch/arm/include/pthread_md.h
@@ -43,10 +43,8 @@
* Variant II tcb, first two members are required by rtld.
*/
struct tcb {
- struct tcb *tcb_self; /* required by rtld */
void *tcb_dtv; /* required by rtld */
struct pthread *tcb_thread; /* our hook */
- void *tcb_spare[1];
};
/*
diff --git a/lib/libthr/arch/mips/include/pthread_md.h b/lib/libthr/arch/mips/include/pthread_md.h
index 24139a3a71f1..19c9f38193dc 100644
--- a/lib/libthr/arch/mips/include/pthread_md.h
+++ b/lib/libthr/arch/mips/include/pthread_md.h
@@ -35,19 +35,19 @@
#include <sys/types.h>
#include <machine/sysarch.h>
+#include <machine/tls.h>
#include <stddef.h>
#define CPU_SPINWAIT
#define DTV_OFFSET offsetof(struct tcb, tcb_dtv)
/*
- * Variant II tcb, first two members are required by rtld.
+ * Variant I tcb. The structure layout is fixed, don't blindly
+ * change it!
*/
struct tcb {
- struct tcb *tcb_self; /* required by rtld */
- void *tcb_dtv; /* required by rtld */
- struct pthread *tcb_thread; /* our hook */
- void *tcb_spare[1];
+ void *tcb_dtv;
+ struct pthread *tcb_thread;
};
/*
@@ -70,7 +70,7 @@ _tcb_set(struct tcb *tcb)
static __inline struct tcb *
_tcb_get(void)
{
- void *tcb;
+ struct tcb *tcb;
sysarch(MIPS_GET_TLS, &tcb);
return tcb;
diff --git a/lib/libthr/arch/mips/mips/pthread_md.c b/lib/libthr/arch/mips/mips/pthread_md.c
index 53ac5971da1a..e596edc0e2ec 100644
--- a/lib/libthr/arch/mips/mips/pthread_md.c
+++ b/lib/libthr/arch/mips/mips/pthread_md.c
@@ -34,6 +34,8 @@ __FBSDID("$FreeBSD$");
#include <rtld_tls.h>
#include <strings.h>
+#include <machine/sysarch.h>
+
#include "pthread_md.h"
struct tcb *
@@ -41,16 +43,17 @@ _tcb_ctor(struct pthread *thread, int initial)
{
struct tcb *tcb;
- tcb = malloc(sizeof(struct tcb));
- if (tcb) {
- bzero(tcb, sizeof(struct tcb));
+ tcb = _rtld_allocate_tls((initial) ? _tcb_get() : NULL,
+ sizeof(struct tcb), 16);
+ if (tcb)
tcb->tcb_thread = thread;
- }
+
return (tcb);
}
void
_tcb_dtor(struct tcb *tcb)
{
- free(tcb);
+
+ _rtld_free_tls(tcb, sizeof(struct tcb), 16);
}
diff --git a/lib/libthr/thread/thr_barrier.c b/lib/libthr/thread/thr_barrier.c
index bbd444708dee..86f880efac1d 100644
--- a/lib/libthr/thread/thr_barrier.c
+++ b/lib/libthr/thread/thr_barrier.c
@@ -42,13 +42,34 @@ int
_pthread_barrier_destroy(pthread_barrier_t *barrier)
{
pthread_barrier_t bar;
+ struct pthread *curthread;
if (barrier == NULL || *barrier == NULL)
return (EINVAL);
+ curthread = _get_curthread();
bar = *barrier;
- if (bar->b_waiters > 0)
+ THR_UMUTEX_LOCK(curthread, &bar->b_lock);
+ if (bar->b_destroying) {
+ THR_UMUTEX_UNLOCK(curthread, &bar->b_lock);
return (EBUSY);
+ }
+ bar->b_destroying = 1;
+ do {
+ if (bar->b_waiters > 0) {
+ bar->b_destroying = 0;
+ THR_UMUTEX_UNLOCK(curthread, &bar->b_lock);
+ return (EBUSY);
+ }
+ if (bar->b_refcount != 0) {
+ _thr_ucond_wait(&bar->b_cv, &bar->b_lock, NULL, 0);
+ THR_UMUTEX_LOCK(curthread, &bar->b_lock);
+ } else
+ break;
+ } while (1);
+ bar->b_destroying = 0;
+ THR_UMUTEX_UNLOCK(curthread, &bar->b_lock);
+
*barrier = NULL;
free(bar);
return (0);
@@ -74,6 +95,7 @@ _pthread_barrier_init(pthread_barrier_t *barrier,
bar->b_cycle = 0;
bar->b_waiters = 0;
bar->b_count = count;
+ bar->b_refcount = 0;
*barrier = bar;
return (0);
@@ -101,11 +123,14 @@ _pthread_barrier_wait(pthread_barrier_t *barrier)
ret = PTHREAD_BARRIER_SERIAL_THREAD;
} else {
cycle = bar->b_cycle;
+ bar->b_refcount++;
do {
_thr_ucond_wait(&bar->b_cv, &bar->b_lock, NULL, 0);
THR_UMUTEX_LOCK(curthread, &bar->b_lock);
/* test cycle to avoid bogus wakeup */
} while (cycle == bar->b_cycle);
+ if (--bar->b_refcount == 0 && bar->b_destroying)
+ _thr_ucond_broadcast(&bar->b_cv);
THR_UMUTEX_UNLOCK(curthread, &bar->b_lock);
ret = 0;
}
diff --git a/lib/libthr/thread/thr_list.c b/lib/libthr/thread/thr_list.c
index 249501cc5293..d27d87dac37c 100644
--- a/lib/libthr/thread/thr_list.c
+++ b/lib/libthr/thread/thr_list.c
@@ -149,11 +149,20 @@ _thr_alloc(struct pthread *curthread)
if (total_threads > MAX_THREADS)
return (NULL);
atomic_fetchadd_int(&total_threads, 1);
- thread = malloc(sizeof(struct pthread));
+ thread = calloc(1, sizeof(struct pthread));
if (thread == NULL) {
atomic_fetchadd_int(&total_threads, -1);
return (NULL);
}
+ if ((thread->sleepqueue = _sleepq_alloc()) == NULL ||
+ (thread->wake_addr = _thr_alloc_wake_addr()) == NULL) {
+ thr_destroy(curthread, thread);
+ atomic_fetchadd_int(&total_threads, -1);
+ return (NULL);
+ }
+ } else {
+ bzero(&thread->_pthread_startzero,
+ __rangeof(struct pthread, _pthread_startzero, _pthread_endzero));
}
if (curthread != NULL) {
THR_LOCK_ACQUIRE(curthread, &tcb_lock);
@@ -163,10 +172,7 @@ _thr_alloc(struct pthread *curthread)
tcb = _tcb_ctor(thread, 1 /* initial tls */);
}
if (tcb != NULL) {
- memset(thread, 0, sizeof(*thread));
thread->tcb = tcb;
- thread->sleepqueue = _sleepq_alloc();
- thread->wake_addr = _thr_alloc_wake_addr();
} else {
thr_destroy(curthread, thread);
atomic_fetchadd_int(&total_threads, -1);
@@ -194,8 +200,6 @@ _thr_free(struct pthread *curthread, struct pthread *thread)
}
thread->tcb = NULL;
if ((curthread == NULL) || (free_thread_count >= MAX_CACHED_THREADS)) {
- _sleepq_free(thread->sleepqueue);
- _thr_release_wake_addr(thread->wake_addr);
thr_destroy(curthread, thread);
atomic_fetchadd_int(&total_threads, -1);
} else {
@@ -213,6 +217,10 @@ _thr_free(struct pthread *curthread, struct pthread *thread)
static void
thr_destroy(struct pthread *curthread __unused, struct pthread *thread)
{
+ if (thread->sleepqueue != NULL)
+ _sleepq_free(thread->sleepqueue);
+ if (thread->wake_addr != NULL)
+ _thr_release_wake_addr(thread->wake_addr);
free(thread);
}
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h
index 9b9227b2bece..4469f6bea345 100644
--- a/lib/libthr/thread/thr_private.h
+++ b/lib/libthr/thread/thr_private.h
@@ -80,7 +80,7 @@ typedef TAILQ_HEAD(atfork_head, pthread_atfork) atfork_head;
TAILQ_HEAD(mutex_queue, pthread_mutex);
/* Signal to do cancellation */
-#define SIGCANCEL 32
+#define SIGCANCEL SIGTHR
/*
* Kernel fatal error handler macro.
@@ -182,9 +182,11 @@ struct pthread_cond_attr {
struct pthread_barrier {
struct umutex b_lock;
struct ucond b_cv;
- volatile int64_t b_cycle;
- volatile int b_count;
- volatile int b_waiters;
+ int64_t b_cycle;
+ int b_count;
+ int b_waiters;
+ int b_refcount;
+ int b_destroying;
};
struct pthread_barrierattr {
@@ -343,6 +345,7 @@ struct pthread_key {
* Thread structure.
*/
struct pthread {
+#define _pthread_startzero tid
/* Kernel thread id. */
long tid;
#define TID_TERMINATED 1
@@ -506,12 +509,6 @@ struct pthread {
/* Event */
td_event_msg_t event_buf;
- struct wake_addr *wake_addr;
-#define WAKE_ADDR(td) ((td)->wake_addr)
-
- /* Sleep queue */
- struct sleepqueue *sleepqueue;
-
/* Wait channel */
void *wchan;
@@ -526,6 +523,14 @@ struct pthread {
/* Deferred threads from pthread_cond_signal. */
unsigned int *defer_waiters[MAX_DEFER_WAITERS];
+#define _pthread_endzero wake_addr
+
+ struct wake_addr *wake_addr;
+#define WAKE_ADDR(td) ((td)->wake_addr)
+
+ /* Sleep queue */
+ struct sleepqueue *sleepqueue;
+
};
#define THR_SHOULD_GC(thrd) \
@@ -829,8 +834,6 @@ ssize_t __sys_write(int, const void *, size_t);
void __sys_exit(int);
#endif
-int _umtx_op_err(void *, int op, u_long, void *, void *) __hidden;
-
static inline int
_thr_isthreaded(void)
{
diff --git a/lib/libthr/thread/thr_rwlock.c b/lib/libthr/thread/thr_rwlock.c
index ebdeae7e6113..397663e9c710 100644
--- a/lib/libthr/thread/thr_rwlock.c
+++ b/lib/libthr/thread/thr_rwlock.c
@@ -123,7 +123,6 @@ rwlock_rdlock_common(pthread_rwlock_t *rwlock, const struct timespec *abstime)
{
struct pthread *curthread = _get_curthread();
pthread_rwlock_t prwlock;
- struct timespec ts, ts2, *tsp;
int flags;
int ret;
@@ -162,18 +161,8 @@ rwlock_rdlock_common(pthread_rwlock_t *rwlock, const struct timespec *abstime)
return (EINVAL);
for (;;) {
- if (abstime) {
- clock_gettime(CLOCK_REALTIME, &ts);
- TIMESPEC_SUB(&ts2, abstime, &ts);
- if (ts2.tv_sec < 0 ||
- (ts2.tv_sec == 0 && ts2.tv_nsec <= 0))
- return (ETIMEDOUT);
- tsp = &ts2;
- } else
- tsp = NULL;
-
/* goto kernel and lock it */
- ret = __thr_rwlock_rdlock(&prwlock->lock, flags, tsp);
+ ret = __thr_rwlock_rdlock(&prwlock->lock, flags, abstime);
if (ret != EINTR)
break;
@@ -255,7 +244,6 @@ rwlock_wrlock_common (pthread_rwlock_t *rwlock, const struct timespec *abstime)
{
struct pthread *curthread = _get_curthread();
pthread_rwlock_t prwlock;
- struct timespec ts, ts2, *tsp;
int ret;
CHECK_AND_INIT_RWLOCK
@@ -275,18 +263,8 @@ rwlock_wrlock_common (pthread_rwlock_t *rwlock, const struct timespec *abstime)
return (EINVAL);
for (;;) {
- if (abstime != NULL) {
- clock_gettime(CLOCK_REALTIME, &ts);
- TIMESPEC_SUB(&ts2, abstime, &ts);
- if (ts2.tv_sec < 0 ||
- (ts2.tv_sec == 0 && ts2.tv_nsec <= 0))
- return (ETIMEDOUT);
- tsp = &ts2;
- } else
- tsp = NULL;
-
/* goto kernel and lock it */
- ret = __thr_rwlock_wrlock(&prwlock->lock, tsp);
+ ret = __thr_rwlock_wrlock(&prwlock->lock, abstime);
if (ret == 0) {
prwlock->owner = curthread;
break;
diff --git a/lib/libthr/thread/thr_sig.c b/lib/libthr/thread/thr_sig.c
index 66358dbec5f5..3dee8b7a66c3 100644
--- a/lib/libthr/thread/thr_sig.c
+++ b/lib/libthr/thread/thr_sig.c
@@ -32,6 +32,7 @@
#include <sys/signalvar.h>
#include <signal.h>
#include <errno.h>
+#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "un-namespace.h"
@@ -314,16 +315,24 @@ check_cancel(struct pthread *curthread, ucontext_t *ucp)
static void
check_deferred_signal(struct pthread *curthread)
{
- ucontext_t uc;
+ ucontext_t *uc;
struct sigaction act;
siginfo_t info;
if (__predict_true(curthread->deferred_siginfo.si_signo == 0))
return;
- getcontext(&uc);
+
+#if defined(__amd64__) || defined(__i386__)
+ uc = alloca(__getcontextx_size());
+ __fillcontextx((char *)uc);
+#else
+ ucontext_t ucv;
+ uc = &ucv;
+ getcontext(uc);
+#endif
if (curthread->deferred_siginfo.si_signo != 0) {
act = curthread->deferred_sigact;
- uc.uc_sigmask = curthread->deferred_sigmask;
+ uc->uc_sigmask = curthread->deferred_sigmask;
memcpy(&info, &curthread->deferred_siginfo, sizeof(siginfo_t));
/* remove signal */
curthread->deferred_siginfo.si_signo = 0;
@@ -334,7 +343,7 @@ check_deferred_signal(struct pthread *curthread)
tact.sa_handler = SIG_DFL;
_sigaction(info.si_signo, &tact, NULL);
}
- handle_signal(&act, info.si_signo, &info, &uc);
+ handle_signal(&act, info.si_signo, &info, uc);
}
}
@@ -449,7 +458,7 @@ _thr_signal_prefork(void)
{
int i;
- for (i = 1; i < _SIG_MAXSIG; ++i)
+ for (i = 1; i <= _SIG_MAXSIG; ++i)
_thr_rwl_rdlock(&_thr_sigact[i-1].lock);
}
@@ -458,7 +467,7 @@ _thr_signal_postfork(void)
{
int i;
- for (i = 1; i < _SIG_MAXSIG; ++i)
+ for (i = 1; i <= _SIG_MAXSIG; ++i)
_thr_rwl_unlock(&_thr_sigact[i-1].lock);
}
@@ -467,7 +476,7 @@ _thr_signal_postfork_child(void)
{
int i;
- for (i = 1; i < _SIG_MAXSIG; ++i)
+ for (i = 1; i <= _SIG_MAXSIG; ++i)
bzero(&_thr_sigact[i-1].lock, sizeof(struct urwlock));
}
diff --git a/lib/libthr/thread/thr_umtx.c b/lib/libthr/thread/thr_umtx.c
index e96237823d9b..a61dab023f52 100644
--- a/lib/libthr/thread/thr_umtx.c
+++ b/lib/libthr/thread/thr_umtx.c
@@ -109,23 +109,30 @@ __thr_umutex_lock_spin(struct umutex *mtx, uint32_t id)
int
__thr_umutex_timedlock(struct umutex *mtx, uint32_t id,
- const struct timespec *ets)
+ const struct timespec *abstime)
{
- struct timespec timo, cts;
+ struct _umtx_time *tm_p, timeout;
+ size_t tm_size;
uint32_t owner;
int ret;
- clock_gettime(CLOCK_REALTIME, &cts);
- TIMESPEC_SUB(&timo, ets, &cts);
-
- if (timo.tv_sec < 0)
- return (ETIMEDOUT);
+ if (abstime == NULL) {
+ tm_p = NULL;
+ tm_size = 0;
+ } else {
+ timeout._clockid = CLOCK_REALTIME;
+ timeout._flags = UMTX_ABSTIME;
+ timeout._timeout = *abstime;
+ tm_p = &timeout;
+ tm_size = sizeof(timeout);
+ }
for (;;) {
if ((mtx->m_flags & (UMUTEX_PRIO_PROTECT | UMUTEX_PRIO_INHERIT)) == 0) {
/* wait in kernel */
- ret = _umtx_op_err(mtx, UMTX_OP_MUTEX_WAIT, 0, 0, &timo);
+ ret = _umtx_op_err(mtx, UMTX_OP_MUTEX_WAIT, 0,
+ (void *)tm_size, __DECONST(void *, tm_p));
/* now try to lock it */
owner = mtx->m_owner;
@@ -133,18 +140,13 @@ __thr_umutex_timedlock(struct umutex *mtx, uint32_t id,
atomic_cmpset_acq_32(&mtx->m_owner, owner, id|owner))
return (0);
} else {
- ret = _umtx_op_err(mtx, UMTX_OP_MUTEX_LOCK, 0, 0, &timo);
+ ret = _umtx_op_err(mtx, UMTX_OP_MUTEX_LOCK, 0,
+ (void *)tm_size, __DECONST(void *, tm_p));
if (ret == 0)
break;
}
if (ret == ETIMEDOUT)
break;
- clock_gettime(CLOCK_REALTIME, &cts);
- TIMESPEC_SUB(&timo, ets, &cts);
- if (timo.tv_sec < 0 || (timo.tv_sec == 0 && timo.tv_nsec == 0)) {
- ret = ETIMEDOUT;
- break;
- }
}
return (ret);
}
@@ -152,13 +154,6 @@ __thr_umutex_timedlock(struct umutex *mtx, uint32_t id,
int
__thr_umutex_unlock(struct umutex *mtx, uint32_t id)
{
-#ifndef __ia64__
- /* XXX this logic has a race-condition on ia64. */
- if ((mtx->m_flags & (UMUTEX_PRIO_PROTECT | UMUTEX_PRIO_INHERIT)) == 0) {
- atomic_cmpset_rel_32(&mtx->m_owner, id | UMUTEX_CONTESTED, UMUTEX_CONTESTED);
- return _umtx_op_err(mtx, UMTX_OP_MUTEX_WAKE, 0, 0, 0);
- }
-#endif /* __ia64__ */
return _umtx_op_err(mtx, UMTX_OP_MUTEX_UNLOCK, 0, 0, 0);
}
@@ -200,20 +195,23 @@ int
_thr_umtx_timedwait_uint(volatile u_int *mtx, u_int id, int clockid,
const struct timespec *abstime, int shared)
{
- struct timespec ts, ts2, *tsp;
-
- if (abstime != NULL) {
- clock_gettime(clockid, &ts);
- TIMESPEC_SUB(&ts2, abstime, &ts);
- if (ts2.tv_sec < 0 || ts2.tv_nsec <= 0)
- return (ETIMEDOUT);
- tsp = &ts2;
+ struct _umtx_time *tm_p, timeout;
+ size_t tm_size;
+
+ if (abstime == NULL) {
+ tm_p = NULL;
+ tm_size = 0;
} else {
- tsp = NULL;
+ timeout._clockid = clockid;
+ timeout._flags = UMTX_ABSTIME;
+ timeout._timeout = *abstime;
+ tm_p = &timeout;
+ tm_size = sizeof(timeout);
}
+
return _umtx_op_err(__DEVOLATILE(void *, mtx),
- shared ? UMTX_OP_WAIT_UINT : UMTX_OP_WAIT_UINT_PRIVATE, id, NULL,
- tsp);
+ shared ? UMTX_OP_WAIT_UINT : UMTX_OP_WAIT_UINT_PRIVATE, id,
+ (void *)tm_size, __DECONST(void *, tm_p));
}
int
@@ -260,15 +258,42 @@ _thr_ucond_broadcast(struct ucond *cv)
}
int
-__thr_rwlock_rdlock(struct urwlock *rwlock, int flags, struct timespec *tsp)
+__thr_rwlock_rdlock(struct urwlock *rwlock, int flags,
+ const struct timespec *tsp)
{
- return _umtx_op_err(rwlock, UMTX_OP_RW_RDLOCK, flags, NULL, tsp);
+ struct _umtx_time timeout, *tm_p;
+ size_t tm_size;
+
+ if (tsp == NULL) {
+ tm_p = NULL;
+ tm_size = 0;
+ } else {
+ timeout._timeout = *tsp;
+ timeout._flags = UMTX_ABSTIME;
+ timeout._clockid = CLOCK_REALTIME;
+ tm_p = &timeout;
+ tm_size = sizeof(timeout);
+ }
+ return _umtx_op_err(rwlock, UMTX_OP_RW_RDLOCK, flags, (void *)tm_size, tm_p);
}
int
-__thr_rwlock_wrlock(struct urwlock *rwlock, struct timespec *tsp)
+__thr_rwlock_wrlock(struct urwlock *rwlock, const struct timespec *tsp)
{
- return _umtx_op_err(rwlock, UMTX_OP_RW_WRLOCK, 0, NULL, tsp);
+ struct _umtx_time timeout, *tm_p;
+ size_t tm_size;
+
+ if (tsp == NULL) {
+ tm_p = NULL;
+ tm_size = 0;
+ } else {
+ timeout._timeout = *tsp;
+ timeout._flags = UMTX_ABSTIME;
+ timeout._clockid = CLOCK_REALTIME;
+ tm_p = &timeout;
+ tm_size = sizeof(timeout);
+ }
+ return _umtx_op_err(rwlock, UMTX_OP_RW_WRLOCK, 0, (void *)tm_size, tm_p);
}
int
diff --git a/lib/libthr/thread/thr_umtx.h b/lib/libthr/thread/thr_umtx.h
index 0a8034b364e2..d74cc8121c6b 100644
--- a/lib/libthr/thread/thr_umtx.h
+++ b/lib/libthr/thread/thr_umtx.h
@@ -35,6 +35,7 @@
#define DEFAULT_UMUTEX {0,0,{0,0},{0,0,0,0}}
#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,
@@ -60,8 +61,10 @@ void _thr_ucond_init(struct ucond *cv) __hidden;
int _thr_ucond_signal(struct ucond *cv) __hidden;
int _thr_ucond_broadcast(struct ucond *cv) __hidden;
-int __thr_rwlock_rdlock(struct urwlock *rwlock, int flags, struct timespec *tsp) __hidden;
-int __thr_rwlock_wrlock(struct urwlock *rwlock, struct timespec *tsp) __hidden;
+int __thr_rwlock_rdlock(struct urwlock *rwlock, int flags,
+ const struct timespec *tsp) __hidden;
+int __thr_rwlock_wrlock(struct urwlock *rwlock,
+ const struct timespec *tsp) __hidden;
int __thr_rwlock_unlock(struct urwlock *rwlock) __hidden;
/* Internal used only */
@@ -119,9 +122,23 @@ _thr_umutex_timedlock(struct umutex *mtx, uint32_t id,
static inline int
_thr_umutex_unlock(struct umutex *mtx, uint32_t id)
{
- if (atomic_cmpset_rel_32(&mtx->m_owner, id, UMUTEX_UNOWNED))
- return (0);
- return (__thr_umutex_unlock(mtx, id));
+ uint32_t flags = mtx->m_flags;
+
+ if ((flags & (UMUTEX_PRIO_PROTECT | UMUTEX_PRIO_INHERIT)) == 0) {
+ uint32_t owner;
+ do {
+ owner = mtx->m_owner;
+ if (__predict_false((owner & ~UMUTEX_CONTESTED) != id))
+ return (EPERM);
+ } while (__predict_false(!atomic_cmpset_rel_32(&mtx->m_owner,
+ owner, UMUTEX_UNOWNED)));
+ if ((owner & UMUTEX_CONTESTED))
+ (void)_umtx_op_err(mtx, UMTX_OP_MUTEX_WAKE2, flags, 0, 0);
+ return (0);
+ }
+ if (atomic_cmpset_rel_32(&mtx->m_owner, id, UMUTEX_UNOWNED))
+ return (0);
+ return (__thr_umutex_unlock(mtx, id));
}
static inline int
diff --git a/lib/libthread_db/Makefile b/lib/libthread_db/Makefile
index a66f25da6f63..b612f4f8d789 100644
--- a/lib/libthread_db/Makefile
+++ b/lib/libthread_db/Makefile
@@ -16,10 +16,8 @@ SYM_MAPS+=${.CURDIR}/Symbol.map
SYMBOL_MAPS=${SYM_MAPS}
VERSION_DEF=${.CURDIR}/../libc/Versions.def
-.if ${CC:T:Mclang} == "clang"
# Unfortunately, clang gives an incorrect warning about alignment in
# arch/i386/libpthread_md.c, so turn that off for now.
-NO_WCAST_ALIGN=
-.endif
+NO_WCAST_ALIGN.clang=
.include <bsd.lib.mk>
diff --git a/lib/libulog/ulog_login.c b/lib/libulog/ulog_login.c
index 3058b9f53399..a053328ac22d 100644
--- a/lib/libulog/ulog_login.c
+++ b/lib/libulog/ulog_login.c
@@ -55,7 +55,7 @@ ulog_fill(struct utmpx *utx, const char *line)
SHA1_Init(&c);
SHA1_Update(&c, "libulog", 7);
SHA1_Update(&c, utx->ut_line, sizeof utx->ut_line);
- SHA_Final(id, &c);
+ SHA1_Final(id, &c);
memcpy(utx->ut_id, id, MIN(sizeof utx->ut_id, sizeof id));
}
diff --git a/lib/libulog/utempter_add_record.3 b/lib/libulog/utempter_add_record.3
index cd8e8f1e69fb..948363eca63e 100644
--- a/lib/libulog/utempter_add_record.3
+++ b/lib/libulog/utempter_add_record.3
@@ -85,7 +85,7 @@ descriptor passed to the login functions.
.Pp
The
.Fa pty
-arguments of
+arguments of
.Fn addToUtmp
and
.Fn removeLineFromUtmp
diff --git a/lib/libusb/Makefile b/lib/libusb/Makefile
index 8d7861918d1a..75efe2eb60dc 100644
--- a/lib/libusb/Makefile
+++ b/lib/libusb/Makefile
@@ -5,7 +5,7 @@
#
LIB= usb
-SHLIB_MAJOR= 2
+SHLIB_MAJOR= 3
SHLIB_MINOR= 0
SRCS= libusb20.c
SRCS+= libusb20_desc.c
@@ -48,6 +48,7 @@ MLINKS += libusb.3 libusb_get_bus_number.3
MLINKS += libusb.3 libusb_get_device_address.3
MLINKS += libusb.3 libusb_get_device_speed.3
MLINKS += libusb.3 libusb_get_max_packet_size.3
+MLINKS += libusb.3 libusb_get_max_iso_packet_size.3
MLINKS += libusb.3 libusb_ref_device.3
MLINKS += libusb.3 libusb_unref_device.3
MLINKS += libusb.3 libusb_open.3
@@ -69,7 +70,7 @@ MLINKS += libusb.3 libusb_detach_kernel_driver.3
MLINKS += libusb.3 libusb_detach_kernel_driver_np.3
MLINKS += libusb.3 libusb_attach_kernel_driver.3
MLINKS += libusb.3 libusb_get_device_descriptor.3
-MLINKS += libusb.3 libsub_get_active_config_descriptor.3
+MLINKS += libusb.3 libusb_get_active_config_descriptor.3
MLINKS += libusb.3 libusb_get_config_descriptor.3
MLINKS += libusb.3 libusb_get_config_descriptor_by_value.3
MLINKS += libusb.3 libusb_free_config_descriptor.3
diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3
index 4e4dd1012bd3..6b1defdcca05 100644
--- a/lib/libusb/libusb.3
+++ b/lib/libusb/libusb.3
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 9, 2011
+.Dd April 12, 2012
.Dt LIBUSB 3
.Os
.Sh NAME
@@ -43,7 +43,6 @@ The
library contains interfaces for directly managing a usb device.
The current implementation supports v1.0 of the libusb API.
.Sh LIBRARY INITIALISATION / DEINITIALISATION
-.Pp
.Ft int
.Fn libusb_init libusb_context **ctx
This function initialises libusb.
@@ -119,6 +118,12 @@ LIBUSB_SPEED_UNKNOWN is returned in case of unknown wire speed.
Returns the wMaxPacketSize value on success, LIBUSB_ERROR_NOT_FOUND if the
endpoint does not exist and LIBUSB_ERROR_OTHERS on other failure.
.Pp
+.Ft int
+.Fn libusb_get_max_iso_packet_size "libusb_device *dev" "unsigned char endpoint"
+Returns the packet size multiplied by the packet multiplier on success,
+LIBUSB_ERROR_NOT_FOUND if the endpoint does not exist and
+LIBUSB_ERROR_OTHERS on other failure.
+.Pp
.Ft libusb_device *
.Fn libusb_ref_device "libusb_device *dev"
Increment the reference counter of the device
@@ -270,9 +275,7 @@ LIBUSB_ERROR_NO_DEVICE
if the device has been disconnected, LIBUSB_ERROR_BUSY if the driver cannot be
attached because the interface is claimed by a program or driver and a
LIBUSB_ERROR code on failure.
-.Pp
.Sh USB DESCRIPTORS
-.Pp
.Ft int
.Fn libusb_get_device_descriptor "libusb_device *dev" "libusb_device_descriptor *desc"
Get the USB device descriptor for the device
@@ -282,7 +285,7 @@ Returns 0 on success and a LIBUSB_ERROR code on
failure.
.Pp
.Ft int
-.Fn libsub_get_active_config_descriptor "libusb_device *dev" "struct libusb_config_descriptor **config"
+.Fn libusb_get_active_config_descriptor "libusb_device *dev" "struct libusb_config_descriptor **config"
Get the USB configuration descriptor for the active configuration.
Returns 0 on
success, LIBUSB_ERROR_NOT_FOUND if the device is in
@@ -349,9 +352,7 @@ libusb_free_bos_descriptor function.
.Ft void
.Fn libusb_free_bos_descriptor "libusb_bos_descriptor *bos"
This function is NULL safe and frees a parsed BOS descriptor.
-.Pp
.Sh USB ASYNCHRONOUS I/O
-.Pp
.Ft struct libusb_transfer *
.Fn libusb_alloc_transfer "int iso_packets"
Allocate a transfer with the number of isochronous packet descriptors
@@ -374,9 +375,7 @@ LIBUSB_ERROR code on other failure.
.Fn libusb_cancel_transfer "struct libusb_transfer *tr"
This function asynchronously cancels a transfer.
Returns 0 on success and a LIBUSB_ERROR code on failure.
-.Pp
.Sh USB SYNCHRONOUS I/O
-.Pp
.Ft int
.Fn libusb_control_transfer "libusb_device_handle *devh" "uint8_t bmRequestType" "uint8_t bRequest" "uint16_t wValue" "uint16_t wIndex" "unsigned char *data" "uint16_t wLength" "unsigned int timeout"
Perform a USB control transfer.
@@ -411,9 +410,7 @@ if the transfer timed out, LIBUSB_ERROR_PIPE if the control request was not
supported, LIBUSB_ERROR_OVERFLOW if the device offered more data,
LIBUSB_ERROR_NO_DEVICE if the device has been disconnected and
a LIBUSB_ERROR code on other failure.
-.Pp
.Sh USB EVENTS
-.Pp
.Ft int
.Fn libusb_try_lock_events "libusb_context *ctx"
Try to acquire the event handling lock.
@@ -429,7 +426,7 @@ This function is blocking.
Release the event handling lock.
This will wake up any thread blocked
on
-.B libusb_wait_for_event() .
+.Fn libusb_wait_for_event .
.Pp
.Ft int
.Fn libusb_event_handling_ok "libusb_context *ctx"
@@ -483,7 +480,7 @@ on success and a LIBUSB_ERROR code on failure.
.Pp
.Ft int
.Fn libusb_handle_events_locked "libusb_context *ctx" "struct timeval *tv"
-Handle any pending events by polling file desciptors, without checking if
+Handle any pending events by polling file descriptors, without checking if
another thread is already doing so.
Must be called with the event lock held.
.Pp
@@ -506,7 +503,6 @@ Retrive a list of file descriptors that should be polled by your main loop as
libusb event sources.
Returns a NULL-terminated list on success or NULL on failure.
.Sh LIBUSB VERSION 0.1 COMPATIBILITY
-.Pp
The library is also compliant with LibUSB version 0.1.12.
.Pp
.Fn usb_open
diff --git a/lib/libusb/libusb.h b/lib/libusb/libusb.h
index 5a4d2df98057..d8a22b569839 100644
--- a/lib/libusb/libusb.h
+++ b/lib/libusb/libusb.h
@@ -340,7 +340,7 @@ typedef void (*libusb_transfer_cb_fn) (struct libusb_transfer *transfer);
typedef struct libusb_transfer {
libusb_device_handle *dev_handle;
uint8_t flags;
- uint32_t endpoint;
+ uint8_t endpoint;
uint8_t type;
uint32_t timeout;
enum libusb_transfer_status status;
@@ -349,7 +349,6 @@ typedef struct libusb_transfer {
libusb_transfer_cb_fn callback;
void *user_data;
uint8_t *buffer;
- void *os_priv;
int num_iso_packets;
struct libusb_iso_packet_descriptor iso_packet_desc[0];
} libusb_transfer __aligned(sizeof(void *));
@@ -371,6 +370,7 @@ uint8_t libusb_get_device_address(libusb_device * dev);
enum libusb_speed libusb_get_device_speed(libusb_device * dev);
int libusb_clear_halt(libusb_device_handle *devh, uint8_t endpoint);
int libusb_get_max_packet_size(libusb_device * dev, uint8_t endpoint);
+int libusb_get_max_iso_packet_size(libusb_device * dev, uint8_t endpoint);
libusb_device *libusb_ref_device(libusb_device * dev);
void libusb_unref_device(libusb_device * dev);
int libusb_open(libusb_device * dev, libusb_device_handle ** devh);
diff --git a/lib/libusb/libusb10.c b/lib/libusb/libusb10.c
index 0be318a10381..44331bc6ad3c 100644
--- a/lib/libusb/libusb10.c
+++ b/lib/libusb/libusb10.c
@@ -331,6 +331,30 @@ out:
return (ret);
}
+int
+libusb_get_max_iso_packet_size(libusb_device *dev, uint8_t endpoint)
+{
+ int multiplier;
+ int ret;
+
+ ret = libusb_get_max_packet_size(dev, endpoint);
+
+ switch (libusb20_dev_get_speed(dev->os_priv)) {
+ case LIBUSB20_SPEED_LOW:
+ case LIBUSB20_SPEED_FULL:
+ break;
+ default:
+ if (ret > -1) {
+ multiplier = (1 + ((ret >> 11) & 3));
+ if (multiplier > 3)
+ multiplier = 3;
+ ret = (ret & 0x7FF) * multiplier;
+ }
+ break;
+ }
+ return (ret);
+}
+
libusb_device *
libusb_ref_device(libusb_device *dev)
{
@@ -627,17 +651,17 @@ libusb_set_interface_alt_setting(struct libusb20_device *pdev,
static struct libusb20_transfer *
libusb10_get_transfer(struct libusb20_device *pdev,
- uint8_t endpoint, uint8_t index)
+ uint8_t endpoint, uint8_t xfer_index)
{
- index &= 1; /* double buffering */
+ xfer_index &= 1; /* double buffering */
- index |= (endpoint & LIBUSB20_ENDPOINT_ADDRESS_MASK) * 4;
+ xfer_index |= (endpoint & LIBUSB20_ENDPOINT_ADDRESS_MASK) * 4;
if (endpoint & LIBUSB20_ENDPOINT_DIR_MASK) {
/* this is an IN endpoint */
- index |= 2;
+ xfer_index |= 2;
}
- return (libusb20_tr_get_pointer(pdev, index));
+ return (libusb20_tr_get_pointer(pdev, xfer_index));
}
int
@@ -1298,7 +1322,7 @@ libusb_submit_transfer(struct libusb_transfer *uxfer)
struct libusb20_transfer *pxfer1;
struct libusb_super_transfer *sxfer;
struct libusb_device *dev;
- uint32_t endpoint;
+ uint8_t endpoint;
int err;
if (uxfer == NULL)
@@ -1309,9 +1333,6 @@ libusb_submit_transfer(struct libusb_transfer *uxfer)
endpoint = uxfer->endpoint;
- if (endpoint > 255)
- return (LIBUSB_ERROR_INVALID_PARAM);
-
dev = libusb_get_device(uxfer->dev_handle);
DPRINTF(dev->ctx, LIBUSB_DEBUG_FUNCTION, "libusb_submit_transfer enter");
@@ -1361,7 +1382,7 @@ libusb_cancel_transfer(struct libusb_transfer *uxfer)
struct libusb20_transfer *pxfer1;
struct libusb_super_transfer *sxfer;
struct libusb_device *dev;
- uint32_t endpoint;
+ uint8_t endpoint;
int retval;
if (uxfer == NULL)
@@ -1373,9 +1394,6 @@ libusb_cancel_transfer(struct libusb_transfer *uxfer)
endpoint = uxfer->endpoint;
- if (endpoint > 255)
- return (LIBUSB_ERROR_INVALID_PARAM);
-
dev = libusb_get_device(uxfer->dev_handle);
DPRINTF(dev->ctx, LIBUSB_DEBUG_FUNCTION, "libusb_cancel_transfer enter");
diff --git a/lib/libusb/libusb10_desc.c b/lib/libusb/libusb10_desc.c
index 6d5822e8c395..8e39bab15b2c 100644
--- a/lib/libusb/libusb10_desc.c
+++ b/lib/libusb/libusb10_desc.c
@@ -390,8 +390,8 @@ libusb_parse_bos_descriptor(const void *buf, int len,
struct libusb_bos_descriptor **bos)
{
struct libusb_bos_descriptor *ptr;
- struct libusb_usb_2_0_device_capability_descriptor *dcap_20;
- struct libusb_ss_usb_device_capability_descriptor *ss_cap;
+ struct libusb_usb_2_0_device_capability_descriptor *dcap_20 = NULL;
+ struct libusb_ss_usb_device_capability_descriptor *ss_cap = NULL;
if (buf == NULL || bos == NULL || len < 1)
return (LIBUSB_ERROR_INVALID_PARAM);
@@ -438,7 +438,7 @@ libusb_parse_bos_descriptor(const void *buf, int len,
dtype == LIBUSB_DT_DEVICE_CAPABILITY) {
switch (((const uint8_t *)buf)[2]) {
case LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY:
- if (ptr->usb_2_0_ext_cap != NULL)
+ if (ptr->usb_2_0_ext_cap != NULL || dcap_20 == NULL)
break;
if (dlen < LIBUSB_USB_2_0_EXTENSION_DEVICE_CAPABILITY_SIZE)
break;
@@ -455,7 +455,7 @@ libusb_parse_bos_descriptor(const void *buf, int len,
break;
case LIBUSB_SS_USB_DEVICE_CAPABILITY:
- if (ptr->ss_usb_cap != NULL)
+ if (ptr->ss_usb_cap != NULL || ss_cap == NULL)
break;
if (dlen < LIBUSB_SS_USB_DEVICE_CAPABILITY_SIZE)
break;
diff --git a/lib/libusb/libusb10_io.c b/lib/libusb/libusb10_io.c
index 380e312bf6b6..63f833af8828 100644
--- a/lib/libusb/libusb10_io.c
+++ b/lib/libusb/libusb10_io.c
@@ -481,7 +481,7 @@ libusb10_do_transfer(libusb_device_handle *devh,
{
libusb_context *ctx;
struct libusb_transfer *xfer;
- volatile int complet;
+ int done;
int ret;
if (devh == NULL)
@@ -502,15 +502,15 @@ libusb10_do_transfer(libusb_device_handle *devh,
xfer->timeout = timeout;
xfer->buffer = data;
xfer->length = length;
- xfer->user_data = (void *)&complet;
+ xfer->user_data = (void *)&done;
xfer->callback = libusb10_do_transfer_cb;
- complet = 0;
+ done = 0;
if ((ret = libusb_submit_transfer(xfer)) < 0) {
libusb_free_transfer(xfer);
return (ret);
}
- while (complet == 0) {
+ while (done == 0) {
if ((ret = libusb_handle_events(ctx)) < 0) {
libusb_cancel_transfer(xfer);
usleep(1000); /* nice it */
@@ -581,7 +581,7 @@ libusb_interrupt_transfer(libusb_device_handle *devh,
}
uint8_t *
-libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t index)
+libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t off)
{
uint8_t *ptr;
uint32_t n;
@@ -589,35 +589,35 @@ libusb_get_iso_packet_buffer(struct libusb_transfer *transfer, uint32_t index)
if (transfer->num_iso_packets < 0)
return (NULL);
- if (index >= (uint32_t)transfer->num_iso_packets)
+ if (off >= (uint32_t)transfer->num_iso_packets)
return (NULL);
ptr = transfer->buffer;
if (ptr == NULL)
return (NULL);
- for (n = 0; n != index; n++) {
+ for (n = 0; n != off; n++) {
ptr += transfer->iso_packet_desc[n].length;
}
return (ptr);
}
uint8_t *
-libusb_get_iso_packet_buffer_simple(struct libusb_transfer *transfer, uint32_t index)
+libusb_get_iso_packet_buffer_simple(struct libusb_transfer *transfer, uint32_t off)
{
uint8_t *ptr;
if (transfer->num_iso_packets < 0)
return (NULL);
- if (index >= (uint32_t)transfer->num_iso_packets)
+ if (off >= (uint32_t)transfer->num_iso_packets)
return (NULL);
ptr = transfer->buffer;
if (ptr == NULL)
return (NULL);
- ptr += transfer->iso_packet_desc[0].length * index;
+ ptr += transfer->iso_packet_desc[0].length * off;
return (ptr);
}
diff --git a/lib/libusb/libusb20.3 b/lib/libusb/libusb20.3
index bd167b239d75..d1abc554d083 100644
--- a/lib/libusb/libusb20.3
+++ b/lib/libusb/libusb20.3
@@ -235,7 +235,6 @@ applications should consider using
.
.Sh USB TRANSFER OPERATIONS
.
-.Pp
.
.Fn libusb20_tr_close
will release all kernel resources associated with an USB
@@ -534,7 +533,6 @@ with an USB transfer.
.
.Sh USB DEVICE OPERATIONS
.
-.Pp
.
.Fn libusb20_dev_get_backend_name
returns a zero terminated string describing the backend used.
@@ -542,7 +540,7 @@ returns a zero terminated string describing the backend used.
.Pp
.
.Fn libusb20_dev_get_info
-retrieves the BSD specific usb_device_info structure into the memory location given by
+retrieves the BSD specific usb_device_info structure into the memory location given by
.Fa pinfo .
The USB device given by
.Fa pdev
@@ -1000,7 +998,6 @@ The buffer pointer cannot be NULL.
.
.
.Sh USB DEBUGGING
-.Pp
.Ft const char *
.Fn libusb20_strerror "int code"
Get the ASCII representation of the error given by the
diff --git a/lib/libusb/libusb20.c b/lib/libusb/libusb20.c
index 747c16003ce0..75af7a1865c1 100644
--- a/lib/libusb/libusb20.c
+++ b/lib/libusb/libusb20.c
@@ -948,9 +948,8 @@ libusb20_dev_get_config_index(struct libusb20_device *pdev)
}
error = pdev->methods->get_config_index(pdev, &cfg_index);
- if (error) {
- cfg_index = 0 - 1; /* current config index */
- }
+ if (error)
+ cfg_index = 0xFF; /* current config index */
if (do_close) {
if (libusb20_dev_close(pdev)) {
/* ignore */
diff --git a/lib/libusb/libusb20_desc.c b/lib/libusb/libusb20_desc.c
index 0781067be78b..e2fa5b55c95b 100644
--- a/lib/libusb/libusb20_desc.c
+++ b/lib/libusb/libusb20_desc.c
@@ -69,7 +69,7 @@ libusb20_parse_config_desc(const void *config_desc)
uint16_t niface_no_alt;
uint16_t niface;
uint16_t nendpoint;
- uint8_t iface_no;
+ uint16_t iface_no;
ptr = config_desc;
if (ptr[1] != LIBUSB20_DT_CONFIG) {
@@ -82,7 +82,7 @@ libusb20_parse_config_desc(const void *config_desc)
niface_no_alt = 0;
nendpoint = 0;
niface = 0;
- iface_no = 0 - 1;
+ iface_no = 0xFFFF;
ptr = NULL;
/* get "wTotalLength" and setup "pcdesc" */
@@ -155,7 +155,7 @@ libusb20_parse_config_desc(const void *config_desc)
/* reset states */
niface = 0;
- iface_no = 0 - 1;
+ iface_no = 0xFFFF;
ptr = NULL;
lub_interface--;
lub_endpoint--;
@@ -450,7 +450,7 @@ libusb20_me_encode(void *ptr, uint16_t len, const void *pd)
* and should be
* correct:
*/
- ps->len = 0 - 1;
+ ps->len = 0xFFFF;
}
src_len = libusb20_me_get_1(pd, 0);
src_ptr = LIBUSB20_ADD_BYTES(ps->ptr, 1);
@@ -465,7 +465,7 @@ libusb20_me_encode(void *ptr, uint16_t len, const void *pd)
case LIBUSB20_ME_IS_DECODED:
/* reserve 3 length bytes */
src_len = libusb20_me_encode(NULL,
- 0 - 1 - 3, ps->ptr);
+ 0xFFFF - 3, ps->ptr);
src_ptr = NULL;
break;
@@ -476,7 +476,7 @@ libusb20_me_encode(void *ptr, uint16_t len, const void *pd)
}
if (src_len > 0xFE) {
- if (src_len > (uint16_t)(0 - 1 - 3))
+ if (src_len > (0xFFFF - 3))
/* overflow */
goto done;
@@ -516,7 +516,7 @@ libusb20_me_encode(void *ptr, uint16_t len, const void *pd)
uint16_t dummy;
dummy = libusb20_me_encode(buf,
- 0 - 1 - 3, ps->ptr);
+ 0xFFFF - 3, ps->ptr);
} else {
bcopy(src_ptr, buf, src_len);
}
diff --git a/lib/libusb/libusb20_ugen20.c b/lib/libusb/libusb20_ugen20.c
index 307ed96d2274..17c948b4ac38 100644
--- a/lib/libusb/libusb20_ugen20.c
+++ b/lib/libusb/libusb20_ugen20.c
@@ -104,7 +104,7 @@ ugen20_path_convert_one(const char **pp)
temp += (*ptr - '0');
if (temp >= 1000000) {
/* catch overflow early */
- return (0 - 1);
+ return (0xFFFFFFFF);
}
ptr++;
}
diff --git a/lib/libutil/Makefile b/lib/libutil/Makefile
index b2378adf768e..3136a050d5e3 100644
--- a/lib/libutil/Makefile
+++ b/lib/libutil/Makefile
@@ -25,47 +25,48 @@ CFLAGS+= -DINET6
CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../libc/gen/
-MAN+= kld.3 login_auth.3 login_tty.3 pty.3 \
- login_cap.3 login_class.3 login_times.3 login_ok.3 \
- _secure_path.3 uucplock.3 property.3 auth.3 realhostname.3 \
- realhostname_sa.3 trimdomain.3 fparseln.3 humanize_number.3 \
- pidfile.3 flopen.3 expand_number.3 hexdump.3 \
- kinfo_getfile.3 kinfo_getallproc.3 kinfo_getproc.3 \
- kinfo_getvmmap.3 quotafile.3
-MAN+= login.conf.5 auth.conf.5
-MLINKS+= kld.3 kld_isloaded.3 kld.3 kld_load.3
-MLINKS+= property.3 properties_read.3 property.3 properties_free.3
-MLINKS+= property.3 property_find.3
+MAN+= auth.3 expand_number.3 flopen.3 fparseln.3 hexdump.3 \
+ humanize_number.3 kinfo_getallproc.3 kinfo_getfile.3 \
+ kinfo_getproc.3 kinfo_getvmmap.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
+MAN+= auth.conf.5 login.conf.5
MLINKS+= auth.3 auth_getval.3
-MLINKS+= pty.3 openpty.3 pty.3 forkpty.3
-MLINKS+=login_cap.3 login_getclassbyname.3 login_cap.3 login_close.3 \
- login_cap.3 login_getclass.3 login_cap.3 login_getuserclass.3 \
- login_cap.3 login_getcapstr.3 login_cap.3 login_getcaplist.3 \
- login_cap.3 login_getstyle.3 login_cap.3 login_getcaptime.3 \
- login_cap.3 login_getcapnum.3 login_cap.3 login_getcapsize.3 \
- login_cap.3 login_getcapbool.3 login_cap.3 login_getpath.3 \
- login_cap.3 login_getpwclass.3 login_cap.3 login_setcryptfmt.3
-MLINKS+=login_class.3 setusercontext.3 login_class.3 setclasscontext.3 \
- login_class.3 setclassenvironment.3 login_class.3 setclassresources.3
-MLINKS+=login_times.3 parse_lt.3 login_times.3 in_ltm.3 \
- login_times.3 in_lt.3 login_times.3 in_ltms.3 \
- login_times.3 in_lts.3
-MLINKS+=login_ok.3 auth_ttyok.3 login_ok.3 auth_hostok.3 \
- login_ok.3 auth_timeok.3
-MLINKS+=login_auth.3 auth_checknologin.3 login_auth.3 auth_cat.3
-MLINKS+=uucplock.3 uu_lock.3 uucplock.3 uu_lock_txfr.3 \
- uucplock.3 uu_unlock.3 uucplock.3 uu_lockerr.3
-MLINKS+=pidfile.3 pidfile_open.3 \
- pidfile.3 pidfile_write.3 \
- pidfile.3 pidfile_close.3 \
- pidfile.3 pidfile_remove.3
-MLINKS+=quotafile.3 quota_open.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
+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_statfs.3 \
quotafile.3 quota_read.3 \
+ quotafile.3 quota_statfs.3 \
quotafile.3 quota_write_limits.3 \
- quotafile.3 quota_write_usage.3 \
- quotafile.3 quota_close.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
.include <bsd.lib.mk>
diff --git a/lib/libutil/flopen.3 b/lib/libutil/flopen.3
index 26d1c044aefc..66657022c0ee 100644
--- a/lib/libutil/flopen.3
+++ b/lib/libutil/flopen.3
@@ -1,5 +1,5 @@
.\"-
-.\" Copyright (c) 2007 Dag-Erling Coïdan Smørgrav
+.\" Copyright (c) 2007 Dag-Erling Coïdan Smørgrav
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
diff --git a/lib/libutil/kinfo_getallproc.3 b/lib/libutil/kinfo_getallproc.3
index 73981ae36bea..56d4ad613bb9 100644
--- a/lib/libutil/kinfo_getallproc.3
+++ b/lib/libutil/kinfo_getallproc.3
@@ -26,8 +26,8 @@
.\" $FreeBSD$
.\"
.Dd July 9, 2009
-.Os
.Dt KINFO_GETALLPROC 3
+.Os
.Sh NAME
.Nm kinfo_getallproc
.Nd function for getting process information of all processes from kernel
diff --git a/lib/libutil/kinfo_getproc.3 b/lib/libutil/kinfo_getproc.3
index 2778ad1fc56e..68b8819b556b 100644
--- a/lib/libutil/kinfo_getproc.3
+++ b/lib/libutil/kinfo_getproc.3
@@ -25,9 +25,9 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 9, 2009
-.Os
+.Dd February 25, 2012
.Dt KINFO_GETPROC 3
+.Os
.Sh NAME
.Nm kinfo_getproc
.Nd function for getting process information from kernel
@@ -44,7 +44,7 @@ This function is used for obtaining process information from the kernel.
The
.Ar pid
field contains the process identifier.
-This should be the a process that you have privilige to access.
+This should be a process that you have privilege to access.
This function is a wrapper around
.Xr sysctl 3
with the
diff --git a/lib/libutil/kld.3 b/lib/libutil/kld.3
index 6b77c47fc0db..595ac96730b4 100644
--- a/lib/libutil/kld.3
+++ b/lib/libutil/kld.3
@@ -1,5 +1,5 @@
.\"-
-.\" Copyright (c) 2006 Dag-Erling Coïdan Smørgrav
+.\" Copyright (c) 2006 Dag-Erling Coïdan Smørgrav
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
diff --git a/lib/libutil/libutil.h b/lib/libutil/libutil.h
index dea14cfffa7a..bf42766a128c 100644
--- a/lib/libutil/libutil.h
+++ b/lib/libutil/libutil.h
@@ -48,6 +48,11 @@ typedef __gid_t gid_t;
#define _GID_T_DECLARED
#endif
+#ifndef _MODE_T_DECLARED
+typedef __mode_t mode_t;
+#define _MODE_T_DECLARED
+#endif
+
#ifndef _PID_T_DECLARED
typedef __pid_t pid_t;
#define _PID_T_DECLARED
@@ -63,66 +68,36 @@ typedef __uid_t uid_t;
#define _UID_T_DECLARED
#endif
-#define PROPERTY_MAX_NAME 64
-#define PROPERTY_MAX_VALUE 512
+#define PROPERTY_MAX_NAME 64
+#define PROPERTY_MAX_VALUE 512
-/* for properties.c */
+/* For properties.c. */
typedef struct _property {
struct _property *next;
- char *name;
- char *value;
+ char *name;
+ char *value;
} *properties;
-#ifdef _SYS_PARAM_H_
-/* for pidfile.c */
-struct pidfh {
- int pf_fd;
- char pf_path[MAXPATHLEN + 1];
- __dev_t pf_dev;
- ino_t pf_ino;
-};
-#endif
-
-/* Avoid pulling in all the include files for no need */
+/* Avoid pulling in all the include files for no need. */
+struct in_addr;
+struct pidfh;
+struct sockaddr;
struct termios;
struct winsize;
-struct in_addr;
-struct kinfo_file;
-struct kinfo_proc;
-struct kinfo_vmentry;
__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 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, ...);
-void hexdump(const void *ptr, int length, const char *hdr, int flags);
-int login_tty(int _fd);
-void trimdomain(char *_fullhost, int _hostsize);
-int openpty(int *_amaster, int *_aslave, char *_name,
- struct termios *_termp, struct winsize *_winp);
int forkpty(int *_amaster, char *_name,
- struct termios *_termp, struct winsize *_winp);
+ struct termios *_termp, struct winsize *_winp);
+void hexdump(const void *_ptr, int _length, const char *_hdr, int _flags);
int humanize_number(char *_buf, size_t _len, int64_t _number,
const char *_suffix, int _scale, int _flags);
-int expand_number(const char *_buf, uint64_t *_num);
-const char *uu_lockerr(int _uu_lockresult);
-int uu_lock(const char *_ttyname);
-int uu_unlock(const char *_ttyname);
-int uu_lock_txfr(const char *_ttyname, pid_t _pid);
-int _secure_path(const char *_path, uid_t _uid, gid_t _gid);
-properties properties_read(int fd);
-void properties_free(properties list);
-char *property_find(properties list, const char *name);
-char *auth_getval(const char *name);
-int realhostname(char *host, size_t hsize, const struct in_addr *ip);
-struct sockaddr;
-int realhostname_sa(char *host, size_t hsize, struct sockaddr *addr,
- int addrlen);
-
-int kld_isloaded(const char *name);
-int kld_load(const char *name);
struct kinfo_file *
kinfo_getfile(pid_t _pid, int *_cntp);
struct kinfo_vmentry *
@@ -131,81 +106,99 @@ struct kinfo_proc *
kinfo_getallproc(int *_cntp);
struct kinfo_proc *
kinfo_getproc(pid_t _pid);
+int kld_isloaded(const char *_name);
+int kld_load(const char *_name);
+int login_tty(int _fd);
+int openpty(int *_amaster, int *_aslave, char *_name,
+ struct termios *_termp, struct winsize *_winp);
+int pidfile_close(struct pidfh *_pfh);
+int pidfile_fileno(const struct pidfh *_pfh);
+struct pidfh *
+ pidfile_open(const char *_path, mode_t _mode, pid_t *_pidptr);
+int pidfile_remove(struct pidfh *_pfh);
+int pidfile_write(struct pidfh *_pfh);
+void properties_free(properties _list);
+char *property_find(properties _list, const char *_name);
+properties
+ properties_read(int _fd);
+int realhostname(char *_host, size_t _hsize, const struct in_addr *_ip);
+int realhostname_sa(char *_host, size_t _hsize, struct sockaddr *_addr,
+ int _addrlen);
+int _secure_path(const char *_path, uid_t _uid, gid_t _gid);
+void trimdomain(char *_fullhost, int _hostsize);
+const char *
+ uu_lockerr(int _uu_lockresult);
+int uu_lock(const char *_ttyname);
+int uu_unlock(const char *_ttyname);
+int uu_lock_txfr(const char *_ttyname, pid_t _pid);
-#ifdef _STDIO_H_ /* avoid adding new includes */
-char *fparseln(FILE *, size_t *, size_t *, const char[3], int);
+/*
+ * Conditionally prototype the following functions if the include
+ * files upon which they depend have been included.
+ */
+#ifdef _STDIO_H_
+char *fparseln(FILE *_fp, size_t *_len, size_t *_lineno,
+ const char _delim[3], int _flags);
#endif
#ifdef _PWD_H_
-int pw_copy(int _ffd, int _tfd, const struct passwd *_pw, struct passwd *_old_pw);
-struct passwd *pw_dup(const struct passwd *_pw);
+int pw_copy(int _ffd, int _tfd, const struct passwd *_pw,
+ struct passwd *_old_pw);
+struct passwd
+ *pw_dup(const struct passwd *_pw);
int pw_edit(int _notsetuid);
int pw_equal(const struct passwd *_pw1, const struct passwd *_pw2);
void pw_fini(void);
int pw_init(const char *_dir, const char *_master);
char *pw_make(const struct passwd *_pw);
+char *pw_make_v7(const struct passwd *_pw);
int pw_mkdb(const char *_user);
int pw_lock(void);
-struct passwd *pw_scan(const char *_line, int _flags);
-const char *pw_tempname(void);
+struct passwd *
+ pw_scan(const char *_line, int _flags);
+const char *
+ pw_tempname(void);
int pw_tmp(int _mfd);
#endif
#ifdef _GRP_H_
-int gr_copy(int __ffd, int _tfd, const struct group *_gr, struct group *_old_gr);
-struct group *gr_dup(const struct group *gr);
-int gr_equal(const struct group *gr1, const struct group *gr2);
+int gr_copy(int __ffd, int _tfd, const struct group *_gr,
+ struct group *_old_gr);
+struct group *
+ gr_dup(const struct group *_gr);
+int gr_equal(const struct group *_gr1, const struct group *_gr2);
void gr_fini(void);
int gr_init(const char *_dir, const char *_master);
int gr_lock(void);
-char *gr_make(const struct group *gr);
+char *gr_make(const struct group *_gr);
int gr_mkdb(void);
+struct group *
+ gr_scan(const char *_line);
int gr_tmp(int _mdf);
-struct group *gr_scan(const char *line);
-#endif
-
-#ifdef _SYS_PARAM_H_
-struct pidfh *pidfile_open(const char *path, mode_t mode, pid_t *pidptr);
-int pidfile_write(struct pidfh *pfh);
-int pidfile_close(struct pidfh *pfh);
-int pidfile_remove(struct pidfh *pfh);
#endif
#ifdef _UFS_UFS_QUOTA_H_
-struct quotafile;
struct fstab;
-struct quotafile *quota_open(struct fstab *, int, int);
-void quota_close(struct quotafile *);
-int quota_on(struct quotafile *);
-int quota_off(struct quotafile *);
-const char *quota_fsname(const struct quotafile *);
-const char *quota_qfname(const struct quotafile *);
-int quota_maxid(struct quotafile *);
-int quota_check_path(const struct quotafile *, const char *path);
-int quota_read(struct quotafile *, struct dqblk *, int);
-int quota_write_limits(struct quotafile *, struct dqblk *, int);
-int quota_write_usage(struct quotafile *, struct dqblk *, int);
-int quota_convert(struct quotafile *, int);
+struct quotafile;
+int quota_check_path(const struct quotafile *_qf, const char *_path);
+void quota_close(struct quotafile *_qf);
+int quota_convert(struct quotafile *_qf, int _wordsize);
+const char *
+ quota_fsname(const struct quotafile *_qf);
+int quota_maxid(struct quotafile *_qf);
+int quota_off(struct quotafile *_qf);
+int quota_on(struct quotafile *_qf);
+struct quotafile *
+ quota_open(struct fstab *_fs, int _quotatype, int _openflags);
+const char *
+ quota_qfname(const struct quotafile *_qf);
+int quota_read(struct quotafile *_qf, struct dqblk *_dqb, int _id);
+int quota_write_limits(struct quotafile *_qf, struct dqblk *_dqb, int _id);
+int quota_write_usage(struct quotafile *_qf, struct dqblk *_dqb, int _id);
#endif
__END_DECLS
-#define UU_LOCK_INUSE (1)
-#define UU_LOCK_OK (0)
-#define UU_LOCK_OPEN_ERR (-1)
-#define UU_LOCK_READ_ERR (-2)
-#define UU_LOCK_CREAT_ERR (-3)
-#define UU_LOCK_WRITE_ERR (-4)
-#define UU_LOCK_LINK_ERR (-5)
-#define UU_LOCK_TRY_ERR (-6)
-#define UU_LOCK_OWNER_ERR (-7)
-
-/* return values from realhostname() */
-#define HOSTNAME_FOUND (0)
-#define HOSTNAME_INCORRECTNAME (1)
-#define HOSTNAME_INVALIDADDR (2)
-#define HOSTNAME_INVALIDNAME (3)
-
/* fparseln(3) */
#define FPARSELN_UNESCESC 0x01
#define FPARSELN_UNESCCONT 0x02
@@ -213,26 +206,43 @@ __END_DECLS
#define FPARSELN_UNESCREST 0x08
#define FPARSELN_UNESCALL 0x0f
-/* pw_scan() */
-#define PWSCAN_MASTER 0x01
-#define PWSCAN_WARN 0x02
-
-/* humanize_number(3) */
-#define HN_DECIMAL 0x01
-#define HN_NOSPACE 0x02
-#define HN_B 0x04
-#define HN_DIVISOR_1000 0x08
-#define HN_IEC_PREFIXES 0x10
-
-/* maxscale = 0x07 */
-#define HN_GETSCALE 0x10
-#define HN_AUTOSCALE 0x20
-
-/* hexdump(3) */
+/* Flags for hexdump(3). */
#define HD_COLUMN_MASK 0xff
#define HD_DELIM_MASK 0xff00
#define HD_OMIT_COUNT (1 << 16)
#define HD_OMIT_HEX (1 << 17)
#define HD_OMIT_CHARS (1 << 18)
+/* Values for humanize_number(3)'s flags parameter. */
+#define HN_DECIMAL 0x01
+#define HN_NOSPACE 0x02
+#define HN_B 0x04
+#define HN_DIVISOR_1000 0x08
+#define HN_IEC_PREFIXES 0x10
+
+/* Values for humanize_number(3)'s scale parameter. */
+#define HN_GETSCALE 0x10
+#define HN_AUTOSCALE 0x20
+
+/* Return values from realhostname(). */
+#define HOSTNAME_FOUND 0
+#define HOSTNAME_INCORRECTNAME 1
+#define HOSTNAME_INVALIDADDR 2
+#define HOSTNAME_INVALIDNAME 3
+
+/* Flags for pw_scan(). */
+#define PWSCAN_MASTER 0x01
+#define PWSCAN_WARN 0x02
+
+/* Return values from uu_lock(). */
+#define UU_LOCK_INUSE 1
+#define UU_LOCK_OK 0
+#define UU_LOCK_OPEN_ERR (-1)
+#define UU_LOCK_READ_ERR (-2)
+#define UU_LOCK_CREAT_ERR (-3)
+#define UU_LOCK_WRITE_ERR (-4)
+#define UU_LOCK_LINK_ERR (-5)
+#define UU_LOCK_TRY_ERR (-6)
+#define UU_LOCK_OWNER_ERR (-7)
+
#endif /* !_LIBUTIL_H_ */
diff --git a/lib/libutil/login.conf.5 b/lib/libutil/login.conf.5
index 134c779b5503..a272073f67e4 100644
--- a/lib/libutil/login.conf.5
+++ b/lib/libutil/login.conf.5
@@ -177,20 +177,20 @@ The usual convention to interpolate capability entries using the special
notation may be used.
.Sh RESOURCE LIMITS
.Bl -column pseudoterminals indent indent
-.It Sy "Name Type Notes Description
-.It "coredumpsize size Maximum coredump size limit.
-.It "cputime time CPU usage limit.
-.It "datasize size Maximum data size limit.
-.It "filesize size Maximum file size limit.
-.It "maxproc number Maximum number of processes.
-.It "memorylocked size Maximum locked in core memory size limit.
-.It "memoryuse size Maximum of core memory use size limit.
-.It "openfiles number Maximum number of open files per process.
-.It "sbsize size Maximum permitted socketbuffer size.
-.It "vmemoryuse size Maximum permitted total VM usage per process.
-.It "stacksize size Maximum stack size limit.
-.It "pseudoterminals number Maximum number of pseudo-terminals.
-.It "swapuse size Maximum swap space size limit.
+.It Sy "Name Type Notes Description"
+.It "coredumpsize size Maximum coredump size limit."
+.It "cputime time CPU usage limit."
+.It "datasize size Maximum data size limit."
+.It "filesize size Maximum file size limit."
+.It "maxproc number Maximum number of processes."
+.It "memorylocked size Maximum locked in core memory size limit."
+.It "memoryuse size Maximum of core memory use size limit."
+.It "openfiles number Maximum number of open files per process."
+.It "sbsize size Maximum permitted socketbuffer size."
+.It "vmemoryuse size Maximum permitted total VM usage per process."
+.It "stacksize size Maximum stack size limit."
+.It "pseudoterminals number Maximum number of pseudo-terminals."
+.It "swapuse size Maximum swap space size limit."
.El
.Pp
These resource limit entries actually specify both the maximum
@@ -202,10 +202,10 @@ 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 "charset string Set $MM_CHARSET environment variable to the specified
+.It Sy "Name Type Notes Description"
+.It "charset string Set $MM_CHARSET environment variable to the specified"
value.
-.It "cpumask string List of cpus to bind the user to.
+.It "cpumask string List of cpus to bind the user to."
The syntax is the same as for the
.Fl l
argument of
@@ -214,9 +214,9 @@ argument of
If set to
.Ql default
no action is taken.
-.It "hushlogin bool false Same as having a ~/.hushlogin file.
-.It "ignorenologin bool false Login not prevented by nologin.
-.It "ftp-chroot bool false Limit FTP access with
+.It "hushlogin bool false Same as having a ~/.hushlogin file."
+.It "ignorenologin bool false Login not prevented by nologin."
+.It "ftp-chroot bool false Limit FTP access with"
.Xr chroot 2
to the
.Ev HOME
@@ -224,66 +224,66 @@ directory of the user.
See
.Xr ftpd 8
for details.
-.It "label string Default MAC policy; see
+.It "label string Default MAC policy; see"
.Xr maclabel 7 .
-.It "lang string Set $LANG environment variable to the specified value.
-.It "manpath path Default search path for manpages.
-.It "nocheckmail bool false Display mail status at login.
-.It "nologin file If the file exists it will be displayed and
+.It "lang string Set $LANG environment variable to the specified value."
+.It "manpath path Default search path for manpages."
+.It "nocheckmail bool false Display mail status at login."
+.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 "requirehome bool false Require a valid home directory to login.
-.It "setenv list A comma-separated list of environment variables and
+.It "path path /bin /usr/bin Default search path."
+.It "priority number Initial priority (nice) level."
+.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.
-.It "shell prog Session shell to execute rather than the
+.It "shell prog Session shell to execute rather than the"
shell specified in the passwd file.
The SHELL environment variable will
contain the shell specified in the password file.
-.It "term string Default terminal type if not able to determine
+.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 "timezone string Default value of $TZ environment variable."
+.It "umask number 022 Initial umask. Should always have a leading 0 to"
ensure octal interpretation.
-.It "welcome file /etc/motd File containing welcome message.
+.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 Notes 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
+.It "copyright file File containing additional copyright information"
+.It "host.allow list List of remote host wildcards from which users in"
the class may access.
-.It "host.deny list List of remote host wildcards from which users
+.It "host.deny list List of remote host wildcards from which users"
in the class may not access.
-.It "login_prompt string The login prompt given by
+.It "login_prompt string The login prompt given by"
.Xr login 1
-.It "login-backoff number 3 The number of login attempts
+.It "login-backoff number 3 The number of login attempts"
allowed before the backoff delay is inserted after each subsequent
attempt.
The backoff delay is the number of tries above
.Em login-backoff
multiplied by 5 seconds.
-.It "login-retries number 10 The number of login attempts
+.It "login-retries number 10 The number of login attempts"
allowed before the login fails.
-.It "passwd_format string md5 The encryption format that new or
+.It "passwd_format string md5 The encryption format that new or"
changed passwords will use.
Valid values include "des", "md5" and "blf".
NIS clients using a
.No non- Ns Fx
NIS server should probably use "des".
-.It "passwd_prompt string The password prompt presented by
+.It "passwd_prompt string The password prompt presented by"
.Xr login 1
-.It "times.allow list List of time periods during which
+.It "times.allow list List of time periods during which"
logins are allowed.
-.It "times.deny list List of time periods during which logins are
+.It "times.deny list List of time periods during which logins are"
disallowed.
-.It "ttys.allow list List of ttys and ttygroups which users
+.It "ttys.allow list List of ttys and ttygroups which users"
in the class may use for access.
-.It "ttys.deny list List of ttys and ttygroups which users
+.It "ttys.deny list List of ttys and ttygroups which users"
in the class may not use for access.
-.It "warnexpire time Advance notice for pending account expiry.
-.It "warnpassword time Advance notice for pending password expiry.
+.It "warnexpire time Advance notice for pending account expiry."
+.It "warnpassword time Advance notice for pending password expiry."
.\".It "widepasswords bool false Use the wide password format. The wide password
.\" format allows up to 128 significant characters in the password.
.El
@@ -388,46 +388,46 @@ 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 "accounted bool false Enable session time accounting for all users
+.It Sy "Name Type Notes Description"
+.It "accounted bool false Enable session time accounting for all users"
in this class.
-.It "auth list passwd Allowed authentication styles.
+.It "auth list passwd Allowed authentication styles."
The first item is the default style.
-.It "auth-" Ns Ar type Ta "list Allowed authentication styles for the
+.It "auth-" Ns Ar type Ta "list Allowed authentication styles for the"
authentication
.Ar type .
-.It "autodelete time Time after expiry when account is auto-deleted.
-.It "bootfull bool false Enable 'boot only if ttygroup is full' strategy
+.It "autodelete time Time after expiry when account is auto-deleted."
+.It "bootfull bool false Enable 'boot only if ttygroup is full' strategy"
when terminating sessions.
-.It "daytime time Maximum login time per day.
-.It "expireperiod time Time for expiry allocation.
-.It "graceexpire time Grace days for expired account.
-.It "gracetime time Additional grace login time allowed.
-.It "host.accounted list List of remote host wildcards from which
+.It "daytime time Maximum login time per day."
+.It "expireperiod time Time for expiry allocation."
+.It "graceexpire time Grace days for expired account."
+.It "gracetime time Additional grace login time allowed."
+.It "host.accounted list List of remote host wildcards from which"
login sessions will be accounted.
-.It "host.exempt list List of remote host wildcards from which
+.It "host.exempt list List of remote host wildcards from which"
login session accounting is exempted.
-.It "idletime time Maximum idle time before logout.
-.It "minpasswordlen number 6 The minimum length a local
+.It "idletime time Maximum idle time before logout."
+.It "minpasswordlen number 6 The minimum length a local"
password may be.
-.It "mixpasswordcase bool true Whether
+.It "mixpasswordcase bool true Whether"
.Xr passwd 1
will warn the user if an all lower case password is entered.
-.It "monthtime time Maximum login time per month.
-.It "passwordtime time Used by
+.It "monthtime time Maximum login time per month."
+.It "passwordtime time Used by"
.Xr passwd 1
to set next password expiry date.
-.It "refreshtime time New time allowed on account refresh.
-.It "refreshperiod str How often account time is refreshed.
-.It "sessiontime time Maximum login time per session.
-.It "sessionlimit number Maximum number of concurrent
+.It "refreshtime time New time allowed on account refresh."
+.It "refreshperiod str How often account time is refreshed."
+.It "sessiontime time Maximum login time per session."
+.It "sessionlimit number Maximum number of concurrent"
login sessions on ttys in any group.
-.It "ttys.accounted list List of ttys and ttygroups for which
+.It "ttys.accounted list List of ttys and ttygroups for which"
login accounting is active.
-.It "ttys.exempt list List of ttys and ttygroups for which login accounting
+.It "ttys.exempt list List of ttys and ttygroups for which login accounting"
is exempt.
-.It "warntime time Advance notice for pending out-of-time.
-.It "weektime time Maximum login time per week.
+.It "warntime time Advance notice for pending out-of-time."
+.It "weektime time Maximum login time per week."
.El
.Pp
The
diff --git a/lib/libutil/login_cap.3 b/lib/libutil/login_cap.3
index bdab56eba50a..942171868d85 100644
--- a/lib/libutil/login_cap.3
+++ b/lib/libutil/login_cap.3
@@ -509,7 +509,7 @@ applies these to determine the authorisation style that best suites
these rules.
.Bl -bullet
.It
-If
+If
.Fa auth
is neither
.Dv NULL
@@ -524,7 +524,7 @@ default to
.Ql passwd
as the authorisation list.
.It
-If
+If
.Fa style
is not
.Dv NULL
diff --git a/lib/libutil/login_class.c b/lib/libutil/login_class.c
index 68fdf2b49ff7..263044f446a9 100644
--- a/lib/libutil/login_class.c
+++ b/lib/libutil/login_class.c
@@ -452,18 +452,21 @@ setusercontext(login_cap_t *lc, const struct passwd *pwd, uid_t uid, unsigned in
p = (rtp.prio > RTP_PRIO_MAX) ? 31 : p;
if (rtprio(RTP_SET, 0, &rtp))
syslog(LOG_WARNING, "rtprio '%s' (%s): %m",
- pwd->pw_name, lc ? lc->lc_class : LOGIN_DEFCLASS);
+ pwd ? pwd->pw_name : "-",
+ lc ? lc->lc_class : LOGIN_DEFCLASS);
} else if (p < PRIO_MIN) {
rtp.type = RTP_PRIO_REALTIME;
rtp.prio = abs(p - PRIO_MIN + RTP_PRIO_MAX);
p = (rtp.prio > RTP_PRIO_MAX) ? 1 : p;
if (rtprio(RTP_SET, 0, &rtp))
syslog(LOG_WARNING, "rtprio '%s' (%s): %m",
- pwd->pw_name, lc ? lc->lc_class : LOGIN_DEFCLASS);
+ 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->pw_name, lc ? lc->lc_class : LOGIN_DEFCLASS);
+ pwd ? pwd->pw_name : "-",
+ lc ? lc->lc_class : LOGIN_DEFCLASS);
}
}
diff --git a/lib/libutil/pidfile.3 b/lib/libutil/pidfile.3
index c42b95b1f838..30c880c1ad06 100644
--- a/lib/libutil/pidfile.3
+++ b/lib/libutil/pidfile.3
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 16, 2011
+.Dd February 8, 2012
.Dt PIDFILE 3
.Os
.Sh NAME
@@ -36,7 +36,6 @@
.Sh LIBRARY
.Lb libutil
.Sh SYNOPSIS
-.In sys/param.h
.In libutil.h
.Ft "struct pidfh *"
.Fn pidfile_open "const char *path" "mode_t mode" "pid_t *pidptr"
@@ -46,6 +45,8 @@
.Fn pidfile_close "struct pidfh *pfh"
.Ft int
.Fn pidfile_remove "struct pidfh *pfh"
+.Ft int
+.Fn pidfile_fileno "struct pidfh *pfh"
.Sh DESCRIPTION
The
.Nm pidfile
@@ -77,10 +78,16 @@ argument is
.Dv NULL ,
.Pa /var/run/ Ns Ao Va progname Ac Ns Pa .pid
file will be used.
+The
+.Fn pidfile_open
+function sets the O_CLOEXEC close-on-exec flag when opening the pidfile.
.Pp
The
.Fn pidfile_write
function writes process' PID into a previously opened file.
+The file is truncated before write, so calling the
+.Fn pidfile_write
+function multiple times is supported.
.Pp
The
.Fn pidfile_close
@@ -92,6 +99,10 @@ to start a child process.
The
.Fn pidfile_remove
function closes and removes a pidfile.
+.Pp
+The
+.Fn pidfile_fileno
+function returns the file descriptor for the open pidfile.
.Sh RETURN VALUES
The
.Fn pidfile_open
@@ -105,15 +116,27 @@ If an error occurs,
will be set.
.Pp
.Rv -std pidfile_write pidfile_close pidfile_remove
+.Pp
+The
+.Fn pidfile_fileno
+function returns the low-level file descriptor.
+It returns
+.Li -1
+and sets
+.Va errno
+if a NULL
+.Vt pidfh
+is specified, or if the pidfile is no longer open.
.Sh EXAMPLES
The following example shows in which order these functions should be used.
Note that it is safe to pass
.Dv NULL
to
.Fn pidfile_write ,
-.Fn pidfile_remove
-and
+.Fn pidfile_remove ,
.Fn pidfile_close
+and
+.Fn pidfile_fileno
functions.
.Bd -literal
struct pidfh *pfh;
@@ -127,6 +150,11 @@ if (pfh == NULL) {
}
/* If we cannot create pidfile from other reasons, only warn. */
warn("Cannot open or create pidfile");
+ /*
+ * Eventhough pfh is NULL we can continue, as the other pidfile_*
+ * function can handle such situation by doing nothing except setting
+ * errno to EDOOFUS.
+ */
}
if (daemon(0, 0) == -1) {
@@ -244,6 +272,16 @@ and
system calls and the
.Xr flopen 3
library function.
+.Pp
+The
+.Fn pidfile_fileno
+function will fail if:
+.Bl -tag -width Er
+.It Bq Er EDOOFUS
+Improper function use.
+Probably called not from the process which used
+.Fn pidfile_open .
+.El
.Sh SEE ALSO
.Xr open 2 ,
.Xr daemon 3 ,
diff --git a/lib/libutil/pidfile.c b/lib/libutil/pidfile.c
index 953d1e0438e6..bca0315b219c 100644
--- a/lib/libutil/pidfile.c
+++ b/lib/libutil/pidfile.c
@@ -41,10 +41,17 @@ __FBSDID("$FreeBSD$");
#include <errno.h>
#include <libutil.h>
+struct pidfh {
+ int pf_fd;
+ char pf_path[MAXPATHLEN + 1];
+ dev_t pf_dev;
+ ino_t pf_ino;
+};
+
static int _pidfile_remove(struct pidfh *pfh, int freeit);
static int
-pidfile_verify(struct pidfh *pfh)
+pidfile_verify(const struct pidfh *pfh)
{
struct stat sb;
@@ -117,7 +124,7 @@ pidfile_open(const char *path, mode_t mode, pid_t *pidptr)
* pidfile_write() can be called multiple times.
*/
fd = flopen(pfh->pf_path,
- O_WRONLY | O_CREAT | O_TRUNC | O_NONBLOCK, mode);
+ O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NONBLOCK, mode);
if (fd == -1) {
if (errno == EWOULDBLOCK && pidptr != NULL) {
count = 20;
@@ -137,6 +144,7 @@ pidfile_open(const char *path, mode_t mode, pid_t *pidptr)
free(pfh);
return (NULL);
}
+
/*
* Remember file information, so in pidfile_write() we are sure we write
* to the proper descriptor.
@@ -252,3 +260,14 @@ pidfile_remove(struct pidfh *pfh)
return (_pidfile_remove(pfh, 1));
}
+
+int
+pidfile_fileno(const struct pidfh *pfh)
+{
+
+ if (pfh == NULL || pfh->pf_fd == -1) {
+ errno = EDOOFUS;
+ return (-1);
+ }
+ return (pfh->pf_fd);
+}
diff --git a/lib/libutil/property.3 b/lib/libutil/property.3
index b3630890c8ca..efe0079f07f9 100644
--- a/lib/libutil/property.3
+++ b/lib/libutil/property.3
@@ -36,7 +36,6 @@
.Sh LIBRARY
.Lb libutil
.Sh SYNOPSIS
-.In sys/types.h
.In libutil.h
.Ft properties
.Fn properties_read "int fd"
diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c
index 1068eff6ea9d..63c63de81aa6 100644
--- a/lib/libutil/pw_util.c
+++ b/lib/libutil/pw_util.c
@@ -347,7 +347,8 @@ pw_edit(int notsetuid)
sigprocmask(SIG_SETMASK, &oldsigset, NULL);
if (stat(tempname, &st2) == -1)
return (-1);
- return (st1.st_mtime != st2.st_mtime);
+ return (st1.st_mtim.tv_sec != st2.st_mtim.tv_sec ||
+ st1.st_mtim.tv_nsec != st2.st_mtim.tv_nsec);
}
/*
@@ -406,7 +407,21 @@ pw_make(const struct passwd *pw)
pw->pw_passwd, (uintmax_t)pw->pw_uid, (uintmax_t)pw->pw_gid,
pw->pw_class, (uintmax_t)pw->pw_change, (uintmax_t)pw->pw_expire,
pw->pw_gecos, pw->pw_dir, pw->pw_shell);
- return line;
+ return (line);
+}
+
+/*
+ * Make a passwd line (in v7 format) out of a struct passwd
+ */
+char *
+pw_make_v7(const struct passwd *pw)
+{
+ char *line;
+
+ asprintf(&line, "%s:*:%ju:%ju:%s:%s:%s", pw->pw_name,
+ (uintmax_t)pw->pw_uid, (uintmax_t)pw->pw_gid,
+ pw->pw_gecos, pw->pw_dir, pw->pw_shell);
+ return (line);
}
/*
diff --git a/lib/libutil/quotafile.3 b/lib/libutil/quotafile.3
index 8a78cd33c62b..1e75e9a87164 100644
--- a/lib/libutil/quotafile.3
+++ b/lib/libutil/quotafile.3
@@ -242,7 +242,7 @@ limit and usage values written to the quota file will be clipped to 32 bits.
.Sh RETURN VALUES
If the filesystem has quotas associated with it,
.Fn quota_open
-returns a pointer to a
+returns a pointer to a
.Vt quotafile
structure used in subsequent quota access calls.
If the filesystem has no quotas, or access permission is denied
@@ -285,6 +285,6 @@ functions first appeared in
The
.Nm quotafile
functions and this manual page were written by
-.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org
+.An Dag-Erling Sm\(/orgrav Aq des@FreeBSD.org
and
.An Marshall Kirk McKusick Aq mckusick@mckusick.com .
diff --git a/lib/libutil/realhostname.3 b/lib/libutil/realhostname.3
index 0300ed3525b5..28e232567bf9 100644
--- a/lib/libutil/realhostname.3
+++ b/lib/libutil/realhostname.3
@@ -33,8 +33,6 @@
.Sh LIBRARY
.Lb libutil
.Sh SYNOPSIS
-.In sys/types.h
-.In netinet/in.h
.In libutil.h
.Ft int
.Fn realhostname "char *host" "size_t hsize" "const struct in_addr *ip"
diff --git a/lib/libvgl/bitmap.c b/lib/libvgl/bitmap.c
index ec99d26c7126..fa130c580583 100644
--- a/lib/libvgl/bitmap.c
+++ b/lib/libvgl/bitmap.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1991-1997 Søren Schmidt
+ * Copyright (c) 1991-1997 Søren Schmidt
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/lib/libvgl/keyboard.c b/lib/libvgl/keyboard.c
index 5c437ad45334..9811650cc4a8 100644
--- a/lib/libvgl/keyboard.c
+++ b/lib/libvgl/keyboard.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1997 Søren Schmidt
+ * Copyright (c) 1997 Søren Schmidt
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/lib/libvgl/main.c b/lib/libvgl/main.c
index 8506a1bc8729..964d355377f9 100644
--- a/lib/libvgl/main.c
+++ b/lib/libvgl/main.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1991-1997 Søren Schmidt
+ * Copyright (c) 1991-1997 Søren Schmidt
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/lib/libvgl/mouse.c b/lib/libvgl/mouse.c
index 4f9dc6210530..7d9465b1b541 100644
--- a/lib/libvgl/mouse.c
+++ b/lib/libvgl/mouse.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1991-1997 Søren Schmidt
+ * Copyright (c) 1991-1997 Søren Schmidt
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/lib/libvgl/simple.c b/lib/libvgl/simple.c
index 3961aa0aca30..4ca90fc05a5a 100644
--- a/lib/libvgl/simple.c
+++ b/lib/libvgl/simple.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1991-1997 Søren Schmidt
+ * Copyright (c) 1991-1997 Søren Schmidt
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -242,8 +242,8 @@ VGLLine(VGLBitmap *object, int x1, int y1, int x2, int y2, u_long color)
if (x1 > x2) { /* start from the smaller coordinate */
x = x2;
y = y2;
- x1 = x1;
- y1 = y1;
+/* x1 = x1;
+ y1 = y1; */
} else {
x = x1;
y = y1;
diff --git a/lib/libvgl/text.c b/lib/libvgl/text.c
index 757702f12655..02ee420e3cb4 100644
--- a/lib/libvgl/text.c
+++ b/lib/libvgl/text.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1991-1997 Søren Schmidt
+ * Copyright (c) 1991-1997 Søren Schmidt
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/lib/libvgl/vgl.3 b/lib/libvgl/vgl.3
index ca628f75e62d..0979e44483a8 100644
--- a/lib/libvgl/vgl.3
+++ b/lib/libvgl/vgl.3
@@ -1,4 +1,5 @@
-.\" Copyright (c) 1997 Søren Schmidt
+.\"-
+.\" Copyright (c) 1997 Søren Schmidt
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -25,7 +26,7 @@
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
-.Dd November 7, 1999
+.Dd February 25, 2012
.Dt VGL 3
.Os
.Sh NAME
@@ -385,7 +386,7 @@ Passing an in-memory bitmap to this function results in error.
The desired virtual screen width may not be achievable because
of the video card hardware.
In such case the video driver (and
-underlaying video BIOS) may choose the next largest values.
+underlying video BIOS) may choose the next largest values.
Always examine
.Va object->VXsize
and
diff --git a/lib/libvgl/vgl.h b/lib/libvgl/vgl.h
index 1b843829d72b..742a903c0763 100644
--- a/lib/libvgl/vgl.h
+++ b/lib/libvgl/vgl.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 1991-1997 Søren Schmidt
+ * Copyright (c) 1991-1997 Søren Schmidt
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/lib/libypclnt/Makefile b/lib/libypclnt/Makefile
index 5a3ecb42aa2c..2e302f124289 100644
--- a/lib/libypclnt/Makefile
+++ b/lib/libypclnt/Makefile
@@ -22,7 +22,7 @@ GENSRCS=yp.h \
yppasswd_private_clnt.c \
yppasswd_private_xdr.c
-RPCGEN= rpcgen -C
+RPCGEN= RPCGEN_CPP=${CPP:Q} rpcgen -C
RPCSRC= ${.CURDIR}/../../include/rpcsvc/yp.x
RPCSRC_PW= ${.CURDIR}/../../include/rpcsvc/yppasswd.x
RPCSRC_PRIV= ${.CURDIR}/../../usr.sbin/rpc.yppasswdd/yppasswd_private.x
diff --git a/lib/libz/Makefile b/lib/libz/Makefile
index 8ae9aeb4929f..e373e834cbf6 100644
--- a/lib/libz/Makefile
+++ b/lib/libz/Makefile
@@ -47,10 +47,6 @@ ACFLAGS+= -Wa,--noexecstack
#SRCS+= gvmat64.S
#CFLAGS+= -DASMV -DNO_UNDERLINE
#ACFLAGS+= -Wa,--noexecstack
-#.if ${CC:T:Mclang} == "clang"
-## XXX: clang integrated-as doesn't grok .intel_syntax directives yet
-#ACFLAGS+= ${.IMPSRC:T:Mgvmat64.S:C/^.+$/-no-integrated-as/}
-#.endif
#.endif
VERSION_DEF= ${.CURDIR}/Versions.def
@@ -71,3 +67,7 @@ test: example minigzip
echo hello world | ./minigzip | ./minigzip -d )
.include <bsd.lib.mk>
+
+## XXX: clang integrated-as doesn't grok .intel_syntax directives yet
+#ACFLAGS.gvmat64.S= ${CLANG_NO_IAS}
+#ACFLAGS+= ${ACFLAGS.${.IMPSRC:T}}
diff --git a/lib/msun/Makefile b/lib/msun/Makefile
index f1385f13dc63..0646dc05d6da 100644
--- a/lib/msun/Makefile
+++ b/lib/msun/Makefile
@@ -125,7 +125,7 @@ XRINT_CFLAGS:= ${.IMPSRC:M*/s_nearbyint.c:C/^.+$/${XRINT_CFLAGS}/:C/^$//}
SRCS= ${COMMON_SRCS} ${ARCH_SRCS}
-INCS= fenv.h math.h
+INCS+= fenv.h math.h
MAN= acos.3 acosh.3 asin.3 asinh.3 atan.3 atan2.3 atanh.3 \
ceil.3 ccos.3 ccosh.3 cexp.3 \
diff --git a/lib/msun/arm/Symbol.map b/lib/msun/arm/Symbol.map
index 971112e30c8a..c43d8cf09052 100644
--- a/lib/msun/arm/Symbol.map
+++ b/lib/msun/arm/Symbol.map
@@ -5,8 +5,13 @@ FBSD_1.0 {
};
FBSD_1.3 {
+ feclearexcept;
+ fegetexceptflag;
fesetexceptflag;
feraiseexcept;
+ fetestexcept;
+ fegetround;
+ fesetround;
fegetenv;
feholdexcept;
feupdateenv;
diff --git a/lib/msun/arm/fenv.c b/lib/msun/arm/fenv.c
index a5a5c03d3a74..c94f9b4060c5 100644
--- a/lib/msun/arm/fenv.c
+++ b/lib/msun/arm/fenv.c
@@ -29,6 +29,20 @@
#define __fenv_static
#include "fenv.h"
+/*
+ * The following macros map between the softfloat emulator's flags and
+ * the hardware's FPSR. The hardware this file was written for doesn't
+ * have rounding control bits, so we stick those in the system ID byte.
+ */
+#define __set_env(env, flags, mask, rnd) env = ((flags) \
+ | (mask)<<_FPUSW_SHIFT \
+ | (rnd) << 24)
+#define __env_flags(env) ((env) & FE_ALL_EXCEPT)
+#define __env_mask(env) (((env) >> _FPUSW_SHIFT) \
+ & FE_ALL_EXCEPT)
+#define __env_round(env) (((env) >> 24) & _ROUND_MASK)
+#include "fenv-softfloat.h"
+
#ifdef __GNUC_GNU_INLINE__
#error "This file must be compiled with C99 'inline' semantics"
#endif
diff --git a/lib/msun/arm/fenv.h b/lib/msun/arm/fenv.h
index f11499806bea..e245fb0ca9a8 100644
--- a/lib/msun/arm/fenv.h
+++ b/lib/msun/arm/fenv.h
@@ -64,13 +64,24 @@ extern const fenv_t __fe_dfl_env;
#define _FPUSW_SHIFT 16
#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT)
-#ifdef ARM_HARD_FLOAT
+#ifndef ARM_HARD_FLOAT
+
+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 /* ARM_HARD_FLOAT */
+
#define __rfs(__fpsr) __asm __volatile("rfs %0" : "=r" (*(__fpsr)))
#define __wfs(__fpsr) __asm __volatile("wfs %0" : : "r" (__fpsr))
-#else
-#define __rfs(__fpsr)
-#define __wfs(__fpsr)
-#endif
__fenv_static inline int
feclearexcept(int __excepts)
@@ -218,6 +229,8 @@ fegetexcept(void)
#endif /* __BSD_VISIBLE */
+#endif /* ARM_HARD_FLOAT */
+
__END_DECLS
#endif /* !_FENV_H_ */
diff --git a/lib/msun/man/csqrt.3 b/lib/msun/man/csqrt.3
index ef5445f6050a..1a1dfa055631 100644
--- a/lib/msun/man/csqrt.3
+++ b/lib/msun/man/csqrt.3
@@ -66,14 +66,14 @@ the same sign.
For infinities and \*(Nas, the following rules apply, with the
earlier rules having precedence:
.Bl -column -offset indent "-\*(If + \*(Na*I" "\*(If \*(Pm \*(If*I " "(for all k)"
-.Em Input Result
+.Em "Input" Ta Em "Result" Ta \&
k + \*(If*I \*(If + \*(If*I (for all k)
--\*(If + \*(Na*I \*(Na \*(Pm \*(If*I
-\*(If + \*(Na*I \*(If + \*(Na*I
-k + \*(Na*I \*(Na + \*(Na*I
-\*(Na + k*I \*(Na + \*(Na*I
--\*(If + k*I +0 + \*(If*I
-\*(If + k*I \*(If + 0*I
+-\*(If + \*(Na*I \*(Na \*(Pm \*(If*I \&
+\*(If + \*(Na*I \*(If + \*(Na*I \&
+k + \*(Na*I \*(Na + \*(Na*I \&
+\*(Na + k*I \*(Na + \*(Na*I \&
+-\*(If + k*I +0 + \*(If*I \&
+\*(If + k*I \*(If + 0*I \&
.El
.Pp
For numbers with negative imaginary parts, the above special cases
diff --git a/lib/msun/man/ieee.3 b/lib/msun/man/ieee.3
index d25a98f1735d..57e1fcde2fd5 100644
--- a/lib/msun/man/ieee.3
+++ b/lib/msun/man/ieee.3
@@ -271,7 +271,6 @@ integer multiple of 0.5**16494 = 6.5e\-4966.
.Ed
.Ed
.Ss Additional Information Regarding Exceptions
-.Pp
For each kind of floating-point exception, IEEE 754
provides a Flag that is raised each time its exception
is signaled, and stays raised until the program resets
diff --git a/lib/msun/src/fenv-softfloat.h b/lib/msun/src/fenv-softfloat.h
new file mode 100644
index 000000000000..02d2a2c6b879
--- /dev/null
+++ b/lib/msun/src/fenv-softfloat.h
@@ -0,0 +1,184 @@
+/*-
+ * Copyright (c) 2004-2011 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.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _FENV_H_
+#error "This file is meant to be included only by <fenv.h>."
+#endif
+
+/*
+ * This file implements the functionality of <fenv.h> on platforms that
+ * lack an FPU and use softfloat in libc for floating point. To use it,
+ * you must write an <fenv.h> that provides the following:
+ *
+ * - a typedef for fenv_t, which may be an integer or struct type
+ * - a typedef for fexcept_t (XXX This file assumes fexcept_t is a
+ * simple integer type containing the exception mask.)
+ * - definitions of FE_* constants for the five exceptions and four
+ * rounding modes in IEEE 754, as described in fenv(3)
+ * - a definition, and the corresponding external symbol, for FE_DFL_ENV
+ * - a macro __set_env(env, flags, mask, rnd), which sets the given fenv_t
+ * from the exception flags, mask, and rounding mode
+ * - macros __env_flags(env), __env_mask(env), and __env_round(env), which
+ * extract fields from an fenv_t
+ * - a definition of __fenv_static
+ *
+ * If the architecture supports an optional FPU, it's recommended that you
+ * define fenv_t and fexcept_t to match the hardware ABI. Otherwise, it
+ * doesn't matter how you define them.
+ */
+
+extern int __softfloat_float_exception_flags;
+extern int __softfloat_float_exception_mask;
+extern int __softfloat_float_rounding_mode;
+void __softfloat_float_raise(int);
+
+__fenv_static inline int
+feclearexcept(int __excepts)
+{
+
+ __softfloat_float_exception_flags &= ~__excepts;
+ return (0);
+}
+
+__fenv_static inline int
+fegetexceptflag(fexcept_t *__flagp, int __excepts)
+{
+
+ *__flagp = __softfloat_float_exception_flags & __excepts;
+ return (0);
+}
+
+__fenv_static inline int
+fesetexceptflag(const fexcept_t *__flagp, int __excepts)
+{
+
+ __softfloat_float_exception_flags &= ~__excepts;
+ __softfloat_float_exception_flags |= *__flagp & __excepts;
+ return (0);
+}
+
+__fenv_static inline int
+feraiseexcept(int __excepts)
+{
+
+ __softfloat_float_raise(__excepts);
+ return (0);
+}
+
+__fenv_static inline int
+fetestexcept(int __excepts)
+{
+
+ return (__softfloat_float_exception_flags & __excepts);
+}
+
+__fenv_static inline int
+fegetround(void)
+{
+
+ return (__softfloat_float_rounding_mode);
+}
+
+__fenv_static inline int
+fesetround(int __round)
+{
+
+ __softfloat_float_rounding_mode = __round;
+ return (0);
+}
+
+__fenv_static inline int
+fegetenv(fenv_t *__envp)
+{
+
+ __set_env(*__envp, __softfloat_float_exception_flags,
+ __softfloat_float_exception_mask, __softfloat_float_rounding_mode);
+ return (0);
+}
+
+__fenv_static inline int
+feholdexcept(fenv_t *__envp)
+{
+ fenv_t __env;
+
+ fegetenv(__envp);
+ __softfloat_float_exception_flags = 0;
+ __softfloat_float_exception_mask = 0;
+ return (0);
+}
+
+__fenv_static inline int
+fesetenv(const fenv_t *__envp)
+{
+
+ __softfloat_float_exception_flags = __env_flags(*__envp);
+ __softfloat_float_exception_mask = __env_mask(*__envp);
+ __softfloat_float_rounding_mode = __env_round(*__envp);
+ return (0);
+}
+
+__fenv_static inline int
+feupdateenv(const fenv_t *__envp)
+{
+ int __oflags = __softfloat_float_exception_flags;
+
+ fesetenv(__envp);
+ feraiseexcept(__oflags);
+ return (0);
+}
+
+#if __BSD_VISIBLE
+
+/* We currently provide no external definitions of the functions below. */
+
+static inline int
+feenableexcept(int __mask)
+{
+ int __omask = __softfloat_float_exception_mask;
+
+ __softfloat_float_exception_mask |= __mask;
+ return (__omask);
+}
+
+static inline int
+fedisableexcept(int __mask)
+{
+ int __omask = __softfloat_float_exception_mask;
+
+ __softfloat_float_exception_mask &= ~__mask;
+ return (__omask);
+}
+
+static inline int
+fegetexcept(void)
+{
+
+ return (__softfloat_float_exception_mask);
+}
+
+#endif /* __BSD_VISIBLE */
diff --git a/lib/msun/src/k_expf.c b/lib/msun/src/k_expf.c
index a860b9f74aed..548a008f86be 100644
--- a/lib/msun/src/k_expf.c
+++ b/lib/msun/src/k_expf.c
@@ -44,7 +44,7 @@ static const float kln2 = 162.88958740F; /* k * ln2 */
static float
__frexp_expf(float x, int *expt)
{
- double exp_x;
+ float exp_x;
uint32_t hx;
exp_x = expf(x - kln2);
diff --git a/lib/msun/src/s_fabsl.c b/lib/msun/src/s_fabsl.c
index f150dddb842c..29831d2d24fd 100644
--- a/lib/msun/src/s_fabsl.c
+++ b/lib/msun/src/s_fabsl.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2003 Dag-Erling Coïdan Smørgrav
+ * Copyright (c) 2003 Dag-Erling Smørgrav
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/lib/msun/src/s_remquo.c b/lib/msun/src/s_remquo.c
index a64277a2df44..d811c69da90c 100644
--- a/lib/msun/src/s_remquo.c
+++ b/lib/msun/src/s_remquo.c
@@ -51,7 +51,7 @@ remquo(double x, double y, int *quo)
goto fixup; /* |x|<|y| return x or x-y */
}
if(lx==ly) {
- *quo = 1;
+ *quo = (sxy ? -1 : 1);
return Zero[(u_int32_t)sx>>31]; /* |x|=|y| return x*0*/
}
}
@@ -114,6 +114,7 @@ remquo(double x, double y, int *quo)
/* convert back to floating value and restore the sign */
if((hx|lx)==0) { /* return sign(x)*0 */
+ q &= 0x7fffffff;
*quo = (sxy ? -q : q);
return Zero[(u_int32_t)sx>>31];
}
@@ -129,9 +130,9 @@ remquo(double x, double y, int *quo)
lx = (lx>>n)|((u_int32_t)hx<<(32-n));
hx >>= n;
} else if (n<=31) {
- lx = (hx<<(32-n))|(lx>>n); hx = sx;
+ lx = (hx<<(32-n))|(lx>>n); hx = 0;
} else {
- lx = hx>>(n-32); hx = sx;
+ lx = hx>>(n-32); hx = 0;
}
}
fixup:
diff --git a/lib/msun/src/s_remquof.c b/lib/msun/src/s_remquof.c
index 3141642116a2..f7b4c0065ce8 100644
--- a/lib/msun/src/s_remquof.c
+++ b/lib/msun/src/s_remquof.c
@@ -46,7 +46,7 @@ remquof(float x, float y, int *quo)
q = 0;
goto fixup; /* |x|<|y| return x or x-y */
} else if(hx==hy) {
- *quo = 1;
+ *quo = (sxy ? -1 : 1);
return Zero[(u_int32_t)sx>>31]; /* |x|=|y| return x*0*/
}
@@ -88,6 +88,7 @@ remquof(float x, float y, int *quo)
/* convert back to floating value and restore the sign */
if(hx==0) { /* return sign(x)*0 */
+ q &= 0x7fffffff;
*quo = (sxy ? -q : q);
return Zero[(u_int32_t)sx>>31];
}
diff --git a/lib/msun/src/s_remquol.c b/lib/msun/src/s_remquol.c
index 9f5b578f32d1..712651c94ee6 100644
--- a/lib/msun/src/s_remquol.c
+++ b/lib/msun/src/s_remquol.c
@@ -96,7 +96,7 @@ remquol(long double x, long double y, int *quo)
goto fixup; /* |x|<|y| return x or x-y */
}
if(ux.bits.manh==uy.bits.manh && ux.bits.manl==uy.bits.manl) {
- *quo = 1;
+ *quo = (sxy ? -1 : 1);
return Zero[sx]; /* |x|=|y| return x*0*/
}
}
@@ -138,6 +138,7 @@ remquol(long double x, long double y, int *quo)
/* convert back to floating value and restore the sign */
if((hx|lx)==0) { /* return sign(x)*0 */
+ q &= 0x7fffffff;
*quo = (sxy ? -q : q);
return Zero[sx];
}