aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-05-16 19:54:47 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-05-16 19:54:47 +0000
commit209be2056033a52a8df733cbc88eeefc104b16e8 (patch)
tree4deb264d4d552251180fe91c11e50eace938853d
parent50f2b14e11634ced16ed987dd667da900522dd57 (diff)
parent4dd362f93f0ab737b0ecdf3d706bea46826708d1 (diff)
Merge ^/head r317971 through r318379.
Notes
Notes: svn path=/projects/clang500-import/; revision=318381
-rw-r--r--Makefile.inc147
-rw-r--r--Makefile.libcompat4
-rw-r--r--README2
-rw-r--r--bin/dd/Makefile.depend1
-rw-r--r--bin/sh/expand.c11
-rw-r--r--bin/sh/tests/builtins/Makefile2
-rw-r--r--bin/sh/tests/builtins/case21.010
-rw-r--r--bin/sh/tests/builtins/case22.010
-rw-r--r--contrib/atf/atf-c/detail/process_test.c11
-rw-r--r--contrib/binutils/gas/config/tc-arm.c16
-rw-r--r--contrib/bmake/ChangeLog26
-rw-r--r--contrib/bmake/Makefile4
-rw-r--r--contrib/bmake/main.c9
-rw-r--r--contrib/bmake/mk/ChangeLog34
-rw-r--r--contrib/bmake/mk/FILES1
-rw-r--r--contrib/bmake/mk/dirdeps.mk12
-rw-r--r--contrib/bmake/mk/doc.mk4
-rw-r--r--contrib/bmake/mk/files.mk83
-rw-r--r--contrib/bmake/mk/final.mk12
-rw-r--r--contrib/bmake/mk/inc.mk72
-rw-r--r--contrib/bmake/mk/init.mk16
-rw-r--r--contrib/bmake/mk/install-mk6
-rw-r--r--contrib/bmake/mk/lib.mk30
-rwxr-xr-xcontrib/bmake/mk/meta2deps.py6
-rw-r--r--contrib/bmake/mk/own.mk27
-rw-r--r--contrib/bmake/mk/prog.mk25
-rw-r--r--contrib/bmake/mk/scripts.mk101
-rw-r--r--contrib/bmake/mk/sys/AIX.mk2
-rw-r--r--contrib/bmake/mk/sys/Darwin.mk2
-rw-r--r--contrib/bmake/mk/sys/Generic.mk4
-rw-r--r--contrib/bmake/mk/sys/HP-UX.mk4
-rw-r--r--contrib/bmake/mk/sys/IRIX.mk2
-rw-r--r--contrib/bmake/mk/sys/Linux.mk4
-rw-r--r--contrib/bmake/mk/sys/NetBSD.mk2
-rw-r--r--contrib/bmake/mk/sys/OSF1.mk4
-rw-r--r--contrib/bmake/mk/sys/OpenBSD.mk2
-rw-r--r--contrib/bmake/mk/sys/SunOS.mk4
-rw-r--r--contrib/bmake/mk/sys/UnixWare.mk4
-rw-r--r--contrib/bmake/parse.c5
-rw-r--r--contrib/bmake/str.c6
-rw-r--r--contrib/gcc/config/arm/libgcc-bpabi.ver8
-rw-r--r--contrib/gcc/config/arm/libunwind-arm.S18
-rw-r--r--contrib/gcc/libgcc-std.ver2
-rw-r--r--contrib/ipfilter/lib/ipf_perror.c2
-rw-r--r--contrib/ipfilter/lib/printhash_live.c2
-rw-r--r--contrib/ipfilter/lib/printhashnode.c49
-rw-r--r--contrib/ipfilter/lib/printpoolnode.c26
-rw-r--r--contrib/ipfilter/tools/ippool.c67
-rw-r--r--contrib/libarchive/cpio/test/test_option_lz4.c2
-rw-r--r--contrib/libxo/configure.ac25
-rw-r--r--contrib/libxo/doc/Makefile.am4
-rw-r--r--contrib/libxo/doc/libxo-manual.html391
-rw-r--r--contrib/libxo/doc/libxo.txt45
-rw-r--r--contrib/libxo/libxo/Makefile.am7
-rw-r--r--contrib/libxo/libxo/libxo.c543
-rw-r--r--contrib/libxo/libxo/xo.h109
-rw-r--r--contrib/libxo/libxo/xo_buf.h10
-rw-r--r--contrib/libxo/libxo/xo_encoder.c4
-rw-r--r--contrib/libxo/libxo/xo_format.52
-rw-r--r--contrib/libxo/libxo/xo_options.7147
-rw-r--r--contrib/libxo/libxo/xo_syslog.c15
-rw-r--r--contrib/libxo/tests/core/saved/test_01.E.out2
-rw-r--r--contrib/libxo/tests/core/saved/test_01.J.out2
-rw-r--r--contrib/libxo/tests/core/saved/test_01.JP.out2
-rw-r--r--contrib/libxo/tests/core/saved/test_01.X.out2
-rw-r--r--contrib/libxo/tests/core/saved/test_01.XP.out2
-rw-r--r--contrib/libxo/tests/core/saved/test_10.X.out2
-rw-r--r--contrib/libxo/tests/core/saved/test_10.XP.out2
-rw-r--r--contrib/libxo/tests/core/saved/test_11.X.out2
-rw-r--r--contrib/libxo/tests/core/saved/test_11.XP.out2
-rw-r--r--contrib/libxo/tests/core/test_01.c4
-rw-r--r--contrib/libxo/tests/gettext/saved/gt_01.J.out2
-rw-r--r--contrib/libxo/tests/gettext/saved/gt_01.JP.out2
-rw-r--r--contrib/libxo/xo/xo.c4
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_realpath.c10
-rwxr-xr-xcontrib/netbsd-tests/lib/libc/ssp/t_ssp.sh6
-rw-r--r--contrib/netbsd-tests/lib/libc/sys/t_wait.c12
-rwxr-xr-xcontrib/netbsd-tests/usr.bin/grep/t_grep.sh64
-rw-r--r--crypto/openssh/auth-pam.c3
-rw-r--r--crypto/openssh/auth.c4
-rw-r--r--crypto/openssh/auth1.c5
-rw-r--r--crypto/openssh/auth2.c5
-rw-r--r--crypto/openssh/blacklist.c6
-rw-r--r--crypto/openssh/blacklist_client.h12
-rw-r--r--crypto/openssh/packet.c2
-rw-r--r--crypto/openssh/sshd.c2
-rw-r--r--etc/Makefile3
-rw-r--r--etc/mtree/BSD.tests.dist2
-rw-r--r--etc/newsyslog.conf6
-rw-r--r--etc/newsyslog.conf.d/Makefile24
-rw-r--r--etc/newsyslog.conf.d/amd.conf2
-rw-r--r--etc/newsyslog.conf.d/ftp.conf2
-rw-r--r--etc/newsyslog.conf.d/lpr.conf2
-rw-r--r--etc/newsyslog.conf.d/pf.conf2
-rw-r--r--etc/newsyslog.conf.d/ppp.conf2
-rw-r--r--etc/newsyslog.conf.d/sendmail.conf2
-rw-r--r--etc/syslog.conf4
-rw-r--r--etc/syslog.d/Makefile19
-rw-r--r--etc/syslog.d/ftp.conf2
-rw-r--r--etc/syslog.d/lpr.conf2
-rw-r--r--etc/syslog.d/ppp.conf3
-rw-r--r--lib/libbsnmp/libbsnmp/Makefile.depend1
-rw-r--r--lib/libc/gen/getusershell.c6
-rw-r--r--lib/libc/stdlib/realpath.c123
-rw-r--r--lib/libc/sys/open.210
-rw-r--r--lib/libmt/mtlib.c1
-rw-r--r--lib/libstand/Makefile2
-rw-r--r--lib/libstand/ip.c422
-rw-r--r--lib/libstand/net.h2
-rw-r--r--lib/libstand/nfs.c2
-rw-r--r--lib/libstand/rarp.c2
-rw-r--r--lib/libstand/udp.c136
-rw-r--r--lib/libsysdecode/Makefile.depend115
-rw-r--r--lib/libthr/thread/thr_mutex.c2
-rw-r--r--lib/libxo/Makefile3
-rw-r--r--lib/libxo/add.man4
-rw-r--r--lib/libxo/xo_config.h15
-rw-r--r--lib/libzstd/Makefile.depend19
-rw-r--r--lib/msun/src/catrig.c2
-rw-r--r--lib/msun/src/catrigf.c2
-rw-r--r--lib/msun/src/catrigl.c2
-rw-r--r--libexec/dma/dma-mbox-create/Makefile.depend1
-rw-r--r--libexec/rtld-elf/map_object.c2
-rw-r--r--libexec/rtld-elf/rtld.c116
-rwxr-xr-xrelease/scripts/atlas-upload.sh10
-rw-r--r--rescue/rescue/Makefile.depend2
-rw-r--r--sbin/decryptcore/Makefile.depend21
-rw-r--r--sbin/dumpon/Makefile.depend1
-rw-r--r--sbin/hastctl/Makefile.depend2
-rw-r--r--sbin/hastd/Makefile.depend2
-rw-r--r--sbin/ifconfig/af_link.c45
-rw-r--r--sbin/newfs_msdos/mkfs_msdos.c14
-rw-r--r--sbin/newfs_msdos/mkfs_msdos.h2
-rw-r--r--sbin/newfs_msdos/newfs_msdos.815
-rw-r--r--sbin/newfs_msdos/newfs_msdos.c25
-rw-r--r--secure/lib/libssh/Makefile4
-rw-r--r--share/doc/pjdfstest/Makefile.depend11
-rw-r--r--share/man/man4/Makefile4
-rw-r--r--share/man/man4/bnxt.44
-rw-r--r--share/man/man4/bytgpio.44
-rw-r--r--share/man/man4/cxgbev.44
-rw-r--r--share/man/man4/jedec_ts.44
-rw-r--r--share/man/man4/qlnxe.44
-rw-r--r--share/man/man4/u3g.414
-rw-r--r--share/man/man4/uark.414
-rw-r--r--share/man/man4/uart.42
-rw-r--r--share/man/man4/ubsa.414
-rw-r--r--share/man/man4/ubser.414
-rw-r--r--share/man/man4/uchcom.414
-rw-r--r--share/man/man4/ucom.414
-rw-r--r--share/man/man4/ucycom.414
-rw-r--r--share/man/man4/uftdi.414
-rw-r--r--share/man/man4/uipaq.414
-rw-r--r--share/man/man4/umcs.414
-rw-r--r--share/man/man4/umct.414
-rw-r--r--share/man/man4/umodem.414
-rw-r--r--share/man/man4/umoscom.414
-rw-r--r--share/man/man4/uplcom.414
-rw-r--r--share/man/man4/uslcom.414
-rw-r--r--share/man/man4/uvisor.414
-rw-r--r--share/man/man4/uvscom.414
-rw-r--r--share/man/man7/build.735
-rw-r--r--share/mk/bsd.progs.mk20
-rw-r--r--share/mk/local.meta.sys.mk3
-rwxr-xr-xshare/mk/meta2deps.py4
-rw-r--r--sys/amd64/acpica/acpi_wakecode.S9
-rw-r--r--sys/amd64/amd64/cpu_switch.S2
-rw-r--r--sys/amd64/amd64/pmap.c2
-rw-r--r--sys/arm/arm/busdma_machdep-v4.c6
-rw-r--r--sys/arm/arm/busdma_machdep-v6.c10
-rw-r--r--sys/arm/arm/pmap-v6.c36
-rw-r--r--sys/arm/conf/ARMADA38X10
-rw-r--r--sys/arm/include/pmap-v6.h1
-rw-r--r--sys/arm/mv/armada38x/files.armada38x1
-rw-r--r--sys/arm/mv/mv_common.c66
-rw-r--r--sys/arm/mv/mvwin.h4
-rw-r--r--sys/arm64/arm64/busdma_bounce.c29
-rw-r--r--sys/arm64/include/armreg.h2
-rw-r--r--sys/arm64/include/vm.h12
-rw-r--r--sys/boot/efi/loader/main.c2
-rw-r--r--sys/boot/i386/loader/Makefile.depend1
-rw-r--r--sys/boot/i386/pxeldr/pxeboot.84
-rw-r--r--sys/boot/i386/zfsloader/Makefile.depend1
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c114
-rw-r--r--sys/cddl/dev/dtrace/powerpc/dtrace_isa.c57
-rw-r--r--sys/cddl/dev/fbt/powerpc/fbt_isa.c4
-rw-r--r--sys/cddl/dev/profile/profile.c60
-rw-r--r--sys/compat/linuxkpi/common/src/linux_rcu.c2
-rw-r--r--sys/conf/files2
-rw-r--r--sys/conf/files.amd641
-rw-r--r--sys/conf/files.i3861
-rw-r--r--sys/conf/kern.opts.mk1
-rw-r--r--sys/conf/kern.post.mk2
-rw-r--r--sys/conf/kern.pre.mk8
-rw-r--r--sys/dev/acpica/acpi_container.c166
-rw-r--r--sys/dev/acpica/acpi_pcib_acpi.c1
-rw-r--r--sys/dev/bnxt/if_bnxt.c3
-rw-r--r--sys/dev/cxgbe/adapter.h31
-rw-r--r--sys/dev/cxgbe/t4_main.c14
-rw-r--r--sys/dev/cxgbe/t4_sge.c16
-rw-r--r--sys/dev/dpaa/if_dtsec_rm.c4
-rw-r--r--sys/dev/e1000/e1000_ich8lan.c50
-rw-r--r--sys/dev/hyperv/vmbus/vmbus.c102
-rw-r--r--sys/dev/hyperv/vmbus/vmbus_res.c98
-rw-r--r--sys/dev/iwm/if_iwm.c700
-rw-r--r--sys/dev/iwm/if_iwm_7000.c3
-rw-r--r--sys/dev/iwm/if_iwm_8000.c3
-rw-r--r--sys/dev/iwm/if_iwm_binding.c116
-rw-r--r--sys/dev/iwm/if_iwm_binding.h6
-rw-r--r--sys/dev/iwm/if_iwm_constants.h154
-rw-r--r--sys/dev/iwm/if_iwm_fw.c1
-rw-r--r--sys/dev/iwm/if_iwm_led.c3
-rw-r--r--sys/dev/iwm/if_iwm_mac_ctxt.c32
-rw-r--r--sys/dev/iwm/if_iwm_mac_ctxt.h2
-rw-r--r--sys/dev/iwm/if_iwm_notif_wait.c1
-rw-r--r--sys/dev/iwm/if_iwm_pcie_trans.c33
-rw-r--r--sys/dev/iwm/if_iwm_phy_ctxt.c13
-rw-r--r--sys/dev/iwm/if_iwm_phy_db.c1
-rw-r--r--sys/dev/iwm/if_iwm_power.c283
-rw-r--r--sys/dev/iwm/if_iwm_power.h6
-rw-r--r--sys/dev/iwm/if_iwm_scan.c1
-rw-r--r--sys/dev/iwm/if_iwm_sta.c384
-rw-r--r--sys/dev/iwm/if_iwm_sta.h223
-rw-r--r--sys/dev/iwm/if_iwm_time_event.c9
-rw-r--r--sys/dev/iwm/if_iwm_time_event.h2
-rw-r--r--sys/dev/iwm/if_iwm_util.c20
-rw-r--r--sys/dev/iwm/if_iwm_util.h9
-rw-r--r--sys/dev/iwm/if_iwmreg.h43
-rw-r--r--sys/dev/iwm/if_iwmvar.h26
-rw-r--r--sys/dev/mpr/mpr_sas.c9
-rw-r--r--sys/dev/mps/mps_sas.c11
-rw-r--r--sys/dev/qlnx/qlnxe/ecore_dev.c34
-rw-r--r--sys/dev/qlxgbe/ql_isr.c3
-rw-r--r--sys/dev/qlxgbe/ql_os.c24
-rw-r--r--sys/dev/sdhci/sdhci.c14
-rw-r--r--sys/dev/sdhci/sdhci.h2
-rw-r--r--sys/dev/sdhci/sdhci_acpi.c25
-rw-r--r--sys/dev/sdhci/sdhci_fdt.c26
-rw-r--r--sys/dev/sdhci/sdhci_pci.c3
-rw-r--r--sys/dev/usb/controller/xhci_pci.c4
-rw-r--r--sys/dev/vt/vt_core.c43
-rw-r--r--sys/fs/nfsclient/nfs_clcomsubs.c1
-rw-r--r--sys/kern/kern_sig.c8
-rw-r--r--sys/kern/subr_kobj.c12
-rw-r--r--sys/kern/vfs_subr.c98
-rw-r--r--sys/mips/include/cpuinfo.h1
-rw-r--r--sys/mips/include/frame.h2
-rw-r--r--sys/mips/include/md_var.h1
-rw-r--r--sys/mips/include/regnum.h3
-rw-r--r--sys/mips/mips/busdma_machdep.c10
-rw-r--r--sys/mips/mips/cpu.c17
-rw-r--r--sys/mips/mips/pm_machdep.c4
-rw-r--r--sys/mips/mips/swtch.S38
-rw-r--r--sys/modules/Makefile6
-rw-r--r--sys/modules/dtb/mv/Makefile7
-rw-r--r--sys/modules/hyperv/vmbus/Makefile1
-rw-r--r--sys/modules/iwm/Makefile4
-rw-r--r--sys/modules/mmcsd/Makefile2
-rw-r--r--sys/modules/tests/Makefile9
-rw-r--r--sys/net/ieee8023ad_lacp.c4
-rw-r--r--sys/net/if.c34
-rw-r--r--sys/net/if_ethersubr.c3
-rw-r--r--sys/net/if_media.h12
-rw-r--r--sys/net/if_var.h2
-rw-r--r--sys/net/iflib.c1
-rw-r--r--sys/netinet/in_mcast.c3
-rw-r--r--sys/netinet/in_pcb.c18
-rw-r--r--sys/netinet/in_pcb.h2
-rw-r--r--sys/netinet/ip_divert.c10
-rw-r--r--sys/netinet/libalias/alias.c4
-rw-r--r--sys/netinet/raw_ip.c2
-rw-r--r--sys/netinet/tcp_reass.c2
-rw-r--r--sys/netinet/tcp_subr.c2
-rw-r--r--sys/netinet/udp_usrreq.c7
-rw-r--r--sys/netinet6/in6_mcast.c3
-rw-r--r--sys/netinet6/ip6_output.c1
-rw-r--r--sys/opencrypto/criov.c4
-rw-r--r--sys/opencrypto/cryptodev.h24
-rw-r--r--sys/powerpc/booke/trap_subr.S14
-rw-r--r--sys/powerpc/include/pmap.h2
-rw-r--r--sys/powerpc/powerpc/bus_machdep.c3
-rw-r--r--sys/powerpc/powerpc/pmap_dispatch.c2
-rw-r--r--sys/sys/kobj.h6
-rw-r--r--sys/sys/proc.h8
-rw-r--r--sys/sys/sockio.h1
-rw-r--r--sys/tests/callout_test/callout_test.c12
-rw-r--r--sys/tests/framework/kern_testfrwk.c6
-rw-r--r--sys/x86/acpica/acpi_wakeup.c4
-rw-r--r--sys/x86/x86/busdma_bounce.c31
-rw-r--r--targets/pseudo/clang/Makefile.depend6
-rw-r--r--targets/pseudo/userland/Makefile.depend18
-rw-r--r--targets/pseudo/userland/share/Makefile.depend2
-rw-r--r--tests/sys/aio/aio_test.c12
-rw-r--r--tests/sys/aio/local.h73
-rw-r--r--tests/sys/kern/ptrace_test.c95
-rw-r--r--tools/build/mk/OptionalObsoleteFiles.inc11
-rwxr-xr-xtools/build/options/makeman14
-rw-r--r--usr.bin/bmake/Makefile4
-rw-r--r--usr.bin/fold/Makefile.depend1
-rw-r--r--usr.bin/getaddrinfo/Makefile.depend20
-rw-r--r--usr.bin/getconf/fake-gperf.awk3
-rw-r--r--usr.bin/grep/Makefile.depend1
-rw-r--r--usr.bin/grep/grep.c18
-rw-r--r--usr.bin/grep/grep.h2
-rw-r--r--usr.bin/grep/queue.c2
-rw-r--r--usr.bin/grep/util.c3
-rw-r--r--usr.bin/hexdump/Makefile.depend1
-rw-r--r--usr.bin/iconv/Makefile.depend1
-rw-r--r--usr.bin/ident/Makefile.depend1
-rw-r--r--usr.bin/ktrdump/Makefile.depend1
-rw-r--r--usr.bin/lam/Makefile.depend1
-rw-r--r--usr.bin/last/Makefile.depend1
-rw-r--r--usr.bin/localedef/localedef.c14
-rw-r--r--usr.bin/localedef/localedef.h9
-rw-r--r--usr.bin/localedef/wide.c4
-rw-r--r--usr.bin/ministat/Makefile.depend1
-rw-r--r--usr.bin/mkimg/mkimg.118
-rw-r--r--usr.bin/mkimg/mkimg.c51
-rw-r--r--usr.bin/mkuzip/mkuzip.c5
-rw-r--r--usr.bin/mt/mt.13
-rw-r--r--usr.bin/pom/Makefile.depend1
-rw-r--r--usr.bin/procstat/Makefile6
-rw-r--r--usr.bin/procstat/procstat.173
-rw-r--r--usr.bin/procstat/tests/Makefile9
-rwxr-xr-xusr.bin/procstat/tests/procstat_test.sh140
-rw-r--r--usr.bin/procstat/tests/while1.c40
-rw-r--r--usr.bin/resizewin/resizewin.140
-rw-r--r--usr.bin/uniq/uniq.15
-rw-r--r--usr.bin/uniq/uniq.c24
-rw-r--r--usr.bin/xo/Makefile1
-rw-r--r--usr.bin/zstd/Makefile.depend20
-rw-r--r--usr.sbin/amd/amq/Makefile.depend1
-rw-r--r--usr.sbin/amd/fixmount/Makefile.depend1
-rw-r--r--usr.sbin/amd/fsinfo/Makefile.depend1
-rw-r--r--usr.sbin/amd/hlfsd/Makefile.depend1
-rw-r--r--usr.sbin/amd/libamu/Makefile.depend1
-rw-r--r--usr.sbin/amd/mk-amd-map/Makefile.depend1
-rw-r--r--usr.sbin/amd/pawd/Makefile.depend1
-rw-r--r--usr.sbin/amd/wire-test/Makefile.depend1
-rw-r--r--usr.sbin/arp/Makefile.depend2
-rw-r--r--usr.sbin/bhyve/Makefile.depend1
-rw-r--r--usr.sbin/bsnmpd/tools/libbsnmptools/Makefile.depend5
-rw-r--r--usr.sbin/mountd/mountd.c8
-rw-r--r--usr.sbin/prometheus_sysctl_exporter/Makefile.depend20
-rw-r--r--usr.sbin/pw/pw_user.c6
-rw-r--r--usr.sbin/rpc.statd/Makefile.depend1
-rw-r--r--usr.sbin/traceroute/Makefile.depend4
347 files changed, 6082 insertions, 2199 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1
index 34e55d7448f5..122dc7760147 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -302,6 +302,11 @@ CLEANDIR= clean cleandepend
CLEANDIR= cleandir
.endif
+.if defined(WORLDFAST)
+NO_CLEAN= t
+NO_OBJ= t
+.endif
+
.if ${MK_META_MODE} == "yes"
# If filemon is used then we can rely on the build being incremental-safe.
# The .meta files will also track the build command and rebuild should
@@ -310,6 +315,13 @@ CLEANDIR= cleandir
NO_CLEAN= t
.endif
.endif
+.if defined(NO_OBJ) || ${MK_AUTO_OBJ} == "yes"
+NO_OBJ= t
+NO_KERNELOBJ= t
+.endif
+.if !defined(NO_OBJ)
+_obj= obj
+.endif
LOCAL_TOOL_DIRS?=
PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
@@ -824,13 +836,22 @@ everything: .PHONY
${_+_}cd ${.CURDIR}; _PARALLEL_SUBDIR_OK=1 ${WMAKE} all
WMAKE_TGTS=
+.if !defined(WORLDFAST)
WMAKE_TGTS+= _worldtmp _legacy
.if empty(SUBDIR_OVERRIDE)
WMAKE_TGTS+= _bootstrap-tools
.endif
-WMAKE_TGTS+= _cleanobj _obj _build-tools _cross-tools
+WMAKE_TGTS+= _cleanobj
+.if !defined(NO_OBJ)
+WMAKE_TGTS+= _obj
+.endif
+WMAKE_TGTS+= _build-tools _cross-tools
WMAKE_TGTS+= _compiler-metadata
-WMAKE_TGTS+= _includes _libraries
+WMAKE_TGTS+= _includes
+.endif
+.if !defined(NO_LIBS)
+WMAKE_TGTS+= _libraries
+.endif
WMAKE_TGTS+= everything
.if defined(LIBCOMPAT) && empty(SUBDIR_OVERRIDE)
WMAKE_TGTS+= build${libcompat}
@@ -1610,7 +1631,7 @@ legacy: .PHONY
.for _tool in tools/build ${_elftoolchain_libs}
${_+_}@${ECHODIR} "===> ${_tool} (obj,includes,all,install)"; \
cd ${.CURDIR}/${_tool}; \
- ${MAKE} DIRPRFX=${_tool}/ obj; \
+ if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy includes; \
${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no all; \
${MAKE} DIRPRFX=${_tool}/ MK_INCLUDES=no \
@@ -1766,7 +1787,7 @@ bootstrap-tools: .PHONY
${_bt}-${_tool}: .PHONY .MAKE
${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
cd ${.CURDIR}/${_tool}; \
- ${MAKE} DIRPRFX=${_tool}/ obj; \
+ if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
${MAKE} DIRPRFX=${_tool}/ all; \
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX}/legacy install
@@ -1805,7 +1826,7 @@ _rescue=rescue/rescue
build-tools_${_tool}: .PHONY
${_+_}@${ECHODIR} "===> ${_tool} (obj,build-tools)"; \
cd ${.CURDIR}/${_tool}; \
- ${MAKE} DIRPRFX=${_tool}/ obj; \
+ if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
${MAKE} DIRPRFX=${_tool}/ build-tools
build-tools: build-tools_${_tool}
.endfor
@@ -1814,7 +1835,7 @@ build-tools: build-tools_${_tool}
build-tools_${_tool}: .PHONY
${_+_}@${ECHODIR} "===> ${_tool} (obj,all)"; \
cd ${.CURDIR}/${_tool}; \
- ${MAKE} DIRPRFX=${_tool}/ obj; \
+ if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
${MAKE} DIRPRFX=${_tool}/ all
build-tools: build-tools_${_tool}
.endfor
@@ -1899,7 +1920,7 @@ cross-tools: .MAKE .PHONY
${_usb_tools}
${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
cd ${.CURDIR}/${_tool}; \
- ${MAKE} DIRPRFX=${_tool}/ obj; \
+ if [ -z "${NO_OBJ}" ]; then ${MAKE} DIRPRFX=${_tool}/ obj; fi; \
${MAKE} DIRPRFX=${_tool}/ all; \
${MAKE} DIRPRFX=${_tool}/ DESTDIR=${MAKEOBJDIRPREFIX} install
.endfor
@@ -1931,7 +1952,7 @@ native-xtools: .PHONY
mkdir -p ${OBJTREE}/gperf_for_gcc/usr/bin
${_+_}@${ECHODIR} "===> ${_gperf} (obj,all,install)"; \
cd ${.CURDIR}/${_gperf}; \
- ${NXBMAKE} DIRPRFX=${_gperf}/ obj; \
+ if [ -z "${NO_OBJ}" ]; then ${NXBMAKE} DIRPRFX=${_gperf}/ obj; fi; \
${NXBMAKE} DIRPRFX=${_gperf}/ all; \
${NXBMAKE} DIRPRFX=${_gperf}/ DESTDIR=${OBJTREE}/gperf_for_gcc install
.endif
@@ -2007,7 +2028,7 @@ native-xtools: .PHONY
usr.sbin/chown
${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
cd ${.CURDIR}/${_tool}; \
- ${NXBMAKE} DIRPRFX=${_tool}/ obj; \
+ if [ -z "${NO_OBJ}" ]; then ${NXBMAKE} DIRPRFX=${_tool}/ obj; fi; \
${NXBMAKE} DIRPRFX=${_tool}/ all; \
${NXBMAKE} DIRPRFX=${_tool}/ DESTDIR=${NXBDESTDIR} install
.endfor
@@ -2269,7 +2290,7 @@ ${_lib}__PL: .PHONY .MAKE
.if exists(${.CURDIR}/${_lib})
${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
cd ${.CURDIR}/${_lib}; \
- ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
+ if [ -z "${NO_OBJ}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
DIRPRFX=${_lib}/ all; \
${MAKE} MK_TESTS=no MK_PROFILE=no -DNO_PIC \
@@ -2282,7 +2303,7 @@ ${_lib}__L: .PHONY .MAKE
.if exists(${.CURDIR}/${_lib})
${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
cd ${.CURDIR}/${_lib}; \
- ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; \
+ if [ -z "${NO_OBJ}" ]; then ${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ obj; fi; \
${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ all; \
${MAKE} MK_TESTS=no DIRPRFX=${_lib}/ install
.endif
@@ -2609,7 +2630,7 @@ _xb-bootstrap-tools: .PHONY
${_yacc}
${_+_}@${ECHODIR} "===> ${_tool} (obj,all,install)"; \
cd ${.CURDIR}/${_tool}; \
- ${CDMAKE} DIRPRFX=${_tool}/ obj; \
+ if [ -z "${NO_OBJ}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
${CDMAKE} DIRPRFX=${_tool}/ all; \
${CDMAKE} DIRPRFX=${_tool}/ DESTDIR=${CDTMP} install
.endfor
@@ -2628,7 +2649,7 @@ _xb-cross-tools: .PHONY
${_gcc}
${_+_}@${ECHODIR} "===> xdev ${_tool} (obj,all)"; \
cd ${.CURDIR}/${_tool}; \
- ${CDMAKE} DIRPRFX=${_tool}/ obj; \
+ if [ -z "${NO_OBJ}" ]; then ${CDMAKE} DIRPRFX=${_tool}/ obj; fi; \
${CDMAKE} DIRPRFX=${_tool}/ all
.endfor
diff --git a/Makefile.libcompat b/Makefile.libcompat
index e28639391df3..2e075ff098f6 100644
--- a/Makefile.libcompat
+++ b/Makefile.libcompat
@@ -163,7 +163,7 @@ build${libcompat}: .PHONY
.endif
mkdir -p ${WORLDTMP}
ln -sf ${.CURDIR}/sys ${WORLDTMP}
-.for _t in obj includes
+.for _t in ${_obj} includes
.for _dir in ${_LC_INCDIRS}
${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} MK_INCLUDES=yes \
DIRPRFX=${_dir}/ ${_t}
@@ -180,7 +180,7 @@ build${libcompat}: .PHONY
${_+_}cd ${.CURDIR}; \
${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
.if ${libcompat} == "32"
-.for _t in obj all
+.for _t in ${_obj} all
${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \
-DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \
diff --git a/README b/README
index b863557e4baa..a097ddfdb108 100644
--- a/README
+++ b/README
@@ -81,4 +81,4 @@ usr.sbin System administration commands.
For information on synchronizing your source tree with one or more of
the FreeBSD Project's development branches, please see:
- http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/synching.html
+ https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/updating-src.html
diff --git a/bin/dd/Makefile.depend b/bin/dd/Makefile.depend
index 3646e2e2b1af..4def626103ce 100644
--- a/bin/dd/Makefile.depend
+++ b/bin/dd/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/bin/sh/expand.c b/bin/sh/expand.c
index 74bb63e1f67e..3b44d5569a66 100644
--- a/bin/sh/expand.c
+++ b/bin/sh/expand.c
@@ -440,8 +440,15 @@ expari(const char *p, struct nodelist **restrict argbackq, int flag,
fmtstr(expdest, DIGITS(result), ARITH_FORMAT_STR, result);
adj = strlen(expdest);
STADJUST(adj, expdest);
- if (!quoted)
- reprocess(expdest - adj - stackblock(), flag, VSNORMAL, 0, dst);
+ /*
+ * If this is quoted, a '-' must not indicate a range in [...].
+ * If this is not quoted, splitting may occur.
+ */
+ if (quoted ?
+ result < 0 && begoff > 1 && flag & (EXP_GLOB | EXP_CASE) :
+ flag & EXP_SPLIT)
+ reprocess(expdest - adj - stackblock(), flag, VSNORMAL, quoted,
+ dst);
return p;
}
diff --git a/bin/sh/tests/builtins/Makefile b/bin/sh/tests/builtins/Makefile
index 864c8767d034..620951415c6e 100644
--- a/bin/sh/tests/builtins/Makefile
+++ b/bin/sh/tests/builtins/Makefile
@@ -40,6 +40,8 @@ ${PACKAGE}FILES+= case17.0
${PACKAGE}FILES+= case18.0
${PACKAGE}FILES+= case19.0
${PACKAGE}FILES+= case20.0
+${PACKAGE}FILES+= case21.0
+${PACKAGE}FILES+= case22.0
${PACKAGE}FILES+= cd1.0
${PACKAGE}FILES+= cd2.0
${PACKAGE}FILES+= cd3.0
diff --git a/bin/sh/tests/builtins/case21.0 b/bin/sh/tests/builtins/case21.0
new file mode 100644
index 000000000000..ea7fb054a546
--- /dev/null
+++ b/bin/sh/tests/builtins/case21.0
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+case 5 in
+[0$((-9))]) ;;
+*) echo bad1 ;;
+esac
+
+case - in
+[0$((-9))]) echo bad2 ;;
+esac
diff --git a/bin/sh/tests/builtins/case22.0 b/bin/sh/tests/builtins/case22.0
new file mode 100644
index 000000000000..ddc80051fa0a
--- /dev/null
+++ b/bin/sh/tests/builtins/case22.0
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+case 5 in
+[0"$((-9))"]) echo bad1 ;;
+esac
+
+case - in
+[0"$((-9))"]) ;;
+*) echo bad2 ;;
+esac
diff --git a/contrib/atf/atf-c/detail/process_test.c b/contrib/atf/atf-c/detail/process_test.c
index 5ae5565b6a2b..82a911df68cd 100644
--- a/contrib/atf/atf-c/detail/process_test.c
+++ b/contrib/atf/atf-c/detail/process_test.c
@@ -26,6 +26,9 @@
#include "atf-c/detail/process.h"
#include <sys/types.h>
+#ifdef __FreeBSD__
+#include <sys/sysctl.h>
+#endif
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
@@ -667,6 +670,14 @@ ATF_TC_BODY(status_coredump, tc)
atf_tc_skip("Cannot unlimit the core file size; check limits "
"manually");
+#ifdef __FreeBSD__
+ int coredump_enabled;
+ size_t ce_len = sizeof(coredump_enabled);
+ if (sysctlbyname("kern.coredump", &coredump_enabled, &ce_len, NULL,
+ 0) == 0 && !coredump_enabled)
+ atf_tc_skip("Coredumps disabled");
+#endif
+
const int rawstatus = fork_and_wait_child(child_sigquit);
atf_process_status_t s;
RE(atf_process_status_init(&s, rawstatus));
diff --git a/contrib/binutils/gas/config/tc-arm.c b/contrib/binutils/gas/config/tc-arm.c
index 5a9225b42696..1de6c190112e 100644
--- a/contrib/binutils/gas/config/tc-arm.c
+++ b/contrib/binutils/gas/config/tc-arm.c
@@ -5211,12 +5211,6 @@ parse_neon_mov (char **str, int *which_operand)
inst.operands[i].present = 1;
}
}
- else if (parse_qfloat_immediate (&ptr, &inst.operands[i].imm) == SUCCESS)
- /* Case 2: VMOV<c><q>.<dt> <Qd>, #<float-imm>
- Case 3: VMOV<c><q>.<dt> <Dd>, #<float-imm>
- Case 10: VMOV.F32 <Sd>, #<imm>
- Case 11: VMOV.F64 <Dd>, #<imm> */
- inst.operands[i].immisfloat = 1;
else if ((val = arm_typed_reg_parse (&ptr, REG_TYPE_NSDQ, &rtype,
&optype)) != FAIL)
{
@@ -5253,9 +5247,15 @@ parse_neon_mov (char **str, int *which_operand)
inst.operands[i].reg = val;
inst.operands[i].isreg = 1;
- inst.operands[i++].present = 1;
+ inst.operands[i].present = 1;
}
}
+ else if (parse_qfloat_immediate (&ptr, &inst.operands[i].imm) == SUCCESS)
+ /* Case 2: VMOV<c><q>.<dt> <Qd>, #<float-imm>
+ Case 3: VMOV<c><q>.<dt> <Dd>, #<float-imm>
+ Case 10: VMOV.F32 <Sd>, #<imm>
+ Case 11: VMOV.F64 <Dd>, #<imm> */
+ inst.operands[i].immisfloat = 1;
else if (parse_big_immediate (&ptr, i) == SUCCESS)
/* Case 2: VMOV<c><q>.<dt> <Qd>, #<imm>
Case 3: VMOV<c><q>.<dt> <Dd>, #<imm> */
@@ -5337,7 +5337,7 @@ parse_neon_mov (char **str, int *which_operand)
inst.operands[i].isvec = 1;
inst.operands[i].issingle = 1;
inst.operands[i].vectype = optype;
- inst.operands[i++].present = 1;
+ inst.operands[i].present = 1;
}
}
else
diff --git a/contrib/bmake/ChangeLog b/contrib/bmake/ChangeLog
index 99d745295870..37d3e6e32ba9 100644
--- a/contrib/bmake/ChangeLog
+++ b/contrib/bmake/ChangeLog
@@ -1,3 +1,29 @@
+2017-05-10 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile (_MAKE_VERSION): 20170510
+ Merge with NetBSD make, pick up
+ o main.c: Main_SetObjdir: ensure buf2 is in scope
+
+2017-05-08 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile (_MAKE_VERSION): 20170505
+ see mk/ChangeLog
+
+2017-05-05 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * parse.c: not everyone has stdint.h
+
+2017-05-01 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile (_MAKE_VERSION): 20170501
+ see mk/ChangeLog
+
+2017-04-21 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile (_MAKE_VERSION): 20170421
+ Merge with NetBSD make, pick up
+ o str.c: Str_Match: fix closure tests for [^] and add unit-test.
+
2017-04-20 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (_MAKE_VERSION): 20170420
diff --git a/contrib/bmake/Makefile b/contrib/bmake/Makefile
index d945769d0619..1ded36d5170b 100644
--- a/contrib/bmake/Makefile
+++ b/contrib/bmake/Makefile
@@ -1,7 +1,7 @@
-# $Id: Makefile,v 1.88 2017/04/20 14:51:14 sjg Exp $
+# $Id: Makefile,v 1.92 2017/05/10 22:29:04 sjg Exp $
# Base version on src date
-_MAKE_VERSION= 20170420
+_MAKE_VERSION= 20170510
PROG= bmake
diff --git a/contrib/bmake/main.c b/contrib/bmake/main.c
index fa1238770c09..9c52fd210d88 100644
--- a/contrib/bmake/main.c
+++ b/contrib/bmake/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.264 2017/04/20 03:57:27 sjg Exp $ */
+/* $NetBSD: main.c,v 1.265 2017/05/10 22:26:14 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.264 2017/04/20 03:57:27 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.265 2017/05/10 22:26:14 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.264 2017/04/20 03:57:27 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.265 2017/05/10 22:26:14 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -751,6 +751,7 @@ Main_SetObjdir(const char *fmt, ...)
struct stat sb;
char *path;
char buf[MAXPATHLEN + 1];
+ char buf2[MAXPATHLEN + 1];
Boolean rc = FALSE;
va_list ap;
@@ -759,8 +760,6 @@ Main_SetObjdir(const char *fmt, ...)
va_end(ap);
if (path[0] != '/') {
- char buf2[MAXPATHLEN + 1];
-
snprintf(buf2, MAXPATHLEN, "%s/%s", curdir, path);
path = buf2;
}
diff --git a/contrib/bmake/mk/ChangeLog b/contrib/bmake/mk/ChangeLog
index 58b1d0e77be1..8e42c8cbed50 100644
--- a/contrib/bmake/mk/ChangeLog
+++ b/contrib/bmake/mk/ChangeLog
@@ -1,3 +1,37 @@
+2017-05-08 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): 20170505
+
+ * meta2deps.py: fix botched indenation.
+
+2017-05-05 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * sys/*.mk: Remove setting of MAKE it is unnecessary and
+ in many cases wrong (basname rather than full path)
+
+ * scripts.mk (SCRIPTSGROUPS): make this more like files.mk and inc.mk
+
+ * init.mk: define realbuild to simplify logic in {lib,prog}.mk etc
+
+2017-05-01 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): 20170501
+
+ * doc.mk: fix typo in DOC_INSTALL_OWN
+
+ * inc.mk: handle INCGROUPS similar to freebsd
+
+ * files.mk: add something for files too
+
+ * add staging logic to lib.mk prog.mk etc.
+
+2017-04-24 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * install-mk (MK_VERSION): 20170424
+
+ * dirdeps.mk: set NO_DIRDEPS when bootstrapping.
+ also target of bootstrap-this when sed is needed should be ${_want:T}
+
2017-04-18 Simon J. Gerraty <sjg@bad.crufty.net>
* install-mk (MK_VERSION): 20170418
diff --git a/contrib/bmake/mk/FILES b/contrib/bmake/mk/FILES
index 4dde2f05f6f7..acce4c0406a4 100644
--- a/contrib/bmake/mk/FILES
+++ b/contrib/bmake/mk/FILES
@@ -9,6 +9,7 @@ cython.mk
dep.mk
doc.mk
dpadd.mk
+files.mk
final.mk
host-target.mk
host.libnames.mk
diff --git a/contrib/bmake/mk/dirdeps.mk b/contrib/bmake/mk/dirdeps.mk
index 82b781ac0d82..a0a40e586a06 100644
--- a/contrib/bmake/mk/dirdeps.mk
+++ b/contrib/bmake/mk/dirdeps.mk
@@ -1,4 +1,4 @@
-# $Id: dirdeps.mk,v 1.87 2017/03/07 01:49:03 sjg Exp $
+# $Id: dirdeps.mk,v 1.88 2017/04/24 20:34:59 sjg Exp $
# Copyright (c) 2010-2013, Juniper Networks, Inc.
# All rights reserved.
@@ -137,6 +137,14 @@
# built for.
#
+.if !target(bootstrap) && (make(bootstrap) || \
+ make(bootstrap-this) || \
+ make(bootstrap-recurse) || \
+ make(bootstrap-empty))
+# disable most of below
+.MAKE.LEVEL = 1
+.endif
+
# touch this at your peril
_DIRDEP_USE_LEVEL?= 0
.if ${.MAKE.LEVEL} == ${_DIRDEP_USE_LEVEL}
@@ -757,7 +765,7 @@ bootstrap-this: .NOTMAIN
@echo Bootstrapping ${RELDIR}/${_want:T} from ${_src:T}; \
echo You need to build ${RELDIR} to correctly populate it.
.if ${_src:T} != ${.MAKE.DEPENDFILE_PREFIX:T}
- (cd ${.CURDIR} && sed ${.MAKE.DEPENDFILE_BOOTSTRAP_SED} ${_src} > ${_want})
+ (cd ${.CURDIR} && sed ${.MAKE.DEPENDFILE_BOOTSTRAP_SED} ${_src} > ${_want:T})
.else
cp ${.CURDIR}/${_src:T} ${_want}
.endif
diff --git a/contrib/bmake/mk/doc.mk b/contrib/bmake/mk/doc.mk
index d1385e9a4e82..0ff889001cd8 100644
--- a/contrib/bmake/mk/doc.mk
+++ b/contrib/bmake/mk/doc.mk
@@ -1,4 +1,4 @@
-# $Id: doc.mk,v 1.5 2015/09/08 06:15:31 sjg Exp $
+# $Id: doc.mk,v 1.6 2017/05/01 21:24:10 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@@ -59,7 +59,7 @@ spell: ${SRCS}
.include <own.mk>
.if !empty(DOCOWN)
-DOC_INSTALL_OWN?= -o ${DOCOWN} -g ${DOGGRP}
+DOC_INSTALL_OWN?= -o ${DOCOWN} -g ${DOCGRP}
.endif
.endif
diff --git a/contrib/bmake/mk/files.mk b/contrib/bmake/mk/files.mk
new file mode 100644
index 000000000000..fa16b118fb6c
--- /dev/null
+++ b/contrib/bmake/mk/files.mk
@@ -0,0 +1,83 @@
+# $Id: files.mk,v 1.6 2017/05/07 02:21:02 sjg Exp $
+#
+# @(#) Copyright (c) 2017, Simon J. Gerraty
+#
+# This file is provided in the hope that it will
+# be of use. There is absolutely NO WARRANTY.
+# Permission to copy, redistribute or otherwise
+# use this file is hereby granted provided that
+# the above copyright notice and this notice are
+# left intact.
+#
+# Please send copies of changes and bug-fixes to:
+# sjg@crufty.net
+#
+
+.include <init.mk>
+
+FILES_INSTALL_OWN ?= -o ${SHAREOWN} -g ${SHAREGRP}
+FILESMODE ?= ${SHAREMODE}
+FILES_COPY ?= -C
+
+FILESGROUPS ?= FILES
+FILESGROUPS := ${FILESGROUPS:O:u}
+
+.if !target(buildfiles)
+.for group in ${FILESGROUPS}
+buildfiles: ${${group}}
+.endfor
+.endif
+buildfiles:
+realbuild: buildfiles
+
+# there is no default FILESDIR so
+# ignore group if ${group}DIR is not defined
+.for group in ${FILESGROUPS}
+.if !empty(${group}) && defined(${group}DIR)
+.if ${group} != "FILES"
+${group}_INSTALL_OWN ?= ${FILES_INSTALL_OWN}
+.endif
+# incase we are staging
+STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR}
+
+.for file in ${${group}:O:u}
+${group}_INSTALL_OWN.${file:T} ?= ${${group}_INSTALL_OWN}
+${group}DIR.${file:T} ?= ${${group}DIR}
+file_mkdir_list += ${${group}DIR.${file:T}}
+
+.if defined(${group}NAME.${file:T})
+STAGE_AS_SETS += ${group}
+STAGE_AS_${file} = ${${group}NAME.${file:T}}
+stage_as.${group}: ${file}
+
+installfiles: installfiles.${group}.${file:T}
+installfiles.${group}.${file:T}: ${file} file_mkdirs
+ ${INSTALL} ${FILES_COPY} ${${group}_INSTALL_OWN.${file:T}} \
+ -m ${FILESMODE} ${.ALLSRC:Nfile_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${file:T}}
+
+.else
+STAGE_SETS += ${group}
+stage_files.${group}: ${file}
+installfiles.${group}: ${file}
+installfiles: installfiles.${group}
+.endif
+
+.endfor # file
+
+installfiles.${group}: file_mkdirs
+ ${INSTALL} ${FILES_COPY} ${${group}_INSTALL_OWN} -m ${FILESMODE} \
+ ${.ALLSRC:Nfile_mkdirs:O:u} ${DESTDIR}${${group}DIR}
+
+.endif # !empty
+.endfor # group
+
+file_mkdirs:
+ @for d in ${file_mkdir_list:O:u}; do \
+ test -d ${DESTDIR}$$d || \
+ ${INSTALL} -d ${FILES_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \
+ done
+
+beforeinstall:
+installfiles:
+realinstall: installfiles
+.ORDER: beforeinstall installfiles
diff --git a/contrib/bmake/mk/final.mk b/contrib/bmake/mk/final.mk
index 235d36dfe26d..df1c81b9196e 100644
--- a/contrib/bmake/mk/final.mk
+++ b/contrib/bmake/mk/final.mk
@@ -1,4 +1,4 @@
-# $Id: final.mk,v 1.6 2016/04/05 15:58:37 sjg Exp $
+# $Id: final.mk,v 1.8 2017/05/07 20:30:08 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@@ -6,9 +6,17 @@ __${.PARSEFILE}__:
# provide a hook for folk who want to do scary stuff
.-include <${.CURDIR:H}/Makefile-final.inc>
-.if !empty(STAGE)
+.if ${MK_STAGING} == "yes"
+.include <meta.stage.mk>
+.elif !empty(STAGE)
.-include <stage.mk>
.endif
.-include <local.final.mk>
+
+.if empty(_SKIP_BUILD)
+install: realinstall
+.endif
+realinstall:
+
.endif
diff --git a/contrib/bmake/mk/inc.mk b/contrib/bmake/mk/inc.mk
index 5d57f527167d..74626d34646f 100644
--- a/contrib/bmake/mk/inc.mk
+++ b/contrib/bmake/mk/inc.mk
@@ -1,4 +1,4 @@
-# $Id: inc.mk,v 1.3 2011/03/11 05:23:05 sjg Exp $
+# $Id: inc.mk,v 1.7 2017/05/06 17:29:45 sjg Exp $
#
# @(#) Copyright (c) 2008, Simon J. Gerraty
#
@@ -15,8 +15,6 @@
.include <init.mk>
-includes: ${INCS}
-
.if !empty(LIBOWN)
INC_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP}
.endif
@@ -24,12 +22,68 @@ INCMODE ?= 444
INC_COPY ?= -C
INCSDIR ?= ${INCDIR}
-realinstall: incinstall
+STAGE_INCSDIR?= ${STAGE_OBJTOP}${INCSDIR}
+
+# accommodate folk used to freebsd
+INCGROUPS ?= ${INCSGROUPS:UINCS}
+INCGROUPS := ${INCGROUPS:O:u}
+
+.if !target(buildincludes)
+.for group in ${INCGROUPS}
+buildincludes: ${${group}}
+.endfor
+.endif
+buildincludes:
+includes: buildincludes
+
.if !target(incinstall)
-incinstall:
-.if !empty(INCS)
- [ -d ${DESTDIR}${INCSDIR} ] || \
- ${INSTALL} -d ${INC_INSTALL_OWN} -m 775 ${DESTDIR}${INCSDIR}
- ${INSTALL} ${INC_COPY} ${INC_INSTALL_OWN} -m ${INCMODE} ${INCS} ${DESTDIR}${INCSDIR}
+.for group in ${INCGROUPS}
+.if !empty(${group})
+.if ${group} != "INC"
+${group}_INSTALL_OWN ?= ${INC_INSTALL_OWN}
+${group}DIR ?= ${INCDIR}
.endif
+# incase we are staging
+STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR}
+
+.for header in ${${group}:O:u}
+${group}_INSTALL_OWN.${header:T} ?= ${${group}_INSTALL_OWN}
+${group}DIR.${header:T} ?= ${${group}DIR}
+inc_mkdir_list += ${${group}DIR.${header:T}}
+
+.if defined(${group}NAME.${header:T})
+STAGE_AS_SETS += ${group}
+STAGE_AS_${header} = ${${group}NAME.${header:T}}
+stage_as.${group}: ${header}
+
+incinstall: incinstall.${group}.${header:T}
+incinstall.${group}.${header:T}: ${header} inc_mkdirs
+ ${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN.${header:T}} -m ${INCMODE} ${.ALLSRC:Ninc_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${header:T}}
+
+.else
+STAGE_SETS += ${group}
+stage_files.${group}: ${header}
+incinstall.${group}: ${header}
+incinstall: incinstall.${group}
.endif
+
+.endfor # header
+
+incinstall.${group}: inc_mkdirs
+ ${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN} -m ${INCMODE} \
+ ${.ALLSRC:Ninc_mkdirs:O:u} ${DESTDIR}${${group}DIR}
+
+.endif # !empty
+.endfor # group
+
+inc_mkdirs:
+ @for d in ${inc_mkdir_list:O:u}; do \
+ test -d ${DESTDIR}$$d || \
+ ${INSTALL} -d ${INC_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \
+ done
+
+.endif # !target(incinstall)
+
+beforeinstall:
+realinstall: incinstall
+.ORDER: beforeinstall incinstall
diff --git a/contrib/bmake/mk/init.mk b/contrib/bmake/mk/init.mk
index cb5ab820901a..81b76d52a803 100644
--- a/contrib/bmake/mk/init.mk
+++ b/contrib/bmake/mk/init.mk
@@ -1,4 +1,4 @@
-# $Id: init.mk,v 1.12 2016/04/05 15:58:37 sjg Exp $
+# $Id: init.mk,v 1.15 2017/05/07 20:27:54 sjg Exp $
#
# @(#) Copyright (c) 2002, Simon J. Gerraty
#
@@ -50,8 +50,20 @@ PROFFLAGS?= -DGPROF -DPROF
_SKIP_BUILD = not building at level 0
.endif
-.if !empty(_SKIP_BUILD)
+.if !defined(.PARSEDIR)
+# no-op is the best we can do if not bmake.
+.WAIT:
+.endif
+
+# define this once for consistency
+.if empty(_SKIP_BUILD)
+# beforebuild is a hook for things that must be done early
+all: beforebuild .WAIT realbuild
+.else
all: .PHONY
.warning ${_SKIP_BUILD}
.endif
+beforebuild:
+realbuild:
+
.endif
diff --git a/contrib/bmake/mk/install-mk b/contrib/bmake/mk/install-mk
index ffdec6378a0b..50da97cbe61d 100644
--- a/contrib/bmake/mk/install-mk
+++ b/contrib/bmake/mk/install-mk
@@ -55,7 +55,7 @@
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
-# $Id: install-mk,v 1.141 2017/04/18 23:53:18 sjg Exp $
+# $Id: install-mk,v 1.145 2017/05/09 04:05:32 sjg Exp $
#
# @(#) Copyright (c) 1994 Simon J. Gerraty
#
@@ -70,7 +70,7 @@
# sjg@crufty.net
#
-MK_VERSION=20170418
+MK_VERSION=20170505
OWNER=
GROUP=
MODE=444
@@ -176,7 +176,7 @@ $SKIP_MKFILES Do chmod $BINMODE $mk_scripts
[ "$OWNER" ] && $SKIP_MKFILES Do chown $OWNER $mk_files $sys_mk_files
# if this is a BSD system the bsd.*.mk should exist and be used.
if [ -z "$SKIP_BSD_MK" ]; then
- for f in dep doc init lib links man nls obj own prog subdir
+ for f in dep doc files inc init lib links man nls obj own prog subdir
do
b=bsd.$f.mk
[ -s $b ] || Do ln -s $f.mk $b
diff --git a/contrib/bmake/mk/lib.mk b/contrib/bmake/mk/lib.mk
index a70534187882..0cc1466f2fc5 100644
--- a/contrib/bmake/mk/lib.mk
+++ b/contrib/bmake/mk/lib.mk
@@ -1,4 +1,4 @@
-# $Id: lib.mk,v 1.55 2016/09/23 23:04:51 sjg Exp $
+# $Id: lib.mk,v 1.61 2017/05/06 17:30:09 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@@ -37,7 +37,7 @@ PICO?= .pico
CFLAGS+= ${COPTS}
-# Derrived from NetBSD-1.6
+# Originally derrived from NetBSD-1.6
# Set PICFLAGS to cc flags for producing position-independent code,
# if not already set. Includes -DPIC, if required.
@@ -375,15 +375,14 @@ _LIBS+=llib-l${LIB}.ln
.include <dpadd.mk>
.endif
-.if !defined(_SKIP_BUILD)
-all: prebuild .WAIT ${_LIBS}
-# a hook for things that must be done early
-prebuild:
-.if !defined(.PARSEDIR)
-# no-op is the best we can do if not bmake.
-.WAIT:
+.if empty(LIB)
+_LIBS=
.endif
+
+.if !defined(_SKIP_BUILD)
+realbuild: ${_LIBS}
.endif
+
all: _SUBDIRUSE
.for s in ${SRCS:N*.h:M*/*}
@@ -509,7 +508,7 @@ LIB_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP}
.include <links.mk>
-.if !target(realinstall)
+.if !target(realinstall) && !empty(LIB)
realinstall: libinstall
.endif
.if !target(libinstall)
@@ -552,13 +551,19 @@ libinstall:
.endif
.endif
+.if ${MK_MAN} != "no"
install: maninstall _SUBDIRUSE
maninstall: afterinstall
+.endif
afterinstall: realinstall
libinstall: beforeinstall
realinstall: beforeinstall
.endif
+.if defined(FILES) || defined(FILESGROUPS)
+.include <files.mk>
+.endif
+
.if ${MK_MAN} != "no"
.include <man.mk>
.endif
@@ -591,5 +596,10 @@ realinstall: beforeinstall
.endfor
@touch ${.TARGET}
+.if !empty(LIB)
+STAGE_LIBDIR?= ${STAGE_OBJTOP}${LIBDIR}
+stage_libs: ${_LIBS}
+.endif
+
.include <final.mk>
.endif
diff --git a/contrib/bmake/mk/meta2deps.py b/contrib/bmake/mk/meta2deps.py
index 6eee6a51e5b0..22eef5fa749a 100755
--- a/contrib/bmake/mk/meta2deps.py
+++ b/contrib/bmake/mk/meta2deps.py
@@ -37,7 +37,7 @@ We only pay attention to a subset of the information in the
"""
RCSid:
- $Id: meta2deps.py,v 1.25 2017/04/03 21:04:09 sjg Exp $
+ $Id: meta2deps.py,v 1.26 2017/05/09 04:04:16 sjg Exp $
Copyright (c) 2011-2013, Juniper Networks, Inc.
All rights reserved.
@@ -142,7 +142,7 @@ def sort_unique(list, cmp=None, key=None, reverse=False):
for e in list:
if e == le:
continue
- le = e
+ le = e
nl.append(e)
return nl
@@ -534,7 +534,7 @@ class MetaFile:
# to the src dir, we may need to add dependencies for each
rdir = dir
dir = abspath(dir, cwd, self.last_dir, self.debug, self.debug_out)
- rdir = os.path.realpath(dir)
+ rdir = os.path.realpath(dir)
if rdir == dir:
rdir = None
# now put path back together
diff --git a/contrib/bmake/mk/own.mk b/contrib/bmake/mk/own.mk
index b9e4f99ea1f5..1d087ac4dbc1 100644
--- a/contrib/bmake/mk/own.mk
+++ b/contrib/bmake/mk/own.mk
@@ -1,4 +1,4 @@
-# $Id: own.mk,v 1.32 2016/05/18 20:54:29 sjg Exp $
+# $Id: own.mk,v 1.35 2017/05/03 18:09:44 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@@ -117,6 +117,7 @@ OPTIONS_DEFAULT_DEPENDENT+= \
PICINSTALL/LINKLIB \
PICLIB/PIC \
PROFILE/LINKLIB \
+ STAGING_PROG/STAGING \
.include <options.mk>
@@ -128,7 +129,7 @@ _uid!= id -u
USERGRP!= id -g
.export USERGRP
.endif
-.for x in BIN CONF DOC INFO KMOD LIB MAN NLS SHARE
+.for x in BIN CONF DOC INC INFO FILES KMOD LIB MAN NLS SHARE
$xOWN= ${USER}
$xGRP= ${USERGRP}
$x_INSTALL_OWN=
@@ -145,6 +146,9 @@ BINMODE?= 555
NONBINMODE?= 444
DIRMODE?= 755
+INCLUDEDIR?= ${prefix}/include
+INCDIR?= ${INCLUDEDIR}
+
# Define MANZ to have the man pages compressed (gzip)
#MANZ= 1
@@ -184,6 +188,10 @@ KMODGRP?= ${BINGRP}
KMODOWN?= ${BINOWN}
KMODMODE?= ${NONBINMODE}
+SHAREGRP?= ${BINGRP}
+SHAREOWN?= ${BINOWN}
+SHAREMODE?= ${NONBINMODE}
+
COPY?= -c
STRIP_FLAG?= -s
@@ -244,4 +252,19 @@ MK_MAN= no
MK_NLS= no
.endif
+# :U incase not using our sys.mk
+.if ${MK_META_MODE:Uno} == "yes"
+# should all be set by sys.mk if not default
+TARGET_SPEC_VARS ?= MACHINE
+.if ${TARGET_SPEC_VARS:[#]} > 1
+TARGET_SPEC_VARS_REV := ${TARGET_SPEC_VARS:[-1..1]}
+.else
+TARGET_SPEC_VARS_REV = ${TARGET_SPEC_VARS}
+.endif
+.if ${MK_STAGING} == "yes"
+STAGE_ROOT?= ${OBJROOT}/stage
+STAGE_OBJTOP?= ${STAGE_ROOT}/${TARGET_SPEC_VARS_REV:ts/}
+.endif
+.endif
+
.endif
diff --git a/contrib/bmake/mk/prog.mk b/contrib/bmake/mk/prog.mk
index ba87a974bc8c..2d6abb3bc67c 100644
--- a/contrib/bmake/mk/prog.mk
+++ b/contrib/bmake/mk/prog.mk
@@ -1,4 +1,4 @@
-# $Id: prog.mk,v 1.28 2017/02/14 21:26:13 sjg Exp $
+# $Id: prog.mk,v 1.32 2017/05/06 17:30:09 sjg Exp $
.if !target(__${.PARSEFILE}__)
__${.PARSEFILE}__:
@@ -75,6 +75,8 @@ ${CXX_SUFFIXES:%=%.o}:
.if defined(PROG)
+BINDIR ?= ${prefix}/bin
+
SRCS?= ${PROG}.c
.for s in ${SRCS:N*.h:N*.sh:M*/*}
${.o .po .lo:L:@o@${s:T:R}$o@}: $s
@@ -126,8 +128,9 @@ MAN= ${PROG}.1
.endif # defined(PROG)
.if !defined(_SKIP_BUILD)
-all: ${PROG}
+realbuild: ${PROG}
.endif
+
all: _SUBDIRUSE
.if !target(clean)
@@ -208,6 +211,10 @@ lint: ${LOBJS}
.NOPATH: ${OBJS}
.endif
+.if defined(FILES) || defined(FILESGROUPS)
+.include <files.mk>
+.endif
+
.if ${MK_MAN} != "no"
.include <man.mk>
.endif
@@ -219,6 +226,20 @@ lint: ${LOBJS}
.include <obj.mk>
.include <dep.mk>
.include <subdir.mk>
+
+.if !empty(PROG) && ${MK_STAGING_PROG} == "yes"
+STAGE_BINDIR ?= ${STAGE_OBJTOP}${BINDIR}
+STAGE_DIR.prog ?= ${STAGE_BINDIR}
+.if ${PROG_NAME:U${PROG}} != ${PROG}
+STAGE_AS_SETS += prog
+STAGE_AS_${PROG} = ${PROG_NAME}
+stage_as.prog: ${PROG}
+.else
+STAGE_SETS += prog
+stage_files.prog: ${PROG}
+.endif
+.endif
+
.include <final.mk>
.endif
diff --git a/contrib/bmake/mk/scripts.mk b/contrib/bmake/mk/scripts.mk
index efd65f94ccd7..9b6d82f49253 100644
--- a/contrib/bmake/mk/scripts.mk
+++ b/contrib/bmake/mk/scripts.mk
@@ -1,52 +1,91 @@
-# $Id: scripts.mk,v 1.2 2006/11/09 01:55:18 sjg Exp $
+# $Id: scripts.mk,v 1.3 2017/05/06 17:29:45 sjg Exp $
+#
+# @(#) Copyright (c) 2006, Simon J. Gerraty
+#
+# This file is provided in the hope that it will
+# be of use. There is absolutely NO WARRANTY.
+# Permission to copy, redistribute or otherwise
+# use this file is hereby granted provided that
+# the above copyright notice and this notice are
+# left intact.
+#
+# Please send copies of changes and bug-fixes to:
+# sjg@crufty.net
+#
.include <init.mk>
-.if defined(SCRIPTS)
+SCRIPTSGROUPS ?= SCRIPTS
+SCRIPTSGROUPS := ${SCRIPTSGROUPS:O:u}
-all: ${SCRIPTS}
-
-.PHONY: scriptsinstall
-install: scriptsinstall
-
-.if !target(scriptsinstall)
SCRIPTSDIR?= ${BINDIR}
SCRIPTSOWN?= ${BINOWN}
SCRIPTSGRP?= ${BINGRP}
SCRIPTSMODE?= ${BINMODE}
+SCRIPTS_INSTALL_OWN?= -o ${SCRIPTSOWN} -g ${SCRIPTSGRP}
+SCRIPTS_COPY ?= -C
+
# how we get script name from src
SCRIPTSNAME_MOD?=T:R
-script_targets= ${SCRIPTS:@s@${DESTDIR}${SCRIPTSDIR_$s:U${SCRIPTSDIR}}/${SCRIPTSNAME_$s:U${s:${SCRIPTSNAME_MOD}}}@}
-
-scriptsinstall:: ${script_targets}
+.if !target(buildfiles)
+.for group in ${SCRIPTSGROUPS}
+buildfiles: ${${group}}
+.endfor
+.endif
+buildfiles:
+realbuild: buildfiles
-.PRECIOUS: ${script_targets}
-.if !defined(UPDATE)
-.PHONY: ${script_targets}
+.for group in ${SCRIPTSGROUPS}
+.if !empty(${group}) && defined(${group}DIR)
+.if ${group} != "SCRIPTS"
+${group}_INSTALL_OWN ?= ${SCRIPTS_INSTALL_OWN}
.endif
+# incase we are staging
+STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR}
-INSTALL_FLAGS?= ${RENAME} ${PRESERVE} ${COPY} ${INSTPRIV} \
- -o ${OWN_${.TARGET:T}:U${SCRIPTSOWN}} \
- -g ${GRP_${.TARGET:T}:U${SCRIPTSGRP}} \
- -m ${MODE_${.TARGET:T}:U${SCRIPTSMODE}}
+.for script in ${${group}:O:u}
+${group}_INSTALL_OWN.${script:T} ?= ${${group}_INSTALL_OWN}
+${group}DIR.${script:T} ?= ${${group}DIR_${script:T}:U${${group}DIR}}
+script_mkdir_list += ${${group}DIR.${script:T}}
-__SCRIPTINSTALL_USE: .USE
- ${INSTALL} ${INSTALL_FLAGS_${.TARGET:T}:U${INSTALL_FLAGS}} \
- ${.ALLSRC} ${.TARGET}
+${group}NAME.${script} ?= ${${group}NAME_${script:T}:U${script:${SCRIPTSNAME_MOD}}}
+.if ${${group}NAME.${script}:T} != ${script:T}
+STAGE_AS_SETS += ${group}
+STAGE_AS_${script} = ${${group}NAME.${script:T}}
+stage_as.${group}: ${script}
-.for s in ${SCRIPTS}
-.if !defined(BUILD) && !make(all) && !make(${s})
-${DESTDIR}${SCRIPTSDIR_$s:U${SCRIPTSDIR}}/${SCRIPTSNAME_$s:U${s:${SCRIPTSNAME_MOD}}}: .MADE
-.endif
-${DESTDIR}${SCRIPTSDIR_$s:U${SCRIPTSDIR}}/${SCRIPTSNAME_$s:U${s:${SCRIPTSNAME_MOD}}}: ${s} __SCRIPTINSTALL_USE
-.endfor
-.endif
+installscripts: installscripts.${group}.${script:T}
+installscripts.${group}.${script:T}: ${script} script_mkdirs
+ ${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN.${script:T}} \
+ -m ${SCRIPTSMODE} ${.ALLSRC:Nscript_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${script:T}}
+.else
+STAGE_SETS += ${group}
+stage_files.${group}: ${script}
+installscripts.${group}: ${script}
+installscripts: installscripts.${group}
.endif
-.if !target(scriptsinstall)
-scriptsinstall::
-.endif
+.endfor # script
+
+installscripts.${group}: script_mkdirs
+ ${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN} -m ${SCRIPTSMODE} \
+ ${.ALLSRC:Nscript_mkdirs:O:u} ${DESTDIR}${${group}DIR}
+
+.endif # !empty
+.endfor # group
+
+script_mkdirs:
+ @for d in ${script_mkdir_list:O:u}; do \
+ test -d ${DESTDIR}$$d || \
+ ${INSTALL} -d ${SCRIPTS_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \
+ done
+
+
+beforeinstall:
+installscripts:
+realinstall: installscripts
+.ORDER: beforeinstall installscripts
diff --git a/contrib/bmake/mk/sys/AIX.mk b/contrib/bmake/mk/sys/AIX.mk
index 3109c23c58f1..895b92f17cc3 100644
--- a/contrib/bmake/mk/sys/AIX.mk
+++ b/contrib/bmake/mk/sys/AIX.mk
@@ -67,8 +67,6 @@ LDFLAGS=
LINT= lint
LINTFLAGS= -chapbx
-MAKE= bmake
-
PC= pc
PFLAGS=
COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c
diff --git a/contrib/bmake/mk/sys/Darwin.mk b/contrib/bmake/mk/sys/Darwin.mk
index 28cb414a7f1e..c6beb72aeb27 100644
--- a/contrib/bmake/mk/sys/Darwin.mk
+++ b/contrib/bmake/mk/sys/Darwin.mk
@@ -84,8 +84,6 @@ LINTFLAGS?= -chapbx
LORDER?= lorder
-MAKE?= bmake
-
NM?= nm
PC?= pc
diff --git a/contrib/bmake/mk/sys/Generic.mk b/contrib/bmake/mk/sys/Generic.mk
index acf78329cf84..9e3e6a7bc760 100644
--- a/contrib/bmake/mk/sys/Generic.mk
+++ b/contrib/bmake/mk/sys/Generic.mk
@@ -1,4 +1,4 @@
-# $Id: Generic.mk,v 1.12 2016/03/22 20:45:14 sjg Exp $
+# $Id: Generic.mk,v 1.13 2017/05/05 18:02:16 sjg Exp $
#
# some reasonable defaults
@@ -80,8 +80,6 @@ LDFLAGS?=
LINT?= lint
LINTFLAGS?= -chapbxzF
-MAKE?= ${.MAKE}
-
NM?= nm
PC?= pc
diff --git a/contrib/bmake/mk/sys/HP-UX.mk b/contrib/bmake/mk/sys/HP-UX.mk
index 95cc59595c68..29157b9f336c 100644
--- a/contrib/bmake/mk/sys/HP-UX.mk
+++ b/contrib/bmake/mk/sys/HP-UX.mk
@@ -1,4 +1,4 @@
-# $Id: HP-UX.mk,v 1.10 2016/03/22 20:45:14 sjg Exp $
+# $Id: HP-UX.mk,v 1.11 2017/05/05 18:02:16 sjg Exp $
# $NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
# @(#)sys.mk 5.11 (Berkeley) 3/13/91
@@ -101,8 +101,6 @@ LDFLAGS=
LINT= lint
LINTFLAGS= -chapbx
-MAKE= bmake
-
PC= pc
PFLAGS=
COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c
diff --git a/contrib/bmake/mk/sys/IRIX.mk b/contrib/bmake/mk/sys/IRIX.mk
index 6909bdfcb4ba..3d2236b084e3 100644
--- a/contrib/bmake/mk/sys/IRIX.mk
+++ b/contrib/bmake/mk/sys/IRIX.mk
@@ -70,8 +70,6 @@ LINTFLAGS?= -chapbxzF
LORDER?= lorder
-MAKE?= make
-
NM?= nm
PC?= pc
diff --git a/contrib/bmake/mk/sys/Linux.mk b/contrib/bmake/mk/sys/Linux.mk
index c619412bcb86..090de3ae2e2f 100644
--- a/contrib/bmake/mk/sys/Linux.mk
+++ b/contrib/bmake/mk/sys/Linux.mk
@@ -1,4 +1,4 @@
-# $Id: Linux.mk,v 1.8 2016/03/22 20:45:14 sjg Exp $
+# $Id: Linux.mk,v 1.9 2017/05/05 18:02:16 sjg Exp $
# $NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
# @(#)sys.mk 5.11 (Berkeley) 3/13/91
@@ -70,8 +70,6 @@ LDFLAGS=
LINT= lint
LINTFLAGS= -chapbx
-MAKE= bmake
-
PC= pc
PFLAGS=
COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c
diff --git a/contrib/bmake/mk/sys/NetBSD.mk b/contrib/bmake/mk/sys/NetBSD.mk
index a17a3f85bb4b..00ea9a6ed445 100644
--- a/contrib/bmake/mk/sys/NetBSD.mk
+++ b/contrib/bmake/mk/sys/NetBSD.mk
@@ -105,8 +105,6 @@ LINTFLAGS?= -chapbxzF
LORDER?= lorder
-MAKE?= make
-
NM?= nm
PC?= pc
diff --git a/contrib/bmake/mk/sys/OSF1.mk b/contrib/bmake/mk/sys/OSF1.mk
index dfaa896680ef..1b4515a6fee0 100644
--- a/contrib/bmake/mk/sys/OSF1.mk
+++ b/contrib/bmake/mk/sys/OSF1.mk
@@ -1,4 +1,4 @@
-# $Id: OSF1.mk,v 1.7 2016/03/22 20:45:15 sjg Exp $
+# $Id: OSF1.mk,v 1.8 2017/05/05 18:02:16 sjg Exp $
# $NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
# @(#)sys.mk 5.11 (Berkeley) 3/13/91
@@ -77,8 +77,6 @@ LDFLAGS=
LINT= lint
LINTFLAGS= -chapbx
-MAKE= bmake
-
PC= pc
PFLAGS=
COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c
diff --git a/contrib/bmake/mk/sys/OpenBSD.mk b/contrib/bmake/mk/sys/OpenBSD.mk
index c8d7e3e42f9c..a570c1cb9b8c 100644
--- a/contrib/bmake/mk/sys/OpenBSD.mk
+++ b/contrib/bmake/mk/sys/OpenBSD.mk
@@ -80,8 +80,6 @@ LINTFLAGS?= -chapbxzF
LORDER?= lorder
-MAKE?= make
-
NM?= nm
PC?= pc
diff --git a/contrib/bmake/mk/sys/SunOS.mk b/contrib/bmake/mk/sys/SunOS.mk
index 75d83c2bf442..2fb5128ab7d8 100644
--- a/contrib/bmake/mk/sys/SunOS.mk
+++ b/contrib/bmake/mk/sys/SunOS.mk
@@ -1,4 +1,4 @@
-# $Id: SunOS.mk,v 1.7 2016/03/22 20:45:15 sjg Exp $
+# $Id: SunOS.mk,v 1.8 2017/05/05 18:02:17 sjg Exp $
.if ${.PARSEFILE} == "sys.mk"
.include <host-target.mk>
@@ -98,8 +98,6 @@ LDFLAGS=
LINT= lint
LINTFLAGS= -chapbx
-MAKE= bmake
-
PC= pc
PFLAGS=
COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c
diff --git a/contrib/bmake/mk/sys/UnixWare.mk b/contrib/bmake/mk/sys/UnixWare.mk
index 49a52a238997..d65ca01fa2a7 100644
--- a/contrib/bmake/mk/sys/UnixWare.mk
+++ b/contrib/bmake/mk/sys/UnixWare.mk
@@ -1,4 +1,4 @@
-# $Id: UnixWare.mk,v 1.2 2016/03/22 20:45:15 sjg Exp $
+# $Id: UnixWare.mk,v 1.3 2017/05/05 18:02:17 sjg Exp $
# based on "Id: SunOS.5.sys.mk,v 1.6 2003/09/30 16:42:23 sjg Exp "
# $NetBSD: sys.mk,v 1.19.2.1 1994/07/26 19:58:31 cgd Exp $
# @(#)sys.mk 5.11 (Berkeley) 3/13/91
@@ -114,8 +114,6 @@ LINTFLAGS?= -pF
LORDER?= lorder
-MAKE?= bmake
-
NM?= nm
PC?= pc # XXX: UDK probably does not have pc
diff --git a/contrib/bmake/parse.c b/contrib/bmake/parse.c
index fd48f4431190..b351fe11f269 100644
--- a/contrib/bmake/parse.c
+++ b/contrib/bmake/parse.c
@@ -130,7 +130,6 @@ __RCSID("$NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $");
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
-#include <stdint.h>
#include "make.h"
#include "hash.h"
@@ -139,6 +138,10 @@ __RCSID("$NetBSD: parse.c,v 1.225 2017/04/17 13:29:07 maya Exp $");
#include "buf.h"
#include "pathnames.h"
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
#ifdef HAVE_MMAP
#include <sys/mman.h>
diff --git a/contrib/bmake/str.c b/contrib/bmake/str.c
index 5ca2e346e142..b5255bc9c70e 100644
--- a/contrib/bmake/str.c
+++ b/contrib/bmake/str.c
@@ -1,4 +1,4 @@
-/* $NetBSD: str.c,v 1.37 2017/04/11 17:30:13 sjg Exp $ */
+/* $NetBSD: str.c,v 1.38 2017/04/21 22:15:44 sjg Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: str.c,v 1.37 2017/04/11 17:30:13 sjg Exp $";
+static char rcsid[] = "$NetBSD: str.c,v 1.38 2017/04/21 22:15:44 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90";
#else
-__RCSID("$NetBSD: str.c,v 1.37 2017/04/11 17:30:13 sjg Exp $");
+__RCSID("$NetBSD: str.c,v 1.38 2017/04/21 22:15:44 sjg Exp $");
#endif
#endif /* not lint */
#endif
diff --git a/contrib/gcc/config/arm/libgcc-bpabi.ver b/contrib/gcc/config/arm/libgcc-bpabi.ver
index 2f259eb646e0..26d3c49608cb 100644
--- a/contrib/gcc/config/arm/libgcc-bpabi.ver
+++ b/contrib/gcc/config/arm/libgcc-bpabi.ver
@@ -81,3 +81,11 @@ GCC_3.5 {
# GNU-specific entry point.
__gnu_unwind_frame
}
+
+%exclude {
+ _Unwind_Backtrace
+}
+
+GCC_4.3.0 {
+ _Unwind_Backtrace
+}
diff --git a/contrib/gcc/config/arm/libunwind-arm.S b/contrib/gcc/config/arm/libunwind-arm.S
index 8b1e2f3722e4..da553a4bfe78 100644
--- a/contrib/gcc/config/arm/libunwind-arm.S
+++ b/contrib/gcc/config/arm/libunwind-arm.S
@@ -133,4 +133,22 @@ UNWIND_WRAPPER _Unwind_Resume_or_Rethrow 1
UNWIND_WRAPPER _Unwind_ForcedUnwind 3
UNWIND_WRAPPER _Unwind_Backtrace 2
+/*
+ * Originally, we incorrectly export _Unwind_Backtrace symbol
+ * with GCC_3.3 version, but real GCC libgcc export it as GCC_4.3.0.
+ * To maintain backward compatibility, export it with both versions where
+ * GCC_4.3.0 is default one.
+ *
+ * The workaround is complicated by next two issues:
+ * - old GNU ld cannot handle two (or more) symbol versions
+ * targeting same function.
+ * - the .weakref crashes clang 4.0
+ */
+ .globl SYM(_Unwind_Backtrace33)
+ TYPE(_Unwind_Backtrace33)
+SYM(_Unwind_Backtrace33):
+ b _Unwind_Backtrace
+
+ .symver SYM(_Unwind_Backtrace33),_Unwind_Backtrace@GCC_3.3
+
#endif /* ndef __symbian__ */
diff --git a/contrib/gcc/libgcc-std.ver b/contrib/gcc/libgcc-std.ver
index 2d0a43df01d3..6e747ed7bc1b 100644
--- a/contrib/gcc/libgcc-std.ver
+++ b/contrib/gcc/libgcc-std.ver
@@ -275,7 +275,7 @@ GCC_4.2.0 {
_Unwind_GetIPInfo
}
-%inherit GCC_4.3 GCC_4.2.0
+%inherit GCC_4.3.0 GCC_4.2.0
GCC_4.3.0 {
# byte swapping routines
__bswapsi2
diff --git a/contrib/ipfilter/lib/ipf_perror.c b/contrib/ipfilter/lib/ipf_perror.c
index 85a1b1d66e2e..08e31648b053 100644
--- a/contrib/ipfilter/lib/ipf_perror.c
+++ b/contrib/ipfilter/lib/ipf_perror.c
@@ -10,7 +10,7 @@ ipf_perror(err, string)
if (err == 0)
fprintf(stderr, "%s\n", string);
else
- fprintf(stderr, "%s %s\n", string, ipf_strerror(err));
+ fprintf(stderr, "%s: %s\n", string, ipf_strerror(err));
}
int
diff --git a/contrib/ipfilter/lib/printhash_live.c b/contrib/ipfilter/lib/printhash_live.c
index 53159b133023..6003a63f60d2 100644
--- a/contrib/ipfilter/lib/printhash_live.c
+++ b/contrib/ipfilter/lib/printhash_live.c
@@ -59,7 +59,7 @@ printhash_live(hp, fd, name, opts, fields)
printed++;
}
if (last == 0)
- ipferror(fd, "walking hash nodes:");
+ ipferror(fd, "walking hash nodes");
if (printed == 0)
putchar(';');
diff --git a/contrib/ipfilter/lib/printhashnode.c b/contrib/ipfilter/lib/printhashnode.c
index e245535cb1c4..5f0f5f67938f 100644
--- a/contrib/ipfilter/lib/printhashnode.c
+++ b/contrib/ipfilter/lib/printhashnode.c
@@ -35,18 +35,47 @@ printhashnode(iph, ipep, copyfunc, opts, fields)
}
printf("\n");
} else if ((opts & OPT_DEBUG) != 0) {
- PRINTF("\t%d\tAddress: %s", hv,
- inet_ntoa(ipe.ipe_addr.in4));
- printmask(ipe.ipe_family, (u_32_t *)&ipe.ipe_mask.in4_addr);
- PRINTF("\tRef. Count: %d\tGroup: %s\n", ipe.ipe_ref,
- ipe.ipe_group);
+#ifdef AF_INET6
+ if (ipe.ipe_family == AF_INET6) {
+ char buf[INET6_ADDRSTRLEN + 1];
+ const char *str;
+
+ buf[0] = '\0';
+ str = inet_ntop(AF_INET6, &ipe.ipe_addr.in6,
+ buf, sizeof(buf) - 1);
+ if (str == NULL)
+ str = "???";
+ PRINTF("\t%d\tAddress: %s", hv, str);
+ printmask(ipe.ipe_family, (u_32_t *)&ipe.ipe_mask.in4_addr);
+ PRINTF("\tRef. Count: %d\tGroup: %s\n", ipe.ipe_ref,
+ ipe.ipe_group);
+#ifdef USE_QUAD_T
+ PRINTF("\tHits: %"PRIu64"\tBytes: %"PRIu64"\n",
+ ipe.ipe_hits, ipe.ipe_bytes);
+#else
+ PRINTF("\tHits: %lu\tBytes: %lu\n",
+ ipe.ipe_hits, ipe.ipe_bytes);
+#endif /* USE_QUAD_T */
+ } else if (ipe.ipe_family == AF_INET) {
+#else
+ if (ipe.ipe_family == AF_INET) {
+#endif /* AF_INET6 */
+ PRINTF("\t%d\tAddress: %s", hv,
+ inet_ntoa(ipe.ipe_addr.in4));
+ printmask(ipe.ipe_family, (u_32_t *)&ipe.ipe_mask.in4_addr);
+ PRINTF("\tRef. Count: %d\tGroup: %s\n", ipe.ipe_ref,
+ ipe.ipe_group);
#ifdef USE_QUAD_T
- PRINTF("\tHits: %"PRIu64"\tBytes: %"PRIu64"\n",
- ipe.ipe_hits, ipe.ipe_bytes);
+ PRINTF("\tHits: %"PRIu64"\tBytes: %"PRIu64"\n",
+ ipe.ipe_hits, ipe.ipe_bytes);
#else
- PRINTF("\tHits: %lu\tBytes: %lu\n",
- ipe.ipe_hits, ipe.ipe_bytes);
-#endif
+ PRINTF("\tHits: %lu\tBytes: %lu\n",
+ ipe.ipe_hits, ipe.ipe_bytes);
+#endif /* USE_QUAD_T */
+ } else {
+ PRINTF("\tAddress: family: %d\n",
+ ipe.ipe_family);
+ }
} else {
putchar(' ');
printip(ipe.ipe_family, (u_32_t *)&ipe.ipe_addr.in4_addr);
diff --git a/contrib/ipfilter/lib/printpoolnode.c b/contrib/ipfilter/lib/printpoolnode.c
index aa2aed96cad3..59e09228f05e 100644
--- a/contrib/ipfilter/lib/printpoolnode.c
+++ b/contrib/ipfilter/lib/printpoolnode.c
@@ -33,8 +33,30 @@ printpoolnode(np, opts, fields)
printmask(np->ipn_addr.adf_family,
(u_32_t *)&np->ipn_mask.adf_addr);
} else {
- PRINTF("\tAddress: %s%s", np->ipn_info ? "! " : "",
- inet_ntoa(np->ipn_addr.adf_addr.in4));
+#ifdef AF_INET6
+ if (np->ipn_addr.adf_family == AF_INET6) {
+ char buf[INET6_ADDRSTRLEN + 1];
+ const char *str;
+
+ buf[0] = '\0';
+ str = inet_ntop(AF_INET6, &np->ipn_addr.adf_addr.in6,
+ buf, sizeof(buf) - 1);
+ if (str == NULL)
+ str = "???";
+ PRINTF("\tAddress: %s%s", np->ipn_info ? "! " : "",
+ str);
+ } else if (np->ipn_addr.adf_family == AF_INET) {
+#else
+ if (np->ipn_addr.adf_family == AF_INET) {
+#endif
+ PRINTF("\tAddress: %s%s", np->ipn_info ? "! " : "",
+ inet_ntoa(np->ipn_addr.adf_addr.in4));
+ } else {
+ PRINTF("\tAddress: family: %d\n",
+ np->ipn_addr.adf_family);
+#ifdef AF_INET6
+ }
+#endif
printmask(np->ipn_addr.adf_family,
(u_32_t *)&np->ipn_mask.adf_addr);
#ifdef USE_QUAD_T
diff --git a/contrib/ipfilter/tools/ippool.c b/contrib/ipfilter/tools/ippool.c
index 883f82a675b6..ae1d466f1983 100644
--- a/contrib/ipfilter/tools/ippool.c
+++ b/contrib/ipfilter/tools/ippool.c
@@ -1030,45 +1030,80 @@ int
setnodeaddr(int type, int role, void *ptr, char *arg)
{
struct in_addr mask;
+ sa_family_t family;
char *s;
- s = strchr(arg, '/');
- if (s == NULL)
- mask.s_addr = 0xffffffff;
- else if (strchr(s, '.') == NULL) {
- if (ntomask(AF_INET, atoi(s + 1), &mask.s_addr) != 0)
- return -1;
+ if (strchr(arg, ':') == NULL) {
+ family = AF_INET;
+ s = strchr(arg, '/');
+ if (s == NULL)
+ mask.s_addr = 0xffffffff;
+ else if (strchr(s, '.') == NULL) {
+ if (ntomask(AF_INET, atoi(s + 1), &mask.s_addr) != 0)
+ return -1;
+ } else {
+ mask.s_addr = inet_addr(s + 1);
+ }
+ if (s != NULL)
+ *s = '\0';
} else {
- mask.s_addr = inet_addr(s + 1);
+ family = AF_INET6;
+
+ /* XXX for now we use mask for IPv6 prefix length */
+ /* XXX mask should be a union with prefix */
+ /* XXX Currently address handling is sloppy. */
+
+ if ((s = strchr(arg, '/')) == NULL)
+ mask.s_addr = 128;
+ else
+ mask.s_addr = atoi(s + 1);
}
- if (s != NULL)
- *s = '\0';
if (type == IPLT_POOL) {
ip_pool_node_t *node = ptr;
+ node->ipn_addr.adf_family = family;
+
#ifdef USE_INET6
- if (node->ipn_addr.adf_family == AF_INET)
+ if (node->ipn_addr.adf_family == AF_INET) {
#endif
node->ipn_addr.adf_len = offsetof(addrfamily_t,
adf_addr) +
sizeof(struct in_addr);
+ node->ipn_addr.adf_addr.in4.s_addr = inet_addr(arg);
#ifdef USE_INET6
- else
+ } else {
node->ipn_addr.adf_len = offsetof(addrfamily_t,
adf_addr) +
sizeof(struct in6_addr);
+ inet_pton(AF_INET6, arg,
+ &node->ipn_addr.adf_addr.in6.s6_addr);
+ }
#endif
- node->ipn_addr.adf_addr.in4.s_addr = inet_addr(arg);
node->ipn_mask.adf_len = node->ipn_addr.adf_len;
node->ipn_mask.adf_addr.in4.s_addr = mask.s_addr;
} else if (type == IPLT_HASH) {
iphtent_t *node = ptr;
- node->ipe_addr.in4.s_addr = inet_addr(arg);
- node->ipe_mask.in4.s_addr = mask.s_addr;
- node->ipe_family = AF_INET;
- node->ipe_unit = role;
+ node->ipe_family = family;
+ node->ipe_unit = role;
+
+#ifdef USE_INET6
+ if (node->ipe_family == AF_INET) {
+#endif
+ node->ipe_addr.in4.s_addr = inet_addr(arg);
+ node->ipe_mask.in4.s_addr = mask.s_addr;
+#ifdef USE_INET6
+ } else {
+ inet_pton(AF_INET6, arg,
+ &node->ipe_addr.in6.__u6_addr.__u6_addr32);
+ node->ipe_mask.in6.__u6_addr.__u6_addr32[0] =
+ mask.s_addr;
+ node->ipe_mask.in6.__u6_addr.__u6_addr32[1] =
+ node->ipe_mask.in6.__u6_addr.__u6_addr32[2] =
+ node->ipe_mask.in6.__u6_addr.__u6_addr32[3] = 0;
+ }
+#endif
}
return 0;
diff --git a/contrib/libarchive/cpio/test/test_option_lz4.c b/contrib/libarchive/cpio/test/test_option_lz4.c
index 88dfbd63bae9..ebd376736f42 100644
--- a/contrib/libarchive/cpio/test/test_option_lz4.c
+++ b/contrib/libarchive/cpio/test/test_option_lz4.c
@@ -74,8 +74,8 @@ DEFINE_TEST(test_option_lz4)
free(p);
return;
}
- free(p);
failure("--lz4 option is broken: %s", p);
+ free(p);
assertEqualInt(r, 0);
return;
}
diff --git a/contrib/libxo/configure.ac b/contrib/libxo/configure.ac
index b47dedb0758f..26d85b6283d5 100644
--- a/contrib/libxo/configure.ac
+++ b/contrib/libxo/configure.ac
@@ -12,7 +12,7 @@
#
AC_PREREQ(2.2)
-AC_INIT([libxo], [0.6.3], [phil@juniper.net])
+AC_INIT([libxo], [0.7.2], [phil@juniper.net])
AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability])
# Support silent build rules. Requires at least automake-1.11.
@@ -20,7 +20,6 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AC_PROG_CC
-AM_PROG_AR
AC_PROG_INSTALL
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_LN_S
@@ -135,6 +134,21 @@ if test "$GETTEXT_ENABLE" != "no"; then
AC_MSG_RESULT([$HAVE_GETTEXT])
fi
+
+ if test "$HAVE_GETTEXT" != "yes"; then
+ GETTEXT_PREFIX=/usr/local
+ AC_MSG_CHECKING([gettext in ${GETTEXT_PREFIX}])
+
+ _save_cflags="$CFLAGS"
+ CFLAGS="$CFLAGS -I${GETTEXT_PREFIX}/include -L${GETTEXT_PREFIX}/lib -Werror -lintl"
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[#include <libintl.h>]
+ [int main() {char *cp = dgettext(NULL, "xx"); return 0; }]])],
+ [HAVE_GETTEXT=yes],
+ [HAVE_GETTEXT=no])
+ CFLAGS="$_save_cflags"
+
+ AC_MSG_RESULT([$HAVE_GETTEXT])
+ fi
fi
if test "$HAVE_GETTEXT" = "yes"; then
@@ -278,6 +292,13 @@ AC_ARG_ENABLE([debug],
AC_MSG_RESULT([$LIBXO_DEBUG])
AM_CONDITIONAL([LIBXO_DEBUG], [test "$LIBXO_DEBUG" != "no"])
+AC_MSG_CHECKING([whether to use int return codes])
+AC_ARG_ENABLE([int-return-codes],
+ [ --enable-int-return-codes Use int return codes (instead of ssize_t)],
+ [USE_INT_RETURN_CODES=yes; AC_DEFINE([USE_INT_RETURN_CODES], [1], [Use int return codes])],
+ [USE_INT_RETURN_CODES=no])
+AC_MSG_RESULT([$USE_INT_RETURN_CODES])
+
AC_MSG_CHECKING([whether to build with text-only rendering])
AC_ARG_ENABLE([text-only],
[ --enable-text-only Turn on text-only rendering],
diff --git a/contrib/libxo/doc/Makefile.am b/contrib/libxo/doc/Makefile.am
index 16d6ba5bffaf..a00994cacb6f 100644
--- a/contrib/libxo/doc/Makefile.am
+++ b/contrib/libxo/doc/Makefile.am
@@ -61,9 +61,9 @@ xolint.txt: ${top_srcdir}/xolint/xolint.pl
CLEANFILES = \
xolint.txt \
${INPUT}.xml \
-${INPUT}.txt \
${INPUT}.fxml \
-${INPUT}.html
+${OUTPUT}.txt \
+${OUTPUT}.html
else
doc docs:
@${ECHO} "The 'oxtradoc' tool is not installed; see libslax.org"
diff --git a/contrib/libxo/doc/libxo-manual.html b/contrib/libxo/doc/libxo-manual.html
index 0c042a47a418..34053c98b1f9 100644
--- a/contrib/libxo/doc/libxo-manual.html
+++ b/contrib/libxo/doc/libxo-manual.html
@@ -515,7 +515,7 @@ li.indline1 {
}
@top-right {
- content: "May 2016";
+ content: "May 2017";
}
@top-center {
@@ -22009,7 +22009,7 @@ jQuery(function ($) {
</tr>
<tr>
<td class="header left"></td>
-<td class="header right">May 28, 2016</td>
+<td class="header right">May 15, 2017</td>
</tr>
</table></div>
<p id="title" class="title">libxo: The Easy Way to Generate text, XML, JSON, and HTML output<br><span class="filename">libxo-manual</span></p>
@@ -22271,36 +22271,40 @@ jQuery(function ($) {
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_3_1_4">3.1.4   </div>
-<a href="#xo_set_style">xo_set_style</a><ul class="toc">
+<a href="#xo_set_style">xo_set_style</a>
+</li>
+<li class="tocline1">
+<div class="section-number" id="toc_doc_section_3_1_5">3.1.5   </div>
+<a href="#xo_get_style">xo_get_style</a><ul class="toc">
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_3_1_4_1">3.1.4.1   </div>
+<div class="section-number" id="toc_doc_section_3_1_5_1">3.1.5.1   </div>
<a href="#styles">Output Styles (XO_STYLE_*)</a>
</li>
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_3_1_4_2">3.1.4.2   </div>
+<div class="section-number" id="toc_doc_section_3_1_5_2">3.1.5.2   </div>
<a href="#xo_set_style_name">xo_set_style_name</a>
</li>
</ul>
</li>
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_3_1_5">3.1.5   </div>
+<div class="section-number" id="toc_doc_section_3_1_6">3.1.6   </div>
<a href="#xo_set_flags">xo_set_flags</a><ul class="toc">
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_3_1_5_1">3.1.5.1   </div>
+<div class="section-number" id="toc_doc_section_3_1_6_1">3.1.6.1   </div>
<a href="#flags">Flags (XOF_*)</a>
</li>
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_3_1_5_2">3.1.5.2   </div>
+<div class="section-number" id="toc_doc_section_3_1_6_2">3.1.6.2   </div>
<a href="#xo_clear_flags">xo_clear_flags</a>
</li>
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_3_1_5_3">3.1.5.3   </div>
+<div class="section-number" id="toc_doc_section_3_1_6_3">3.1.6.3   </div>
<a href="#xo_set_options">xo_set_options</a>
</li>
</ul>
</li>
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_3_1_6">3.1.6   </div>
+<div class="section-number" id="toc_doc_section_3_1_7">3.1.7   </div>
<a href="#xo_destroy">xo_destroy</a>
</li>
</ul>
@@ -23879,7 +23883,7 @@ jQuery(function ($) {
<p id="doc_section_2_2_4_p_1">For strings, the 'h' and 'l' modifiers affect the interpretation of the bytes pointed to argument. The default '%s' string is a 'char *' pointer to a string encoded as UTF-8. Since UTF-8 is compatible with ASCII data, a normal 7-bit ASCII string can be used. '%ls' expects a 'wchar_t *' pointer to a wide-character string, encoded as a 32-bit Unicode values. '%hs' expects a 'char *' pointer to a multi-byte string encoded with the current locale, as given by the LC_CTYPE, LANG, or LC_ALL environment varibles. The first of this list of variables is used and if none of the variables are set, the locale defaults to "UTF&#8209;8".</p>
<p id="doc_section_2_2_4_p_2">libxo will convert these arguments as needed to either UTF-8 (for XML, JSON, and HTML styles) or locale-based strings for display in text style.</p>
<div id="doc_figure_u.64"></div> <pre>
- xo_emit("Alll strings are utf-8 content {:tag/%ls}",
+ xo_emit("All strings are utf-8 content {:tag/%ls}",
L"except for wide strings");
</pre> <p id="doc_section_2_2_4_p_4">"%S" is equivalent to "%ls".</p>
<div id="doc_table_u.7"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
@@ -24316,6 +24320,14 @@ jQuery(function ($) {
<td>Enable "Do The Right Thing" mode</td>
</tr>
<tr>
+<td>flush</td>
+<td>Flush after every libxo function call</td>
+</tr>
+<tr>
+<td>flush-line</td>
+<td>Flush after every line (line-buffered)</td>
+</tr>
+<tr>
<td>html</td>
<td>Emit HTML output</td>
</tr>
@@ -24377,7 +24389,7 @@ jQuery(function ($) {
</tr>
<tr>
<td>underscores</td>
-<td>Replace XML-friendly "-"s with JSON friendly "_"s e</td>
+<td>Replace XML-friendly "-"s with JSON friendly "_"s</td>
</tr>
<tr>
<td>units</td>
@@ -24402,6 +24414,19 @@ jQuery(function ($) {
</tbody>
</table></div>
<p id="doc_section_2_4_p_5">The brief options are detailed in <a href="#LIBXO_OPTIONS" title="LIBXO_OPTIONS">Section 3.4.6</a>.</p>
+<p id="doc_section_2_4_p_6">Most of these option are simple and direct, but some require additional details:</p>
+<p id="doc_section_2_4_p_7"> </p>
+<ul>
+<li>"flush&#8209;line" performs line buffering, even when the output is not directed to a TTY device.</li>
+<li>"info" generates additional data for HTML, encoded in attributes using names that state with "data&#8209;".</li>
+<li>"keys" adds a "key" attribute for XML output to indicate that a leaf is an identifier for the list member.</li>
+<li>"no&#8209;humanize"avoids "humanizing" numeric output (see humanize_number(3) for details).</li>
+<li>"no&#8209;locale" instructs libxo to avoid translating output to the current locale.</li>
+<li>"no&#8209;retain" disables the ability of libxo to internally retain "compiled" information about formatting strings.</li>
+<li>"underscores" can be used with JSON output to change XML-friendly names with dashes into JSON-friendly name with underscores.</li>
+<li>"warn" allows libxo to emit warnings on stderr when application code make incorrect calls.</li>
+<li>"warn&#8209;xml" causes those warnings to be placed in XML inside the output.</li>
+</ul>
</div>
</div>
<hr class="noprint">
@@ -24443,8 +24468,9 @@ jQuery(function ($) {
<li><a href="#xo_create_to_file" title="xo_create_to_file">Section 3.1.2</a></li>
<li><a href="#xo_set_writer" title="xo_set_writer">Section 3.1.3</a></li>
<li><a href="#xo_set_style" title="xo_set_style">Section 3.1.4</a></li>
-<li><a href="#xo_set_flags" title="xo_set_flags">Section 3.1.5</a></li>
-<li><a href="#xo_destroy" title="xo_destroy">Section 3.1.6</a></li>
+<li><a href="#xo_get_style" title="xo_get_style">Section 3.1.5</a></li>
+<li><a href="#xo_set_flags" title="xo_set_flags">Section 3.1.6</a></li>
+<li><a href="#xo_destroy" title="xo_destroy">Section 3.1.7</a></li>
</ul>
<div class="content">
<h3 id="doc_section_3_1_1">
@@ -24460,7 +24486,7 @@ jQuery(function ($) {
xo_handle_t *xop = xo_create(XO_STYLE_JSON, XOF_WARN);
....
xo_emit_h(xop, "testing\n");
- </pre> <p id="doc_section_3_1_1_p_3">See also <a href="#styles" title="Output Styles (XO_STYLE_*)">Section 3.1.4.1</a> and <a href="#flags" title="Flags (XOF_*)">Section 3.1.5.1</a>.</p>
+ </pre> <p id="doc_section_3_1_1_p_3">See also <a href="#styles" title="Output Styles (XO_STYLE_*)">Section 3.1.5.1</a> and <a href="#flags" title="Flags (XOF_*)">Section 3.1.6.1</a>.</p>
</div>
<div class="content">
<h3 id="doc_section_3_1_2">
@@ -24499,18 +24525,31 @@ jQuery(function ($) {
</pre> <p id="doc_section_3_1_4_p_3">To use the default handle, pass a NULL handle:</p>
<div id="doc_figure_u.89"></div> <pre>
xo_set_style(NULL, XO_STYLE_XML);
- </pre> <p id="doc_section_3_1_4_p_5">Section Contents: </p>
+ </pre> </div>
+<div class="content">
+<h3 id="doc_section_3_1_5">
+<div class="self-section-number">
+<a href="#doc_section_3_1_5">3.1.5</a> </div>
+<a id="xo_get_style" href="#xo_get_style">xo_get_style</a>
+</h3>
+<p id="doc_section_3_1_5_p_1">To find the current style, use the xo_get_style() function:</p>
+<div id="doc_figure_u.90"></div> <pre>
+ xo_style_t xo_get_style(xo_handle_t *xop);
+ </pre> <p id="doc_section_3_1_5_p_3">To use the default handle, pass a NULL handle:</p>
+<div id="doc_figure_u.91"></div> <pre>
+ style = xo_get_style(NULL);
+ </pre> <p id="doc_section_3_1_5_p_5">Section Contents: </p>
<ul>
-<li><a href="#styles" title="Output Styles (XO_STYLE_*)">Section 3.1.4.1</a></li>
-<li><a href="#xo_set_style_name" title="xo_set_style_name">Section 3.1.4.2</a></li>
+<li><a href="#styles" title="Output Styles (XO_STYLE_*)">Section 3.1.5.1</a></li>
+<li><a href="#xo_set_style_name" title="xo_set_style_name">Section 3.1.5.2</a></li>
</ul>
<div class="content">
-<h4 id="doc_section_3_1_4_1">
+<h4 id="doc_section_3_1_5_1">
<div class="self-section-number">
-<a href="#doc_section_3_1_4_1">3.1.4.1</a> </div>
+<a href="#doc_section_3_1_5_1">3.1.5.1</a> </div>
<a id="styles" href="#styles">Output Styles (XO_STYLE_*)</a>
</h4>
-<p id="doc_section_3_1_4_1_p_1">The libxo functions accept a set of output styles:</p>
+<p id="doc_section_3_1_5_1_p_1">The libxo functions accept a set of output styles:</p>
<div id="doc_table_u.11"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Flag</th>
@@ -24537,45 +24576,45 @@ jQuery(function ($) {
</table></div>
</div>
<div class="content">
-<h4 id="doc_section_3_1_4_2">
+<h4 id="doc_section_3_1_5_2">
<div class="self-section-number">
-<a href="#doc_section_3_1_4_2">3.1.4.2</a> </div>
+<a href="#doc_section_3_1_5_2">3.1.5.2</a> </div>
<a id="xo_set_style_name" href="#xo_set_style_name">xo_set_style_name</a>
</h4>
-<p id="doc_section_3_1_4_2_p_1">The xo_set_style_name() can be used to set the style based on a name encoded as a string:</p>
-<div id="doc_figure_u.90"></div> <pre>
+<p id="doc_section_3_1_5_2_p_1">The xo_set_style_name() can be used to set the style based on a name encoded as a string:</p>
+<div id="doc_figure_u.92"></div> <pre>
int xo_set_style_name (xo_handle_t *xop, const char *style);
- </pre> <p id="doc_section_3_1_4_2_p_3">The name can be any of the styles: "text", "xml", "json", or "html".</p>
-<div id="doc_figure_u.91"></div> <pre>
+ </pre> <p id="doc_section_3_1_5_2_p_3">The name can be any of the styles: "text", "xml", "json", or "html".</p>
+<div id="doc_figure_u.93"></div> <pre>
EXAMPLE:
xo_set_style_name(NULL, "html");
</pre> </div>
</div>
<div class="content">
-<h3 id="doc_section_3_1_5">
+<h3 id="doc_section_3_1_6">
<div class="self-section-number">
-<a href="#doc_section_3_1_5">3.1.5</a> </div>
+<a href="#doc_section_3_1_6">3.1.6</a> </div>
<a id="xo_set_flags" href="#xo_set_flags">xo_set_flags</a>
</h3>
-<p id="doc_section_3_1_5_p_1">To set the flags, use the xo_set_flags() function:</p>
-<div id="doc_figure_u.92"></div> <pre>
+<p id="doc_section_3_1_6_p_1">To set the flags, use the xo_set_flags() function:</p>
+<div id="doc_figure_u.94"></div> <pre>
void xo_set_flags(xo_handle_t *xop, unsigned flags);
- </pre> <p id="doc_section_3_1_5_p_3">To use the default handle, pass a NULL handle:</p>
-<div id="doc_figure_u.93"></div> <pre>
+ </pre> <p id="doc_section_3_1_6_p_3">To use the default handle, pass a NULL handle:</p>
+<div id="doc_figure_u.95"></div> <pre>
xo_set_style(NULL, XO_STYLE_XML);
- </pre> <p id="doc_section_3_1_5_p_5">Section Contents: </p>
+ </pre> <p id="doc_section_3_1_6_p_5">Section Contents: </p>
<ul>
-<li><a href="#flags" title="Flags (XOF_*)">Section 3.1.5.1</a></li>
-<li><a href="#xo_clear_flags" title="xo_clear_flags">Section 3.1.5.2</a></li>
-<li><a href="#xo_set_options" title="xo_set_options">Section 3.1.5.3</a></li>
+<li><a href="#flags" title="Flags (XOF_*)">Section 3.1.6.1</a></li>
+<li><a href="#xo_clear_flags" title="xo_clear_flags">Section 3.1.6.2</a></li>
+<li><a href="#xo_set_options" title="xo_set_options">Section 3.1.6.3</a></li>
</ul>
<div class="content">
-<h4 id="doc_section_3_1_5_1">
+<h4 id="doc_section_3_1_6_1">
<div class="self-section-number">
-<a href="#doc_section_3_1_5_1">3.1.5.1</a> </div>
+<a href="#doc_section_3_1_6_1">3.1.6.1</a> </div>
<a id="flags" href="#flags">Flags (XOF_*)</a>
</h4>
-<p id="doc_section_3_1_5_1_p_1">The set of valid flags include:</p>
+<p id="doc_section_3_1_6_1_p_1">The set of valid flags include:</p>
<div id="doc_table_u.12"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Flag</th>
@@ -24648,12 +24687,12 @@ jQuery(function ($) {
</tr>
</tbody>
</table></div>
-<p id="doc_section_3_1_5_1_p_2">The XOF_CLOSE_FP flag will trigger the call of the close_func (provided via xo_set_writer()) when the handle is destroyed.</p>
-<p id="doc_section_3_1_5_1_p_3">The XOF_COLOR flag enables color and effects in output regardless of output device, while the XOF_COLOR_ALLOWED flag allows color and effects only if the output device is a terminal.</p>
-<p id="doc_section_3_1_5_1_p_4">The XOF_PRETTY flag requests 'pretty printing', which will trigger the addition of indentation and newlines to enhance the readability of XML, JSON, and HTML output. Text output is not affected.</p>
-<p id="doc_section_3_1_5_1_p_5">The XOF_WARN flag requests that warnings will trigger diagnostic output (on standard error) when the library notices errors during operations, or with arguments to functions. Without warnings enabled, such conditions are ignored.</p>
-<p id="doc_section_3_1_5_1_p_6">Warnings allow developers to debug their interaction with libxo. The function "xo_failure" can used as a breakpoint for a debugger, regardless of whether warnings are enabled.</p>
-<p id="doc_section_3_1_5_1_p_7">If the style is XO_STYLE_HTML, the following additional flags can be used:</p>
+<p id="doc_section_3_1_6_1_p_2">The XOF_CLOSE_FP flag will trigger the call of the close_func (provided via xo_set_writer()) when the handle is destroyed.</p>
+<p id="doc_section_3_1_6_1_p_3">The XOF_COLOR flag enables color and effects in output regardless of output device, while the XOF_COLOR_ALLOWED flag allows color and effects only if the output device is a terminal.</p>
+<p id="doc_section_3_1_6_1_p_4">The XOF_PRETTY flag requests 'pretty printing', which will trigger the addition of indentation and newlines to enhance the readability of XML, JSON, and HTML output. Text output is not affected.</p>
+<p id="doc_section_3_1_6_1_p_5">The XOF_WARN flag requests that warnings will trigger diagnostic output (on standard error) when the library notices errors during operations, or with arguments to functions. Without warnings enabled, such conditions are ignored.</p>
+<p id="doc_section_3_1_6_1_p_6">Warnings allow developers to debug their interaction with libxo. The function "xo_failure" can used as a breakpoint for a debugger, regardless of whether warnings are enabled.</p>
+<p id="doc_section_3_1_6_1_p_7">If the style is XO_STYLE_HTML, the following additional flags can be used:</p>
<div id="doc_table_u.13"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Flag</th>
@@ -24670,9 +24709,9 @@ jQuery(function ($) {
</tr>
</tbody>
</table></div>
-<p id="doc_section_3_1_5_1_p_8">The XOF_XPATH flag enables the emission of XPath expressions detailing the hierarchy of XML elements used to encode the data field, if the XPATH style of output were requested.</p>
-<p id="doc_section_3_1_5_1_p_9">The XOF_INFO flag encodes additional informational fields for HTML output. See <a href="#info" title="Field Information (xo_info_t)">Section 3.4.4</a> for details.</p>
-<p id="doc_section_3_1_5_1_p_10">If the style is XO_STYLE_XML, the following additional flags can be used:</p>
+<p id="doc_section_3_1_6_1_p_8">The XOF_XPATH flag enables the emission of XPath expressions detailing the hierarchy of XML elements used to encode the data field, if the XPATH style of output were requested.</p>
+<p id="doc_section_3_1_6_1_p_9">The XOF_INFO flag encodes additional informational fields for HTML output. See <a href="#info" title="Field Information (xo_info_t)">Section 3.4.4</a> for details.</p>
+<p id="doc_section_3_1_6_1_p_10">If the style is XO_STYLE_XML, the following additional flags can be used:</p>
<div id="doc_table_u.14"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Flag</th>
@@ -24683,43 +24722,43 @@ jQuery(function ($) {
<td>Flag 'key' fields for xml</td>
</tr></tbody>
</table></div>
-<p id="doc_section_3_1_5_1_p_11">The XOF_KEYS flag adds 'key' attribute to the XML encoding for field definitions that use the 'k' modifier. The key attribute has the value "key":</p>
-<div id="doc_figure_u.94"></div> <pre>
+<p id="doc_section_3_1_6_1_p_11">The XOF_KEYS flag adds 'key' attribute to the XML encoding for field definitions that use the 'k' modifier. The key attribute has the value "key":</p>
+<div id="doc_figure_u.96"></div> <pre>
xo_emit("{k:name}", item);
XML:
&lt;name key="key"&gt;truck&lt;/name&gt;
</pre> </div>
<div class="content">
-<h4 id="doc_section_3_1_5_2">
+<h4 id="doc_section_3_1_6_2">
<div class="self-section-number">
-<a href="#doc_section_3_1_5_2">3.1.5.2</a> </div>
+<a href="#doc_section_3_1_6_2">3.1.6.2</a> </div>
<a id="xo_clear_flags" href="#xo_clear_flags">xo_clear_flags</a>
</h4>
-<p id="doc_section_3_1_5_2_p_1">The xo_clear_flags() function turns off the given flags in a specific handle.</p>
-<div id="doc_figure_u.95"></div> <pre>
+<p id="doc_section_3_1_6_2_p_1">The xo_clear_flags() function turns off the given flags in a specific handle.</p>
+<div id="doc_figure_u.97"></div> <pre>
void xo_clear_flags (xo_handle_t *xop, xo_xof_flags_t flags);
</pre> </div>
<div class="content">
-<h4 id="doc_section_3_1_5_3">
+<h4 id="doc_section_3_1_6_3">
<div class="self-section-number">
-<a href="#doc_section_3_1_5_3">3.1.5.3</a> </div>
+<a href="#doc_section_3_1_6_3">3.1.6.3</a> </div>
<a id="xo_set_options" href="#xo_set_options">xo_set_options</a>
</h4>
-<p id="doc_section_3_1_5_3_p_1">The xo_set_options() function accepts a comma-separated list of styles and flags and enables them for a specific handle.</p>
-<div id="doc_figure_u.96"></div> <pre>
+<p id="doc_section_3_1_6_3_p_1">The xo_set_options() function accepts a comma-separated list of styles and flags and enables them for a specific handle.</p>
+<div id="doc_figure_u.98"></div> <pre>
int xo_set_options (xo_handle_t *xop, const char *input);
- </pre> <p id="doc_section_3_1_5_3_p_3">The options are identical to those listed in <a href="#command-line-arguments" title="Command-line Arguments">Section 2.4</a>.</p>
+ </pre> <p id="doc_section_3_1_6_3_p_3">The options are identical to those listed in <a href="#command-line-arguments" title="Command-line Arguments">Section 2.4</a>.</p>
</div>
</div>
<div class="content">
-<h3 id="doc_section_3_1_6">
+<h3 id="doc_section_3_1_7">
<div class="self-section-number">
-<a href="#doc_section_3_1_6">3.1.6</a> </div>
+<a href="#doc_section_3_1_7">3.1.7</a> </div>
<a id="xo_destroy" href="#xo_destroy">xo_destroy</a>
</h3>
-<p id="doc_section_3_1_6_p_1">The xo_destroy function releases a handle and any resources it is using. Calling xo_destroy with a NULL handle will release any resources associated with the default handle.</p>
-<div id="doc_figure_u.97"></div> <pre>
+<p id="doc_section_3_1_7_p_1">The xo_destroy function releases a handle and any resources it is using. Calling xo_destroy with a NULL handle will release any resources associated with the default handle.</p>
+<div id="doc_figure_u.99"></div> <pre>
void xo_destroy(xo_handle_t *xop);
</pre> </div>
</div>
@@ -24730,7 +24769,7 @@ jQuery(function ($) {
<a id="emitting-content-xo_emit" href="#emitting-content-xo_emit">Emitting Content (xo_emit)</a>
</h2>
<p id="doc_section_3_2_p_1">The following functions are used to emit output:</p>
-<div id="doc_figure_u.98"></div> <pre>
+<div id="doc_figure_u.100"></div> <pre>
int xo_emit (const char *fmt, ...);
int xo_emit_h (xo_handle_t *xop, const char *fmt, ...);
int xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap);
@@ -24750,7 +24789,7 @@ jQuery(function ($) {
<a id="xo_emit_field" href="#xo_emit_field">Single Field Emitting Functions (xo_emit_field)</a>
</h3>
<p id="doc_section_3_2_1_p_1">The following functions can also make output, but only make a single field at a time:</p>
-<div id="doc_figure_u.99"></div> <pre>
+<div id="doc_figure_u.101"></div> <pre>
int xo_emit_field_hv (xo_handle_t *xop, const char *rolmod,
const char *contents, const char *fmt,
const char *efmt, va_list vap);
@@ -24762,7 +24801,7 @@ jQuery(function ($) {
int xo_emit_field (const char *rolmod, const char *contents,
const char *fmt, const char *efmt, ...);
</pre> <p id="doc_section_3_2_1_p_3">These functions are intended to avoid the scenario where one would otherwise need to compose a format descriptors using snprintf(). The individual parts of the format descriptor are passed in distinctly.</p>
-<div id="doc_figure_u.100"></div> <pre>
+<div id="doc_figure_u.102"></div> <pre>
xo_emit("T", "Host name is ", NULL, NULL);
xo_emit("V", "host-name", NULL, NULL, host-name);
</pre> </div>
@@ -24773,14 +24812,14 @@ jQuery(function ($) {
<a id="xo_attr" href="#xo_attr">Attributes (xo_attr)</a>
</h3>
<p id="doc_section_3_2_2_p_1">The xo_attr() function emits attributes for the XML output style.</p>
-<div id="doc_figure_u.101"></div> <pre>
+<div id="doc_figure_u.103"></div> <pre>
int xo_attr (const char *name, const char *fmt, ...);
int xo_attr_h (xo_handle_t *xop, const char *name,
const char *fmt, ...);
int xo_attr_hv (xo_handle_t *xop, const char *name,
const char *fmt, va_list vap);
</pre> <p id="doc_section_3_2_2_p_3">The name parameter give the name of the attribute to be encoded. The fmt parameter gives a printf-style format string used to format the value of the attribute using any remaining arguments, or the vap parameter passed to xo_attr_hv().</p>
-<div id="doc_figure_u.102"></div> <pre>
+<div id="doc_figure_u.104"></div> <pre>
EXAMPLE:
xo_attr("seconds", "%ld", (unsigned long) login_time);
struct tm *tmp = localtime(login_time);
@@ -24798,7 +24837,7 @@ jQuery(function ($) {
<a id="flushing-output-xo_flush" href="#flushing-output-xo_flush">Flushing Output (xo_flush)</a>
</h3>
<p id="doc_section_3_2_3_p_1">libxo buffers data, both for performance and consistency, but also to allow some advanced features to work properly. At various times, the caller may wish to flush any data buffered within the library. The xo_flush() call is used for this:</p>
-<div id="doc_figure_u.103"></div> <pre>
+<div id="doc_figure_u.105"></div> <pre>
void xo_flush (void);
void xo_flush_h (xo_handle_t *xop);
</pre> <p id="doc_section_3_2_3_p_3">Calling xo_flush also triggers the flush function associated with the handle. For the default handle, this is equivalent to "fflush(stdio);".</p>
@@ -24810,7 +24849,7 @@ jQuery(function ($) {
<a id="finishing-output-xo_finish" href="#finishing-output-xo_finish">Finishing Output (xo_finish)</a>
</h3>
<p id="doc_section_3_2_4_p_1">When the program is ready to exit or close a handle, a call to xo_finish() is required. This flushes any buffered data, closes open libxo constructs, and completes any pending operations.</p>
-<div id="doc_figure_u.104"></div> <pre>
+<div id="doc_figure_u.106"></div> <pre>
int xo_finish (void);
int xo_finish_h (xo_handle_t *xop);
void xo_finish_atexit (void);
@@ -24826,7 +24865,7 @@ jQuery(function ($) {
</h2>
<p id="doc_section_3_3_p_1">libxo represents to types of hierarchy: containers and lists. A container appears once under a given parent where a list contains instances that can appear multiple times. A container is used to hold related fields and to give the data organization and scope.</p>
<p id="doc_section_3_3_p_2">To create a container, use the xo_open_container and xo_close_container functions:</p>
-<div id="doc_figure_u.105"></div> <pre>
+<div id="doc_figure_u.107"></div> <pre>
int xo_open_container (const char *name);
int xo_open_container_h (xo_handle_t *xop, const char *name);
int xo_open_container_hd (xo_handle_t *xop, const char *name);
@@ -24840,7 +24879,7 @@ jQuery(function ($) {
<p id="doc_section_3_3_p_5">The close functions with the "_d" suffix are used in "Do The Right Thing" mode, where the name of the open containers, lists, and instances are maintained internally by libxo to allow the caller to avoid keeping track of the open container name.</p>
<p id="doc_section_3_3_p_6">Use the XOF_WARN flag to generate a warning if the name given on the close does not match the current open container.</p>
<p id="doc_section_3_3_p_7">For TEXT and HTML output, containers are not rendered into output text, though for HTML they are used when the XOF_XPATH flag is set.</p>
-<div id="doc_figure_u.106"></div> <pre>
+<div id="doc_figure_u.108"></div> <pre>
EXAMPLE:
xo_open_container("system");
xo_emit("The host name is {:host-name}\n", hn);
@@ -24857,7 +24896,7 @@ jQuery(function ($) {
</h3>
<p id="doc_section_3_3_1_p_1">Lists are sequences of instances of homogeneous data objects. Two distinct levels of calls are needed to represent them in our output styles. Calls must be made to open and close a list, and for each instance of data in that list, calls must be make to open and close that instance.</p>
<p id="doc_section_3_3_1_p_2">The name given to all calls must be identical, and it is strongly suggested that the name be singular, not plural, as a matter of style and usage expectations.</p>
-<div id="doc_figure_u.107"></div> <pre>
+<div id="doc_figure_u.109"></div> <pre>
EXAMPLE:
xo_open_list("user");
for (i = 0; i &lt; num_users; i++) {
@@ -24926,7 +24965,7 @@ jQuery(function ($) {
<a id="xo_parse_args" href="#xo_parse_args">Parsing Command-line Arguments (xo_parse_args)</a>
</h3>
<p id="doc_section_3_4_1_p_1">The xo_parse_args() function is used to process a program's arguments. libxo-specific options are processed and removed from the argument list so the calling application does not need to process them. If successful, a new value for argc is returned. On failure, a message it emitted and -1 is returned.</p>
-<div id="doc_figure_u.108"></div> <pre>
+<div id="doc_figure_u.110"></div> <pre>
argc = xo_parse_args(argc, argv);
if (argc &lt; 0)
exit(EXIT_FAILURE);
@@ -24939,7 +24978,7 @@ jQuery(function ($) {
<a id="xo_set_program" href="#xo_set_program">xo_set_program</a>
</h3>
<p id="doc_section_3_4_2_p_1">The xo_set_program function sets name of the program as reported by functions like xo_failure, xo_warn, xo_err, etc. The program name is initialized by xo_parse_args, but subsequent calls to xo_set_program can override this value.</p>
-<div id="doc_figure_u.109"></div> <pre>
+<div id="doc_figure_u.111"></div> <pre>
xo_set_program(argv[0]);
</pre> <p id="doc_section_3_4_2_p_3">Note that the value is not copied, so the memory passed to xo_set_program (and xo_parse_args) must be maintained by the caller.</p>
</div>
@@ -24950,7 +24989,7 @@ jQuery(function ($) {
<a id="xo_set_version" href="#xo_set_version">xo_set_version</a>
</h3>
<p id="doc_section_3_4_3_p_1">The xo_set_version function records a version number to be emitted as part of the data for encoding styles (XML and JSON). This version number is suitable for tracking changes in the content, allowing a user of the data to discern which version of the data model is in use.</p>
-<div id="doc_figure_u.110"></div> <pre>
+<div id="doc_figure_u.112"></div> <pre>
void xo_set_version (const char *version);
void xo_set_version_h (xo_handle_t *xop, const char *version);
</pre> </div>
@@ -24963,7 +25002,7 @@ jQuery(function ($) {
<p id="doc_section_3_4_4_p_1">HTML data can include additional information in attributes that begin with "data&#8209;". To enable this, three things must occur:</p>
<p id="doc_section_3_4_4_p_2">First the application must build an array of xo_info_t structures, one per tag. The array must be sorted by name, since libxo uses a binary search to find the entry that matches names from format instructions.</p>
<p id="doc_section_3_4_4_p_3">Second, the application must inform libxo about this information using the xo_set_info() call:</p>
-<div id="doc_figure_u.111"></div> <pre>
+<div id="doc_figure_u.113"></div> <pre>
typedef struct xo_info_s {
const char *xi_name; /* Name of the element */
const char *xi_type; /* Type of field */
@@ -24973,7 +25012,7 @@ jQuery(function ($) {
void xo_set_info (xo_handle_t *xop, xo_info_t *infop, int count);
</pre> <p id="doc_section_3_4_4_p_5">Like other libxo calls, passing NULL for the handle tells libxo to use the default handle.</p>
<p id="doc_section_3_4_4_p_6">If the count is -1, libxo will count the elements of infop, but there must be an empty element at the end. More typically, the number is known to the application:</p>
-<div id="doc_figure_u.112"></div> <pre>
+<div id="doc_figure_u.114"></div> <pre>
xo_info_t info[] = {
{ "in-stock", "number", "Number of items in stock" },
{ "name", "string", "Name of the item" },
@@ -24986,7 +25025,7 @@ jQuery(function ($) {
xo_set_info(NULL, info, info_count);
</pre> <p id="doc_section_3_4_4_p_8">Third, the emission of info must be triggered with the XOF_INFO flag using either the xo_set_flags() function or the "&#8209;&#8209;libxo=info" command line argument.</p>
<p id="doc_section_3_4_4_p_9">The type and help values, if present, are emitted as the "data&#8209;type" and "data&#8209;help" attributes:</p>
-<div id="doc_figure_u.113"></div> <pre>
+<div id="doc_figure_u.115"></div> <pre>
&lt;div class="data" data-tag="sku" data-type="string"
data-help="Stock Keeping Unit"&gt;GRO-000-533&lt;/div&gt;
</pre> </div>
@@ -24997,7 +25036,7 @@ jQuery(function ($) {
<a id="memory-allocation" href="#memory-allocation">Memory Allocation</a>
</h3>
<p id="doc_section_3_4_5_p_1">The xo_set_allocator function allows libxo to be used in environments where the standard realloc() and free() functions are not available.</p>
-<div id="doc_figure_u.114"></div> <pre>
+<div id="doc_figure_u.116"></div> <pre>
void xo_set_allocator (xo_realloc_func_t realloc_func,
xo_free_func_t free_func);
</pre> <p id="doc_section_3_4_5_p_3">realloc_func should expect the same arguments as realloc(3) and return a pointer to memory following the same convention. free_func will receive the same argument as free(3) and should release it, as appropriate for the environment.</p>
@@ -25079,10 +25118,10 @@ jQuery(function ($) {
</tbody>
</table></div>
<p id="doc_section_3_4_6_p_2">For example, warnings can be enabled by:</p>
-<div id="doc_figure_u.115"></div> <pre>
+<div id="doc_figure_u.117"></div> <pre>
% env LIBXO_OPTIONS=W my-app
</pre> <p id="doc_section_3_4_6_p_4">Complete HTML output can be generated with:</p>
-<div id="doc_figure_u.116"></div> <pre>
+<div id="doc_figure_u.118"></div> <pre>
% env LIBXO_OPTIONS=HXI my-app
</pre> <p id="doc_section_3_4_6_p_6">Since environment variables are inherited, child processes will have the same options, which may be undesirable, making the use of the "&#8209;&#8209;libxo" option is preferable in most situations.</p>
</div>
@@ -25093,7 +25132,7 @@ jQuery(function ($) {
<a id="errors-warnings-and-messages" href="#errors-warnings-and-messages">Errors, Warnings, and Messages</a>
</h3>
<p id="doc_section_3_4_7_p_1">Many programs make use of the standard library functions err() and warn() to generate errors and warnings for the user. libxo wants to pass that information via the current output style, and provides compatible functions to allow this:</p>
-<div id="doc_figure_u.117"></div> <pre>
+<div id="doc_figure_u.119"></div> <pre>
void xo_warn (const char *fmt, ...);
void xo_warnx (const char *fmt, ...);
void xo_warn_c (int code, const char *fmt, ...);
@@ -25109,7 +25148,7 @@ jQuery(function ($) {
void xo_message_hcv (xo_handle_t *xop, int code,
const char *fmt, va_list vap);
</pre> <p id="doc_section_3_4_7_p_3">These functions display the program name, a colon, a formatted message based on the arguments, and then optionally a colon and an error message associated with either "errno" or the "code" parameter.</p>
-<div id="doc_figure_u.118"></div> <pre>
+<div id="doc_figure_u.120"></div> <pre>
EXAMPLE:
if (open(filename, O_RDONLY) &lt; 0)
xo_err(1, "cannot open file '%s'", filename);
@@ -25121,7 +25160,7 @@ jQuery(function ($) {
<a id="xo_error" href="#xo_error">xo_error</a>
</h3>
<p id="doc_section_3_4_8_p_1">The xo_error function can be used for generic errors that should be reported over the handle, rather than to stderr. The xo_error function behaves like xo_err for TEXT and HTML output styles, but puts the error into XML or JSON elements:</p>
-<div id="doc_figure_u.119"></div> <pre>
+<div id="doc_figure_u.121"></div> <pre>
EXAMPLE::
xo_error("Does not %s", "compute");
XML::
@@ -25136,7 +25175,7 @@ jQuery(function ($) {
<a id="xo_no_setlocale" href="#xo_no_setlocale">xo_no_setlocale</a>
</h3>
<p id="doc_section_3_4_9_p_1">libxo automatically initializes the locale based on setting of the environment variables LC_CTYPE, LANG, and LC_ALL. The first of this list of variables is used and if none of the variables, the locale defaults to "UTF&#8209;8". The caller may wish to avoid this behavior, and can do so by calling the xo_no_setlocale() function.</p>
-<div id="doc_figure_u.120"></div> <pre>
+<div id="doc_figure_u.122"></div> <pre>
void xo_no_setlocale (void);
</pre> </div>
</div>
@@ -25152,7 +25191,7 @@ jQuery(function ($) {
<p id="doc_section_3_5_p_4">https://www.iana.org/assignments/enterprise-numbers/enterprise-numbers</p>
<p id="doc_section_3_5_p_5">Use the <a href="#xo_set_syslog_enterprise_id" title="xo_set_syslog_enterprise_id">Section 3.5.3.5</a>() function to set the Enterprise ID, as needed.</p>
<p id="doc_section_3_5_p_6">The message name should follow the conventions in <a href="#good-field-names" title="What makes a good field name?">Section 8.1.3</a>, as should the fields within the message.</p>
-<div id="doc_figure_u.121"></div> <pre>
+<div id="doc_figure_u.123"></div> <pre>
/* Both of these calls are optional */
xo_set_syslog_enterprise_id(32473);
xo_open_log("my-program", 0, LOG_DAEMON);
@@ -25180,7 +25219,7 @@ jQuery(function ($) {
<a id="priority" href="#priority">Priority, Facility, and Flags</a>
</h3>
<p id="doc_section_3_5_1_p_1">The xo_syslog, xo_vsyslog, and xo_open_log functions accept a set of flags which provide the priority of the message, the source facility, and some additional features. These values are OR'd together to create a single integer argument:</p>
-<div id="doc_figure_u.122"></div> <pre>
+<div id="doc_figure_u.124"></div> <pre>
xo_syslog(LOG_ERR | LOG_AUTH, "login-failed",
"Login failed; user '{:user}' from host '{:address}'",
user, addr);
@@ -25325,7 +25364,7 @@ jQuery(function ($) {
</h3>
<p id="doc_section_3_5_2_p_1">Use the xo_syslog function to generate syslog messages by calling it with a log priority and facility, a message name, a format string, and a set of arguments. The priority/facility argument are discussed above, as is the message name.</p>
<p id="doc_section_3_5_2_p_2">The format string follows the same conventions as xo_emit's format string, with each field being rendered as an SD-PARAM pair.</p>
-<div id="doc_figure_u.123"></div> <pre>
+<div id="doc_figure_u.125"></div> <pre>
xo_syslog(LOG_ERR, "poofd-missing-file",
"'{:filename}' not found: {:error/%m}", filename);
@@ -25354,7 +25393,7 @@ jQuery(function ($) {
<a id="xo_vsyslog" href="#xo_vsyslog">xo_vsyslog</a>
</h4>
<p id="doc_section_3_5_3_1_p_1">xo_vsyslog is identical in function to xo_syslog, but takes the set of arguments using a va_list.</p>
-<div id="doc_figure_u.124"></div> <pre>
+<div id="doc_figure_u.126"></div> <pre>
void my_log (const char *name, const char *fmt, ...)
{
va_list vap;
@@ -25370,7 +25409,7 @@ jQuery(function ($) {
<a id="xo_open_log" href="#xo_open_log">xo_open_log</a>
</h4>
<p id="doc_section_3_5_3_2_p_1">xo_open_log functions similar to openlog(3), allowing customization of the program name, the log facility number, and the additional option flags described in <a href="#priority" title="Priority, Facility, and Flags">Section 3.5.1</a>.</p>
-<div id="doc_figure_u.125"></div> <pre>
+<div id="doc_figure_u.127"></div> <pre>
void
xo_open_log (const char *ident, int logopt, int facility);
</pre> </div>
@@ -25381,7 +25420,7 @@ jQuery(function ($) {
<a id="xo_close_log" href="#xo_close_log">xo_close_log</a>
</h4>
<p id="doc_section_3_5_3_3_p_1">xo_close_log functions similar to closelog(3), closing the log file and releasing any associated resources.</p>
-<div id="doc_figure_u.126"></div> <pre>
+<div id="doc_figure_u.128"></div> <pre>
void
xo_close_log (void);
</pre> </div>
@@ -25392,7 +25431,7 @@ jQuery(function ($) {
<a id="xo_set_logmask" href="#xo_set_logmask">xo_set_logmask</a>
</h4>
<p id="doc_section_3_5_3_4_p_1">xo_set_logmask function similar to setlogmask(3), restricting the set of generated log event to those whose associated bit is set in maskpri. Use LOG_MASK(pri) to find the appropriate bit, or LOG_UPTO(toppri) to create a mask for all priorities up to and including toppri.</p>
-<div id="doc_figure_u.127"></div> <pre>
+<div id="doc_figure_u.129"></div> <pre>
int
xo_set_logmask (int maskpri);
@@ -25407,7 +25446,7 @@ jQuery(function ($) {
</h4>
<p id="doc_section_3_5_3_5_p_1">Use the xo_set_syslog_enterprise_id to supply a platform- or application-specific enterprise id. This value is used in any future syslog messages.</p>
<p id="doc_section_3_5_3_5_p_2">Ideally, the operating system should supply a default value via the "kern.syslog.enterprise_id" sysctl value. Lacking that, the application should provide a suitable value.</p>
-<div id="doc_figure_u.128"></div> <pre>
+<div id="doc_figure_u.130"></div> <pre>
void
xo_set_syslog_enterprise_id (unsigned short eid);
</pre> <p id="doc_section_3_5_3_5_p_4">Enterprise IDs are administered by IANA, the Internet Assigned Number Authority. The complete list is EIDs on their web site:</p>
@@ -25449,7 +25488,7 @@ jQuery(function ($) {
<a id="loading-encoders" href="#loading-encoders">Loading Encoders</a>
</h3>
<p id="doc_section_3_6_1_p_1">Encoders can be registered statically or discovered dynamically. Applications can choose to call the xo_encoder_register() function to explicitly register encoders, but more typically they are built as shared libraries, placed in the libxo/extensions directory, and loaded based on name. libxo looks for a file with the name of the encoder and an extension of ".enc". This can be a file or a symlink to the shared library file that supports the encoder.</p>
-<div id="doc_figure_u.129"></div> <pre>
+<div id="doc_figure_u.131"></div> <pre>
% ls -1 lib/libxo/extensions/*.enc
lib/libxo/extensions/cbor.enc
lib/libxo/extensions/test.enc
@@ -25461,7 +25500,7 @@ jQuery(function ($) {
<a id="encoder-initialization" href="#encoder-initialization">Encoder Initialization</a>
</h3>
<p id="doc_section_3_6_2_p_1">Each encoder must export a symbol used to access the library, which must have the following signature:</p>
-<div id="doc_figure_u.130"></div> <pre>
+<div id="doc_figure_u.132"></div> <pre>
int xo_encoder_library_init (XO_ENCODER_INIT_ARGS);
</pre> <p id="doc_section_3_6_2_p_3">XO_ENCODER_INIT_ARGS is a macro defined in xo_encoder.h that defines an argument called "arg", a pointer of the type xo_encoder_init_args_t. This structure contains two fields:</p>
<p id="doc_section_3_6_2_p_4"> </p>
@@ -25566,7 +25605,7 @@ jQuery(function ($) {
<p id="doc_section_4_p_1">The "xo" utility allows command line access to the functionality of the libxo library. Using "xo", shell scripts can emit XML, JSON, and HTML using the same commands that emit text output.</p>
<p id="doc_section_4_p_2">The style of output can be selected using a specific option: "&#8209;X" for XML, "&#8209;J" for JSON, "&#8209;H" for HTML, or "&#8209;T" for TEXT, which is the default. The "--style &lt;style&gt;" option can also be used. The LIBXO_OPTIONS environment variable can also be used to set the style, as well as other flags.</p>
<p id="doc_section_4_p_3">The "xo" utility accepts a format string suitable for xo_emit() and a set of zero or more arguments used to supply data for that string.</p>
-<div id="doc_figure_u.131"></div> <pre>
+<div id="doc_figure_u.133"></div> <pre>
xo "The {k:name} weighs {:weight/%d} pounds.\n" fish 6
TEXT:
@@ -25586,7 +25625,7 @@ jQuery(function ($) {
&lt;div class="text"&gt; pounds.&lt;/div&gt;
&lt;/div&gt;
</pre> <p id="doc_section_4_p_5">The "--wrap &lt;path&gt;" option can be used to wrap emitted content in a specific hierarchy. The path is a set of hierarchical names separated by the '/' character.</p>
-<div id="doc_figure_u.132"></div> <pre>
+<div id="doc_figure_u.134"></div> <pre>
xo --wrap top/a/b/c '{:tag}' value
XML:
@@ -25610,7 +25649,7 @@ jQuery(function ($) {
}
}
</pre> <p id="doc_section_4_p_7">The "--open &lt;path&gt;" and "--close &lt;path&gt;" can be used to emit hierarchical information without the matching close and open tag. This allows a shell script to emit open tags, data, and then close tags. The "&#8209;&#8209;depth" option may be used to set the depth for indentation. The "&#8209;&#8209;leading&#8209;xpath" may be used to prepend data to the XPath values used for HTML output style.</p>
-<div id="doc_figure_u.133"></div> <pre>
+<div id="doc_figure_u.135"></div> <pre>
#!/bin/sh
xo --open top/data
xo --depth 2 '{tag}' value
@@ -25639,7 +25678,7 @@ jQuery(function ($) {
<a id="command-line-options" href="#command-line-options">Command Line Options</a>
</h2>
<p id="doc_section_4_1_p_1">Usage: xo [options] format [fields]</p>
-<div id="doc_figure_u.134"></div> <pre>
+<div id="doc_figure_u.136"></div> <pre>
--close &lt;path&gt; Close tags for the given path
--depth &lt;num&gt; Set the depth for pretty printing
--help Display this help text
@@ -25663,7 +25702,7 @@ jQuery(function ($) {
<a href="#doc_section_4_2">4.2</a> </div>
<a id="example-2" href="#example-2">Example</a>
</h2>
-<div id="doc_figure_u.135"></div> <pre>
+<div id="doc_figure_u.137"></div> <pre>
% xo 'The {:product} is {:status}\n' stereo "in route"
The stereo is in route
% ./xo/xo -p -X 'The {:product} is {:status}\n' stereo "in route"
@@ -25721,7 +25760,7 @@ jQuery(function ($) {
</tbody>
</table></div>
<p id="doc_section_5_p_3">The output message will contain the source filename and line number, the class of the message, the message, and, if -p is given, the line that contains the error:</p>
-<div id="doc_figure_u.136"></div> <pre>
+<div id="doc_figure_u.138"></div> <pre>
% xolint.pl -t xolint.c
xolint.c: 16: error: anchor format should be "%d"
16 xo_emit("{[:/%s}");
@@ -25789,7 +25828,7 @@ jQuery(function ($) {
</tr>
</tbody>
</table></div>
-<div id="doc_figure_u.137"></div> <pre>
+<div id="doc_figure_u.139"></div> <pre>
EXAMPLE:
% xopo -s "There are {:count/%u} {:event/%.6s} events\n"
There are {:count} {:event} events\n
@@ -25848,7 +25887,7 @@ jQuery(function ($) {
<a id="did-the-complex-semantics-of-format-strings-evolve-over-time" href="#did-the-complex-semantics-of-format-strings-evolve-over-time">Did the complex semantics of format strings evolve over time?</a>
</h3>
<p id="doc_section_8_1_2_p_1">The history is both long and short: libxo's functionality is based on what JUNOS does in a data modeling language called ODL (output definition language). In JUNOS, all subcomponents generate XML, which is feed to the CLI, where data from the ODL files tell is how to render that XML into text. ODL might had a set of tags like:</p>
-<div id="doc_figure_u.138"></div> <pre>
+<div id="doc_figure_u.140"></div> <pre>
tag docsis-state {
help "State of the DOCSIS interface";
type string;
@@ -25927,7 +25966,7 @@ jQuery(function ($) {
<dt>Reuse existing field names</dt>
<dd>Nothing's worse than writing expressions like:</dd>
</dl>
-<div id="doc_figure_u.139"></div> <pre>
+<div id="doc_figure_u.141"></div> <pre>
if ($src1/process[pid == $pid]/name ==
$src2/proc-table/proc-list
/proc-entry[process-id == $pid]/proc-name) {
@@ -25988,10 +26027,10 @@ jQuery(function ($) {
<a id="a-percent-sign-appearing-in-text-is-a-literal" href="#a-percent-sign-appearing-in-text-is-a-literal">'A percent sign appearing in text is a literal'</a>
</h3>
<p id="doc_section_8_2_1_p_1">The message "A percent sign appearing in text is a literal" can be caused by code like:</p>
-<div id="doc_figure_u.140"></div> <pre>
+<div id="doc_figure_u.142"></div> <pre>
xo_emit("cost: %d", cost);
</pre> <p id="doc_section_8_2_1_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.141"></div> <pre>
+<div id="doc_figure_u.143"></div> <pre>
xo_emit("{L:cost}: {:cost/%d}", cost);
</pre> <p id="doc_section_8_2_1_p_5">This can be a bit surprising and could be a field that was not properly converted to a libxo-style format string.</p>
</div>
@@ -26002,10 +26041,10 @@ jQuery(function ($) {
<a id="unknown-long-name-for-rolemodifier" href="#unknown-long-name-for-rolemodifier">'Unknown long name for role/modifier'</a>
</h3>
<p id="doc_section_8_2_2_p_1">The message "Unknown long name for role/modifier" can be caused by code like:</p>
-<div id="doc_figure_u.142"></div> <pre>
+<div id="doc_figure_u.144"></div> <pre>
xo_emit("{,humanization:value}", value);
</pre> <p id="doc_section_8_2_2_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.143"></div> <pre>
+<div id="doc_figure_u.145"></div> <pre>
xo_emit("{,humanize:value}", value);
</pre> <p id="doc_section_8_2_2_p_5">The hn-* modifiers (hn-decimal, hn-space, hn-1000) are only valid for fields with the {h:} modifier.</p>
</div>
@@ -26017,10 +26056,10 @@ jQuery(function ($) {
</h3>
<p id="doc_section_8_2_3_p_1">The message "Last character before field definition is a field type" can be caused by code like:</p>
<p id="doc_section_8_2_3_p_2">A common typo:</p>
-<div id="doc_figure_u.144"></div> <pre>
+<div id="doc_figure_u.146"></div> <pre>
xo_emit("{T:Min} T{:Max}");
</pre> <p id="doc_section_8_2_3_p_4">This code should be replaced with code like:</p>
-<div id="doc_figure_u.145"></div> <pre>
+<div id="doc_figure_u.147"></div> <pre>
xo_emit("{T:Min} {T:Max}");
</pre> <p id="doc_section_8_2_3_p_6">Twiddling the "{" and the field role is a common typo.</p>
</div>
@@ -26031,10 +26070,10 @@ jQuery(function ($) {
<a id="encoding-format-uses-different-number-of-arguments" href="#encoding-format-uses-different-number-of-arguments">'Encoding format uses different number of arguments'</a>
</h3>
<p id="doc_section_8_2_4_p_1">The message "Encoding format uses different number of arguments" can be caused by code like:</p>
-<div id="doc_figure_u.146"></div> <pre>
+<div id="doc_figure_u.148"></div> <pre>
xo_emit("{:name/%6.6s %%04d/%s}", name, number);
</pre> <p id="doc_section_8_2_4_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.147"></div> <pre>
+<div id="doc_figure_u.149"></div> <pre>
xo_emit("{:name/%6.6s %04d/%s-%d}", name, number);
</pre> <p id="doc_section_8_2_4_p_5">Both format should consume the same number of arguments off the stack</p>
</div>
@@ -26045,10 +26084,10 @@ jQuery(function ($) {
<a id="only-one-field-role-can-be-used" href="#only-one-field-role-can-be-used">'Only one field role can be used'</a>
</h3>
<p id="doc_section_8_2_5_p_1">The message "Only one field role can be used" can be caused by code like:</p>
-<div id="doc_figure_u.148"></div> <pre>
+<div id="doc_figure_u.150"></div> <pre>
xo_emit("{LT:Max}");
</pre> <p id="doc_section_8_2_5_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.149"></div> <pre>
+<div id="doc_figure_u.151"></div> <pre>
xo_emit("{T:Max}");
</pre> </div>
<div class="content">
@@ -26058,10 +26097,10 @@ jQuery(function ($) {
<a id="potential-missing-slash-after-c-d-n-l-or-t-with-format" href="#potential-missing-slash-after-c-d-n-l-or-t-with-format">'Potential missing slash after C, D, N, L, or T with format'</a>
</h3>
<p id="doc_section_8_2_6_p_1">The message "Potential missing slash after C, D, N, L, or T with format" can be caused by code like:</p>
-<div id="doc_figure_u.150"></div> <pre>
+<div id="doc_figure_u.152"></div> <pre>
xo_emit("{T:%6.6s}\n", "Max");
</pre> <p id="doc_section_8_2_6_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.151"></div> <pre>
+<div id="doc_figure_u.153"></div> <pre>
xo_emit("{T:/%6.6s}\n", "Max");
</pre> <p id="doc_section_8_2_6_p_5">The "%6.6s" will be a literal, not a field format. While it's possibly valid, it's likely a missing "/".</p>
</div>
@@ -26072,7 +26111,7 @@ jQuery(function ($) {
<a id="an-encoding-format-cannot-be-given-roles-dnlt" href="#an-encoding-format-cannot-be-given-roles-dnlt">'An encoding format cannot be given (roles: DNLT)'</a>
</h3>
<p id="doc_section_8_2_7_p_1">The message "An encoding format cannot be given (roles: DNLT)" can be caused by code like:</p>
-<div id="doc_figure_u.152"></div> <pre>
+<div id="doc_figure_u.154"></div> <pre>
xo_emit("{T:Max//%s}", "Max");
</pre> <p id="doc_section_8_2_7_p_3">Fields with the C, D, N, L, and T roles are not emitted in the 'encoding' style (JSON, XML), so an encoding format would make no sense.</p>
</div>
@@ -26083,7 +26122,7 @@ jQuery(function ($) {
<a id="format-cannot-be-given-when-content-is-present-roles-cdln" href="#format-cannot-be-given-when-content-is-present-roles-cdln">'Format cannot be given when content is present (roles: CDLN)'</a>
</h3>
<p id="doc_section_8_2_8_p_1">The message "Format cannot be given when content is present (roles: CDLN)" can be caused by code like:</p>
-<div id="doc_figure_u.153"></div> <pre>
+<div id="doc_figure_u.155"></div> <pre>
xo_emit("{N:Max/%6.6s}", "Max");
</pre> <p id="doc_section_8_2_8_p_3">Fields with the C, D, L, or N roles can't have both static literal content ("{L:Label}") and a format ("{L:/%s}"). This error will also occur when the content has a backslash in it, like "{N:Type of I/O}"; backslashes should be escaped, like "{N:Type of I\\/O}". Note the double backslash, one for handling 'C' strings, and one for libxo.</p>
</div>
@@ -26094,10 +26133,10 @@ jQuery(function ($) {
<a id="field-has-color-without-fg--or-bg--role-c" href="#field-has-color-without-fg--or-bg--role-c">'Field has color without fg- or bg- (role: C)'</a>
</h3>
<p id="doc_section_8_2_9_p_1">The message "Field has color without fg- or bg- (role: C)" can be caused by code like:</p>
-<div id="doc_figure_u.154"></div> <pre>
+<div id="doc_figure_u.156"></div> <pre>
xo_emit("{C:green}{:foo}{C:}", x);
</pre> <p id="doc_section_8_2_9_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.155"></div> <pre>
+<div id="doc_figure_u.157"></div> <pre>
xo_emit("{C:fg-green}{:foo}{C:}", x);
</pre> <p id="doc_section_8_2_9_p_5">Colors must be prefixed by either "fg&#8209;" or "bg&#8209;".</p>
</div>
@@ -26108,10 +26147,10 @@ jQuery(function ($) {
<a id="field-has-invalid-color-or-effect-role-c" href="#field-has-invalid-color-or-effect-role-c">'Field has invalid color or effect (role: C)'</a>
</h3>
<p id="doc_section_8_2_10_p_1">The message "Field has invalid color or effect (role: C)" can be caused by code like:</p>
-<div id="doc_figure_u.156"></div> <pre>
+<div id="doc_figure_u.158"></div> <pre>
xo_emit("{C:fg-purple,bold}{:foo}{C:gween}", x);
</pre> <p id="doc_section_8_2_10_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.157"></div> <pre>
+<div id="doc_figure_u.159"></div> <pre>
xo_emit("{C:fg-red,bold}{:foo}{C:fg-green}", x);
</pre> <p id="doc_section_8_2_10_p_5">The list of colors and effects are limited. The set of colors includes default, black, red, green, yellow, blue, magenta, cyan, and white, which must be prefixed by either "fg&#8209;" or "bg&#8209;". Effects are limited to bold, no-bold, underline, no-underline, inverse, no-inverse, normal, and reset. Values must be separated by commas.</p>
</div>
@@ -26122,10 +26161,10 @@ jQuery(function ($) {
<a id="field-has-humanize-modifier-but-no-format-string" href="#field-has-humanize-modifier-but-no-format-string">'Field has humanize modifier but no format string'</a>
</h3>
<p id="doc_section_8_2_11_p_1">The message "Field has humanize modifier but no format string" can be caused by code like:</p>
-<div id="doc_figure_u.158"></div> <pre>
+<div id="doc_figure_u.160"></div> <pre>
xo_emit("{h:value}", value);
</pre> <p id="doc_section_8_2_11_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.159"></div> <pre>
+<div id="doc_figure_u.161"></div> <pre>
xo_emit("{h:value/%d}", value);
</pre> <p id="doc_section_8_2_11_p_5">Humanization is only value for numbers, which are not likely to use the default format ("%s").</p>
</div>
@@ -26136,10 +26175,10 @@ jQuery(function ($) {
<a id="field-has-hn--modifier-but-not-h-modifier" href="#field-has-hn--modifier-but-not-h-modifier">'Field has hn-* modifier but not 'h' modifier'</a>
</h3>
<p id="doc_section_8_2_12_p_1">The message "Field has hn-* modifier but not 'h' modifier" can be caused by code like:</p>
-<div id="doc_figure_u.160"></div> <pre>
+<div id="doc_figure_u.162"></div> <pre>
xo_emit("{,hn-1000:value}", value);
</pre> <p id="doc_section_8_2_12_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.161"></div> <pre>
+<div id="doc_figure_u.163"></div> <pre>
xo_emit("{h,hn-1000:value}", value);
</pre> <p id="doc_section_8_2_12_p_5">The hn-* modifiers (hn-decimal, hn-space, hn-1000) are only valid for fields with the {h:} modifier.</p>
</div>
@@ -26150,10 +26189,10 @@ jQuery(function ($) {
<a id="value-field-must-have-a-name-as-content" href="#value-field-must-have-a-name-as-content">'Value field must have a name (as content)")'</a>
</h3>
<p id="doc_section_8_2_13_p_1">The message "Value field must have a name (as content)")" can be caused by code like:</p>
-<div id="doc_figure_u.162"></div> <pre>
+<div id="doc_figure_u.164"></div> <pre>
xo_emit("{:/%s}", "value");
</pre> <p id="doc_section_8_2_13_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.163"></div> <pre>
+<div id="doc_figure_u.165"></div> <pre>
xo_emit("{:tag-name/%s}", "value");
</pre> <p id="doc_section_8_2_13_p_5">The field name is used for XML and JSON encodings. These tags names are static and must appear directly in the field descriptor.</p>
</div>
@@ -26164,10 +26203,10 @@ jQuery(function ($) {
<a id="use-hyphens-not-underscores-for-value-field-name" href="#use-hyphens-not-underscores-for-value-field-name">'Use hyphens, not underscores, for value field name'</a>
</h3>
<p id="doc_section_8_2_14_p_1">The message "Use hyphens, not underscores, for value field name" can be caused by code like:</p>
-<div id="doc_figure_u.164"></div> <pre>
+<div id="doc_figure_u.166"></div> <pre>
xo_emit("{:no_under_scores}", "bad");
</pre> <p id="doc_section_8_2_14_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.165"></div> <pre>
+<div id="doc_figure_u.167"></div> <pre>
xo_emit("{:no-under-scores}", "bad");
</pre> <p id="doc_section_8_2_14_p_5">Use of hyphens is traditional in XML, and the XOF_UNDERSCORES flag can be used to generate underscores in JSON, if desired. But the raw field name should use hyphens.</p>
</div>
@@ -26178,10 +26217,10 @@ jQuery(function ($) {
<a id="value-field-name-cannot-start-with-digit" href="#value-field-name-cannot-start-with-digit">'Value field name cannot start with digit'</a>
</h3>
<p id="doc_section_8_2_15_p_1">The message "Value field name cannot start with digit" can be caused by code like:</p>
-<div id="doc_figure_u.166"></div> <pre>
+<div id="doc_figure_u.168"></div> <pre>
xo_emit("{:10-gig/}");
</pre> <p id="doc_section_8_2_15_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.167"></div> <pre>
+<div id="doc_figure_u.169"></div> <pre>
xo_emit("{:ten-gig/}");
</pre> <p id="doc_section_8_2_15_p_5">XML element names cannot start with a digit.</p>
</div>
@@ -26192,10 +26231,10 @@ jQuery(function ($) {
<a id="value-field-name-should-be-lower-case" href="#value-field-name-should-be-lower-case">'Value field name should be lower case'</a>
</h3>
<p id="doc_section_8_2_16_p_1">The message "Value field name should be lower case" can be caused by code like:</p>
-<div id="doc_figure_u.168"></div> <pre>
+<div id="doc_figure_u.170"></div> <pre>
xo_emit("{:WHY-ARE-YOU-SHOUTING}", "NO REASON");
</pre> <p id="doc_section_8_2_16_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.169"></div> <pre>
+<div id="doc_figure_u.171"></div> <pre>
xo_emit("{:why-are-you-shouting}", "no reason");
</pre> <p id="doc_section_8_2_16_p_5">Lower case is more civilized. Even TLAs should be lower case to avoid scenarios where the differences between "XPath" and "Xpath" drive your users crazy. Lower case rules the seas.</p>
</div>
@@ -26206,10 +26245,10 @@ jQuery(function ($) {
<a id="value-field-name-should-be-longer-than-two-characters" href="#value-field-name-should-be-longer-than-two-characters">'Value field name should be longer than two characters'</a>
</h3>
<p id="doc_section_8_2_17_p_1">The message "Value field name should be longer than two characters" can be caused by code like:</p>
-<div id="doc_figure_u.170"></div> <pre>
+<div id="doc_figure_u.172"></div> <pre>
xo_emit("{:x}", "mumble");
</pre> <p id="doc_section_8_2_17_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.171"></div> <pre>
+<div id="doc_figure_u.173"></div> <pre>
xo_emit("{:something-meaningful}", "mumble");
</pre> <p id="doc_section_8_2_17_p_5">Field names should be descriptive, and it's hard to be descriptive in less than two characters. Consider your users and try to make something more useful. Note that this error often occurs when the field type is placed after the colon ("{:T/%20s}"), instead of before it ("{T:/20s}").</p>
</div>
@@ -26220,10 +26259,10 @@ jQuery(function ($) {
<a id="value-field-name-contains-invalid-character" href="#value-field-name-contains-invalid-character">'Value field name contains invalid character'</a>
</h3>
<p id="doc_section_8_2_18_p_1">The message "Value field name contains invalid character" can be caused by code like:</p>
-<div id="doc_figure_u.172"></div> <pre>
+<div id="doc_figure_u.174"></div> <pre>
xo_emit("{:cost-in-$$/%u}", 15);
</pre> <p id="doc_section_8_2_18_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.173"></div> <pre>
+<div id="doc_figure_u.175"></div> <pre>
xo_emit("{:cost-in-dollars/%u}", 15);
</pre> <p id="doc_section_8_2_18_p_5">An invalid character is often a sign of a typo, like "{:]}" instead of "{]:}". Field names are restricted to lower-case characters, digits, and hyphens.</p>
</div>
@@ -26234,10 +26273,10 @@ jQuery(function ($) {
<a id="decoration-field-contains-invalid-character" href="#decoration-field-contains-invalid-character">'decoration field contains invalid character'</a>
</h3>
<p id="doc_section_8_2_19_p_1">The message "decoration field contains invalid character" can be caused by code like:</p>
-<div id="doc_figure_u.174"></div> <pre>
+<div id="doc_figure_u.176"></div> <pre>
xo_emit("{D:not good}");
</pre> <p id="doc_section_8_2_19_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.175"></div> <pre>
+<div id="doc_figure_u.177"></div> <pre>
xo_emit("{D:((}{:good}{D:))}", "yes");
</pre> <p id="doc_section_8_2_19_p_5">This is minor, but fields should use proper roles. Decoration fields are meant to hold punctuation and other characters used to decorate the content, typically to make it more readable to human readers.</p>
</div>
@@ -26248,10 +26287,10 @@ jQuery(function ($) {
<a id="anchor-content-should-be-decimal-width" href="#anchor-content-should-be-decimal-width">'Anchor content should be decimal width'</a>
</h3>
<p id="doc_section_8_2_20_p_1">The message "Anchor content should be decimal width" can be caused by code like:</p>
-<div id="doc_figure_u.176"></div> <pre>
+<div id="doc_figure_u.178"></div> <pre>
xo_emit("{[:mumble}");
</pre> <p id="doc_section_8_2_20_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.177"></div> <pre>
+<div id="doc_figure_u.179"></div> <pre>
xo_emit("{[:32}");
</pre> <p id="doc_section_8_2_20_p_5">Anchors need an integer value to specify the width of the set of anchored fields. The value can be positive (for left padding/right justification) or negative (for right padding/left justification) and can appear in either the start or stop anchor field descriptor.</p>
</div>
@@ -26262,10 +26301,10 @@ jQuery(function ($) {
<a id="anchor-format-should-be-d" href="#anchor-format-should-be-d">'Anchor format should be "%d"'</a>
</h3>
<p id="doc_section_8_2_21_p_1">The message "Anchor format should be "%d"" can be caused by code like:</p>
-<div id="doc_figure_u.178"></div> <pre>
+<div id="doc_figure_u.180"></div> <pre>
xo_emit("{[:/%s}");
</pre> <p id="doc_section_8_2_21_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.179"></div> <pre>
+<div id="doc_figure_u.181"></div> <pre>
xo_emit("{[:/%d}");
</pre> <p id="doc_section_8_2_21_p_5">Anchors only grok integer values, and if the value is not static, if must be in an 'int' argument, represented by the "%d" format. Anything else is an error.</p>
</div>
@@ -26276,10 +26315,10 @@ jQuery(function ($) {
<a id="anchor-cannot-have-both-format-and-encoding-format" href="#anchor-cannot-have-both-format-and-encoding-format">'Anchor cannot have both format and encoding format")'</a>
</h3>
<p id="doc_section_8_2_22_p_1">The message "Anchor cannot have both format and encoding format")" can be caused by code like:</p>
-<div id="doc_figure_u.180"></div> <pre>
+<div id="doc_figure_u.182"></div> <pre>
xo_emit("{[:32/%d}");
</pre> <p id="doc_section_8_2_22_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.181"></div> <pre>
+<div id="doc_figure_u.183"></div> <pre>
xo_emit("{[:32}");
</pre> <p id="doc_section_8_2_22_p_5">Anchors can have a static value or argument for the width, but cannot have both.</p>
</div>
@@ -26290,10 +26329,10 @@ jQuery(function ($) {
<a id="max-width-only-valid-for-strings" href="#max-width-only-valid-for-strings">'Max width only valid for strings'</a>
</h3>
<p id="doc_section_8_2_23_p_1">The message "Max width only valid for strings" can be caused by code like:</p>
-<div id="doc_figure_u.182"></div> <pre>
+<div id="doc_figure_u.184"></div> <pre>
xo_emit("{:tag/%2.4.6d}", 55);
</pre> <p id="doc_section_8_2_23_p_3">This code should be replaced with code like:</p>
-<div id="doc_figure_u.183"></div> <pre>
+<div id="doc_figure_u.185"></div> <pre>
xo_emit("{:tag/%2.6d}", 55);
</pre> <p id="doc_section_8_2_23_p_5">libxo allows a true 'max width' in addition to the traditional printf-style 'max number of bytes to use for input'. But this is supported only for string values, since it makes no sense for non-strings. This error may occur from a typo, like "{:tag/%6..6d}" where only one period should be used.</p>
</div>
@@ -26333,7 +26372,7 @@ jQuery(function ($) {
<p id="doc_section_9_2_p_1">libxo is open source, under a new BSD license. Source code is available on github, as are recent releases. To get the most current release, please visit:</p>
<p id="doc_section_9_2_p_2"> <a href="https://github.com/Juniper/libxo/releases">https://github.com/Juniper/libxo/releases</a></p>
<p id="doc_section_9_2_p_3">After downloading and untarring the source code, building involves the following steps:</p>
-<div id="doc_figure_u.184"></div> <pre>
+<div id="doc_figure_u.186"></div> <pre>
sh bin/setup.sh
cd build
../configure
@@ -26342,7 +26381,7 @@ jQuery(function ($) {
sudo make install
</pre> <p id="doc_section_9_2_p_5">libxo uses a distinct "build" directory to keep generated files separated from source files.</p>
<p id="doc_section_9_2_p_6">Use "../configure --help" to display available configuration options, which include the following:</p>
-<div id="doc_figure_u.185"></div> <pre>
+<div id="doc_figure_u.187"></div> <pre>
--enable-warnings Turn on compiler warnings
--enable-debug Turn on debugging
--enable-text-only Turn on text-only rendering
@@ -26362,7 +26401,7 @@ jQuery(function ($) {
<a href="#doc_section_9_3">9.3</a> </div>
<a id="howto-convert-command-line-applications" href="#howto-convert-command-line-applications">Howto: Convert command line applications</a>
</h2>
-<div id="doc_figure_u.186"></div> <pre>
+<div id="doc_figure_u.188"></div> <pre>
How do I convert an existing command line application?
</pre> <p id="doc_section_9_3_p_2">There are three basic steps for converting command line application to use libxo.</p>
<p id="doc_section_9_3_p_3"> </p>
@@ -26386,10 +26425,10 @@ jQuery(function ($) {
<a id="setting-up-the-context" href="#setting-up-the-context">Setting up the context</a>
</h3>
<p id="doc_section_9_3_1_p_1">To use libxo, you'll need to include the "xo.h" header file in your source code files:</p>
-<div id="doc_figure_u.187"></div> <pre>
+<div id="doc_figure_u.189"></div> <pre>
#include &lt;libxo/xo.h&gt;
</pre> <p id="doc_section_9_3_1_p_3">In your main() function, you'll need to call xo_parse_args to handling argument parsing (<a href="#xo_parse_args" title="Parsing Command-line Arguments (xo_parse_args)">Section 3.4.1</a>). This function removes libxo-specific arguments the program's argv and returns either the number of remaining arguments or -1 to indicate an error.</p>
-<div id="doc_figure_u.188"></div> <pre>
+<div id="doc_figure_u.190"></div> <pre>
int main (int argc, char **argv)
{
argc = xo_parse_args(argc, argv);
@@ -26398,7 +26437,7 @@ jQuery(function ($) {
....
}
</pre> <p id="doc_section_9_3_1_p_5">At the bottom of your main(), you'll need to call xo_finish() to complete output processing for the default handle (<a href="#handles" title="Handles">Section 3.1</a>). libxo provides the xo_finish_atexit function that is suitable for use with the atexit(3) function.</p>
-<div id="doc_figure_u.189"></div> <pre>
+<div id="doc_figure_u.191"></div> <pre>
atexit(xo_finish_atexit);
</pre> </div>
<div class="content">
@@ -26408,20 +26447,20 @@ jQuery(function ($) {
<a id="converting-printf-calls" href="#converting-printf-calls">Converting printf Calls</a>
</h3>
<p id="doc_section_9_3_2_p_1">The second task is inspecting code for printf(3) calls and replacing them with xo_emit() calls. The format strings are similar in task, but libxo format strings wrap output fields in braces. The following two calls produce identical text output:</p>
-<div id="doc_figure_u.190"></div> <pre>
+<div id="doc_figure_u.192"></div> <pre>
printf("There are %d %s events\n", count, etype);
xo_emit("There are {:count/%d} {:event} events\n", count, etype);
</pre> <p id="doc_section_9_3_2_p_3">"count" and "event" are used as names for JSON and XML output. The "count" field uses the format "%d" and "event" uses the default "%s" format. Both are "value" roles, which is the default role.</p>
<p id="doc_section_9_3_2_p_4">Since text outside of output fields is passed verbatim, other roles are less important, but their proper use can help make output more useful. The "note" and "label" roles allow HTML output to recognize the relationship between text and the associated values, allowing appropriate "hover" and "onclick" behavior. Using the "units" role allows the presentation layer to perform conversions when needed. The "warning" and "error" roles allows use of color and font to draw attention to warnings. The "padding" role makes the use of vital whitespace more clear (<a href="#padding-role" title="The Padding Role ({P:})">Section 2.2.1.6</a>).</p>
<p id="doc_section_9_3_2_p_5">The "title" role indicates the headings of table and sections. This allows HTML output to use CSS to make this relationship more obvious.</p>
-<div id="doc_figure_u.191"></div> <pre>
+<div id="doc_figure_u.193"></div> <pre>
printf("Statistics:\n");
xo_emit("{T:Statistics}:\n");
</pre> <p id="doc_section_9_3_2_p_7">The "color" roles controls foreground and background colors, as well as effects like bold and underline (see <a href="#color-role" title="The Color Role ({C:})">Section 2.2.1.1</a>).</p>
-<div id="doc_figure_u.192"></div> <pre>
+<div id="doc_figure_u.194"></div> <pre>
xo_emit("{C:bold}required{C:}\n");
</pre> <p id="doc_section_9_3_2_p_9">Finally, the start- and stop-anchor roles allow justification and padding over multiple fields (see <a href="#anchor-role" title="The Anchor Roles ({[:} and {]:})">Section 2.2.1.10</a>).</p>
-<div id="doc_figure_u.193"></div> <pre>
+<div id="doc_figure_u.195"></div> <pre>
snprintf(buf, sizeof(buf), "(%u/%u/%u)", min, ave, max);
printf("%30s", buf);
@@ -26435,7 +26474,7 @@ jQuery(function ($) {
<a id="creating-hierarchy" href="#creating-hierarchy">Creating Hierarchy</a>
</h3>
<p id="doc_section_9_3_3_p_1">Text output doesn't have any sort of hierarchy, but XML and JSON require this. Typically applications use indentation to represent these relationship:</p>
-<div id="doc_figure_u.194"></div> <pre>
+<div id="doc_figure_u.196"></div> <pre>
printf("table %d\n", tnum);
for (i = 0; i &lt; tmax; i++) {
printf(" %s %d\n", table[i].name, table[i].size);
@@ -26453,7 +26492,7 @@ jQuery(function ($) {
</pre> <p id="doc_section_9_3_3_p_3">The open and close list functions are used before and after the list, and the open and close instance functions are used before and after each instance with in the list.</p>
<p id="doc_section_9_3_3_p_4">Typically these developer looks for a "for" loop as an indication of where to put these calls.</p>
<p id="doc_section_9_3_3_p_5">In addition, the open and close container functions allow for organization levels of hierarchy.</p>
-<div id="doc_figure_u.195"></div> <pre>
+<div id="doc_figure_u.197"></div> <pre>
printf("Paging information:\n");
printf(" Free: %lu\n", free);
printf(" Active: %lu\n", active);
@@ -26472,7 +26511,7 @@ jQuery(function ($) {
<a id="converting-error-functions" href="#converting-error-functions">Converting Error Functions</a>
</h3>
<p id="doc_section_9_3_4_p_1">libxo provides variants of the standard error and warning functions, err(3) and warn(3). There are two variants, one for putting the errors on standard error, and the other writes the errors and warnings to the handle using the appropriate encoding style:</p>
-<div id="doc_figure_u.196"></div> <pre>
+<div id="doc_figure_u.198"></div> <pre>
err(1, "cannot open output file: %s", file);
xo_err(1, "cannot open output file: %s", file);
@@ -26490,12 +26529,12 @@ jQuery(function ($) {
<a href="#doc_section_9_5">9.5</a> </div>
<a id="howto-i18n" href="#howto-i18n">Howto: Internationalization (i18n)</a>
</h2>
-<div id="doc_figure_u.197"></div> <pre>
+<div id="doc_figure_u.199"></div> <pre>
How do I use libxo to support internationalization?
</pre> <p id="doc_section_9_5_p_2">libxo allows format and field strings to be used a keys into message catalogs to enable translation into a user's native language by invoking the standard gettext(3) functions.</p>
<p id="doc_section_9_5_p_3">gettext setup is a bit complicated: text strings are extracted from source files into "portable object template" (.pot) files using the "xgettext" command. For each language, this template file is used as the source for a message catalog in the "portable object" (.po) format, which are translated by hand and compiled into "machine object" (.mo) files using the "msgfmt" command. The .mo files are then typically installed in the /usr/share/locale or /opt/local/share/locale directories. At run time, the user's language settings are used to select a .mo file which is searched for matching messages. Text strings in the source code are used as keys to look up the native language strings in the .mo file.</p>
<p id="doc_section_9_5_p_4">Since the xo_emit format string is used as the key into the message catalog, libxo removes unimportant field formatting and modifiers from the format string before use so that minor formatting changes will not impact the expensive translation process. We don't want a developer change such as changing "/%06d" to "/%08d" to force hand inspection of all .po files. The simplified version can be generated for a single message using the "xopo -s &lt;text&gt;" command, or an entire .pot can be translated using the "xopo -f &lt;input&gt; -o &lt;output&gt;" command.</p>
-<div id="doc_figure_u.198"></div> <pre>
+<div id="doc_figure_u.200"></div> <pre>
EXAMPLE:
% xopo -s "There are {:count/%u} {:event/%.6s} events\n"
There are {:count} {:event} events\n
@@ -26528,7 +26567,7 @@ jQuery(function ($) {
sudo cp po/my_lang/LC_MESSAGES/foo.mo \
/opt/local/share/locale/my_lang/LC_MESSAGE/
</pre> <p id="doc_section_9_5_p_6">Once these steps are complete, you can use the "gettext" command to test the message catalog:</p>
-<div id="doc_figure_u.199"></div> <pre>
+<div id="doc_figure_u.201"></div> <pre>
gettext -d foo -e "some text"
</pre> <p id="doc_section_9_5_p_8">Section Contents: </p>
<ul><li><a href="#i18n-and-xo_emit" title="i18n and xo_emit">Section 9.5.1</a></li></ul>
@@ -26546,7 +26585,7 @@ jQuery(function ($) {
<li>The "{p:}" modifier looks for a pluralized version of the field.</li>
</ul>
<p id="doc_section_9_5_1_p_3">Together these three flags allows a single function call to give native language support, as well as libxo's normal XML, JSON, and HTML support.</p>
-<div id="doc_figure_u.200"></div> <pre>
+<div id="doc_figure_u.202"></div> <pre>
printf(gettext("Received %zu %s from {g:server} server\n"),
counter, ngettext("byte", "bytes", counter),
gettext("web"));
@@ -26554,17 +26593,17 @@ jQuery(function ($) {
xo_emit("{G:}Received {:received/%zu} {Ngp:byte,bytes} "
"from {g:server} server\n", counter, "web");
</pre> <p id="doc_section_9_5_1_p_5">libxo will see the "{G:}" role and will first simplify the format string, removing field formats and modifiers.</p>
-<div id="doc_figure_u.201"></div> <pre>
+<div id="doc_figure_u.203"></div> <pre>
"Received {:received} {N:byte,bytes} from {:server} server\n"
</pre> <p id="doc_section_9_5_1_p_7">libxo calls gettext(3) with that string to get a localized version. If your language were Pig Latin, the result might look like:</p>
-<div id="doc_figure_u.202"></div> <pre>
+<div id="doc_figure_u.204"></div> <pre>
"Eceivedray {:received} {N:byte,bytes} omfray "
"{:server} erversay\n"
</pre> <p id="doc_section_9_5_1_p_9">Note the field names do not change and they should not be translated. The contents of the note ("byte,bytes") should also not be translated, since the "g" modifier will need the untranslated value as the key for the message catalog.</p>
<p id="doc_section_9_5_1_p_10">The field "{g:server}" requests the rendered value of the field be translated using gettext(3). In this example, "web" would be used.</p>
<p id="doc_section_9_5_1_p_11">The field "{Ngp:byte,bytes}" shows an example of plural form using the "p" modifier with the "g" modifier. The base singular and plural forms appear inside the field, separated by a comma. At run time, libxo uses the previous field's numeric value to decide which form to use by calling ngettext(3).</p>
<p id="doc_section_9_5_1_p_12">If a domain name is needed, it can be supplied as the content of the {G:} role. Domain names remain in use throughout the format string until cleared with another domain name.</p>
-<div id="doc_figure_u.203"></div> <pre>
+<div id="doc_figure_u.205"></div> <pre>
printf(dgettext("dns", "Host %s not found: %d(%s)\n"),
name, errno, dgettext("strerror", strerror(errno)));
@@ -26589,7 +26628,7 @@ jQuery(function ($) {
<a id="unit-test" href="#unit-test">Unit Test</a>
</h2>
<p id="doc_section_10_1_p_1">Here is the unit test example:</p>
-<div id="doc_figure_u.204"></div> <pre>
+<div id="doc_figure_u.206"></div> <pre>
int
main (int argc, char **argv)
{
@@ -26682,7 +26721,7 @@ jQuery(function ($) {
return 0;
}
</pre> <p id="doc_section_10_1_p_3">Text output:</p>
-<div id="doc_figure_u.205"></div> <pre>
+<div id="doc_figure_u.207"></div> <pre>
% ./testxo --libxo text
Item 'gum':
Total sold: 1412.0
@@ -26715,7 +26754,7 @@ jQuery(function ($) {
On order: 1
SKU: GRO-000-533
</pre> <p id="doc_section_10_1_p_5">JSON output:</p>
-<div id="doc_figure_u.206"></div> <pre>
+<div id="doc_figure_u.208"></div> <pre>
% ./testxo --libxo json,pretty
"top": {
"data": {
@@ -26770,7 +26809,7 @@ jQuery(function ($) {
}
}
</pre> <p id="doc_section_10_1_p_7">XML output:</p>
-<div id="doc_figure_u.207"></div> <pre>
+<div id="doc_figure_u.209"></div> <pre>
% ./testxo --libxo pretty,xml
&lt;top&gt;
&lt;data&gt;
@@ -26821,7 +26860,7 @@ jQuery(function ($) {
&lt;/data&gt;
&lt;/top&gt;
</pre> <p id="doc_section_10_1_p_9">HMTL output:</p>
-<div id="doc_figure_u.208"></div> <pre>
+<div id="doc_figure_u.210"></div> <pre>
% ./testxo --libxo pretty,html
&lt;div class="line"&gt;
&lt;div class="label"&gt;Item&lt;/div&gt;
@@ -27016,7 +27055,7 @@ jQuery(function ($) {
&lt;div class="data" data-tag="sku"&gt;GRO-000-533&lt;/div&gt;
&lt;/div&gt;
</pre> <p id="doc_section_10_1_p_11">HTML output with xpath and info flags:</p>
-<div id="doc_figure_u.209"></div> <pre>
+<div id="doc_figure_u.211"></div> <pre>
% ./testxo --libxo pretty,html,xpath,info
&lt;div class="line"&gt;
&lt;div class="label"&gt;Item&lt;/div&gt;
diff --git a/contrib/libxo/doc/libxo.txt b/contrib/libxo/doc/libxo.txt
index 4cd51cca5d57..f4b0eff5ebc0 100644
--- a/contrib/libxo/doc/libxo.txt
+++ b/contrib/libxo/doc/libxo.txt
@@ -1070,7 +1070,7 @@ libxo will convert these arguments as needed to either UTF-8 (for XML,
JSON, and HTML styles) or locale-based strings for display in text
style.
- xo_emit("Alll strings are utf-8 content {:tag/%ls}",
+ xo_emit("All strings are utf-8 content {:tag/%ls}",
L"except for wide strings");
"%S" is equivalent to "%ls".
@@ -1464,6 +1464,8 @@ styles, flags, or features:
|-------------+-------------------------------------------------------|
| color | Enable colors/effects for display styles (TEXT, HTML) |
| dtrt | Enable "Do The Right Thing" mode |
+| flush | Flush after every libxo function call |
+| flush-line | Flush after every line (line-buffered) |
| html | Emit HTML output |
| indent=xx | Set the indentation level |
| info | Add info attributes (HTML) |
@@ -1479,7 +1481,7 @@ styles, flags, or features:
| pretty | Emit pretty-printed output |
| retain | Force retaining formatting information |
| text | Emit TEXT output |
-| underscores | Replace XML-friendly "-"s with JSON friendly "_"s e |
+| underscores | Replace XML-friendly "-"s with JSON friendly "_"s |
| units | Add the 'units' (XML) or 'data-units (HTML) attribute |
| warn | Emit warnings when libxo detects bad calls |
| warn-xml | Emit warnings in XML |
@@ -1489,6 +1491,29 @@ styles, flags, or features:
The brief options are detailed in ^LIBXO_OPTIONS^.
+Most of these option are simple and direct, but some require
+additional details:
+
+- "flush-line" performs line buffering, even when the output is not
+directed to a TTY device.
+- "info" generates additional data for HTML, encoded in attributes
+using names that state with "data-".
+- "keys" adds a "key" attribute for XML output to indicate that a leaf
+is an identifier for the list member.
+- "no-humanize"avoids "humanizing" numeric output (see
+humanize_number(3) for details).
+- "no-locale" instructs libxo to avoid translating output to the
+current locale.
+- "no-retain" disables the ability of libxo to internally retain
+"compiled" information about formatting strings.
+- "underscores" can be used with JSON output to change XML-friendly
+names with dashes into JSON-friendly name with underscores.
+- "warn" allows libxo to emit warnings on stderr when application code
+make incorrect calls.
+- "warn-xml" causes those warnings to be placed in XML inside the
+output.
+
+
* The libxo API
This section gives details about the functions in libxo, how to call
@@ -1577,6 +1602,16 @@ To use the default handle, pass a NULL handle:
xo_set_style(NULL, XO_STYLE_XML);
+*** xo_get_style
+
+To find the current style, use the xo_get_style() function:
+
+ xo_style_t xo_get_style(xo_handle_t *xop);
+
+To use the default handle, pass a NULL handle:
+
+ style = xo_get_style(NULL);
+
**** Output Styles (XO_STYLE_*) @styles@
The libxo functions accept a set of output styles:
@@ -2883,9 +2918,9 @@ which include the following:
Compiler warnings are a very good thing, but recent compiler version
have added some very pedantic checks. While every attempt is made to
keep libxo code warning-free, warnings are now optional. If you are
-doing development work on libxo, it is required that you use
---enable-warnings to keep the code warning free, but most users need
-not use this option.
+doing development work on libxo, it is required that you
+use --enable-warnings to keep the code warning free, but most users
+need not use this option.
libxo provides the --enable-text-only option to reduce the footprint
of the library for smaller installations. XML, JSON, and HTML
diff --git a/contrib/libxo/libxo/Makefile.am b/contrib/libxo/libxo/Makefile.am
index b11c311e70b2..a484a9b71dd9 100644
--- a/contrib/libxo/libxo/Makefile.am
+++ b/contrib/libxo/libxo/Makefile.am
@@ -72,7 +72,10 @@ man3_files = \
man5_files = \
xo_format.5
-man_MANS = ${man3_files} ${man5_files}
+man7_files = \
+ xo_options.7
+
+man_MANS = ${man3_files} ${man5_files} ${man7_files}
EXTRA_DIST = \
${man_MANS}
@@ -87,3 +90,5 @@ install-data-hook:
cat ../libxo/add.man >> ${DESTDIR}${man3dir}/$$file ; done
for file in ${man5_files}; do \
cat ../libxo/add.man >> ${DESTDIR}${man5dir}/$$file ; done
+ for file in ${man7_files}; do \
+ cat ../libxo/add.man >> ${DESTDIR}${man7dir}/$$file ; done
diff --git a/contrib/libxo/libxo/libxo.c b/contrib/libxo/libxo/libxo.c
index 7a714b1573d1..973675a7b115 100644
--- a/contrib/libxo/libxo/libxo.c
+++ b/contrib/libxo/libxo/libxo.c
@@ -274,11 +274,11 @@ struct xo_handle_s {
va_list xo_vap; /* Variable arguments (stdargs) */
char *xo_leading_xpath; /* A leading XPath expression */
mbstate_t xo_mbstate; /* Multi-byte character conversion state */
- unsigned xo_anchor_offset; /* Start of anchored text */
- unsigned xo_anchor_columns; /* Number of columns since the start anchor */
- int xo_anchor_min_width; /* Desired width of anchored text */
- unsigned xo_units_offset; /* Start of units insertion point */
- unsigned xo_columns; /* Columns emitted during this xo_emit call */
+ ssize_t xo_anchor_offset; /* Start of anchored text */
+ ssize_t xo_anchor_columns; /* Number of columns since the start anchor */
+ ssize_t xo_anchor_min_width; /* Desired width of anchored text */
+ ssize_t xo_units_offset; /* Start of units insertion point */
+ ssize_t xo_columns; /* Columns emitted during this xo_emit call */
uint8_t xo_color_map_fg[XO_NUM_COLORS]; /* Foreground color mappings */
uint8_t xo_color_map_bg[XO_NUM_COLORS]; /* Background color mappings */
xo_colors_t xo_colors; /* Current color and effect values */
@@ -426,10 +426,10 @@ typedef struct xo_field_info_s {
const char *xfi_format; /* Field's Format */
const char *xfi_encoding; /* Field's encoding format */
const char *xfi_next; /* Next character in format string */
- unsigned xfi_len; /* Length of field */
- unsigned xfi_clen; /* Content length */
- unsigned xfi_flen; /* Format length */
- unsigned xfi_elen; /* Encoding length */
+ ssize_t xfi_len; /* Length of field */
+ ssize_t xfi_clen; /* Content length */
+ ssize_t xfi_flen; /* Format length */
+ ssize_t xfi_elen; /* Encoding length */
unsigned xfi_fnum; /* Field number (if used; 0 otherwise) */
unsigned xfi_renum; /* Reordered number (0 == no renumbering) */
} xo_field_info_t;
@@ -457,15 +457,15 @@ xo_free_func_t xo_free = free;
static void
xo_failure (xo_handle_t *xop, const char *fmt, ...);
-static int
+static ssize_t
xo_transition (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name,
xo_state_t new_state);
static void
xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
- const char *name, int nlen,
- const char *value, int vlen,
- const char *encoding, int elen);
+ const char *name, ssize_t nlen,
+ const char *value, ssize_t vlen,
+ const char *encoding, ssize_t elen);
static void
xo_anchor_clear (xo_handle_t *xop);
@@ -491,7 +491,7 @@ xo_style (xo_handle_t *xop UNUSED)
/*
* Callback to write data to a FILE pointer
*/
-static int
+static xo_ssize_t
xo_write_to_file (void *opaque, const char *data)
{
FILE *fp = (FILE *) opaque;
@@ -750,14 +750,14 @@ static char xo_xml_lt[] = "&lt;";
static char xo_xml_gt[] = "&gt;";
static char xo_xml_quot[] = "&quot;";
-static int
-xo_escape_xml (xo_buffer_t *xbp, int len, xo_xff_flags_t flags)
+static ssize_t
+xo_escape_xml (xo_buffer_t *xbp, ssize_t len, xo_xff_flags_t flags)
{
- int slen;
- unsigned delta = 0;
+ ssize_t slen;
+ ssize_t delta = 0;
char *cp, *ep, *ip;
const char *sp;
- int attr = (flags & XFF_ATTR);
+ int attr = XOF_BIT_ISSET(flags, XFF_ATTR);
for (cp = xbp->xb_curp, ep = cp + len; cp < ep; cp++) {
/* We're subtracting 2: 1 for the NUL, 1 for the char we replace */
@@ -806,10 +806,10 @@ xo_escape_xml (xo_buffer_t *xbp, int len, xo_xff_flags_t flags)
return len + delta;
}
-static int
-xo_escape_json (xo_buffer_t *xbp, int len, xo_xff_flags_t flags UNUSED)
+static ssize_t
+xo_escape_json (xo_buffer_t *xbp, ssize_t len, xo_xff_flags_t flags UNUSED)
{
- unsigned delta = 0;
+ ssize_t delta = 0;
char *cp, *ep, *ip;
for (cp = xbp->xb_curp, ep = cp + len; cp < ep; cp++) {
@@ -854,10 +854,10 @@ xo_escape_json (xo_buffer_t *xbp, int len, xo_xff_flags_t flags UNUSED)
* PARAM-VALUE = UTF-8-STRING ; characters '"', '\' and
* ; ']' MUST be escaped.
*/
-static int
-xo_escape_sdparams (xo_buffer_t *xbp, int len, xo_xff_flags_t flags UNUSED)
+static ssize_t
+xo_escape_sdparams (xo_buffer_t *xbp, ssize_t len, xo_xff_flags_t flags UNUSED)
{
- unsigned delta = 0;
+ ssize_t delta = 0;
char *cp, *ep, *ip;
for (cp = xbp->xb_curp, ep = cp + len; cp < ep; cp++) {
@@ -892,7 +892,7 @@ xo_escape_sdparams (xo_buffer_t *xbp, int len, xo_xff_flags_t flags UNUSED)
static void
xo_buf_escape (xo_handle_t *xop, xo_buffer_t *xbp,
- const char *str, int len, xo_xff_flags_t flags)
+ const char *str, ssize_t len, xo_xff_flags_t flags)
{
if (!xo_buf_has_room(xbp, len))
return;
@@ -921,10 +921,10 @@ xo_buf_escape (xo_handle_t *xop, xo_buffer_t *xbp,
* Write the current contents of the data buffer using the handle's
* xo_write function.
*/
-static int
+static ssize_t
xo_write (xo_handle_t *xop)
{
- int rc = 0;
+ ssize_t rc = 0;
xo_buffer_t *xbp = &xop->xo_data;
if (xbp->xb_curp != xbp->xb_bufp) {
@@ -945,12 +945,12 @@ xo_write (xo_handle_t *xop)
* Format arguments into our buffer. If a custom formatter has been set,
* we use that to do the work; otherwise we vsnprintf().
*/
-static int
+static ssize_t
xo_vsnprintf (xo_handle_t *xop, xo_buffer_t *xbp, const char *fmt, va_list vap)
{
va_list va_local;
- int rc;
- int left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
+ ssize_t rc;
+ ssize_t left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
va_copy(va_local, vap);
@@ -990,12 +990,12 @@ xo_vsnprintf (xo_handle_t *xop, xo_buffer_t *xbp, const char *fmt, va_list vap)
/*
* Print some data through the handle.
*/
-static int
+static ssize_t
xo_printf_v (xo_handle_t *xop, const char *fmt, va_list vap)
{
xo_buffer_t *xbp = &xop->xo_data;
- int left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
- int rc;
+ ssize_t left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
+ ssize_t rc;
va_list va_local;
va_copy(va_local, vap);
@@ -1023,10 +1023,10 @@ xo_printf_v (xo_handle_t *xop, const char *fmt, va_list vap)
return rc;
}
-static int
+static ssize_t
xo_printf (xo_handle_t *xop, const char *fmt, ...)
{
- int rc;
+ ssize_t rc;
va_list vap;
va_start(vap, fmt);
@@ -1041,7 +1041,7 @@ xo_printf (xo_handle_t *xop, const char *fmt, ...)
* These next few function are make The Essential UTF-8 Ginsu Knife.
* Identify an input and output character, and convert it.
*/
-static int xo_utf8_bits[7] = { 0, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };
+static uint8_t xo_utf8_bits[7] = { 0, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };
static int
xo_is_utf8 (char ch)
@@ -1049,11 +1049,11 @@ xo_is_utf8 (char ch)
return (ch & 0x80);
}
-static inline int
+static inline ssize_t
xo_utf8_to_wc_len (const char *buf)
{
unsigned b = (unsigned char) *buf;
- int len;
+ ssize_t len;
if ((b & 0x80) == 0x0)
len = 1;
@@ -1073,12 +1073,12 @@ xo_utf8_to_wc_len (const char *buf)
return len;
}
-static int
-xo_buf_utf8_len (xo_handle_t *xop, const char *buf, int bufsiz)
+static ssize_t
+xo_buf_utf8_len (xo_handle_t *xop, const char *buf, ssize_t bufsiz)
{
unsigned b = (unsigned char) *buf;
- int len, i;
+ ssize_t len, i;
len = xo_utf8_to_wc_len(buf);
if (len == -1) {
@@ -1109,13 +1109,13 @@ xo_buf_utf8_len (xo_handle_t *xop, const char *buf, int bufsiz)
* but we put 6 bits off all other bytes.
*/
static inline wchar_t
-xo_utf8_char (const char *buf, int len)
+xo_utf8_char (const char *buf, ssize_t len)
{
/* Most common case: singleton byte */
if (len == 1)
return (unsigned char) buf[0];
- int i;
+ ssize_t i;
wchar_t wc;
const unsigned char *cp = (const unsigned char *) buf;
@@ -1133,10 +1133,10 @@ xo_utf8_char (const char *buf, int len)
/*
* Determine the number of bytes needed to encode a wide character.
*/
-static int
+static ssize_t
xo_utf8_emit_len (wchar_t wc)
{
- int len;
+ ssize_t len;
if ((wc & ((1<<7) - 1)) == wc) /* Simple case */
len = 1;
@@ -1155,9 +1155,9 @@ xo_utf8_emit_len (wchar_t wc)
}
static void
-xo_utf8_emit_char (char *buf, int len, wchar_t wc)
+xo_utf8_emit_char (char *buf, ssize_t len, wchar_t wc)
{
- int i;
+ ssize_t i;
if (len == 1) { /* Simple case */
buf[0] = wc & 0x7f;
@@ -1173,12 +1173,12 @@ xo_utf8_emit_char (char *buf, int len, wchar_t wc)
buf[0] |= ~xo_utf8_bits[len] << 1;
}
-static int
+static ssize_t
xo_buf_append_locale_from_utf8 (xo_handle_t *xop, xo_buffer_t *xbp,
- const char *ibuf, int ilen)
+ const char *ibuf, ssize_t ilen)
{
wchar_t wc;
- int len;
+ ssize_t len;
/*
* Build our wide character from the input buffer; the number of
@@ -1218,11 +1218,11 @@ xo_buf_append_locale_from_utf8 (xo_handle_t *xop, xo_buffer_t *xbp,
static void
xo_buf_append_locale (xo_handle_t *xop, xo_buffer_t *xbp,
- const char *cp, int len)
+ const char *cp, ssize_t len)
{
const char *sp = cp, *ep = cp + len;
- unsigned save_off = xbp->xb_bufp - xbp->xb_curp;
- int slen;
+ ssize_t save_off = xbp->xb_bufp - xbp->xb_curp;
+ ssize_t slen;
int cols = 0;
for ( ; cp < ep; cp++) {
@@ -1274,7 +1274,7 @@ xo_buf_append_locale (xo_handle_t *xop, xo_buffer_t *xbp,
* buffer with no fanciness.
*/
static void
-xo_data_append (xo_handle_t *xop, const char *str, int len)
+xo_data_append (xo_handle_t *xop, const char *str, ssize_t len)
{
xo_buf_append(&xop->xo_data, str, len);
}
@@ -1283,7 +1283,7 @@ xo_data_append (xo_handle_t *xop, const char *str, int len)
* Append the given string to the given buffer
*/
static void
-xo_data_escape (xo_handle_t *xop, const char *str, int len)
+xo_data_escape (xo_handle_t *xop, const char *str, ssize_t len)
{
xo_buf_escape(xop, &xop->xo_data, str, len, 0);
}
@@ -1453,7 +1453,7 @@ xo_retain_add (const char *fmt, xo_field_info_t *fields, unsigned num_fields)
{
unsigned hash = xo_retain_hash(fmt);
xo_retain_entry_t *xrep;
- unsigned sz = sizeof(*xrep) + (num_fields + 1) * sizeof(*fields);
+ ssize_t sz = sizeof(*xrep) + (num_fields + 1) * sizeof(*fields);
xo_field_info_t *xfip;
xrep = xo_realloc(NULL, sz);
@@ -1493,8 +1493,8 @@ xo_warn_hcv (xo_handle_t *xop, int code, int check_warn,
if (fmt == NULL)
return;
- int len = strlen(fmt);
- int plen = xo_program ? strlen(xo_program) : 0;
+ ssize_t len = strlen(fmt);
+ ssize_t plen = xo_program ? strlen(xo_program) : 0;
char *newfmt = alloca(len + 1 + plen + 2); /* NUL, and ": " */
if (plen) {
@@ -1519,8 +1519,8 @@ xo_warn_hcv (xo_handle_t *xop, int code, int check_warn,
va_list va_local;
va_copy(va_local, vap);
- int left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
- int rc = vsnprintf(xbp->xb_curp, left, newfmt, vap);
+ ssize_t left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
+ ssize_t rc = vsnprintf(xbp->xb_curp, left, newfmt, vap);
if (rc >= left) {
if (!xo_buf_has_room(xbp, rc)) {
va_end(va_local);
@@ -1652,7 +1652,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap)
static char msg_open[] = "<message>";
static char msg_close[] = "</message>";
xo_buffer_t *xbp;
- int rc;
+ ssize_t rc;
va_list va_local;
xop = xo_default(xop);
@@ -1671,7 +1671,7 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap)
va_copy(va_local, vap);
- int left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
+ ssize_t left = xbp->xb_size - (xbp->xb_curp - xbp->xb_bufp);
rc = vsnprintf(xbp->xb_curp, left, fmt, vap);
if (rc >= left) {
if (!xo_buf_has_room(xbp, rc)) {
@@ -1712,8 +1712,8 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap)
case XO_STYLE_HTML:
{
char buf[BUFSIZ], *bp = buf, *cp;
- int bufsiz = sizeof(buf);
- int rc2;
+ ssize_t bufsiz = sizeof(buf);
+ ssize_t rc2;
va_copy(va_local, vap);
@@ -2013,7 +2013,7 @@ typedef struct xo_mapping_s {
} xo_mapping_t;
static xo_xff_flags_t
-xo_name_lookup (xo_mapping_t *map, const char *value, int len)
+xo_name_lookup (xo_mapping_t *map, const char *value, ssize_t len)
{
if (len == 0)
return 0;
@@ -2059,6 +2059,7 @@ static xo_mapping_t xo_xof_names[] = {
{ XOF_COLUMNS, "columns" },
{ XOF_DTRT, "dtrt" },
{ XOF_FLUSH, "flush" },
+ { XOF_FLUSH_LINE, "flush-line" },
{ XOF_IGNORE_CLOSE, "ignore-close" },
{ XOF_INFO, "info" },
{ XOF_KEYS, "keys" },
@@ -2112,7 +2113,8 @@ int
xo_set_options (xo_handle_t *xop, const char *input)
{
char *cp, *ep, *vp, *np, *bp;
- int style = -1, new_style, len, rc = 0;
+ int style = -1, new_style, rc = 0;
+ ssize_t len;
xo_xof_flags_t new_flag;
if (input == NULL)
@@ -2131,7 +2133,7 @@ xo_set_options (xo_handle_t *xop, const char *input)
* ideal for lazy people, such as myself.
*/
if (*input == ':') {
- int sz;
+ ssize_t sz;
for (input++ ; *input; input++) {
switch (*input) {
@@ -2302,7 +2304,7 @@ xo_get_flags (xo_handle_t *xop)
* strndup with a twist: len < 0 means strlen
*/
static char *
-xo_strndup (const char *str, int len)
+xo_strndup (const char *str, ssize_t len)
{
if (len < 0)
len = strlen(str);
@@ -2476,7 +2478,7 @@ xo_info_compare (const void *key, const void *data)
static xo_info_t *
-xo_info_find (xo_handle_t *xop, const char *name, int nlen)
+xo_info_find (xo_handle_t *xop, const char *name, ssize_t nlen)
{
xo_info_t *xip;
char *cp = alloca(nlen + 1); /* Need local copy for NUL termination */
@@ -2515,13 +2517,15 @@ xo_check_conversion (xo_handle_t *xop, int have_enc, int need_enc)
static int
xo_format_string_direct (xo_handle_t *xop, xo_buffer_t *xbp,
xo_xff_flags_t flags,
- const wchar_t *wcp, const char *cp, int len, int max,
+ const wchar_t *wcp, const char *cp,
+ ssize_t len, int max,
int need_enc, int have_enc)
{
int cols = 0;
wchar_t wc = 0;
- int ilen, olen, width;
- int attr = (flags & XFF_ATTR);
+ ssize_t ilen, olen;
+ ssize_t width;
+ int attr = XOF_BIT_ISSET(flags, XFF_ATTR);
const char *sp;
if (len > 0 && !xo_buf_has_room(xbp, len))
@@ -2629,7 +2633,7 @@ xo_format_string_direct (xo_handle_t *xop, xo_buffer_t *xbp,
else
break;
- int slen = strlen(sp);
+ ssize_t slen = strlen(sp);
if (!xo_buf_has_room(xbp, slen - 1))
return -1;
@@ -2714,7 +2718,7 @@ xo_needed_encoding (xo_handle_t *xop)
return XF_ENC_UTF8; /* Otherwise, we love UTF-8 */
}
-static int
+static ssize_t
xo_format_string (xo_handle_t *xop, xo_buffer_t *xbp, xo_xff_flags_t flags,
xo_format_t *xfp)
{
@@ -2723,8 +2727,9 @@ xo_format_string (xo_handle_t *xop, xo_buffer_t *xbp, xo_xff_flags_t flags,
char *cp = NULL;
wchar_t *wcp = NULL;
- int len, cols = 0, rc = 0;
- int off = xbp->xb_curp - xbp->xb_bufp, off2;
+ ssize_t len;
+ ssize_t cols = 0, rc = 0;
+ ssize_t off = xbp->xb_curp - xbp->xb_bufp, off2;
int need_enc = xo_needed_encoding(xop);
if (xo_check_conversion(xop, xfp->xf_enc, need_enc))
@@ -2852,7 +2857,7 @@ xo_format_string (xo_handle_t *xop, xo_buffer_t *xbp, xo_xff_flags_t flags,
* Look backwards in a buffer to find a numeric value
*/
static int
-xo_buf_find_last_number (xo_buffer_t *xbp, int start_offset)
+xo_buf_find_last_number (xo_buffer_t *xbp, ssize_t start_offset)
{
int rc = 0; /* Fail with zero */
int digit = 1;
@@ -2873,12 +2878,12 @@ xo_buf_find_last_number (xo_buffer_t *xbp, int start_offset)
return rc;
}
-static int
-xo_count_utf8_cols (const char *str, int len)
+static ssize_t
+xo_count_utf8_cols (const char *str, ssize_t len)
{
- int tlen;
+ ssize_t tlen;
wchar_t wc;
- int cols = 0;
+ ssize_t cols = 0;
const char *ep = str + len;
while (str < ep) {
@@ -2896,7 +2901,7 @@ xo_count_utf8_cols (const char *str, int len)
* Find the width-in-columns of this character, which must be done
* in wide characters, since we lack a mbswidth() function.
*/
- int width = xo_wcwidth(wc);
+ ssize_t width = xo_wcwidth(wc);
if (width < 0)
width = iswcntrl(wc) ? 0 : 1;
@@ -2967,9 +2972,9 @@ xo_dngettext (xo_handle_t *xop UNUSED, const char *singular,
* call to d[n]gettext() to get the locale-based version. Note that
* both input and output of gettext() this should be UTF-8.
*/
-static int
+static ssize_t
xo_format_gettext (xo_handle_t *xop, xo_xff_flags_t flags,
- int start_offset, int cols, int need_enc)
+ ssize_t start_offset, ssize_t cols, int need_enc)
{
xo_buffer_t *xbp = &xop->xo_data;
@@ -2979,7 +2984,7 @@ xo_format_gettext (xo_handle_t *xop, xo_xff_flags_t flags,
xbp->xb_curp[0] = '\0'; /* NUL-terminate the input string */
char *cp = xbp->xb_bufp + start_offset;
- int len = xbp->xb_curp - cp;
+ ssize_t len = xbp->xb_curp - cp;
const char *newstr = NULL;
/*
@@ -3043,7 +3048,7 @@ xo_format_gettext (xo_handle_t *xop, xo_xff_flags_t flags,
* Since the new string string might be in gettext's buffer or
* in the buffer (as the plural form), we make a copy.
*/
- int nlen = strlen(newstr);
+ ssize_t nlen = strlen(newstr);
char *newcopy = alloca(nlen + 1);
memcpy(newcopy, newstr, nlen + 1);
@@ -3053,12 +3058,12 @@ xo_format_gettext (xo_handle_t *xop, xo_xff_flags_t flags,
}
static void
-xo_data_append_content (xo_handle_t *xop, const char *str, int len,
+xo_data_append_content (xo_handle_t *xop, const char *str, ssize_t len,
xo_xff_flags_t flags)
{
int cols;
int need_enc = xo_needed_encoding(xop);
- int start_offset = xo_buf_offset(&xop->xo_data);
+ ssize_t start_offset = xo_buf_offset(&xop->xo_data);
cols = xo_format_string_direct(xop, &xop->xo_data, XFF_UNESCAPE | flags,
NULL, str, len, -1,
@@ -3080,11 +3085,11 @@ xo_bump_width (xo_format_t *xfp, int digit)
*ip = ((*ip > 0) ? *ip : 0) * 10 + digit;
}
-static int
-xo_trim_ws (xo_buffer_t *xbp, int len)
+static ssize_t
+xo_trim_ws (xo_buffer_t *xbp, ssize_t len)
{
char *cp, *sp, *ep;
- int delta;
+ ssize_t delta;
/* First trim leading space */
for (cp = sp = xbp->xb_curp, ep = cp + len; cp < ep; cp++) {
@@ -3118,18 +3123,18 @@ xo_trim_ws (xo_buffer_t *xbp, int len)
* and the format is in 'fmt'. If 'xbp' is null, we use xop->xo_data;
* this is the most common case.
*/
-static int
+static ssize_t
xo_do_format_field (xo_handle_t *xop, xo_buffer_t *xbp,
- const char *fmt, int flen, xo_xff_flags_t flags)
+ const char *fmt, ssize_t flen, xo_xff_flags_t flags)
{
xo_format_t xf;
const char *cp, *ep, *sp, *xp = NULL;
- int rc, cols;
+ ssize_t rc, cols;
int style = (flags & XFF_XML) ? XO_STYLE_XML : xo_style(xop);
- unsigned make_output = !(flags & XFF_NO_OUTPUT);
+ unsigned make_output = !(flags & XFF_NO_OUTPUT) ? 1 : 0;
int need_enc = xo_needed_encoding(xop);
int real_need_enc = need_enc;
- int old_cols = xop->xo_columns;
+ ssize_t old_cols = xop->xo_columns;
/* The gettext interface is UTF-8, so we'll need that for now */
if (flags & XFF_GT_FIELD)
@@ -3138,7 +3143,7 @@ xo_do_format_field (xo_handle_t *xop, xo_buffer_t *xbp,
if (xbp == NULL)
xbp = &xop->xo_data;
- unsigned start_offset = xo_buf_offset(xbp);
+ ssize_t start_offset = xo_buf_offset(xbp);
for (cp = fmt, ep = fmt + flen; cp < ep; cp++) {
/*
@@ -3290,7 +3295,7 @@ xo_do_format_field (xo_handle_t *xop, xo_buffer_t *xbp,
if (!xf.xf_skip) {
xo_buffer_t *fbp = &xop->xo_fmt;
- int len = cp - sp + 1;
+ ssize_t len = cp - sp + 1;
if (!xo_buf_has_room(fbp, len + 1))
return -1;
@@ -3318,7 +3323,7 @@ xo_do_format_field (xo_handle_t *xop, xo_buffer_t *xbp,
rc = xo_trim_ws(xbp, rc);
} else {
- int columns = rc = xo_vsnprintf(xop, xbp, newfmt, xop->xo_vap);
+ ssize_t columns = rc = xo_vsnprintf(xop, xbp, newfmt, xop->xo_vap);
/*
* For XML and HTML, we need "&<>" processing; for JSON,
@@ -3459,7 +3464,7 @@ xo_do_format_field (xo_handle_t *xop, xo_buffer_t *xbp,
* and then copying it in, while converting to locale, if
* needed.
*/
- int new_cols = xo_format_gettext(xop, flags, start_offset,
+ ssize_t new_cols = xo_format_gettext(xop, flags, start_offset,
old_cols, real_need_enc);
if (XOF_ISSET(xop, XOF_COLUMNS))
@@ -3512,8 +3517,8 @@ xo_color_append_html (xo_handle_t *xop)
* test. But the boat only goes where we want when we hold
* the rudder, so xo_humanize fixes part of the problem.
*/
-static int
-xo_humanize (char *buf, int len, uint64_t value, int flags)
+static ssize_t
+xo_humanize (char *buf, ssize_t len, uint64_t value, int flags)
{
int scale = 0;
@@ -3539,9 +3544,9 @@ xo_humanize (char *buf, int len, uint64_t value, int flags)
* what needs cleaned up.
*/
typedef struct xo_humanize_save_s {
- unsigned xhs_offset; /* Saved xo_offset */
- unsigned xhs_columns; /* Saved xo_columns */
- unsigned xhs_anchor_columns; /* Saved xo_anchor_columns */
+ ssize_t xhs_offset; /* Saved xo_offset */
+ ssize_t xhs_columns; /* Saved xo_columns */
+ ssize_t xhs_anchor_columns; /* Saved xo_anchor_columns */
} xo_humanize_save_t;
/*
@@ -3556,7 +3561,7 @@ xo_format_humanize (xo_handle_t *xop, xo_buffer_t *xbp,
if (XOF_ISSET(xop, XOF_NO_HUMANIZE))
return;
- unsigned end_offset = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t end_offset = xbp->xb_curp - xbp->xb_bufp;
if (end_offset == savep->xhs_offset) /* Huh? Nothing to render */
return;
@@ -3581,8 +3586,8 @@ xo_format_humanize (xo_handle_t *xop, xo_buffer_t *xbp,
if (xo_buf_has_room(xbp, 10)) {
xbp->xb_curp = xbp->xb_bufp + savep->xhs_offset;
- int rc;
- int left = (xbp->xb_bufp + xbp->xb_size) - xbp->xb_curp;
+ ssize_t rc;
+ ssize_t left = (xbp->xb_bufp + xbp->xb_size) - xbp->xb_curp;
int hn_flags = HN_NOSPACE; /* On by default */
if (flags & XFF_HN_SPACE)
@@ -3594,8 +3599,7 @@ xo_format_humanize (xo_handle_t *xop, xo_buffer_t *xbp,
if (flags & XFF_HN_1000)
hn_flags |= HN_DIVISOR_1000;
- rc = xo_humanize(xbp->xb_curp,
- left, value, hn_flags);
+ rc = xo_humanize(xbp->xb_curp, left, value, hn_flags);
if (rc > 0) {
xbp->xb_curp += rc;
xop->xo_columns = savep->xhs_columns + rc;
@@ -3607,9 +3611,9 @@ xo_format_humanize (xo_handle_t *xop, xo_buffer_t *xbp,
static void
xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
- const char *name, int nlen,
- const char *value, int vlen,
- const char *encoding, int elen)
+ const char *name, ssize_t nlen,
+ const char *value, ssize_t vlen,
+ const char *encoding, ssize_t elen)
{
static char div_start[] = "<div class=\"";
static char div_tag[] = "\" data-tag=\"";
@@ -3636,7 +3640,7 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
*/
int need_predidate =
(name && (flags & XFF_KEY) && !(flags & XFF_DISPLAY_ONLY)
- && XOF_ISSET(xop, XOF_XPATH));
+ && XOF_ISSET(xop, XOF_XPATH)) ? 1 : 0;
if (need_predidate) {
va_list va_local;
@@ -3667,8 +3671,8 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
/* Now we record this predicate expression in the stack */
xo_stack_t *xsp = &xop->xo_stack[xop->xo_depth];
- int olen = xsp->xs_keys ? strlen(xsp->xs_keys) : 0;
- int dlen = pbp->xb_curp - pbp->xb_bufp;
+ ssize_t olen = xsp->xs_keys ? strlen(xsp->xs_keys) : 0;
+ ssize_t dlen = pbp->xb_curp - pbp->xb_bufp;
char *cp = xo_realloc(xsp->xs_keys, olen + dlen + 1);
if (cp) {
@@ -3790,7 +3794,7 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
}
xo_buffer_t *xbp = &xop->xo_data;
- unsigned base_offset = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t base_offset = xbp->xb_curp - xbp->xb_bufp;
xo_data_append(xop, div_end, sizeof(div_end) - 1);
@@ -3808,10 +3812,10 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
* stuff it into the "data-number" attribute.
*/
static const char div_number[] = "\" data-number=\"";
- int div_len = sizeof(div_number) - 1;
+ ssize_t div_len = sizeof(div_number) - 1;
- unsigned end_offset = xbp->xb_curp - xbp->xb_bufp;
- int olen = end_offset - save.xhs_offset;
+ ssize_t end_offset = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t olen = end_offset - save.xhs_offset;
char *cp = alloca(olen + 1);
memcpy(cp, xbp->xb_bufp + save.xhs_offset, olen);
@@ -3820,7 +3824,7 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
xo_format_humanize(xop, xbp, &save, flags);
if (xo_buf_has_room(xbp, div_len + olen)) {
- unsigned new_offset = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t new_offset = xbp->xb_curp - xbp->xb_bufp;
/* Move the humanized string off to the left */
@@ -3843,7 +3847,7 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
}
static void
-xo_format_text (xo_handle_t *xop, const char *str, int len)
+xo_format_text (xo_handle_t *xop, const char *str, ssize_t len)
{
switch (xo_style(xop)) {
case XO_STYLE_TEXT:
@@ -3858,10 +3862,10 @@ xo_format_text (xo_handle_t *xop, const char *str, int len)
static void
xo_format_title (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, unsigned len)
+ const char *str, ssize_t len)
{
const char *fmt = xfip->xfi_format;
- unsigned flen = xfip->xfi_flen;
+ ssize_t flen = xfip->xfi_flen;
xo_xff_flags_t flags = xfip->xfi_flags;
static char div_open[] = "<div class=\"title";
@@ -3888,9 +3892,9 @@ xo_format_title (xo_handle_t *xop, xo_field_info_t *xfip,
}
xo_buffer_t *xbp = &xop->xo_data;
- int start = xbp->xb_curp - xbp->xb_bufp;
- int left = xbp->xb_size - start;
- int rc;
+ ssize_t start = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t left = xbp->xb_size - start;
+ ssize_t rc;
if (xo_style(xop) == XO_STYLE_HTML) {
xo_line_ensure_open(xop, 0);
@@ -3993,9 +3997,9 @@ xo_arg (xo_handle_t *xop)
#endif /* 0 */
static void
-xo_format_value (xo_handle_t *xop, const char *name, int nlen,
- const char *format, int flen,
- const char *encoding, int elen, xo_xff_flags_t flags)
+xo_format_value (xo_handle_t *xop, const char *name, ssize_t nlen,
+ const char *format, ssize_t flen,
+ const char *encoding, ssize_t elen, xo_xff_flags_t flags)
{
int pretty = XOF_ISSET(xop, XOF_PRETTY);
int quote;
@@ -4016,7 +4020,7 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
memcpy(nbuf, name, nlen);
nbuf[nlen] = '\0';
- int rc = xo_transition(xop, 0, nbuf, XSS_EMIT_LEAF_LIST);
+ ssize_t rc = xo_transition(xop, 0, nbuf, XSS_EMIT_LEAF_LIST);
if (rc < 0)
flags |= XFF_DISPLAY_ONLY | XFF_ENCODE_ONLY;
else
@@ -4040,7 +4044,7 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
memcpy(nbuf, name, nlen);
nbuf[nlen] = '\0';
- int rc = xo_transition(xop, 0, nbuf, XSS_EMIT);
+ ssize_t rc = xo_transition(xop, 0, nbuf, XSS_EMIT);
if (rc < 0)
flags |= XFF_DISPLAY_ONLY | XFF_ENCODE_ONLY;
else
@@ -4058,7 +4062,7 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
memcpy(nbuf, name, nlen);
nbuf[nlen] = '\0';
- int rc = xo_transition(xop, 0, nbuf, XSS_EMIT);
+ ssize_t rc = xo_transition(xop, 0, nbuf, XSS_EMIT);
if (rc < 0)
flags |= XFF_DISPLAY_ONLY | XFF_ENCODE_ONLY;
else
@@ -4181,7 +4185,8 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
flen = strlen(format);
}
- int first = !(xop->xo_stack[xop->xo_depth].xs_flags & XSF_NOT_FIRST);
+ int first = (xop->xo_stack[xop->xo_depth].xs_flags & XSF_NOT_FIRST)
+ ? 0 : 1;
xo_format_prep(xop, flags);
@@ -4193,7 +4198,7 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
quote = 0;
format = "true"; /* JSON encodes empty tags as a boolean true */
flen = 4;
- } else if (strchr("diouxXDOUeEfFgGaAcCp", format[flen - 1]) == NULL)
+ } else if (strchr("diouDOUeEfFgG", format[flen - 1]) == NULL)
quote = 1;
else
quote = 0;
@@ -4216,13 +4221,13 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
xo_data_append(xop, "\"", 1);
xbp = &xop->xo_data;
- int off = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t off = xbp->xb_curp - xbp->xb_bufp;
xo_data_escape(xop, name, nlen);
if (XOF_ISSET(xop, XOF_UNDERSCORES)) {
- int now = xbp->xb_curp - xbp->xb_bufp;
- for ( ; off < now; off++)
+ ssize_t coff = xbp->xb_curp - xbp->xb_bufp;
+ for ( ; off < coff; off++)
if (xbp->xb_bufp[off] == '-')
xbp->xb_bufp[off] = '_';
}
@@ -4309,11 +4314,11 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
nlen = sizeof(missing) - 1;
}
- unsigned name_offset = xo_buf_offset(&xop->xo_data);
+ ssize_t name_offset = xo_buf_offset(&xop->xo_data);
xo_data_append(xop, name, nlen);
xo_data_append(xop, "", 1);
- unsigned value_offset = xo_buf_offset(&xop->xo_data);
+ ssize_t value_offset = xo_buf_offset(&xop->xo_data);
xo_do_format_field(xop, NULL, format, flen, flags);
xo_data_append(xop, "", 1);
@@ -4327,10 +4332,10 @@ xo_format_value (xo_handle_t *xop, const char *name, int nlen,
static void
xo_set_gettext_domain (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, unsigned len)
+ const char *str, ssize_t len)
{
const char *fmt = xfip->xfi_format;
- unsigned flen = xfip->xfi_flen;
+ ssize_t flen = xfip->xfi_flen;
/* Start by discarding previous domain */
if (xop->xo_gt_domain) {
@@ -4342,13 +4347,13 @@ xo_set_gettext_domain (xo_handle_t *xop, xo_field_info_t *xfip,
if (len == 0 && flen == 0)
return;
- int start_offset = -1;
+ ssize_t start_offset = -1;
if (len == 0 && flen != 0) {
/* Need to do format the data to get the domainname from args */
start_offset = xop->xo_data.xb_curp - xop->xo_data.xb_bufp;
xo_do_format_field(xop, NULL, fmt, flen, 0);
- int end_offset = xop->xo_data.xb_curp - xop->xo_data.xb_bufp;
+ ssize_t end_offset = xop->xo_data.xb_curp - xop->xo_data.xb_bufp;
len = end_offset - start_offset;
str = xop->xo_data.xb_bufp + start_offset;
}
@@ -4363,7 +4368,7 @@ xo_set_gettext_domain (xo_handle_t *xop, xo_field_info_t *xfip,
static void
xo_format_content (xo_handle_t *xop, const char *class_name,
const char *tag_name,
- const char *str, int len, const char *fmt, int flen,
+ const char *str, ssize_t len, const char *fmt, ssize_t flen,
xo_xff_flags_t flags)
{
switch (xo_style(xop)) {
@@ -4500,7 +4505,7 @@ xo_colors_parse (xo_handle_t *xop, xo_colors_t *xocp, char *str)
#endif /* LIBXO_TEXT_ONLY */
char *cp, *ep, *np, *xp;
- int len = strlen(str);
+ ssize_t len = strlen(str);
int rc;
/*
@@ -4703,10 +4708,10 @@ xo_colors_handle_html (xo_handle_t *xop, xo_colors_t *newp)
static void
xo_format_colors (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, unsigned len)
+ const char *str, ssize_t len)
{
const char *fmt = xfip->xfi_format;
- unsigned flen = xfip->xfi_flen;
+ ssize_t flen = xfip->xfi_flen;
xo_buffer_t xb;
@@ -4776,10 +4781,10 @@ xo_format_colors (xo_handle_t *xop, xo_field_info_t *xfip,
static void
xo_format_units (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, unsigned len)
+ const char *str, ssize_t len)
{
const char *fmt = xfip->xfi_format;
- unsigned flen = xfip->xfi_flen;
+ ssize_t flen = xfip->xfi_flen;
xo_xff_flags_t flags = xfip->xfi_flags;
static char units_start_xml[] = " units=\"";
@@ -4791,8 +4796,8 @@ xo_format_units (xo_handle_t *xop, xo_field_info_t *xfip,
}
xo_buffer_t *xbp = &xop->xo_data;
- int start = xop->xo_units_offset;
- int stop = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t start = xop->xo_units_offset;
+ ssize_t stop = xbp->xb_curp - xbp->xb_bufp;
if (xo_style(xop) == XO_STYLE_XML)
xo_buf_append(xbp, units_start_xml, sizeof(units_start_xml) - 1);
@@ -4808,8 +4813,8 @@ xo_format_units (xo_handle_t *xop, xo_field_info_t *xfip,
xo_buf_append(xbp, "\"", 1);
- int now = xbp->xb_curp - xbp->xb_bufp;
- int delta = now - stop;
+ ssize_t now = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t delta = now - stop;
if (delta <= 0) { /* Strange; no output to move */
xbp->xb_curp = xbp->xb_bufp + stop; /* Reset buffer to prior state */
return;
@@ -4828,12 +4833,12 @@ xo_format_units (xo_handle_t *xop, xo_field_info_t *xfip,
memmove(xbp->xb_bufp + start, buf, delta);
}
-static int
+static ssize_t
xo_find_width (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, unsigned len)
+ const char *str, ssize_t len)
{
const char *fmt = xfip->xfi_format;
- unsigned flen = xfip->xfi_flen;
+ ssize_t flen = xfip->xfi_flen;
long width = 0;
char *bp;
@@ -4879,7 +4884,7 @@ xo_anchor_clear (xo_handle_t *xop)
*/
static void
xo_anchor_start (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, unsigned len)
+ const char *str, ssize_t len)
{
if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML)
return;
@@ -4901,7 +4906,7 @@ xo_anchor_start (xo_handle_t *xop, xo_field_info_t *xfip,
static void
xo_anchor_stop (xo_handle_t *xop, xo_field_info_t *xfip,
- const char *str, unsigned len)
+ const char *str, ssize_t len)
{
if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML)
return;
@@ -4913,7 +4918,7 @@ xo_anchor_stop (xo_handle_t *xop, xo_field_info_t *xfip,
XOIF_CLEAR(xop, XOIF_UNITS_PENDING);
- int width = xo_find_width(xop, xfip, str, len);
+ ssize_t width = xo_find_width(xop, xfip, str, len);
if (width == 0)
width = xop->xo_anchor_min_width;
@@ -4921,10 +4926,10 @@ xo_anchor_stop (xo_handle_t *xop, xo_field_info_t *xfip,
goto done;
xo_buffer_t *xbp = &xop->xo_data;
- int start = xop->xo_anchor_offset;
- int stop = xbp->xb_curp - xbp->xb_bufp;
- int abswidth = (width > 0) ? width : -width;
- int blen = abswidth - xop->xo_anchor_columns;
+ ssize_t start = xop->xo_anchor_offset;
+ ssize_t stop = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t abswidth = (width > 0) ? width : -width;
+ ssize_t blen = abswidth - xop->xo_anchor_columns;
if (blen <= 0) /* Already over width */
goto done;
@@ -4943,8 +4948,8 @@ xo_anchor_stop (xo_handle_t *xop, xo_field_info_t *xfip,
if (width < 0) /* Already left justified */
goto done;
- int now = xbp->xb_curp - xbp->xb_bufp;
- int delta = now - stop;
+ ssize_t now = xbp->xb_curp - xbp->xb_bufp;
+ ssize_t delta = now - stop;
if (delta <= 0) /* Strange; no output to move */
goto done;
@@ -5148,7 +5153,7 @@ xo_parse_roles (xo_handle_t *xop, const char *fmt,
if (*np == ':' || *np == '/' || *np == '}' || *np == ',')
break;
- int slen = np - sp;
+ ssize_t slen = np - sp;
if (slen > 0) {
xo_xff_flags_t value;
@@ -5440,7 +5445,7 @@ xo_parse_fields (xo_handle_t *xop, xo_field_info_t *fields,
xfip->xfi_start = basep = cp + 1;
const char *format = NULL;
- int flen = 0;
+ ssize_t flen = 0;
/* Looking at roles and modifiers */
sp = xo_parse_roles(xop, fmt, basep, xfip);
@@ -5623,9 +5628,9 @@ xo_dump_fields (xo_field_info_t *fields)
(unsigned long) xfip->xfi_flags,
isprint((int) xfip->xfi_ftype) ? xfip->xfi_ftype : ' ',
xfip->xfi_ftype,
- xfip->xfi_clen, xfip->xfi_content ?: "",
- xfip->xfi_flen, xfip->xfi_format ?: "",
- xfip->xfi_elen, xfip->xfi_encoding ?: "");
+ (int) xfip->xfi_clen, xfip->xfi_content ?: "",
+ (int) xfip->xfi_flen, xfip->xfi_format ?: "",
+ (int) xfip->xfi_elen, xfip->xfi_encoding ?: "");
}
}
@@ -5850,13 +5855,13 @@ xo_gettext_build_format (xo_handle_t *xop,
static void
xo_gettext_rebuild_content (xo_handle_t *xop, xo_field_info_t *fields,
- unsigned *fstart, unsigned min_fstart,
- unsigned *fend, unsigned max_fend)
+ ssize_t *fstart, unsigned min_fstart,
+ ssize_t *fend, unsigned max_fend)
{
xo_field_info_t *xfip;
char *buf;
- unsigned base = fstart[min_fstart];
- unsigned blen = fend[max_fend] - base;
+ ssize_t base = fstart[min_fstart];
+ ssize_t blen = fend[max_fend] - base;
xo_buffer_t *xbp = &xop->xo_data;
if (blen == 0)
@@ -5868,7 +5873,8 @@ xo_gettext_rebuild_content (xo_handle_t *xop, xo_field_info_t *fields,
memcpy(buf, xbp->xb_bufp + fstart[min_fstart], blen); /* Copy our data */
- unsigned field = min_fstart, soff, doff = base, len, fnum;
+ unsigned field = min_fstart, len, fnum;
+ ssize_t soff, doff = base;
xo_field_info_t *zp;
/*
@@ -5923,8 +5929,8 @@ xo_gettext_combine_formats (xo_handle_t *xop UNUSED, const char *fmt UNUSED,
static void
xo_gettext_rebuild_content (xo_handle_t *xop UNUSED,
xo_field_info_t *fields UNUSED,
- unsigned *fstart UNUSED, unsigned min_fstart UNUSED,
- unsigned *fend UNUSED, unsigned max_fend UNUSED)
+ ssize_t *fstart UNUSED, unsigned min_fstart UNUSED,
+ ssize_t *fend UNUSED, unsigned max_fend UNUSED)
{
return;
}
@@ -5933,7 +5939,7 @@ xo_gettext_rebuild_content (xo_handle_t *xop UNUSED,
/*
* Emit a set of fields. This is really the core of libxo.
*/
-static int
+static ssize_t
xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields,
unsigned max_fields, const char *fmt)
{
@@ -5945,7 +5951,7 @@ xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields,
xo_field_info_t *new_fields = NULL;
xo_field_info_t *xfip;
unsigned field;
- int rc = 0;
+ ssize_t rc = 0;
int flush = XOF_ISSET(xop, XOF_FLUSH);
int flush_line = XOF_ISSET(xop, XOF_FLUSH_LINE);
@@ -5964,9 +5970,9 @@ xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields,
unsigned flimit = max_fields * 2; /* Pessimistic limit */
unsigned min_fstart = flimit - 1;
unsigned max_fend = 0; /* Highest recorded fend[] entry */
- unsigned fstart[flimit];
+ ssize_t fstart[flimit];
bzero(fstart, flimit * sizeof(fstart[0]));
- unsigned fend[flimit];
+ ssize_t fend[flimit];
bzero(fend, flimit * sizeof(fend[0]));
for (xfip = fields, field = 0; xfip->xfi_ftype && field < max_fields;
@@ -5982,7 +5988,7 @@ xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields,
}
const char *content = xfip->xfi_content;
- int clen = xfip->xfi_clen;
+ ssize_t clen = xfip->xfi_clen;
if (flags & XFF_ARGUMENT) {
/*
@@ -6060,7 +6066,7 @@ xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields,
new_max_fields = max_fields;
/* Leave a blank slot at the beginning */
- int sz = (new_max_fields + 1) * sizeof(xo_field_info_t);
+ ssize_t sz = (new_max_fields + 1) * sizeof(xo_field_info_t);
new_fields = alloca(sz);
bzero(new_fields, sz);
@@ -6155,7 +6161,7 @@ xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields,
xop->xo_gt_domain = NULL;
}
- return (rc < 0) ? rc : (int) xop->xo_columns;
+ return (rc < 0) ? rc : xop->xo_columns;
}
/*
@@ -6238,10 +6244,10 @@ xo_simplify_format (xo_handle_t *xop, const char *fmt, int with_numbers,
return xb.xb_bufp;
}
-int
+xo_ssize_t
xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap)
{
- int rc;
+ ssize_t rc;
xop = xo_default(xop);
va_copy(xop->xo_vap, vap);
@@ -6252,10 +6258,10 @@ xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap)
return rc;
}
-int
+xo_ssize_t
xo_emit_h (xo_handle_t *xop, const char *fmt, ...)
{
- int rc;
+ ssize_t rc;
xop = xo_default(xop);
va_start(xop->xo_vap, fmt);
@@ -6266,11 +6272,11 @@ xo_emit_h (xo_handle_t *xop, const char *fmt, ...)
return rc;
}
-int
+xo_ssize_t
xo_emit (const char *fmt, ...)
{
xo_handle_t *xop = xo_default(NULL);
- int rc;
+ ssize_t rc;
va_start(xop->xo_vap, fmt);
rc = xo_do_emit(xop, 0, fmt);
@@ -6280,11 +6286,11 @@ xo_emit (const char *fmt, ...)
return rc;
}
-int
+xo_ssize_t
xo_emit_hvf (xo_handle_t *xop, xo_emit_flags_t flags,
const char *fmt, va_list vap)
{
- int rc;
+ ssize_t rc;
xop = xo_default(xop);
va_copy(xop->xo_vap, vap);
@@ -6295,10 +6301,10 @@ xo_emit_hvf (xo_handle_t *xop, xo_emit_flags_t flags,
return rc;
}
-int
+xo_ssize_t
xo_emit_hf (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt, ...)
{
- int rc;
+ ssize_t rc;
xop = xo_default(xop);
va_start(xop->xo_vap, fmt);
@@ -6309,11 +6315,11 @@ xo_emit_hf (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt, ...)
return rc;
}
-int
+xo_ssize_t
xo_emit_f (xo_emit_flags_t flags, const char *fmt, ...)
{
xo_handle_t *xop = xo_default(NULL);
- int rc;
+ ssize_t rc;
va_start(xop->xo_vap, fmt);
rc = xo_do_emit(xop, flags, fmt);
@@ -6329,12 +6335,12 @@ xo_emit_f (xo_emit_flags_t flags, const char *fmt, ...)
* a convenience function to avoid callers using snprintf to build field
* descriptions.
*/
-int
+xo_ssize_t
xo_emit_field_hv (xo_handle_t *xop, const char *rolmod, const char *contents,
const char *fmt, const char *efmt,
va_list vap)
{
- int rc;
+ ssize_t rc;
xop = xo_default(xop);
@@ -6365,8 +6371,6 @@ xo_emit_field_hv (xo_handle_t *xop, const char *rolmod, const char *contents,
xfi.xfi_flen = 2;
}
-
-
va_copy(xop->xo_vap, vap);
rc = xo_do_emit_fields(xop, &xfi, 1, fmt ?: contents ?: "field");
@@ -6376,11 +6380,11 @@ xo_emit_field_hv (xo_handle_t *xop, const char *rolmod, const char *contents,
return rc;
}
-int
+xo_ssize_t
xo_emit_field_h (xo_handle_t *xop, const char *rolmod, const char *contents,
const char *fmt, const char *efmt, ...)
{
- int rc;
+ ssize_t rc;
va_list vap;
va_start(vap, efmt);
@@ -6390,11 +6394,11 @@ xo_emit_field_h (xo_handle_t *xop, const char *rolmod, const char *contents,
return rc;
}
-int
+xo_ssize_t
xo_emit_field (const char *rolmod, const char *contents,
const char *fmt, const char *efmt, ...)
{
- int rc;
+ ssize_t rc;
va_list vap;
va_start(vap, efmt);
@@ -6404,16 +6408,16 @@ xo_emit_field (const char *rolmod, const char *contents,
return rc;
}
-int
+xo_ssize_t
xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap)
{
- const int extra = 5; /* space, equals, quote, quote, and nul */
+ const ssize_t extra = 5; /* space, equals, quote, quote, and nul */
xop = xo_default(xop);
- int rc = 0;
- int nlen = strlen(name);
+ ssize_t rc = 0;
+ ssize_t nlen = strlen(name);
xo_buffer_t *xbp = &xop->xo_attrs;
- unsigned name_offset, value_offset;
+ ssize_t name_offset, value_offset;
switch (xo_style(xop)) {
case XO_STYLE_XML:
@@ -6461,10 +6465,10 @@ xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap)
return rc;
}
-int
+xo_ssize_t
xo_attr_h (xo_handle_t *xop, const char *name, const char *fmt, ...)
{
- int rc;
+ ssize_t rc;
va_list vap;
va_start(vap, fmt);
@@ -6474,10 +6478,10 @@ xo_attr_h (xo_handle_t *xop, const char *name, const char *fmt, ...)
return rc;
}
-int
+xo_ssize_t
xo_attr (const char *name, const char *fmt, ...)
{
- int rc;
+ ssize_t rc;
va_list vap;
va_start(vap, fmt);
@@ -6576,7 +6580,7 @@ xo_set_depth (xo_handle_t *xop, int depth)
}
static xo_xsf_flags_t
-xo_stack_flags (unsigned xflags)
+xo_stack_flags (xo_xof_flags_t xflags)
{
if (xflags & XOF_DTRT)
return XSF_DTRT;
@@ -6597,10 +6601,10 @@ xo_emit_top (xo_handle_t *xop, const char *ppn)
}
}
-static int
+static ssize_t
xo_do_open_container (xo_handle_t *xop, xo_xof_flags_t flags, const char *name)
{
- int rc = 0;
+ ssize_t rc = 0;
const char *ppn = XOF_ISSET(xop, XOF_PRETTY) ? "\n" : "";
const char *pre_nl = "";
@@ -6660,25 +6664,25 @@ xo_open_container_hf (xo_handle_t *xop, xo_xof_flags_t flags, const char *name)
return xo_transition(xop, flags, name, XSS_OPEN_CONTAINER);
}
-int
+xo_ssize_t
xo_open_container_h (xo_handle_t *xop, const char *name)
{
return xo_open_container_hf(xop, 0, name);
}
-int
+xo_ssize_t
xo_open_container (const char *name)
{
return xo_open_container_hf(NULL, 0, name);
}
-int
+xo_ssize_t
xo_open_container_hd (xo_handle_t *xop, const char *name)
{
return xo_open_container_hf(xop, XOF_DTRT, name);
}
-int
+xo_ssize_t
xo_open_container_d (const char *name)
{
return xo_open_container_hf(NULL, XOF_DTRT, name);
@@ -6689,7 +6693,7 @@ xo_do_close_container (xo_handle_t *xop, const char *name)
{
xop = xo_default(xop);
- int rc = 0;
+ ssize_t rc = 0;
const char *ppn = XOF_ISSET(xop, XOF_PRETTY) ? "\n" : "";
const char *pre_nl = "";
@@ -6698,7 +6702,7 @@ xo_do_close_container (xo_handle_t *xop, const char *name)
name = xsp->xs_name;
if (name) {
- int len = strlen(name) + 1;
+ ssize_t len = strlen(name) + 1;
/* We need to make a local copy; xo_depth_change will free it */
char *cp = alloca(len);
memcpy(cp, name, len);
@@ -6741,25 +6745,25 @@ xo_do_close_container (xo_handle_t *xop, const char *name)
return rc;
}
-int
+xo_ssize_t
xo_close_container_h (xo_handle_t *xop, const char *name)
{
return xo_transition(xop, 0, name, XSS_CLOSE_CONTAINER);
}
-int
+xo_ssize_t
xo_close_container (const char *name)
{
return xo_close_container_h(NULL, name);
}
-int
+xo_ssize_t
xo_close_container_hd (xo_handle_t *xop)
{
return xo_close_container_h(xop, NULL);
}
-int
+xo_ssize_t
xo_close_container_d (void)
{
return xo_close_container_h(NULL, NULL);
@@ -6768,7 +6772,7 @@ xo_close_container_d (void)
static int
xo_do_open_list (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
{
- int rc = 0;
+ ssize_t rc = 0;
int indent = 0;
xop = xo_default(xop);
@@ -6816,25 +6820,25 @@ xo_open_list_hf (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
return xo_transition(xop, flags, name, XSS_OPEN_LIST);
}
-int
+xo_ssize_t
xo_open_list_h (xo_handle_t *xop, const char *name)
{
return xo_open_list_hf(xop, 0, name);
}
-int
+xo_ssize_t
xo_open_list (const char *name)
{
return xo_open_list_hf(NULL, 0, name);
}
-int
+xo_ssize_t
xo_open_list_hd (xo_handle_t *xop, const char *name)
{
return xo_open_list_hf(xop, XOF_DTRT, name);
}
-int
+xo_ssize_t
xo_open_list_d (const char *name)
{
return xo_open_list_hf(NULL, XOF_DTRT, name);
@@ -6843,7 +6847,7 @@ xo_open_list_d (const char *name)
static int
xo_do_close_list (xo_handle_t *xop, const char *name)
{
- int rc = 0;
+ ssize_t rc = 0;
const char *pre_nl = "";
if (name == NULL) {
@@ -6851,7 +6855,7 @@ xo_do_close_list (xo_handle_t *xop, const char *name)
name = xsp->xs_name;
if (name) {
- int len = strlen(name) + 1;
+ ssize_t len = strlen(name) + 1;
/* We need to make a local copy; xo_depth_change will free it */
char *cp = alloca(len);
memcpy(cp, name, len);
@@ -6887,25 +6891,25 @@ xo_do_close_list (xo_handle_t *xop, const char *name)
return rc;
}
-int
+xo_ssize_t
xo_close_list_h (xo_handle_t *xop, const char *name)
{
return xo_transition(xop, 0, name, XSS_CLOSE_LIST);
}
-int
+xo_ssize_t
xo_close_list (const char *name)
{
return xo_close_list_h(NULL, name);
}
-int
+xo_ssize_t
xo_close_list_hd (xo_handle_t *xop)
{
return xo_close_list_h(xop, NULL);
}
-int
+xo_ssize_t
xo_close_list_d (void)
{
return xo_close_list_h(NULL, NULL);
@@ -6914,7 +6918,7 @@ xo_close_list_d (void)
static int
xo_do_open_leaf_list (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
{
- int rc = 0;
+ ssize_t rc = 0;
int indent = 0;
xop = xo_default(xop);
@@ -6962,7 +6966,7 @@ xo_do_open_leaf_list (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
static int
xo_do_close_leaf_list (xo_handle_t *xop, const char *name)
{
- int rc = 0;
+ ssize_t rc = 0;
const char *pre_nl = "";
if (name == NULL) {
@@ -6970,7 +6974,7 @@ xo_do_close_leaf_list (xo_handle_t *xop, const char *name)
name = xsp->xs_name;
if (name) {
- int len = strlen(name) + 1;
+ ssize_t len = strlen(name) + 1;
/* We need to make a local copy; xo_depth_change will free it */
char *cp = alloca(len);
memcpy(cp, name, len);
@@ -7010,7 +7014,7 @@ xo_do_open_instance (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
{
xop = xo_default(xop);
- int rc = 0;
+ ssize_t rc = 0;
const char *ppn = XOF_ISSET(xop, XOF_PRETTY) ? "\n" : "";
const char *pre_nl = "";
@@ -7065,25 +7069,25 @@ xo_open_instance_hf (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
return xo_transition(xop, flags, name, XSS_OPEN_INSTANCE);
}
-int
+xo_ssize_t
xo_open_instance_h (xo_handle_t *xop, const char *name)
{
return xo_open_instance_hf(xop, 0, name);
}
-int
+xo_ssize_t
xo_open_instance (const char *name)
{
return xo_open_instance_hf(NULL, 0, name);
}
-int
+xo_ssize_t
xo_open_instance_hd (xo_handle_t *xop, const char *name)
{
return xo_open_instance_hf(xop, XOF_DTRT, name);
}
-int
+xo_ssize_t
xo_open_instance_d (const char *name)
{
return xo_open_instance_hf(NULL, XOF_DTRT, name);
@@ -7094,7 +7098,7 @@ xo_do_close_instance (xo_handle_t *xop, const char *name)
{
xop = xo_default(xop);
- int rc = 0;
+ ssize_t rc = 0;
const char *ppn = XOF_ISSET(xop, XOF_PRETTY) ? "\n" : "";
const char *pre_nl = "";
@@ -7103,7 +7107,7 @@ xo_do_close_instance (xo_handle_t *xop, const char *name)
name = xsp->xs_name;
if (name) {
- int len = strlen(name) + 1;
+ ssize_t len = strlen(name) + 1;
/* We need to make a local copy; xo_depth_change will free it */
char *cp = alloca(len);
memcpy(cp, name, len);
@@ -7145,25 +7149,25 @@ xo_do_close_instance (xo_handle_t *xop, const char *name)
return rc;
}
-int
+xo_ssize_t
xo_close_instance_h (xo_handle_t *xop, const char *name)
{
return xo_transition(xop, 0, name, XSS_CLOSE_INSTANCE);
}
-int
+xo_ssize_t
xo_close_instance (const char *name)
{
return xo_close_instance_h(NULL, name);
}
-int
+xo_ssize_t
xo_close_instance_hd (xo_handle_t *xop)
{
return xo_close_instance_h(xop, NULL);
}
-int
+xo_ssize_t
xo_close_instance_d (void)
{
return xo_close_instance_h(NULL, NULL);
@@ -7173,7 +7177,7 @@ static int
xo_do_close_all (xo_handle_t *xop, xo_stack_t *limit)
{
xo_stack_t *xsp;
- int rc = 0;
+ ssize_t rc = 0;
xo_xsf_flags_t flags;
for (xsp = &xop->xo_stack[xop->xo_depth]; xsp >= limit; xsp--) {
@@ -7222,7 +7226,7 @@ static int
xo_do_close (xo_handle_t *xop, const char *name, xo_state_t new_state)
{
xo_stack_t *xsp, *limit = NULL;
- int rc;
+ ssize_t rc;
xo_state_t need_state = new_state;
if (new_state == XSS_CLOSE_CONTAINER)
@@ -7282,17 +7286,16 @@ xo_do_close (xo_handle_t *xop, const char *name, xo_state_t new_state)
/*
* We are in a given state and need to transition to the new state.
*/
-static int
+static ssize_t
xo_transition (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name,
xo_state_t new_state)
{
xo_stack_t *xsp;
- int rc;
+ ssize_t rc = 0;
int old_state, on_marker;
xop = xo_default(xop);
- rc = 0;
xsp = &xop->xo_stack[xop->xo_depth];
old_state = xsp->xs_state;
on_marker = (old_state == XSS_MARKER);
@@ -7552,7 +7555,7 @@ xo_transition (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name,
return -1;
}
-int
+xo_ssize_t
xo_open_marker_h (xo_handle_t *xop, const char *name)
{
xop = xo_default(xop);
@@ -7563,13 +7566,13 @@ xo_open_marker_h (xo_handle_t *xop, const char *name)
return 0;
}
-int
+xo_ssize_t
xo_open_marker (const char *name)
{
return xo_open_marker_h(NULL, name);
}
-int
+xo_ssize_t
xo_close_marker_h (xo_handle_t *xop, const char *name)
{
xop = xo_default(xop);
@@ -7577,7 +7580,7 @@ xo_close_marker_h (xo_handle_t *xop, const char *name)
return xo_do_close(xop, name, XSS_MARKER);
}
-int
+xo_ssize_t
xo_close_marker (const char *name)
{
return xo_close_marker_h(NULL, name);
@@ -7606,10 +7609,10 @@ xo_set_allocator (xo_realloc_func_t realloc_func, xo_free_func_t free_func)
xo_free = free_func;
}
-int
+xo_ssize_t
xo_flush_h (xo_handle_t *xop)
{
- int rc;
+ ssize_t rc;
xop = xo_default(xop);
@@ -7626,13 +7629,13 @@ xo_flush_h (xo_handle_t *xop)
return rc;
}
-int
+xo_ssize_t
xo_flush (void)
{
return xo_flush_h(NULL);
}
-int
+xo_ssize_t
xo_finish_h (xo_handle_t *xop)
{
const char *cp = "";
@@ -7660,7 +7663,7 @@ xo_finish_h (xo_handle_t *xop)
return xo_flush_h(xop);
}
-int
+xo_ssize_t
xo_finish (void)
{
return xo_finish_h(NULL);
@@ -7688,7 +7691,7 @@ xo_error_hv (xo_handle_t *xop, const char *fmt, va_list vap)
* If the format string doesn't end with a newline, we pop
* one on ourselves.
*/
- int len = strlen(fmt);
+ ssize_t len = strlen(fmt);
if (len > 0 && fmt[len - 1] != '\n') {
char *newfmt = alloca(len + 2);
memcpy(newfmt, fmt, len);
@@ -7867,7 +7870,7 @@ xo_set_version_h (xo_handle_t *xop, const char *version)
switch (xo_style(xop)) {
case XO_STYLE_XML:
/* For XML, we record this as an attribute for the first tag */
- xo_attr_h(xop, "__version", "%s", version);
+ xo_attr_h(xop, "version", "%s", version);
break;
case XO_STYLE_JSON:
@@ -7937,7 +7940,7 @@ xo_emit_warn_hcv (xo_handle_t *xop, int as_warning, int code,
(void) xo_emit_hv(xop, fmt, vap);
- int len = strlen(fmt);
+ ssize_t len = strlen(fmt);
if (len > 0 && fmt[len - 1] != '\n') {
if (code > 0) {
const char *msg = strerror(code);
diff --git a/contrib/libxo/libxo/xo.h b/contrib/libxo/libxo/xo.h
index 310b21cae366..13023d3839b5 100644
--- a/contrib/libxo/libxo/xo.h
+++ b/contrib/libxo/libxo/xo.h
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <sys/types.h>
#include <stdarg.h>
+#include <limits.h>
#include <stdlib.h>
#include <errno.h>
@@ -39,7 +40,10 @@
* coward's path, we'll turn it on inside a #if that allows
* others to turn it off where needed. Not ideal, but functional.
*/
-#if !defined(NO_PRINTFLIKE) && !defined(__linux__)
+#if !defined(NO_PRINTFLIKE)
+#if defined(__linux) && !defined(__printflike)
+#define __printflike(_x, _y) __attribute__((__format__ (__printf__, _x, _y)))
+#endif
#define PRINTFLIKE(_x, _y) __printflike(_x, _y)
#else
#define PRINTFLIKE(_x, _y)
@@ -115,7 +119,18 @@ typedef struct xo_info_s {
struct xo_handle_s; /* Opaque structure forward */
typedef struct xo_handle_s xo_handle_t; /* Handle for XO output */
-typedef int (*xo_write_func_t)(void *, const char *);
+/*
+ * Early versions of the API used "int" instead of "size_t" for buffer
+ * sizes. We want to fix this but allow for backwards compatibility
+ * where needed.
+ */
+#ifdef USE_INT_RETURN_CODES
+typedef int xo_ssize_t; /* Buffer size */
+#else /* USE_INT_RETURN_CODES */
+typedef ssize_t xo_ssize_t; /* Buffer size */
+#endif /* USE_INT_RETURN_CODES */
+
+typedef xo_ssize_t (*xo_write_func_t)(void *, const char *);
typedef void (*xo_close_func_t)(void *);
typedef int (*xo_flush_func_t)(void *);
typedef void *(*xo_realloc_func_t)(void *, size_t);
@@ -126,7 +141,7 @@ typedef void (*xo_free_func_t)(void *);
* of the xo handle. The caller should return the number of bytes _needed_
* to fit the data, even if this exceeds 'len'.
*/
-typedef int (*xo_formatter_t)(xo_handle_t *, char *, int,
+typedef xo_ssize_t (*xo_formatter_t)(xo_handle_t *, char *, xo_ssize_t,
const char *, va_list);
typedef void (*xo_checkpointer_t)(xo_handle_t *, va_list, int);
@@ -182,23 +197,23 @@ xo_set_formatter (xo_handle_t *xop, xo_formatter_t func, xo_checkpointer_t);
void
xo_set_depth (xo_handle_t *xop, int depth);
-int
+xo_ssize_t
xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap);
-int
+xo_ssize_t
xo_emit_h (xo_handle_t *xop, const char *fmt, ...);
-int
+xo_ssize_t
xo_emit (const char *fmt, ...);
-int
+xo_ssize_t
xo_emit_hvf (xo_handle_t *xop, xo_emit_flags_t flags,
const char *fmt, va_list vap);
-int
+xo_ssize_t
xo_emit_hf (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt, ...);
-int
+xo_ssize_t
xo_emit_f (xo_emit_flags_t flags, const char *fmt, ...);
PRINTFLIKE(2, 0)
@@ -260,97 +275,97 @@ xo_emit_fp (xo_emit_flags_t flags, const char *fmt, ...)
return rc;
}
-int
+xo_ssize_t
xo_open_container_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_open_container (const char *name);
-int
+xo_ssize_t
xo_open_container_hd (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_open_container_d (const char *name);
-int
+xo_ssize_t
xo_close_container_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_close_container (const char *name);
-int
+xo_ssize_t
xo_close_container_hd (xo_handle_t *xop);
-int
+xo_ssize_t
xo_close_container_d (void);
-int
+xo_ssize_t
xo_open_list_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_open_list (const char *name);
-int
+xo_ssize_t
xo_open_list_hd (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_open_list_d (const char *name);
-int
+xo_ssize_t
xo_close_list_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_close_list (const char *name);
-int
+xo_ssize_t
xo_close_list_hd (xo_handle_t *xop);
-int
+xo_ssize_t
xo_close_list_d (void);
-int
+xo_ssize_t
xo_open_instance_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_open_instance (const char *name);
-int
+xo_ssize_t
xo_open_instance_hd (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_open_instance_d (const char *name);
-int
+xo_ssize_t
xo_close_instance_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_close_instance (const char *name);
-int
+xo_ssize_t
xo_close_instance_hd (xo_handle_t *xop);
-int
+xo_ssize_t
xo_close_instance_d (void);
-int
+xo_ssize_t
xo_open_marker_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_open_marker (const char *name);
-int
+xo_ssize_t
xo_close_marker_h (xo_handle_t *xop, const char *name);
-int
+xo_ssize_t
xo_close_marker (const char *name);
-int
+xo_ssize_t
xo_attr_h (xo_handle_t *xop, const char *name, const char *fmt, ...);
-int
+xo_ssize_t
xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap);
-int
+xo_ssize_t
xo_attr (const char *name, const char *fmt, ...);
void
@@ -362,16 +377,16 @@ xo_error_h (xo_handle_t *xop, const char *fmt, ...);
void
xo_error (const char *fmt, ...);
-int
+xo_ssize_t
xo_flush_h (xo_handle_t *xop);
-int
+xo_ssize_t
xo_flush (void);
-int
+xo_ssize_t
xo_finish_h (xo_handle_t *xop);
-int
+xo_ssize_t
xo_finish (void);
void
@@ -644,16 +659,16 @@ char *
xo_simplify_format (xo_handle_t *xop, const char *fmt, int with_numbers,
xo_simplify_field_func_t field_cb);
-int
+xo_ssize_t
xo_emit_field_hv (xo_handle_t *xop, const char *rolmod, const char *contents,
const char *fmt, const char *efmt,
va_list vap);
-int
+xo_ssize_t
xo_emit_field_h (xo_handle_t *xop, const char *rolmod, const char *contents,
const char *fmt, const char *efmt, ...);
-int
+xo_ssize_t
xo_emit_field (const char *rolmod, const char *contents,
const char *fmt, const char *efmt, ...);
diff --git a/contrib/libxo/libxo/xo_buf.h b/contrib/libxo/libxo/xo_buf.h
index 01eb397d37c4..3bb5628a6ea0 100644
--- a/contrib/libxo/libxo/xo_buf.h
+++ b/contrib/libxo/libxo/xo_buf.h
@@ -28,7 +28,7 @@
typedef struct xo_buffer_s {
char *xb_bufp; /* Buffer memory */
char *xb_curp; /* Current insertion point */
- unsigned xb_size; /* Size of buffer */
+ ssize_t xb_size; /* Size of buffer */
} xo_buffer_t;
/*
@@ -111,10 +111,10 @@ xo_buf_cleanup (xo_buffer_t *xbp)
* return 0 to tell the caller they are in trouble.
*/
static inline int
-xo_buf_has_room (xo_buffer_t *xbp, int len)
+xo_buf_has_room (xo_buffer_t *xbp, ssize_t len)
{
if (xbp->xb_curp + len >= xbp->xb_bufp + xbp->xb_size) {
- int sz = xbp->xb_size + XO_BUFSIZ;
+ ssize_t sz = xbp->xb_size + XO_BUFSIZ;
char *bp = xo_realloc(xbp->xb_bufp, sz);
if (bp == NULL)
return 0;
@@ -131,7 +131,7 @@ xo_buf_has_room (xo_buffer_t *xbp, int len)
* Append the given string to the given buffer
*/
static inline void
-xo_buf_append (xo_buffer_t *xbp, const char *str, int len)
+xo_buf_append (xo_buffer_t *xbp, const char *str, ssize_t len)
{
if (!xo_buf_has_room(xbp, len))
return;
@@ -146,7 +146,7 @@ xo_buf_append (xo_buffer_t *xbp, const char *str, int len)
static inline void
xo_buf_append_str (xo_buffer_t *xbp, const char *str)
{
- int len = strlen(str);
+ ssize_t len = strlen(str);
if (!xo_buf_has_room(xbp, len))
return;
diff --git a/contrib/libxo/libxo/xo_encoder.c b/contrib/libxo/libxo/xo_encoder.c
index eb2960bf7d9f..ef9403b909aa 100644
--- a/contrib/libxo/libxo/xo_encoder.c
+++ b/contrib/libxo/libxo/xo_encoder.c
@@ -139,7 +139,7 @@ xo_encoder_list_add (const char *name)
xo_encoder_node_t *xep = xo_realloc(NULL, sizeof(*xep));
if (xep) {
- int len = strlen(name) + 1;
+ ssize_t len = strlen(name) + 1;
xep->xe_name = xo_realloc(NULL, len);
if (xep->xe_name == NULL) {
xo_free(xep);
@@ -241,7 +241,7 @@ xo_encoder_discover (const char *name)
bzero(&xei, sizeof(xei));
xei.xei_version = XO_ENCODER_VERSION;
- int rc = func(&xei);
+ ssize_t rc = func(&xei);
if (rc == 0 && xei.xei_handler) {
xep = xo_encoder_list_add(name);
if (xep) {
diff --git a/contrib/libxo/libxo/xo_format.5 b/contrib/libxo/libxo/xo_format.5
index abd1b6f65c5f..b1829c8941dc 100644
--- a/contrib/libxo/libxo/xo_format.5
+++ b/contrib/libxo/libxo/xo_format.5
@@ -630,7 +630,7 @@ The format string has the form:
\(aq%\(aq format\-modifier * format\-character
.Ed
.Pp
-The format\- modifier can be:
+The format\-modifier can be:
.Bl -bullet
.It
a \(aq#\(aq character, indicating the output value should be prefixed with
diff --git a/contrib/libxo/libxo/xo_options.7 b/contrib/libxo/libxo/xo_options.7
new file mode 100644
index 000000000000..5e86668d009f
--- /dev/null
+++ b/contrib/libxo/libxo/xo_options.7
@@ -0,0 +1,147 @@
+.\" #
+.\" # Copyright (c) 2014-2017, Juniper Networks, Inc.
+.\" # All rights reserved.
+.\" # This SOFTWARE is licensed under the LICENSE provided in the
+.\" # ../Copyright file. By downloading, installing, copying, or
+.\" # using the SOFTWARE, you agree to be bound by the terms of that
+.\" # LICENSE.
+.\" # Phil Shafer, July 2014
+.\"
+.Dd May 11, 2017
+.Dt LIBXO 3
+.Os
+.Sh NAME
+.Nm xo_options
+.Nd common options for libxo\-based commands
+.Sh DESCRIPTION
+.Pp
+.Nm libxo
+allows the rendering of data into
+various output styles, including
+.Em text ,
+.Em XML ,
+.Em JSON ,
+and
+.Em HTML .
+.Nm libxo
+uses command line options to trigger rendering behavior.
+Options are recognised in three forms:
+.Bl -bullet
+.It
+\-\-libxo <options>
+.It
+\-\-libxo=<options>
+.It
+\-\-libxo:<brief\-options>
+.El
+.Pp
+The first two forms accept a comma\-separated set of words, detailed
+below, while the third form accepts a set of letters, also below.
+The triggered functionality is identical.
+.Bl -column "Token2341234"
+.It Sy "Option " "Action"
+.It "color " "Enable colors/effects for display styles (TEXT, HTML)"
+.It "flush " "Flush after each emit call"
+.It "flush\-line " "Flush each line of output"
+.It "html " "Emit HTML output"
+.It "indent=xx " "Set the indentation level"
+.It "info " "Add info attributes (HTML)"
+.It "json " "Emit JSON output"
+.It "keys " "Emit the key attribute for keys (XML)"
+.It "log\-gettext" "Log (via stderr) each gettext(3) string lookup"
+.It "log\-syslog " "Log (via stderr) each syslog message (via xo_syslog)"
+.It "no\-humanize" "Ignore the {h:} modifier (TEXT, HTML)"
+.It "no\-locale " "Do not initialize the locale setting"
+.It "no\-retain " "Prevent retaining formatting information"
+.It "pretty " "Emit pretty\-printed output"
+.It "retain " "Force retaining formatting information"
+.It "text " "Emit TEXT output"
+.It "underscores" "Replace XML\-friendly \"\-\"s with JSON friendly \"_\"s"
+.It "units " "Add the 'units' (XML) or 'data\-units (HTML) attribute"
+.It "warn " "Emit warnings when libxo detects bad calls"
+.It "warn\-xml " "Emit warnings in XML"
+.It "xml " "Emit XML output"
+.It "xpath " "Add XPath expressions (HTML)"
+.El
+.Pp
+The brief options are a set of single\-letter aliases for the longer
+terms, used as a single string:
+.Bl -column "Value" "Equivalent Token"
+.It Sy "Value" "Equivalent Token"
+.It "c
+.It "f " "flush"
+.It "F " "flush\-line"
+.It "H " "html"
+.It "I " "info"
+.It "i<num>" "indent=<num>"
+.It "J " "json"
+.It "k " "keys"
+.It "n " "no\-humanize"
+.It "P " "pretty"
+.It "T " "text"
+.It "U " "units"
+.It "u " "underscore
+.It "W " "warn"
+.It "X " "xml"
+.It "x " "xpath"
+.El
+.Pp
+Most of these option are simple and direct, but some require
+additional details:
+.Pp
+.Fa "flush\-line"
+performs line buffering, even when the output is not directed to
+a TTY device.
+.Pp
+.Fa info
+generates additional data for HTML, encoded in attributes using
+names that state with "data\-".
+.Pp
+.Fa keys
+adds a "key" attribute for XML output to indicate that a leaf is
+an identifier for the list member.
+.Pp
+.Fa no\-humanize
+avoids "humanizing" numeric output (see
+.Xr humanize_number 3
+for details).
+.Pp
+.Fa no\-locale
+instructs
+.Nm libxo
+to avoid translating output to the current locale.
+.Pp
+.Fa no\-retain
+disables the ability of
+.Nm libxo
+to internally retain "compiled" information about formatting strings.
+.Pp
+.Fa underscores
+can be used with
+.Em JSON
+output to change
+.Em XML \-friendly
+names with dashes into
+.Em JSON \-friendly
+name with underscores.
+.Pp
+.Fa warn
+allows
+.Nm libxo
+to emit warnings on stderr when application code make incorrect calls.
+.Fa warn\-xml causes those warnings to be placed in
+.Em XML
+inside the output.
+.Sh EXAMPLES
+The following are three example invocations of
+.Xr ps 1 :
+.Bd -literal
+ ps \-\-libxo json,pretty,warn \-ux
+
+ ps \-\-libxo=xml \-lg
+
+ ps \-\-libxo:Hxc 1
+.Ed
+.Sh SEE ALSO
+.Xr libxo 3 ,
+.Xr xo_format 5
diff --git a/contrib/libxo/libxo/xo_syslog.c b/contrib/libxo/libxo/xo_syslog.c
index 43ceb9af1503..c1e19e5d77c2 100644
--- a/contrib/libxo/libxo/xo_syslog.c
+++ b/contrib/libxo/libxo/xo_syslog.c
@@ -53,6 +53,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include <limits.h>
#include <unistd.h>
#include <stdarg.h>
#include <sys/time.h>
@@ -94,11 +95,13 @@
#define XO_DEFAULT_EID 32473 /* Fallback to the "example" number */
#endif
+#ifndef HOST_NAME_MAX
#ifdef _SC_HOST_NAME_MAX
#define HOST_NAME_MAX _SC_HOST_NAME_MAX
#else
#define HOST_NAME_MAX 255
#endif /* _SC_HOST_NAME_MAX */
+#endif /* HOST_NAME_MAX */
#ifndef UNUSED
#define UNUSED __attribute__ ((__unused__))
@@ -425,12 +428,13 @@ xo_set_syslog_handler (xo_syslog_open_t open_func,
xo_syslog_close = close_func;
}
-static size_t
-xo_snprintf (char *out, size_t outsize, const char *fmt, ...)
+static ssize_t
+xo_snprintf (char *out, ssize_t outsize, const char *fmt, ...)
{
- int status;
- size_t retval = 0;
+ ssize_t status;
+ ssize_t retval = 0;
va_list ap;
+
if (out && outsize) {
va_start(ap, fmt);
status = vsnprintf(out, outsize, fmt, ap);
@@ -443,10 +447,11 @@ xo_snprintf (char *out, size_t outsize, const char *fmt, ...)
}
va_end(ap);
}
+
return retval;
}
-static int
+static xo_ssize_t
xo_syslog_handle_write (void *opaque, const char *data)
{
xo_buffer_t *xbp = opaque;
diff --git a/contrib/libxo/tests/core/saved/test_01.E.out b/contrib/libxo/tests/core/saved/test_01.E.out
index de23baad0b16..75f5d0a1d3da 100644
--- a/contrib/libxo/tests/core/saved/test_01.E.out
+++ b/contrib/libxo/tests/core/saved/test_01.E.out
@@ -1,5 +1,7 @@
op create: [] []
op open_container: [top] []
+op content: [kve_start] [0xdeadbeef]
+op content: [kve_end] [0xcabb1e]
op string: [host] [my-box]
op string: [domain] [example.com]
op string: [host] [my-box]
diff --git a/contrib/libxo/tests/core/saved/test_01.J.out b/contrib/libxo/tests/core/saved/test_01.J.out
index 3fc12a173148..1577ce0c0410 100644
--- a/contrib/libxo/tests/core/saved/test_01.J.out
+++ b/contrib/libxo/tests/core/saved/test_01.J.out
@@ -1,2 +1,2 @@
-{"top": {"host":"my-box","domain":"example.com","host":"my-box","domain":"example.com","label":"value","max-chaos":"very","min-chaos":42,"some-chaos":"[42]","host":"my-box","domain":"example.com", "data": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17,"in-stock":14,"on-order":2}]}, "data2": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412.0,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85.0,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123.0,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17.0,"in-stock":14,"on-order":2}]}, "data3": {"item": [{"sku":"GRO-000-533","name":"fish","sold":1321.0,"in-stock":45,"on-order":1}]}, "data4": {"item": ["gum","rope","ladder","bolt","water"]},"cost":425,"cost":455,"mode":"mode","mode_octal":"octal","links":"links","user":"user","group":"group","mode":"/some/file","mode_octal":640,"links":1,"user":"user","group":"group"}
+{"top": {"kve_start":"0xdeadbeef","kve_end":"0xcabb1e","host":"my-box","domain":"example.com","host":"my-box","domain":"example.com","label":"value","max-chaos":"very","min-chaos":42,"some-chaos":"[42]","host":"my-box","domain":"example.com", "data": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17,"in-stock":14,"on-order":2}]}, "data2": {"item": [{"sku":"GRO-000-415","name":"gum","sold":1412.0,"in-stock":54,"on-order":10}, {"sku":"HRD-000-212","name":"rope","sold":85.0,"in-stock":4,"on-order":2}, {"sku":"HRD-000-517","name":"ladder","sold":0,"in-stock":2,"on-order":1}, {"sku":"HRD-000-632","name":"bolt","sold":4123.0,"in-stock":144,"on-order":42}, {"sku":"GRO-000-2331","name":"water","sold":17.0,"in-stock":14,"on-order":2}]}, "data3": {"item": [{"sku":"GRO-000-533","name":"fish","sold":1321.0,"in-stock":45,"on-order":1}]}, "data4": {"item": ["gum","rope","ladder","bolt","water"]},"cost":425,"cost":455,"mode":"mode","mode_octal":"octal","links":"links","user":"user","group":"group","mode":"/some/file","mode_octal":640,"links":1,"user":"user","group":"group"}
}
diff --git a/contrib/libxo/tests/core/saved/test_01.JP.out b/contrib/libxo/tests/core/saved/test_01.JP.out
index 2c7397f5e20a..d24abbc0254f 100644
--- a/contrib/libxo/tests/core/saved/test_01.JP.out
+++ b/contrib/libxo/tests/core/saved/test_01.JP.out
@@ -1,5 +1,7 @@
{
"top": {
+ "kve_start": "0xdeadbeef",
+ "kve_end": "0xcabb1e",
"host": "my-box",
"domain": "example.com",
"host": "my-box",
diff --git a/contrib/libxo/tests/core/saved/test_01.X.out b/contrib/libxo/tests/core/saved/test_01.X.out
index da80e681b27b..a243ce7c79f1 100644
--- a/contrib/libxo/tests/core/saved/test_01.X.out
+++ b/contrib/libxo/tests/core/saved/test_01.X.out
@@ -1 +1 @@
-<top><host>my-box</host><domain>example.com</domain><host>my-box</host><domain>example.com</domain><label>value</label><max-chaos>very</max-chaos><min-chaos>42</min-chaos><some-chaos>[42]</some-chaos><host>my-box</host><domain>example.com</domain><data test="value"><item test2="value2"><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data2><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data2><data3><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data3><data4><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data4><cost>425</cost><cost>455</cost><mode>mode</mode><mode_octal>octal</mode_octal><links>links</links><user>user</user><group>group</group><mode>/some/file</mode><mode_octal>640</mode_octal><links>1</links><user>user</user><group>group</group></top> \ No newline at end of file
+<top><kve_start>0xdeadbeef</kve_start><kve_end>0xcabb1e</kve_end><host>my-box</host><domain>example.com</domain><host>my-box</host><domain>example.com</domain><label>value</label><max-chaos>very</max-chaos><min-chaos>42</min-chaos><some-chaos>[42]</some-chaos><host>my-box</host><domain>example.com</domain><data test="value"><item test2="value2"><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data2><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data2><data3><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data3><data4><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data4><cost>425</cost><cost>455</cost><mode>mode</mode><mode_octal>octal</mode_octal><links>links</links><user>user</user><group>group</group><mode>/some/file</mode><mode_octal>640</mode_octal><links>1</links><user>user</user><group>group</group></top> \ No newline at end of file
diff --git a/contrib/libxo/tests/core/saved/test_01.XP.out b/contrib/libxo/tests/core/saved/test_01.XP.out
index c331dceafe62..98dc13b68f29 100644
--- a/contrib/libxo/tests/core/saved/test_01.XP.out
+++ b/contrib/libxo/tests/core/saved/test_01.XP.out
@@ -1,4 +1,6 @@
<top>
+ <kve_start>0xdeadbeef</kve_start>
+ <kve_end>0xcabb1e</kve_end>
<host>my-box</host>
<domain>example.com</domain>
<host>my-box</host>
diff --git a/contrib/libxo/tests/core/saved/test_10.X.out b/contrib/libxo/tests/core/saved/test_10.X.out
index 49c6dd88c4fd..c9321566d907 100644
--- a/contrib/libxo/tests/core/saved/test_10.X.out
+++ b/contrib/libxo/tests/core/saved/test_10.X.out
@@ -1 +1 @@
-<top __version="3.1.4"><data test="value"><data test2="value2">bold</data><data>bold-ul</data><data>triple</data><data>inv-ul</data><data>underline</data><data>plain</data><item><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data><data><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data><cost>425</cost><cost>455</cost></top> \ No newline at end of file
+<top version="3.1.4"><data test="value"><data test2="value2">bold</data><data>bold-ul</data><data>triple</data><data>inv-ul</data><data>underline</data><data>plain</data><item><sku test3="value3" key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku test3="value3" key="key">HRD-000-212</sku><name key="key">rope</name><sold>85</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku test3="value3" key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku test3="value3" key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku test3="value3" key="key">GRO-000-2331</sku><name key="key">water</name><sold>17</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-415</sku><name key="key">gum</name><sold>1412.0</sold><in-stock>54</in-stock><on-order>10</on-order></item><item><sku key="key">HRD-000-212</sku><name key="key">rope</name><sold>85.0</sold><in-stock>4</in-stock><on-order>2</on-order></item><item><sku key="key">HRD-000-517</sku><name key="key">ladder</name><sold>0</sold><in-stock>2</in-stock><on-order>1</on-order></item><item><sku key="key">HRD-000-632</sku><name key="key">bolt</name><sold>4123.0</sold><in-stock>144</in-stock><on-order>42</on-order></item><item><sku key="key">GRO-000-2331</sku><name key="key">water</name><sold>17.0</sold><in-stock>14</in-stock><on-order>2</on-order></item></data><data><item><sku key="key">GRO-000-533</sku><name key="key">fish</name><sold>1321.0</sold><in-stock>45</in-stock><on-order>1</on-order></item></data><data><item test4="value4">gum</item><item test4="value4">rope</item><item test4="value4">ladder</item><item test4="value4">bolt</item><item test4="value4">water</item></data><cost>425</cost><cost>455</cost></top> \ No newline at end of file
diff --git a/contrib/libxo/tests/core/saved/test_10.XP.out b/contrib/libxo/tests/core/saved/test_10.XP.out
index 33c88d96214f..ec1aa93c7512 100644
--- a/contrib/libxo/tests/core/saved/test_10.XP.out
+++ b/contrib/libxo/tests/core/saved/test_10.XP.out
@@ -1,4 +1,4 @@
-<top __version="3.1.4">
+<top version="3.1.4">
<data test="value">
<data test2="value2">bold</data>
<data>bold-ul</data>
diff --git a/contrib/libxo/tests/core/saved/test_11.X.out b/contrib/libxo/tests/core/saved/test_11.X.out
index bb73a4293c9a..5c279b73b151 100644
--- a/contrib/libxo/tests/core/saved/test_11.X.out
+++ b/contrib/libxo/tests/core/saved/test_11.X.out
@@ -14,4 +14,4 @@
{{test-program: }}
{{An application 1011 log entry}}
-<top __version="3.1.4"></top> \ No newline at end of file
+<top version="3.1.4"></top> \ No newline at end of file
diff --git a/contrib/libxo/tests/core/saved/test_11.XP.out b/contrib/libxo/tests/core/saved/test_11.XP.out
index 46b5dd079ee5..02765614e9ab 100644
--- a/contrib/libxo/tests/core/saved/test_11.XP.out
+++ b/contrib/libxo/tests/core/saved/test_11.XP.out
@@ -14,5 +14,5 @@
{{test-program: }}
{{An application 1011 log entry}}
-<top __version="3.1.4">
+<top version="3.1.4">
</top>
diff --git a/contrib/libxo/tests/core/test_01.c b/contrib/libxo/tests/core/test_01.c
index 05d778a0bca4..a3a6a4be3e29 100644
--- a/contrib/libxo/tests/core/test_01.c
+++ b/contrib/libxo/tests/core/test_01.c
@@ -9,6 +9,7 @@
*/
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#include <unistd.h>
@@ -79,6 +80,9 @@ main (int argc, char **argv)
xo_open_container_h(NULL, "top");
+ xo_emit("{e:kve_start/%#jx}", (uintmax_t) 0xdeadbeef);
+ xo_emit("{e:kve_end/%#jx}", (uintmax_t) 0xcabb1e);
+
xo_emit("testing argument modifier {a:}.{a:}...\n",
"host", "my-box", "domain", "example.com");
diff --git a/contrib/libxo/tests/gettext/saved/gt_01.J.out b/contrib/libxo/tests/gettext/saved/gt_01.J.out
index 86527d149a6d..e6c2dd0e0798 100644
--- a/contrib/libxo/tests/gettext/saved/gt_01.J.out
+++ b/contrib/libxo/tests/gettext/saved/gt_01.J.out
@@ -1,2 +1,2 @@
-{"top": {"adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay","adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay", "bytes": [0,1,2,3,4],"total":1234,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"marzlevanes":3,"version":"1.2.3","date":"Tue Jun 23 18:47:09 UTC 2015", "__warning": {"program":"gt_01.test","message":"Nableuay otay ectulatobjay orwardfay elocipingvay","verb":ectulatobjay,"error":"Ermissionpay eniedday"}, "__warning": {"program":"gt_01.test","message":"automaticyay ynchronizationsay ofyay ardinalyay ammetersgray ailedfay","style":automaticyay,"type":"ardinalyay","target":"ammetersgray","error":"Ermissionpay eniedday"},"marzlevanes":6,"windings":"otuslay-oyay-eltayay"}
+{"top": {"adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay","adjective":"amingflay","noun":"ordsway","verb":"urningbay","owner":"ymay","target":"ouchcay", "bytes": [0,1,2,3,4],"total":1234,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"received":1234,"from":"foop","port":4321,"time":32,"marzlevanes":3,"version":"1.2.3","date":"Tue Jun 23 18:47:09 UTC 2015", "__warning": {"program":"gt_01.test","message":"Nableuay otay ectulatobjay orwardfay elocipingvay","verb":ectulatobjay,"error":"Ermissionpay eniedday"}, "__warning": {"program":"gt_01.test","message":"automaticyay ynchronizationsay ofyay ardinalyay ammetersgray ailedfay","style":"automaticyay","type":"ardinalyay","target":"ammetersgray","error":"Ermissionpay eniedday"},"marzlevanes":6,"windings":"otuslay-oyay-eltayay"}
}
diff --git a/contrib/libxo/tests/gettext/saved/gt_01.JP.out b/contrib/libxo/tests/gettext/saved/gt_01.JP.out
index 537ab213cb7c..6fcfcd6189f1 100644
--- a/contrib/libxo/tests/gettext/saved/gt_01.JP.out
+++ b/contrib/libxo/tests/gettext/saved/gt_01.JP.out
@@ -42,7 +42,7 @@
"__warning": {
"program": "gt_01.test",
"message": "automaticyay ynchronizationsay ofyay ardinalyay ammetersgray ailedfay",
- "style": automaticyay,
+ "style": "automaticyay",
"type": "ardinalyay",
"target": "ammetersgray",
"error": "Ermissionpay eniedday"
diff --git a/contrib/libxo/xo/xo.c b/contrib/libxo/xo/xo.c
index ce758afb7cab..e48d2f8110c0 100644
--- a/contrib/libxo/xo/xo.c
+++ b/contrib/libxo/xo/xo.c
@@ -90,8 +90,8 @@ checkpoint (xo_handle_t *xop UNUSED, va_list vap UNUSED, int restore)
* with our command line arguments to build strings. This involves faking
* some printf-style logic.
*/
-static int
-formatter (xo_handle_t *xop, char *buf, int bufsiz,
+static xo_ssize_t
+formatter (xo_handle_t *xop, char *buf, xo_ssize_t bufsiz,
const char *fmt, va_list vap UNUSED)
{
int lflag UNUSED = 0; /* Parse long flag, though currently ignored */
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_realpath.c b/contrib/netbsd-tests/lib/libc/gen/t_realpath.c
index d4998c7ea265..dfb360f46450 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_realpath.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_realpath.c
@@ -34,6 +34,9 @@ __RCSID("$NetBSD: t_realpath.c,v 1.2 2012/03/27 07:54:58 njoly Exp $");
#include <sys/param.h>
#include <atf-c.h>
+#ifdef __FreeBSD__
+#include <errno.h>
+#endif
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@@ -122,8 +125,15 @@ ATF_TC_BODY(realpath_symlink, tc)
char resb[MAXPATHLEN] = { 0 };
int fd;
+#ifdef __FreeBSD__
+ ATF_REQUIRE_MSG(getcwd(path, sizeof(path)) != NULL,
+ "getcwd(path) failed: %s", strerror(errno));
+ ATF_REQUIRE_MSG(getcwd(slnk, sizeof(slnk)) != NULL,
+ "getcwd(slnk) failed: %s", strerror(errno));
+#else
(void)getcwd(path, sizeof(path));
(void)getcwd(slnk, sizeof(slnk));
+#endif
(void)strlcat(path, "/realpath", sizeof(path));
(void)strlcat(slnk, "/symbolic", sizeof(slnk));
diff --git a/contrib/netbsd-tests/lib/libc/ssp/t_ssp.sh b/contrib/netbsd-tests/lib/libc/ssp/t_ssp.sh
index e535e3e63db1..7b963d18e3f7 100755
--- a/contrib/netbsd-tests/lib/libc/ssp/t_ssp.sh
+++ b/contrib/netbsd-tests/lib/libc/ssp/t_ssp.sh
@@ -386,12 +386,14 @@ read_body()
{
prog="$(atf_get_srcdir)/h_read"
- h_pass "$prog 1024" "echo foo |"
# Begin FreeBSD
if true; then
- h_fail "$prog 1027" "echo bar |"
+ MAX_PATH=$(getconf _XOPEN_PATH_MAX) || atf_fail "getconf failed"
+ h_pass "$prog $MAX_PATH" "echo foo |"
+ h_fail "$prog $(( $MAX_PATH + 3 ))" "echo bar |"
else
# End FreeBSD
+ h_pass "$prog 1024" "echo foo |"
h_fail "$prog 1025" "echo bar |"
# Begin FreeBSD
fi
diff --git a/contrib/netbsd-tests/lib/libc/sys/t_wait.c b/contrib/netbsd-tests/lib/libc/sys/t_wait.c
index 91bbaf1f3dd1..ce060da8937e 100644
--- a/contrib/netbsd-tests/lib/libc/sys/t_wait.c
+++ b/contrib/netbsd-tests/lib/libc/sys/t_wait.c
@@ -31,6 +31,10 @@
#include <sys/cdefs.h>
__RCSID("$NetBSD: t_wait.c,v 1.8 2017/01/13 19:28:55 christos Exp $");
+#ifdef __FreeBSD__
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
#include <sys/wait.h>
#include <sys/resource.h>
@@ -147,6 +151,14 @@ ATF_TC_BODY(wait6_coredumped, tc)
pid_t pid;
static const struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
+#ifdef __FreeBSD__
+ int coredump_enabled;
+ size_t ce_len = sizeof(coredump_enabled);
+ if (sysctlbyname("kern.coredump", &coredump_enabled, &ce_len, NULL,
+ 0) == 0 && !coredump_enabled)
+ atf_tc_skip("Coredumps disabled");
+#endif
+
switch (pid = fork()) {
case 0:
ATF_REQUIRE(setrlimit(RLIMIT_CORE, &rl) == 0);
diff --git a/contrib/netbsd-tests/usr.bin/grep/t_grep.sh b/contrib/netbsd-tests/usr.bin/grep/t_grep.sh
index 57d17172d1bf..05d06f6ba8dd 100755
--- a/contrib/netbsd-tests/usr.bin/grep/t_grep.sh
+++ b/contrib/netbsd-tests/usr.bin/grep/t_grep.sh
@@ -399,11 +399,6 @@ wflag_emptypat_head()
}
wflag_emptypat_body()
{
- grep_type
- if [ $? -eq $GREP_TYPE_GNU_FREEBSD ]; then
- atf_expect_fail "this test does not pass with GNU grep in base"
- fi
-
printf "" > test1
printf "\n" > test2
printf "qaz" > test3
@@ -522,6 +517,63 @@ grep_nomatch_flags_body()
atf_check -o empty grep -q -A 1 -e "B" test1
atf_check -o empty grep -q -C 1 -e "B" test1
}
+
+atf_test_case badcontext
+badcontext_head()
+{
+ atf_set "descr" "Check for handling of invalid context arguments"
+}
+badcontext_body()
+{
+ printf "A\nB\nC\n" > test1
+
+ atf_check -s not-exit:0 -e ignore grep -A "-1" "B" test1
+
+ atf_check -s not-exit:0 -e ignore grep -B "-1" "B" test1
+
+ atf_check -s not-exit:0 -e ignore grep -C "-1" "B" test1
+
+ atf_check -s not-exit:0 -e ignore grep -A "B" "B" test1
+
+ atf_check -s not-exit:0 -e ignore grep -B "B" "B" test1
+
+ atf_check -s not-exit:0 -e ignore grep -C "B" "B" test1
+}
+
+atf_test_case binary_flags
+binary_flags_head()
+{
+ atf_set "descr" "Check output for binary flags (-a, -I, -U, --binary-files)"
+}
+binary_flags_body()
+{
+ printf "A\000B\000C" > test1
+ printf "A\n\000B\n\000C" > test2
+ binmatchtext="Binary file test1 matches\n"
+
+ # Binaries not treated as text (default, -U)
+ atf_check -o inline:"${binmatchtext}" grep 'B' test1
+ atf_check -o inline:"${binmatchtext}" grep 'B' -C 1 test1
+
+ atf_check -o inline:"${binmatchtext}" grep -U 'B' test1
+ atf_check -o inline:"${binmatchtext}" grep -U 'B' -C 1 test1
+
+ # Binary, -a, no newlines
+ atf_check -o inline:"A\000B\000C\n" grep -a 'B' test1
+ atf_check -o inline:"A\000B\000C\n" grep -a 'B' -C 1 test1
+
+ # Binary, -a, newlines
+ atf_check -o inline:"\000B\n" grep -a 'B' test2
+ atf_check -o inline:"A\n\000B\n\000C\n" grep -a 'B' -C 1 test2
+
+ # Binary files ignored
+ atf_check -s exit:1 grep -I 'B' test2
+
+ # --binary-files equivalence
+ atf_check -o inline:"${binmatchtext}" grep --binary-files=binary 'B' test1
+ atf_check -o inline:"A\000B\000C\n" grep --binary-files=text 'B' test1
+ atf_check -s exit:1 grep --binary-files=without-match 'B' test2
+}
# End FreeBSD
atf_init_test_cases()
@@ -556,5 +608,7 @@ atf_init_test_cases()
atf_add_test_case egrep_sanity
atf_add_test_case grep_sanity
atf_add_test_case grep_nomatch_flags
+ atf_add_test_case binary_flags
+ atf_add_test_case badcontext
# End FreeBSD
}
diff --git a/crypto/openssh/auth-pam.c b/crypto/openssh/auth-pam.c
index 8f8625894c8e..77e9e2bae7d3 100644
--- a/crypto/openssh/auth-pam.c
+++ b/crypto/openssh/auth-pam.c
@@ -799,7 +799,8 @@ sshpam_query(void *ctx, char **name, char **info,
free(msg);
return (0);
}
- BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL);
+ BLACKLIST_NOTIFY(BLACKLIST_BAD_USER,
+ sshpam_authctxt->user);
error("PAM: %s for %s%.100s from %.100s", msg,
sshpam_authctxt->valid ? "" : "illegal user ",
sshpam_authctxt->user,
diff --git a/crypto/openssh/auth.c b/crypto/openssh/auth.c
index a769f31e1bbb..1343ea0938a7 100644
--- a/crypto/openssh/auth.c
+++ b/crypto/openssh/auth.c
@@ -311,7 +311,7 @@ auth_log(Authctxt *authctxt, int authenticated, int partial,
else {
authmsg = authenticated ? "Accepted" : "Failed";
if (authenticated)
- BLACKLIST_NOTIFY(BLACKLIST_AUTH_OK);
+ BLACKLIST_NOTIFY(BLACKLIST_AUTH_OK, "ssh");
}
authlog("%s %s%s%s for %s%.100s from %.200s port %d ssh2%s%s",
@@ -664,7 +664,7 @@ getpwnamallow(const char *user)
}
#endif
if (pw == NULL) {
- BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL);
+ BLACKLIST_NOTIFY(BLACKLIST_BAD_USER, user);
logit("Invalid user %.100s from %.100s port %d",
user, ssh_remote_ipaddr(ssh), ssh_remote_port(ssh));
#ifdef CUSTOM_FAILED_LOGIN
diff --git a/crypto/openssh/auth1.c b/crypto/openssh/auth1.c
index 71eb0c21b260..189954425ac2 100644
--- a/crypto/openssh/auth1.c
+++ b/crypto/openssh/auth1.c
@@ -338,7 +338,7 @@ do_authloop(Authctxt *authctxt)
char *msg;
size_t len;
- BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL);
+ BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, "ssh");
error("Access denied for user %s by PAM account "
"configuration", authctxt->user);
len = buffer_len(&loginmsg);
@@ -364,6 +364,7 @@ do_authloop(Authctxt *authctxt)
if (authenticated)
return;
+ BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, "ssh");
if (++authctxt->failures >= options.max_authtries) {
#ifdef SSH_AUDIT_EVENTS
PRIVSEP(audit_event(SSH_LOGIN_EXCEED_MAXTRIES));
@@ -406,7 +407,7 @@ do_authentication(Authctxt *authctxt)
else {
debug("do_authentication: invalid user %s", user);
authctxt->pw = fakepw();
- BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL);
+ BLACKLIST_NOTIFY(BLACKLIST_BAD_USER, user);
}
/* Configuration may have changed as a result of Match */
diff --git a/crypto/openssh/auth2.c b/crypto/openssh/auth2.c
index 133b09a43ae0..b6695f79d0aa 100644
--- a/crypto/openssh/auth2.c
+++ b/crypto/openssh/auth2.c
@@ -245,7 +245,6 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
} else {
logit("input_userauth_request: invalid user %s", user);
authctxt->pw = fakepw();
- BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL);
#ifdef SSH_AUDIT_EVENTS
PRIVSEP(audit_event(SSH_INVALID_USER));
#endif
@@ -386,8 +385,10 @@ userauth_finish(Authctxt *authctxt, int authenticated, const char *method,
/* Allow initial try of "none" auth without failure penalty */
if (!partial && !authctxt->server_caused_failure &&
- (authctxt->attempt > 1 || strcmp(method, "none") != 0))
+ (authctxt->attempt > 1 || strcmp(method, "none") != 0)) {
authctxt->failures++;
+ BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, "ssh");
+ }
if (authctxt->failures >= options.max_authtries) {
#ifdef SSH_AUDIT_EVENTS
PRIVSEP(audit_event(SSH_LOGIN_EXCEED_MAXTRIES));
diff --git a/crypto/openssh/blacklist.c b/crypto/openssh/blacklist.c
index 4c9d91dec164..b4f5d3e128c1 100644
--- a/crypto/openssh/blacklist.c
+++ b/crypto/openssh/blacklist.c
@@ -46,8 +46,8 @@
#include "log.h"
#include "misc.h"
#include "servconf.h"
-#include "blacklist_client.h"
#include <blacklist.h>
+#include "blacklist_client.h"
static struct blacklist *blstate = NULL;
@@ -88,10 +88,10 @@ blacklist_init(void)
}
void
-blacklist_notify(int action)
+blacklist_notify(int action, const char *msg)
{
if (blstate != NULL && packet_connection_is_on_socket())
(void)blacklist_r(blstate, action,
- packet_get_connection_in(), "ssh");
+ packet_get_connection_in(), msg);
}
diff --git a/crypto/openssh/blacklist_client.h b/crypto/openssh/blacklist_client.h
index 9479bb27be46..af5a2a6d3c1d 100644
--- a/crypto/openssh/blacklist_client.h
+++ b/crypto/openssh/blacklist_client.h
@@ -34,22 +34,26 @@
#ifndef BLACKLIST_CLIENT_H
#define BLACKLIST_CLIENT_H
+#ifndef BLACKLIST_API_ENUM
enum {
BLACKLIST_AUTH_OK = 0,
- BLACKLIST_AUTH_FAIL
+ BLACKLIST_AUTH_FAIL,
+ BLACKLIST_ABUSIVE_BEHAVIOR,
+ BLACKLIST_BAD_USER
};
+#endif
#ifdef USE_BLACKLIST
void blacklist_init(void);
-void blacklist_notify(int);
+void blacklist_notify(int, const char *);
#define BLACKLIST_INIT() blacklist_init()
-#define BLACKLIST_NOTIFY(x) blacklist_notify(x)
+#define BLACKLIST_NOTIFY(x,msg) blacklist_notify(x,msg)
#else
#define BLACKLIST_INIT()
-#define BLACKLIST_NOTIFY(x)
+#define BLACKLIST_NOTIFY(x,msg)
#endif
diff --git a/crypto/openssh/packet.c b/crypto/openssh/packet.c
index 5db5828749a4..9ef5778baffc 100644
--- a/crypto/openssh/packet.c
+++ b/crypto/openssh/packet.c
@@ -2104,7 +2104,7 @@ sshpkt_fatal(struct ssh *ssh, const char *tag, int r)
case SSH_ERR_NO_KEX_ALG_MATCH:
case SSH_ERR_NO_HOSTKEY_ALG_MATCH:
if (ssh && ssh->kex && ssh->kex->failed_choice) {
- BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL);
+ BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, "ssh");
logdie("Unable to negotiate with %.200s port %d: %s. "
"Their offer: %s", ssh_remote_ipaddr(ssh),
ssh_remote_port(ssh), ssh_err(r),
diff --git a/crypto/openssh/sshd.c b/crypto/openssh/sshd.c
index 57090d6d51a0..50d3701e78b2 100644
--- a/crypto/openssh/sshd.c
+++ b/crypto/openssh/sshd.c
@@ -371,7 +371,7 @@ grace_alarm_handler(int sig)
kill(0, SIGTERM);
}
- BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL);
+ BLACKLIST_NOTIFY(BLACKLIST_AUTH_FAIL, "ssh");
/* Log error and exit. */
sigdie("Timeout before authentication for %s port %d",
diff --git a/etc/Makefile b/etc/Makefile
index 153e56787632..8bfeac2b6b96 100644
--- a/etc/Makefile
+++ b/etc/Makefile
@@ -8,7 +8,8 @@ FILESGROUPS= FILES
# No need as it is empty and just causes rebuilds since this file does so much.
UPDATE_DEPENDFILE= no
SUBDIR= \
- newsyslog.conf.d
+ newsyslog.conf.d \
+ syslog.d
.if ${MK_SENDMAIL} != "no"
SUBDIR+=sendmail
diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist
index 52f4b00aaa91..f3861c801b3c 100644
--- a/etc/mtree/BSD.tests.dist
+++ b/etc/mtree/BSD.tests.dist
@@ -650,6 +650,8 @@
..
printf
..
+ procstat
+ ..
sdiff
..
sed
diff --git a/etc/newsyslog.conf b/etc/newsyslog.conf
index 7a969691a8bf..9982f91dfc11 100644
--- a/etc/newsyslog.conf
+++ b/etc/newsyslog.conf
@@ -18,7 +18,6 @@
#
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/all.log 600 7 * @T00 J
-/var/log/amd.log 644 7 1000 * J
/var/log/auth.log 600 7 1000 @0101T JC
/var/log/console.log 600 5 1000 * J
/var/log/cron 600 3 1000 * JC
@@ -26,18 +25,13 @@
/var/log/debug.log 600 7 1000 * JC
/var/log/init.log 644 3 1000 * J
/var/log/kerberos.log 600 7 1000 * J
-/var/log/lpd-errs 644 7 1000 * JC
/var/log/maillog 640 7 * @T00 JC
/var/log/messages 644 5 1000 @0101T JC
/var/log/monthly.log 640 12 * $M1D0 JN
-/var/log/pflog 600 3 1000 * JB /var/run/pflogd.pid
-/var/log/ppp.log root:network 640 3 1000 * JC
/var/log/devd.log 644 3 1000 * JC
/var/log/security 600 10 1000 * JC
-/var/log/sendmail.st 640 10 * 168 BN
/var/log/utx.log 644 3 * @01T05 B
/var/log/weekly.log 640 5 * $W6D0 JN
-/var/log/xferlog 600 7 1000 * JC
<include> /etc/newsyslog.conf.d/*
<include> /usr/local/etc/newsyslog.conf.d/*
diff --git a/etc/newsyslog.conf.d/Makefile b/etc/newsyslog.conf.d/Makefile
index c2574b74c432..a831f3d2c6f6 100644
--- a/etc/newsyslog.conf.d/Makefile
+++ b/etc/newsyslog.conf.d/Makefile
@@ -6,8 +6,32 @@ BINDIR= /etc/newsyslog.conf.d
FILES=
+.if ${MK_AMD} != "no"
+FILES+= amd.conf
+.endif
+
+.if ${MK_FTP} != "no"
+FILES+= ftp.conf
+.endif
+
+.if ${MK_LPR} != "no"
+FILES+= lpr.conf
+.endif
+
.if ${MK_OFED} != "no"
FILES+= opensm.conf
.endif
+.if ${MK_PF} != "no"
+FILES+= pf.conf
+.endif
+
+.if ${MK_PPP} != "no"
+FILES+= ppp.conf
+.endif
+
+.if ${MK_SENDMAIL} != "no"
+FILES+= sendmail.conf
+.endif
+
.include <bsd.prog.mk>
diff --git a/etc/newsyslog.conf.d/amd.conf b/etc/newsyslog.conf.d/amd.conf
new file mode 100644
index 000000000000..329652dd5135
--- /dev/null
+++ b/etc/newsyslog.conf.d/amd.conf
@@ -0,0 +1,2 @@
+# $FreeBSD$
+/var/log/amd.log 644 7 1000 * J
diff --git a/etc/newsyslog.conf.d/ftp.conf b/etc/newsyslog.conf.d/ftp.conf
new file mode 100644
index 000000000000..c12e24d7066f
--- /dev/null
+++ b/etc/newsyslog.conf.d/ftp.conf
@@ -0,0 +1,2 @@
+# $FreeBSD$
+/var/log/xferlog 600 7 1000 * JC
diff --git a/etc/newsyslog.conf.d/lpr.conf b/etc/newsyslog.conf.d/lpr.conf
new file mode 100644
index 000000000000..5febb309c6ec
--- /dev/null
+++ b/etc/newsyslog.conf.d/lpr.conf
@@ -0,0 +1,2 @@
+# $FreeBSD$
+/var/log/lpd-errs 644 7 1000 * JC
diff --git a/etc/newsyslog.conf.d/pf.conf b/etc/newsyslog.conf.d/pf.conf
new file mode 100644
index 000000000000..7c41c816c1ff
--- /dev/null
+++ b/etc/newsyslog.conf.d/pf.conf
@@ -0,0 +1,2 @@
+# $FreeBSD$
+/var/log/pflog 600 3 1000 * JB /var/run/pflogd.pid
diff --git a/etc/newsyslog.conf.d/ppp.conf b/etc/newsyslog.conf.d/ppp.conf
new file mode 100644
index 000000000000..198579dae27a
--- /dev/null
+++ b/etc/newsyslog.conf.d/ppp.conf
@@ -0,0 +1,2 @@
+# $FreeBSD$
+/var/log/ppp.log root:network 640 3 1000 * JC
diff --git a/etc/newsyslog.conf.d/sendmail.conf b/etc/newsyslog.conf.d/sendmail.conf
new file mode 100644
index 000000000000..5cb59c4e8c18
--- /dev/null
+++ b/etc/newsyslog.conf.d/sendmail.conf
@@ -0,0 +1,2 @@
+# $FreeBSD$
+/var/log/sendmail.st 640 10 * 168 BN
diff --git a/etc/syslog.conf b/etc/syslog.conf
index a137bdcae65f..e0df421b9021 100644
--- a/etc/syslog.conf
+++ b/etc/syslog.conf
@@ -10,8 +10,6 @@
security.* /var/log/security
auth.info;authpriv.info /var/log/auth.log
mail.info /var/log/maillog
-lpr.info /var/log/lpd-errs
-ftp.info /var/log/xferlog
cron.* /var/log/cron
!-devd
*.=debug /var/log/debug.log
@@ -31,8 +29,6 @@ cron.* /var/log/cron
# Uncomment this if you wish to see messages produced by devd
# !devd
# *.>=notice /var/log/devd.log
-!ppp
-*.* /var/log/ppp.log
!*
include /etc/syslog.d
include /usr/local/etc/syslog.d
diff --git a/etc/syslog.d/Makefile b/etc/syslog.d/Makefile
new file mode 100644
index 000000000000..56047ed2bfba
--- /dev/null
+++ b/etc/syslog.d/Makefile
@@ -0,0 +1,19 @@
+# $FreeBSD$
+
+.include <src.opts.mk>
+
+.if ${MK_FTP} != "no"
+FILES+= ftp.conf
+.endif
+
+.if ${MK_LPR} != "no"
+FILES+= lpr.conf
+.endif
+
+.if ${MK_PPP} != "no"
+FILES+= ppp.conf
+.endif
+
+BINDIR= /etc/syslog.d
+
+.include <bsd.prog.mk>
diff --git a/etc/syslog.d/ftp.conf b/etc/syslog.d/ftp.conf
new file mode 100644
index 000000000000..d4d11cfb7a65
--- /dev/null
+++ b/etc/syslog.d/ftp.conf
@@ -0,0 +1,2 @@
+# $FreeBSD$
+ftp.info /var/log/xferlog
diff --git a/etc/syslog.d/lpr.conf b/etc/syslog.d/lpr.conf
new file mode 100644
index 000000000000..0eb6eb06db2a
--- /dev/null
+++ b/etc/syslog.d/lpr.conf
@@ -0,0 +1,2 @@
+# $FreeBSD$
+lpr.info /var/log/lpd-errs
diff --git a/etc/syslog.d/ppp.conf b/etc/syslog.d/ppp.conf
new file mode 100644
index 000000000000..57ee868bd142
--- /dev/null
+++ b/etc/syslog.d/ppp.conf
@@ -0,0 +1,3 @@
+# $FreeBSD$
+!ppp
+*.* /var/log/ppp.log
diff --git a/lib/libbsnmp/libbsnmp/Makefile.depend b/lib/libbsnmp/libbsnmp/Makefile.depend
index fc0b63320671..f318cc1a6b40 100644
--- a/lib/libbsnmp/libbsnmp/Makefile.depend
+++ b/lib/libbsnmp/libbsnmp/Makefile.depend
@@ -5,6 +5,7 @@ DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \
include \
+ include/arpa \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
diff --git a/lib/libc/gen/getusershell.c b/lib/libc/gen/getusershell.c
index 56659709ba19..810a19af837c 100644
--- a/lib/libc/gen/getusershell.c
+++ b/lib/libc/gen/getusershell.c
@@ -115,8 +115,8 @@ _local_initshells(void *rv, void *cb_data, va_list ap)
if ((fp = fopen(_PATH_SHELLS, "re")) == NULL)
return NS_UNAVAIL;
- cp = line;
- while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) {
+ while (fgets(line, MAXPATHLEN + 1, fp) != NULL) {
+ cp = line;
while (*cp != '#' && *cp != '/' && *cp != '\0')
cp++;
if (*cp == '#' || *cp == '\0')
@@ -124,7 +124,7 @@ _local_initshells(void *rv, void *cb_data, va_list ap)
sp = cp;
while (!isspace(*cp) && *cp != '#' && *cp != '\0')
cp++;
- *cp++ = '\0';
+ *cp = '\0';
sl_add(sl, strdup(sp));
}
(void)fclose(fp);
diff --git a/lib/libc/stdlib/realpath.c b/lib/libc/stdlib/realpath.c
index c4bd953e928b..d19f641cfdee 100644
--- a/lib/libc/stdlib/realpath.c
+++ b/lib/libc/stdlib/realpath.c
@@ -47,31 +47,16 @@ __FBSDID("$FreeBSD$");
* components. Returns (resolved) on success, or (NULL) on failure,
* in which case the path which caused trouble is left in (resolved).
*/
-char *
-realpath(const char * __restrict path, char * __restrict resolved)
+static char *
+realpath1(const char *path, char *resolved)
{
struct stat sb;
- char *p, *q, *s;
- size_t left_len, resolved_len;
+ char *p, *q;
+ size_t left_len, resolved_len, next_token_len;
unsigned symlinks;
- int m, slen;
+ ssize_t slen;
char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX];
- if (path == NULL) {
- errno = EINVAL;
- return (NULL);
- }
- if (path[0] == '\0') {
- errno = ENOENT;
- return (NULL);
- }
- if (resolved == NULL) {
- resolved = malloc(PATH_MAX);
- if (resolved == NULL)
- return (NULL);
- m = 1;
- } else
- m = 0;
symlinks = 0;
if (path[0] == '/') {
resolved[0] = '/';
@@ -82,20 +67,14 @@ realpath(const char * __restrict path, char * __restrict resolved)
left_len = strlcpy(left, path + 1, sizeof(left));
} else {
if (getcwd(resolved, PATH_MAX) == NULL) {
- if (m)
- free(resolved);
- else {
- resolved[0] = '.';
- resolved[1] = '\0';
- }
+ resolved[0] = '.';
+ resolved[1] = '\0';
return (NULL);
}
resolved_len = strlen(resolved);
left_len = strlcpy(left, path, sizeof(left));
}
if (left_len >= sizeof(left) || resolved_len >= PATH_MAX) {
- if (m)
- free(resolved);
errno = ENAMETOOLONG;
return (NULL);
}
@@ -109,22 +88,21 @@ realpath(const char * __restrict path, char * __restrict resolved)
* and its length.
*/
p = strchr(left, '/');
- s = p ? p : left + left_len;
- if (s - left >= sizeof(next_token)) {
- if (m)
- free(resolved);
- errno = ENAMETOOLONG;
- return (NULL);
+
+ next_token_len = p != NULL ? p - left : left_len;
+ memcpy(next_token, left, next_token_len);
+ next_token[next_token_len] = '\0';
+
+ if (p != NULL) {
+ left_len -= next_token_len + 1;
+ memmove(left, p + 1, left_len + 1);
+ } else {
+ left[0] = '\0';
+ left_len = 0;
}
- memcpy(next_token, left, s - left);
- next_token[s - left] = '\0';
- left_len -= s - left;
- if (p != NULL)
- memmove(left, s + 1, left_len + 1);
+
if (resolved[resolved_len - 1] != '/') {
if (resolved_len + 1 >= PATH_MAX) {
- if (m)
- free(resolved);
errno = ENAMETOOLONG;
return (NULL);
}
@@ -134,10 +112,9 @@ realpath(const char * __restrict path, char * __restrict resolved)
if (next_token[0] == '\0') {
/* Handle consequential slashes. */
continue;
- }
- else if (strcmp(next_token, ".") == 0)
+ } else if (strcmp(next_token, ".") == 0) {
continue;
- else if (strcmp(next_token, "..") == 0) {
+ } else if (strcmp(next_token, "..") == 0) {
/*
* Strip the last path component except when we have
* single "/"
@@ -156,36 +133,32 @@ realpath(const char * __restrict path, char * __restrict resolved)
*/
resolved_len = strlcat(resolved, next_token, PATH_MAX);
if (resolved_len >= PATH_MAX) {
- if (m)
- free(resolved);
errno = ENAMETOOLONG;
return (NULL);
}
- if (lstat(resolved, &sb) != 0) {
- if (m)
- free(resolved);
+ if (lstat(resolved, &sb) != 0)
return (NULL);
- }
if (S_ISLNK(sb.st_mode)) {
if (symlinks++ > MAXSYMLINKS) {
- if (m)
- free(resolved);
errno = ELOOP;
return (NULL);
}
- slen = readlink(resolved, symlink, sizeof(symlink) - 1);
- if (slen < 0) {
- if (m)
- free(resolved);
+ slen = readlink(resolved, symlink, sizeof(symlink));
+ if (slen <= 0 || slen >= sizeof(symlink)) {
+ if (slen < 0)
+ ; /* keep errno from readlink(2) call */
+ else if (slen == 0)
+ errno = ENOENT;
+ else
+ errno = ENAMETOOLONG;
return (NULL);
}
symlink[slen] = '\0';
if (symlink[0] == '/') {
resolved[1] = 0;
resolved_len = 1;
- } else if (resolved_len > 1) {
+ } else {
/* Strip the last path component. */
- resolved[resolved_len - 1] = '\0';
q = strrchr(resolved, '/') + 1;
*q = '\0';
resolved_len = q - resolved;
@@ -199,8 +172,6 @@ realpath(const char * __restrict path, char * __restrict resolved)
if (p != NULL) {
if (symlink[slen - 1] != '/') {
if (slen + 1 >= sizeof(symlink)) {
- if (m)
- free(resolved);
errno = ENAMETOOLONG;
return (NULL);
}
@@ -209,17 +180,13 @@ realpath(const char * __restrict path, char * __restrict resolved)
}
left_len = strlcat(symlink, left,
sizeof(symlink));
- if (left_len >= sizeof(left)) {
- if (m)
- free(resolved);
+ if (left_len >= sizeof(symlink)) {
errno = ENAMETOOLONG;
return (NULL);
}
}
left_len = strlcpy(left, symlink, sizeof(left));
} else if (!S_ISDIR(sb.st_mode) && p != NULL) {
- if (m)
- free(resolved);
errno = ENOTDIR;
return (NULL);
}
@@ -233,3 +200,29 @@ realpath(const char * __restrict path, char * __restrict resolved)
resolved[resolved_len - 1] = '\0';
return (resolved);
}
+
+char *
+realpath(const char * __restrict path, char * __restrict resolved)
+{
+ char *m, *res;
+
+ if (path == NULL) {
+ errno = EINVAL;
+ return (NULL);
+ }
+ if (path[0] == '\0') {
+ errno = ENOENT;
+ return (NULL);
+ }
+ if (resolved != NULL) {
+ m = NULL;
+ } else {
+ m = resolved = malloc(PATH_MAX);
+ if (resolved == NULL)
+ return (NULL);
+ }
+ res = realpath1(path, resolved);
+ if (res == NULL)
+ free(m);
+ return (res);
+}
diff --git a/lib/libc/sys/open.2 b/lib/libc/sys/open.2
index 3a02e56f6050..5fae5c63dfe3 100644
--- a/lib/libc/sys/open.2
+++ b/lib/libc/sys/open.2
@@ -141,6 +141,7 @@ O_NOCTTY ignored
O_TTY_INIT ignored
O_DIRECTORY error if file is not a directory
O_CLOEXEC set FD_CLOEXEC upon open
+O_VERIFY verify the contents of the file
.Ed
.Pp
Opening a file with
@@ -259,6 +260,15 @@ may be used to set
.Dv FD_CLOEXEC
flag for the newly returned file descriptor.
.Pp
+.Dv O_VERIFY
+may be used to indicate to the kernel that the contents of the file should
+be verified before allowing the open to proceed.
+The details of what
+.Dq verified
+means is implementation specific.
+The run-time linker (rtld) uses this flag to ensure shared objects have
+been verified before operating on them.
+.Pp
If successful,
.Fn open
returns a non-negative integer, termed a file descriptor.
diff --git a/lib/libmt/mtlib.c b/lib/libmt/mtlib.c
index a36b9bfbb278..e3f39fe3ab50 100644
--- a/lib/libmt/mtlib.c
+++ b/lib/libmt/mtlib.c
@@ -644,6 +644,7 @@ static struct densities {
{ 0x58, 15142, 384607, "LTO-5" },
{ 0x5A, 15142, 384607, "LTO-6" },
{ 0x5C, 19107, 485318, "LTO-7" },
+ { 0x5E, 20669, 524993, "LTO-8" },
{ 0x71, 11800, 299720, "3592A1 (encrypted)" },
{ 0x72, 11800, 299720, "3592A2 (encrypted)" },
{ 0x73, 13452, 341681, "3592A3 (encrypted)" },
diff --git a/lib/libstand/Makefile b/lib/libstand/Makefile
index 853db97aa4b7..188507492805 100644
--- a/lib/libstand/Makefile
+++ b/lib/libstand/Makefile
@@ -141,7 +141,7 @@ SRCS+= closeall.c dev.c ioctl.c nullfs.c stat.c \
fstat.c close.c lseek.c open.c read.c write.c readdir.c
# network routines
-SRCS+= arp.c ether.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
+SRCS+= arp.c ether.c ip.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
# network info services:
SRCS+= bootp.c rarp.c bootparam.c
diff --git a/lib/libstand/ip.c b/lib/libstand/ip.c
new file mode 100644
index 000000000000..541cabc4bdd8
--- /dev/null
+++ b/lib/libstand/ip.c
@@ -0,0 +1,422 @@
+/*
+ * Copyright (c) 1992 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/*
+ * The send and receive functions were originally implemented in udp.c and
+ * moved here. Also it is likely some more cleanup can be done, especially
+ * once we will implement the support for tcp.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <sys/queue.h>
+
+#include <string.h>
+
+#include <net/if.h>
+#include <netinet/in.h>
+#include <netinet/if_ether.h>
+#include <netinet/in_systm.h>
+
+#include <netinet/in_pcb.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+
+#include "stand.h"
+#include "net.h"
+
+typedef STAILQ_HEAD(ipqueue, ip_queue) ip_queue_t;
+struct ip_queue {
+ void *ipq_pkt;
+ struct ip *ipq_hdr;
+ STAILQ_ENTRY(ip_queue) ipq_next;
+};
+
+/*
+ * Fragment re-assembly queue.
+ */
+struct ip_reasm {
+ struct in_addr ip_src;
+ struct in_addr ip_dst;
+ uint16_t ip_id;
+ uint8_t ip_proto;
+ uint8_t ip_ttl;
+ size_t ip_total_size;
+ ip_queue_t ip_queue;
+ void *ip_pkt;
+ struct ip *ip_hdr;
+ STAILQ_ENTRY(ip_reasm) ip_next;
+};
+
+STAILQ_HEAD(ire_list, ip_reasm) ire_list = STAILQ_HEAD_INITIALIZER(ire_list);
+
+/* Caller must leave room for ethernet and ip headers in front!! */
+ssize_t
+sendip(struct iodesc *d, void *pkt, size_t len, uint8_t proto)
+{
+ ssize_t cc;
+ struct ip *ip;
+ u_char *ea;
+
+#ifdef NET_DEBUG
+ if (debug) {
+ printf("sendip: proto: %x d=%p called.\n", proto, (void *)d);
+ if (d) {
+ printf("saddr: %s:%d",
+ inet_ntoa(d->myip), ntohs(d->myport));
+ printf(" daddr: %s:%d\n",
+ inet_ntoa(d->destip), ntohs(d->destport));
+ }
+ }
+#endif
+
+ ip = (struct ip *)pkt - 1;
+ len += sizeof(*ip);
+
+ bzero(ip, sizeof(*ip));
+
+ ip->ip_v = IPVERSION; /* half-char */
+ ip->ip_hl = sizeof(*ip) >> 2; /* half-char */
+ ip->ip_len = htons(len);
+ ip->ip_p = proto; /* char */
+ ip->ip_ttl = IPDEFTTL; /* char */
+ ip->ip_src = d->myip;
+ ip->ip_dst = d->destip;
+ ip->ip_sum = in_cksum(ip, sizeof(*ip)); /* short, but special */
+
+ if (ip->ip_dst.s_addr == INADDR_BROADCAST || ip->ip_src.s_addr == 0 ||
+ netmask == 0 || SAMENET(ip->ip_src, ip->ip_dst, netmask))
+ ea = arpwhohas(d, ip->ip_dst);
+ else
+ ea = arpwhohas(d, gateip);
+
+ cc = sendether(d, ip, len, ea, ETHERTYPE_IP);
+ if (cc == -1)
+ return (-1);
+ if (cc != len)
+ panic("sendip: bad write (%zd != %zd)", cc, len);
+ return (cc - sizeof(*ip));
+}
+
+static void
+ip_reasm_free(struct ip_reasm *ipr)
+{
+ struct ip_queue *ipq;
+
+ while ((ipq = STAILQ_FIRST(&ipr->ip_queue)) != NULL) {
+ STAILQ_REMOVE_HEAD(&ipr->ip_queue, ipq_next);
+ free(ipq->ipq_pkt);
+ free(ipq);
+ }
+ free(ipr->ip_pkt);
+ free(ipr);
+}
+
+static int
+ip_reasm_add(struct ip_reasm *ipr, void *pkt, struct ip *ip)
+{
+ struct ip_queue *ipq, *prev, *p;
+
+ if ((ipq = calloc(1, sizeof (*ipq))) == NULL)
+ return (1);
+
+ ipq->ipq_pkt = pkt;
+ ipq->ipq_hdr = ip;
+
+ prev = NULL;
+ STAILQ_FOREACH(p, &ipr->ip_queue, ipq_next) {
+ if ((ntohs(p->ipq_hdr->ip_off) & IP_OFFMASK) <
+ (ntohs(ip->ip_off) & IP_OFFMASK)) {
+ prev = p;
+ continue;
+ }
+ if (prev == NULL)
+ break;
+
+ STAILQ_INSERT_AFTER(&ipr->ip_queue, prev, ipq, ipq_next);
+ return (0);
+ }
+ STAILQ_INSERT_HEAD(&ipr->ip_queue, ipq, ipq_next);
+ return (0);
+}
+
+/*
+ * Receive a IP packet and validate it is for us.
+ */
+static ssize_t
+readipv4(struct iodesc *d, void **pkt, void **payload, time_t tleft,
+ uint8_t proto)
+{
+ ssize_t n;
+ size_t hlen;
+ struct ether_header *eh;
+ struct ip *ip;
+ struct udphdr *uh;
+ uint16_t etype; /* host order */
+ char *ptr;
+ struct ip_reasm *ipr;
+ struct ip_queue *ipq, *last;
+
+#ifdef NET_DEBUG
+ if (debug)
+ printf("readip: called\n");
+#endif
+
+ ip = NULL;
+ ptr = NULL;
+ n = readether(d, (void **)&ptr, (void **)&ip, tleft, &etype);
+ if (n == -1 || n < sizeof(*ip) + sizeof(*uh)) {
+ free(ptr);
+ return (-1);
+ }
+
+ /* Ethernet address checks now in readether() */
+
+ /* Need to respond to ARP requests. */
+ if (etype == ETHERTYPE_ARP) {
+ struct arphdr *ah = (void *)ip;
+ if (ah->ar_op == htons(ARPOP_REQUEST)) {
+ /* Send ARP reply */
+ arp_reply(d, ah);
+ }
+ free(ptr);
+ errno = EAGAIN; /* Call me again. */
+ return (-1);
+ }
+
+ if (etype != ETHERTYPE_IP) {
+#ifdef NET_DEBUG
+ if (debug)
+ printf("readip: not IP. ether_type=%x\n", etype);
+#endif
+ free(ptr);
+ return (-1);
+ }
+
+ /* Check ip header */
+ if (ip->ip_v != IPVERSION ||
+ ip->ip_p != proto) { /* half char */
+#ifdef NET_DEBUG
+ if (debug) {
+ printf("readip: IP version or proto. ip_v=%d ip_p=%d\n",
+ ip->ip_v, ip->ip_p);
+ }
+#endif
+ free(ptr);
+ return (-1);
+ }
+
+ hlen = ip->ip_hl << 2;
+ if (hlen < sizeof(*ip) ||
+ in_cksum(ip, hlen) != 0) {
+#ifdef NET_DEBUG
+ if (debug)
+ printf("readip: short hdr or bad cksum.\n");
+#endif
+ free(ptr);
+ return (-1);
+ }
+ if (n < ntohs(ip->ip_len)) {
+#ifdef NET_DEBUG
+ if (debug)
+ printf("readip: bad length %d < %d.\n",
+ (int)n, ntohs(ip->ip_len));
+#endif
+ free(ptr);
+ return (-1);
+ }
+ if (d->myip.s_addr && ip->ip_dst.s_addr != d->myip.s_addr) {
+#ifdef NET_DEBUG
+ if (debug) {
+ printf("readip: bad saddr %s != ", inet_ntoa(d->myip));
+ printf("%s\n", inet_ntoa(ip->ip_dst));
+ }
+#endif
+ free(ptr);
+ return (-1);
+ }
+
+ /* Unfragmented packet. */
+ if ((ntohs(ip->ip_off) & IP_MF) == 0 &&
+ (ntohs(ip->ip_off) & IP_OFFMASK) == 0) {
+ uh = (struct udphdr *)((uintptr_t)ip + sizeof (*ip));
+ /* If there were ip options, make them go away */
+ if (hlen != sizeof(*ip)) {
+ bcopy(((u_char *)ip) + hlen, uh, uh->uh_ulen - hlen);
+ ip->ip_len = htons(sizeof(*ip));
+ n -= hlen - sizeof(*ip);
+ }
+
+ n = (n > (ntohs(ip->ip_len) - sizeof(*ip))) ?
+ ntohs(ip->ip_len) - sizeof(*ip) : n;
+ *pkt = ptr;
+ *payload = (void *)((uintptr_t)ip + sizeof(*ip));
+ return (n);
+ }
+
+ STAILQ_FOREACH(ipr, &ire_list, ip_next) {
+ if (ipr->ip_src.s_addr == ip->ip_src.s_addr &&
+ ipr->ip_dst.s_addr == ip->ip_dst.s_addr &&
+ ipr->ip_id == ip->ip_id &&
+ ipr->ip_proto == ip->ip_p)
+ break;
+ }
+
+ /* Allocate new reassembly entry */
+ if (ipr == NULL) {
+ if ((ipr = calloc(1, sizeof (*ipr))) == NULL) {
+ free(ptr);
+ return (-1);
+ }
+
+ ipr->ip_src = ip->ip_src;
+ ipr->ip_dst = ip->ip_dst;
+ ipr->ip_id = ip->ip_id;
+ ipr->ip_proto = ip->ip_p;
+ ipr->ip_ttl = MAXTTL;
+ STAILQ_INIT(&ipr->ip_queue);
+ STAILQ_INSERT_TAIL(&ire_list, ipr, ip_next);
+ }
+
+ if (ip_reasm_add(ipr, ptr, ip) != 0) {
+ STAILQ_REMOVE(&ire_list, ipr, ip_reasm, ip_next);
+ free(ipr);
+ free(ptr);
+ return (-1);
+ }
+
+ if ((ntohs(ip->ip_off) & IP_MF) == 0) {
+ ipr->ip_total_size = (8 * (ntohs(ip->ip_off) & IP_OFFMASK));
+ ipr->ip_total_size += n + sizeof (*ip);
+ ipr->ip_total_size += sizeof (struct ether_header);
+
+ ipr->ip_pkt = malloc(ipr->ip_total_size + 2);
+ if (ipr->ip_pkt == NULL) {
+ STAILQ_REMOVE(&ire_list, ipr, ip_reasm, ip_next);
+ ip_reasm_free(ipr);
+ return (-1);
+ }
+ }
+
+ /*
+ * If we do not have re-assembly buffer ipr->ip_pkt, we are still
+ * missing fragments, so just restart the read.
+ */
+ if (ipr->ip_pkt == NULL) {
+ errno = EAGAIN;
+ return (-1);
+ }
+
+ /*
+ * Walk the packet list in reassembly queue, if we got all the
+ * fragments, build the packet.
+ */
+ n = 0;
+ last = NULL;
+ STAILQ_FOREACH(ipq, &ipr->ip_queue, ipq_next) {
+ if ((ntohs(ipq->ipq_hdr->ip_off) & IP_OFFMASK) != n / 8) {
+ errno = EAGAIN;
+ return (-1);
+ }
+
+ n += ntohs(ipq->ipq_hdr->ip_len) - (ipq->ipq_hdr->ip_hl << 2);
+ last = ipq;
+ }
+ if ((ntohs(last->ipq_hdr->ip_off) & IP_MF) != 0) {
+ errno = EAGAIN;
+ return (-1);
+ }
+
+ ipq = STAILQ_FIRST(&ipr->ip_queue);
+ /* Fabricate ethernet header */
+ eh = (struct ether_header *)((uintptr_t)ipr->ip_pkt + 2);
+ bcopy((void *)((uintptr_t)ipq->ipq_pkt + 2), eh, sizeof (*eh));
+
+ /* Fabricate IP header */
+ ipr->ip_hdr = (struct ip *)((uintptr_t)eh + sizeof (*eh));
+ bcopy(ipq->ipq_hdr, ipr->ip_hdr, sizeof (*ipr->ip_hdr));
+ ipr->ip_hdr->ip_hl = sizeof (*ipr->ip_hdr) >> 2;
+ ipr->ip_hdr->ip_len = htons(n);
+ ipr->ip_hdr->ip_sum = 0;
+ ipr->ip_hdr->ip_sum = in_cksum(ipr->ip_hdr, sizeof (*ipr->ip_hdr));
+
+ n = 0;
+ ptr = (char *)((uintptr_t)ipr->ip_hdr + sizeof (*ipr->ip_hdr));
+ STAILQ_FOREACH(ipq, &ipr->ip_queue, ipq_next) {
+ char *data;
+ size_t len;
+
+ hlen = ipq->ipq_hdr->ip_hl << 2;
+ len = ntohs(ipq->ipq_hdr->ip_len) - hlen;
+ data = (char *)((uintptr_t)ipq->ipq_hdr + hlen);
+
+ bcopy(data, ptr + n, len);
+ n += len;
+ }
+
+ *pkt = ipr->ip_pkt;
+ ipr->ip_pkt = NULL; /* Avoid free from ip_reasm_free() */
+ *payload = ptr;
+
+ /* Clean up the reassembly list */
+ while ((ipr = STAILQ_FIRST(&ire_list)) != NULL) {
+ STAILQ_REMOVE_HEAD(&ire_list, ip_next);
+ ip_reasm_free(ipr);
+ }
+ return (n);
+}
+
+/*
+ * Receive a IP packet.
+ */
+ssize_t
+readip(struct iodesc *d, void **pkt, void **payload, time_t tleft,
+ uint8_t proto)
+{
+ time_t t;
+ ssize_t ret = -1;
+
+ t = getsecs();
+ while ((getsecs() - t) < tleft) {
+ errno = 0;
+ ret = readipv4(d, pkt, payload, tleft, proto);
+ if (errno != EAGAIN)
+ break;
+ }
+ return (ret);
+}
diff --git a/lib/libstand/net.h b/lib/libstand/net.h
index 740b5d970f87..dc2538ca65b7 100644
--- a/lib/libstand/net.h
+++ b/lib/libstand/net.h
@@ -108,6 +108,8 @@ ssize_t sendether(struct iodesc *d, void *pkt, size_t len,
u_char *dea, int etype);
ssize_t readether(struct iodesc *, void **, void **, time_t, uint16_t *);
+ssize_t sendip(struct iodesc *, void *, size_t, uint8_t);
+ssize_t readip(struct iodesc *, void **, void **, time_t, uint8_t);
ssize_t sendudp(struct iodesc *, void *, size_t);
ssize_t readudp(struct iodesc *, void **, void **, time_t);
ssize_t sendrecv(struct iodesc *,
diff --git a/lib/libstand/nfs.c b/lib/libstand/nfs.c
index 6c387b8d8ef7..322acb8d5275 100644
--- a/lib/libstand/nfs.c
+++ b/lib/libstand/nfs.c
@@ -52,7 +52,7 @@ __FBSDID("$FreeBSD$");
#define NFS_DEBUGxx
#define NFSREAD_MIN_SIZE 1024
-#define NFSREAD_MAX_SIZE 4096
+#define NFSREAD_MAX_SIZE 16384
/* NFSv3 definitions */
#define NFS_V3MAXFHSIZE 64
diff --git a/lib/libstand/rarp.c b/lib/libstand/rarp.c
index 8d996d04a3f6..b7e3ea486079 100644
--- a/lib/libstand/rarp.c
+++ b/lib/libstand/rarp.c
@@ -155,7 +155,7 @@ rarprecv(struct iodesc *d, void **pkt, void **payload, time_t tleft)
printf("rarprecv: ");
#endif
- n = readether(d, ptr, (void **)&ap, tleft, &etype);
+ n = readether(d, &ptr, (void **)&ap, tleft, &etype);
errno = 0; /* XXX */
if (n == -1 || n < sizeof(struct ether_arp)) {
#ifdef RARP_DEBUG
diff --git a/lib/libstand/udp.c b/lib/libstand/udp.c
index 2eba7a18eefc..02ac62571fb7 100644
--- a/lib/libstand/udp.c
+++ b/lib/libstand/udp.c
@@ -62,9 +62,8 @@ ssize_t
sendudp(struct iodesc *d, void *pkt, size_t len)
{
ssize_t cc;
- struct ip *ip;
+ struct udpiphdr *ui;
struct udphdr *uh;
- u_char *ea;
#ifdef NET_DEBUG
if (debug) {
@@ -78,52 +77,31 @@ sendudp(struct iodesc *d, void *pkt, size_t len)
}
#endif
- uh = (struct udphdr *)pkt - 1;
- ip = (struct ip *)uh - 1;
- len += sizeof(*ip) + sizeof(*uh);
-
- bzero(ip, sizeof(*ip) + sizeof(*uh));
+ ui = (struct udpiphdr *)pkt - 1;
+ bzero(ui, sizeof(*ui));
- ip->ip_v = IPVERSION; /* half-char */
- ip->ip_hl = sizeof(*ip) >> 2; /* half-char */
- ip->ip_len = htons(len);
- ip->ip_p = IPPROTO_UDP; /* char */
- ip->ip_ttl = IPDEFTTL; /* char */
- ip->ip_src = d->myip;
- ip->ip_dst = d->destip;
- ip->ip_sum = in_cksum(ip, sizeof(*ip)); /* short, but special */
+ uh = (struct udphdr *)pkt - 1;
+ len += sizeof(*uh);
uh->uh_sport = d->myport;
uh->uh_dport = d->destport;
- uh->uh_ulen = htons(len - sizeof(*ip));
+ uh->uh_ulen = htons(len);
-#ifndef UDP_NO_CKSUM
- {
- struct udpiphdr *ui;
- struct ip tip;
+ ui->ui_pr = IPPROTO_UDP;
+ ui->ui_len = uh->uh_ulen;
+ ui->ui_src = d->myip;
+ ui->ui_dst = d->destip;
- /* Calculate checksum (must save and restore ip header) */
- tip = *ip;
- ui = (struct udpiphdr *)ip;
- bzero(&ui->ui_x1, sizeof(ui->ui_x1));
- ui->ui_len = uh->uh_ulen;
- uh->uh_sum = in_cksum(ui, len);
- *ip = tip;
- }
+#ifndef UDP_NO_CKSUM
+ uh->uh_sum = in_cksum(ui, len + sizeof (struct ip));
#endif
- if (ip->ip_dst.s_addr == INADDR_BROADCAST || ip->ip_src.s_addr == 0 ||
- netmask == 0 || SAMENET(ip->ip_src, ip->ip_dst, netmask))
- ea = arpwhohas(d, ip->ip_dst);
- else
- ea = arpwhohas(d, gateip);
-
- cc = sendether(d, ip, len, ea, ETHERTYPE_IP);
+ cc = sendip(d, uh, len, IPPROTO_UDP);
if (cc == -1)
return (-1);
if (cc != len)
panic("sendudp: bad write (%zd != %zd)", cc, len);
- return (cc - (sizeof(*ip) + sizeof(*uh)));
+ return (cc - sizeof(*uh));
}
/*
@@ -133,10 +111,7 @@ ssize_t
readudp(struct iodesc *d, void **pkt, void **payload, time_t tleft)
{
ssize_t n;
- size_t hlen;
- struct ip *ip;
struct udphdr *uh;
- uint16_t etype; /* host order */
void *ptr;
#ifdef NET_DEBUG
@@ -144,84 +119,14 @@ readudp(struct iodesc *d, void **pkt, void **payload, time_t tleft)
printf("readudp: called\n");
#endif
- ip = NULL;
+ uh = NULL;
ptr = NULL;
- n = readether(d, &ptr, (void **)&ip, tleft, &etype);
- if (n == -1 || n < sizeof(*ip) + sizeof(*uh)) {
+ n = readip(d, &ptr, (void **)&uh, tleft, IPPROTO_UDP);
+ if (n == -1 || n < sizeof(*uh) || n != ntohs(uh->uh_ulen)) {
free(ptr);
return (-1);
}
- /* Ethernet address checks now in readether() */
-
- /* Need to respond to ARP requests. */
- if (etype == ETHERTYPE_ARP) {
- struct arphdr *ah = (void *)ip;
- if (ah->ar_op == htons(ARPOP_REQUEST)) {
- /* Send ARP reply */
- arp_reply(d, ah);
- }
- free(ptr);
- return (-1);
- }
-
- if (etype != ETHERTYPE_IP) {
-#ifdef NET_DEBUG
- if (debug)
- printf("readudp: not IP. ether_type=%x\n", etype);
-#endif
- free(ptr);
- return (-1);
- }
-
- /* Check ip header */
- if (ip->ip_v != IPVERSION ||
- ip->ip_p != IPPROTO_UDP) { /* half char */
-#ifdef NET_DEBUG
- if (debug)
- printf("readudp: IP version or not UDP. ip_v=%d ip_p=%d\n", ip->ip_v, ip->ip_p);
-#endif
- free(ptr);
- return (-1);
- }
-
- hlen = ip->ip_hl << 2;
- if (hlen < sizeof(*ip) ||
- in_cksum(ip, hlen) != 0) {
-#ifdef NET_DEBUG
- if (debug)
- printf("readudp: short hdr or bad cksum.\n");
-#endif
- free(ptr);
- return (-1);
- }
- if (n < ntohs(ip->ip_len)) {
-#ifdef NET_DEBUG
- if (debug)
- printf("readudp: bad length %d < %d.\n",
- (int)n, ntohs(ip->ip_len));
-#endif
- free(ptr);
- return (-1);
- }
- if (d->myip.s_addr && ip->ip_dst.s_addr != d->myip.s_addr) {
-#ifdef NET_DEBUG
- if (debug) {
- printf("readudp: bad saddr %s != ", inet_ntoa(d->myip));
- printf("%s\n", inet_ntoa(ip->ip_dst));
- }
-#endif
- free(ptr);
- return (-1);
- }
-
- uh = (struct udphdr *)((uintptr_t)ip + sizeof (*ip));
- /* If there were ip options, make them go away */
- if (hlen != sizeof(*ip)) {
- bcopy(((u_char *)ip) + hlen, uh, uh->uh_ulen - hlen);
- ip->ip_len = htons(sizeof(*ip));
- n -= hlen - sizeof(*ip);
- }
if (uh->uh_dport != d->myport) {
#ifdef NET_DEBUG
if (debug)
@@ -235,16 +140,13 @@ readudp(struct iodesc *d, void **pkt, void **payload, time_t tleft)
#ifndef UDP_NO_CKSUM
if (uh->uh_sum) {
struct udpiphdr *ui;
+ struct ip *ip;
struct ip tip;
n = ntohs(uh->uh_ulen) + sizeof(*ip);
- if (n > RECV_SIZE - ETHER_SIZE) {
- printf("readudp: huge packet, udp len %d\n", (int)n);
- free(ptr);
- return (-1);
- }
/* Check checksum (must save and restore ip header) */
+ ip = (struct ip *)uh - 1;
tip = *ip;
ui = (struct udpiphdr *)ip;
bzero(&ui->ui_x1, sizeof(ui->ui_x1));
diff --git a/lib/libsysdecode/Makefile.depend b/lib/libsysdecode/Makefile.depend
index 106151641a97..c7ab903a0056 100644
--- a/lib/libsysdecode/Makefile.depend
+++ b/lib/libsysdecode/Makefile.depend
@@ -3,13 +3,128 @@
DIRDEPS = \
gnu/lib/csu \
+ gnu/lib/libdialog \
gnu/lib/libgcc \
+ gnu/lib/libgomp \
+ gnu/lib/libregex \
+ gnu/lib/libssp \
+ gnu/lib/libstdc++ \
+ gnu/lib/libsupc++ \
include \
+ include/arpa \
+ include/gssapi \
+ include/protocols \
include/rpc \
+ include/rpcsvc \
include/xlocale \
+ kerberos5/lib/libasn1 \
+ kerberos5/lib/libgssapi_krb5 \
+ kerberos5/lib/libhdb \
+ kerberos5/lib/libheimbase \
+ kerberos5/lib/libheimntlm \
+ kerberos5/lib/libhx509 \
+ kerberos5/lib/libkadm5clnt \
+ kerberos5/lib/libkafs5 \
+ kerberos5/lib/libkdc \
+ kerberos5/lib/libkrb5 \
+ kerberos5/lib/libroken \
+ kerberos5/lib/libwind \
lib/${CSU_DIR} \
+ lib/atf/libatf-c \
+ lib/lib80211 \
+ lib/libalias/libalias \
+ lib/libarchive \
+ lib/libbegemot \
+ lib/libblacklist \
+ lib/libblocksruntime \
+ lib/libbluetooth \
+ lib/libbsdstat \
+ lib/libbsm \
+ lib/libbsnmp/libbsnmp \
+ lib/libbz2 \
lib/libc \
+ lib/libc++ \
+ lib/libcalendar \
+ lib/libcam \
+ lib/libcapsicum \
+ lib/libcasper/libcasper \
+ lib/libcasper/services/cap_dns \
+ lib/libcasper/services/cap_grp \
+ lib/libcasper/services/cap_pwd \
+ lib/libcasper/services/cap_random \
+ lib/libcasper/services/cap_sysctl \
+ lib/libcom_err \
lib/libcompiler_rt \
+ lib/libcuse \
+ lib/libdevctl \
+ lib/libdevdctl \
+ lib/libdevinfo \
+ lib/libdevstat \
+ lib/libdpv \
+ lib/libdwarf \
+ lib/libedit \
+ lib/libedit/edit/readline \
+ lib/libefivar \
+ lib/libelf \
+ lib/libelftc \
+ lib/libevent \
+ lib/libexecinfo \
+ lib/libexpat \
+ lib/libfetch \
+ lib/libfigpar \
+ lib/libgeom \
+ lib/libgpio \
+ lib/libjail \
+ lib/libkvm \
+ lib/liblzma \
+ lib/libmagic \
+ lib/libmd \
+ lib/libmemstat \
+ lib/libmilter \
+ lib/libmp \
+ lib/libmt \
+ lib/libnetgraph \
+ lib/libngatm \
+ lib/libopie \
+ lib/libpam/libpam \
+ lib/libpcap \
+ lib/libpmc \
+ lib/libproc \
+ lib/libprocstat \
+ lib/libradius \
+ lib/librtld_db \
+ lib/libsdp \
+ lib/libsqlite3 \
+ lib/libstand \
+ lib/libstdthreads \
+ lib/libtacplus \
+ lib/libthread_db \
+ lib/libucl \
+ lib/libufs \
+ lib/libugidfw \
+ lib/libulog \
+ lib/libusb \
+ lib/libusbhid \
+ lib/libutil \
+ lib/libvgl \
+ lib/libvmmapi \
+ lib/libwrap \
+ lib/libxo \
+ lib/libypclnt \
+ lib/libz \
+ lib/libzstd \
+ lib/msun \
+ lib/ncurses/formw \
+ lib/ncurses/menuw \
+ lib/ncurses/ncursesw \
+ lib/ncurses/panelw \
+ secure/lib/libcrypto \
+ secure/lib/libssl \
+ usr.bin/lex \
+ usr.sbin/bsnmpd/modules \
+ usr.sbin/bsnmpd/modules/snmp_bridge \
+ usr.sbin/bsnmpd/modules/snmp_mibII \
+ usr.sbin/bsnmpd/modules/snmp_netgraph \
.include <dirdeps.mk>
diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c
index da53c851e511..877bd37fe88b 100644
--- a/lib/libthr/thread/thr_mutex.c
+++ b/lib/libthr/thread/thr_mutex.c
@@ -631,7 +631,7 @@ __pthread_mutex_trylock(pthread_mutex_t *mutex)
} /* else {} */
if (robust)
_mutex_leave_robust(curthread, m);
- if ((ret == 0 || ret == EOWNERDEAD) &&
+ if (ret != 0 && ret != EOWNERDEAD &&
(m->m_flags & PMUTEX_FLAG_PRIVATE) != 0)
THR_CRITICAL_LEAVE(curthread);
return (ret);
diff --git a/lib/libxo/Makefile b/lib/libxo/Makefile
index 040db75bee47..7af301fb9339 100644
--- a/lib/libxo/Makefile
+++ b/lib/libxo/Makefile
@@ -48,8 +48,11 @@ MAN+= xo_attr.3 \
xo_set_version.3 \
xo_set_writer.3 \
xo_syslog.3
+
MAN+= xo_format.5
+MAN+= xo_options.7
+
MLINKS= xo_attr.3 xo_attr_h.3 \
xo_attr.3 xo_attr_hv.3 \
xo_create.3 xo_create_to_file.3 \
diff --git a/lib/libxo/add.man b/lib/libxo/add.man
index ee79bf382a37..00e0ae380334 100644
--- a/lib/libxo/add.man
+++ b/lib/libxo/add.man
@@ -3,10 +3,10 @@
.Fx
uses
.Nm libxo
-version 0.6.2.
+version 0.7.2.
Complete documentation can be found on github:
.Bd -literal -offset indent
-http://juniper.github.io/libxo/0.6.2/libxo\-manual.html
+http://juniper.github.io/libxo/0.7.2/libxo\-manual.html
.Ed
.Pp
.Nm libxo
diff --git a/lib/libxo/xo_config.h b/lib/libxo/xo_config.h
index 9020b8c6496d..60517e1b4a37 100644
--- a/lib/libxo/xo_config.h
+++ b/lib/libxo/xo_config.h
@@ -183,16 +183,16 @@
/* #undef LIBXO_TEXT_ONLY */
/* Version number as dotted value */
-#define LIBXO_VERSION "0.6.2"
+#define LIBXO_VERSION "0.7.2"
/* Version number extra information */
#define LIBXO_VERSION_EXTRA ""
/* Version number as a number */
-#define LIBXO_VERSION_NUMBER 6002
+#define LIBXO_VERSION_NUMBER 7002
/* Version number as string */
-#define LIBXO_VERSION_STRING "6002"
+#define LIBXO_VERSION_STRING "7002"
/* Enable local wcwidth implementation */
#define LIBXO_WCWIDTH 1
@@ -210,7 +210,7 @@
#define PACKAGE_NAME "libxo"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libxo 0.6.2"
+#define PACKAGE_STRING "libxo 0.7.2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libxo"
@@ -219,7 +219,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.6.2"
+#define PACKAGE_VERSION "0.7.2"
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
@@ -232,8 +232,11 @@
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
+/* Use int return codes */
+/* #undef USE_INT_RETURN_CODES */
+
/* Version number of package */
-#define VERSION "0.6.2"
+#define VERSION "0.7.2"
/* Retain hash bucket size */
/* #undef XO_RETAIN_SIZE */
diff --git a/lib/libzstd/Makefile.depend b/lib/libzstd/Makefile.depend
new file mode 100644
index 000000000000..7b92dbd89f4a
--- /dev/null
+++ b/lib/libzstd/Makefile.depend
@@ -0,0 +1,19 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libthr \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/lib/msun/src/catrig.c b/lib/msun/src/catrig.c
index cfc4dcf0aef0..ebfe3567c168 100644
--- a/lib/msun/src/catrig.c
+++ b/lib/msun/src/catrig.c
@@ -37,7 +37,7 @@ __FBSDID("$FreeBSD$");
#define isinf(x) (fabs(x) == INFINITY)
#undef isnan
#define isnan(x) ((x) != (x))
-#define raise_inexact() do { volatile float junk = 1 + tiny; } while(0)
+#define raise_inexact() do { volatile float junk __unused = 1 + tiny; } while(0)
#undef signbit
#define signbit(x) (__builtin_signbit(x))
diff --git a/lib/msun/src/catrigf.c b/lib/msun/src/catrigf.c
index ca84ce2a99a8..3067d314b910 100644
--- a/lib/msun/src/catrigf.c
+++ b/lib/msun/src/catrigf.c
@@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$");
#define isinf(x) (fabsf(x) == INFINITY)
#undef isnan
#define isnan(x) ((x) != (x))
-#define raise_inexact() do { volatile float junk = 1 + tiny; } while(0)
+#define raise_inexact() do { volatile float junk __unused = 1 + tiny; } while(0)
#undef signbit
#define signbit(x) (__builtin_signbitf(x))
diff --git a/lib/msun/src/catrigl.c b/lib/msun/src/catrigl.c
index f71a3118de7e..41357e864456 100644
--- a/lib/msun/src/catrigl.c
+++ b/lib/msun/src/catrigl.c
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
#define isinf(x) (fabsl(x) == INFINITY)
#undef isnan
#define isnan(x) ((x) != (x))
-#define raise_inexact() do { volatile float junk = 1 + tiny; } while(0)
+#define raise_inexact() do { volatile float junk __unused = 1 + tiny; } while(0)
#undef signbit
#define signbit(x) (__builtin_signbitl(x))
diff --git a/libexec/dma/dma-mbox-create/Makefile.depend b/libexec/dma/dma-mbox-create/Makefile.depend
index b3f22d1b14c1..faec9cb603af 100644
--- a/libexec/dma/dma-mbox-create/Makefile.depend
+++ b/libexec/dma/dma-mbox-create/Makefile.depend
@@ -9,6 +9,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
secure/lib/libcrypto \
secure/lib/libssl \
diff --git a/libexec/rtld-elf/map_object.c b/libexec/rtld-elf/map_object.c
index 30af4cefddbe..6f77d987e771 100644
--- a/libexec/rtld-elf/map_object.c
+++ b/libexec/rtld-elf/map_object.c
@@ -193,6 +193,8 @@ map_object(int fd, const char *path, const struct stat *sb)
base_flags = MAP_PRIVATE | MAP_ANON | MAP_NOCORE;
if (npagesizes > 1 && round_page(segs[0]->p_filesz) >= pagesizes[1])
base_flags |= MAP_ALIGNED_SUPER;
+ if (base_vaddr != 0)
+ base_flags |= MAP_FIXED | MAP_EXCL;
mapbase = mmap(base_addr, mapsize, PROT_NONE, base_flags, -1, 0);
if (mapbase == (caddr_t) -1) {
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 8c95387aa027..e1eeba7d64d1 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -115,7 +115,7 @@ static void objlist_push_head(Objlist *, Obj_Entry *);
static void objlist_push_tail(Objlist *, Obj_Entry *);
static void objlist_put_after(Objlist *, Obj_Entry *, Obj_Entry *);
static void objlist_remove(Objlist *, Obj_Entry *);
-static int parse_libdir(const char *);
+static int parse_integer(const char *);
static void *path_enumerate(const char *, path_enum_proc, void *);
static void release_object(Obj_Entry *);
static int relocate_object_dag(Obj_Entry *root, bool bind_now,
@@ -339,22 +339,17 @@ _LD(const char *var)
func_ptr_type
_rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
{
- Elf_Auxinfo *aux_info[AT_COUNT];
- int i;
- int argc;
- char **argv;
- char **env;
- Elf_Auxinfo *aux;
- Elf_Auxinfo *auxp;
- const char *argv0;
+ Elf_Auxinfo *aux, *auxp, *auxpf, *aux_info[AT_COUNT];
Objlist_Entry *entry;
- Obj_Entry *obj;
- Obj_Entry *preload_tail;
- Obj_Entry *last_interposer;
+ Obj_Entry *last_interposer, *obj, *preload_tail;
+ const Elf_Phdr *phdr;
Objlist initlist;
RtldLockState lockstate;
- char *library_path_rpath;
- int mib[2];
+ Elf_Addr *argcp;
+ char **argv, *argv0, **env, **envp, *kexecpath, *library_path_rpath;
+ caddr_t imgentry;
+ char buf[MAXPATHLEN];
+ int argc, fd, i, mib[2], phnum;
size_t len;
/*
@@ -365,6 +360,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
*/
/* Find the auxiliary vector on the stack. */
+ argcp = sp;
argc = *sp++;
argv = (char **) sp;
sp += argc + 1; /* Skip over arguments and NULL terminator */
@@ -416,6 +412,57 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
md_abi_variant_hook(aux_info);
+ fd = -1;
+ if (aux_info[AT_EXECFD] != NULL) {
+ fd = aux_info[AT_EXECFD]->a_un.a_val;
+ } else {
+ assert(aux_info[AT_PHDR] != NULL);
+ phdr = (const Elf_Phdr *)aux_info[AT_PHDR]->a_un.a_ptr;
+ if (phdr == obj_rtld.phdr) {
+ dbg("opening main program in direct exec mode");
+ if (argc >= 2) {
+ argv0 = argv[1];
+ fd = open(argv0, O_RDONLY | O_CLOEXEC | O_VERIFY);
+ if (fd == -1) {
+ rtld_printf("Opening %s: %s\n", argv0,
+ rtld_strerror(errno));
+ rtld_die();
+ }
+
+ /*
+ * For direct exec mode, argv[0] is the interpreter
+ * name, we must remove it and shift arguments left by
+ * 1 before invoking binary main. Since stack layout
+ * places environment pointers and aux vectors right
+ * after the terminating NULL, we must shift
+ * environment and aux as well.
+ * XXX Shift will be > 1 when options are implemented.
+ */
+ do {
+ *argv = *(argv + 1);
+ argv++;
+ } while (*argv != NULL);
+ *argcp -= 1;
+ main_argc = argc - 1;
+ environ = env = envp = argv;
+ do {
+ *envp = *(envp + 1);
+ envp++;
+ } while (*envp != NULL);
+ aux = auxp = (Elf_Auxinfo *)envp;
+ auxpf = (Elf_Auxinfo *)(envp + 1);
+ for (;; auxp++, auxpf++) {
+ *auxp = *auxpf;
+ if (auxp->a_type == AT_NULL)
+ break;
+ }
+ } else {
+ rtld_printf("no binary\n");
+ rtld_die();
+ }
+ }
+ }
+
ld_bind_now = getenv(_LD("BIND_NOW"));
/*
@@ -476,8 +523,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
* Load the main program, or process its program header if it is
* already loaded.
*/
- if (aux_info[AT_EXECFD] != NULL) { /* Load the main program. */
- int fd = aux_info[AT_EXECFD]->a_un.a_val;
+ if (fd != -1) { /* Load the main program. */
dbg("loading main program");
obj_main = map_object(fd, argv0, NULL);
close(fd);
@@ -485,10 +531,6 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
rtld_die();
max_stack_flags = obj->stack_flags;
} else { /* Main program already loaded. */
- const Elf_Phdr *phdr;
- int phnum;
- caddr_t entry;
-
dbg("processing main program's program header");
assert(aux_info[AT_PHDR] != NULL);
phdr = (const Elf_Phdr *) aux_info[AT_PHDR]->a_un.a_ptr;
@@ -497,15 +539,12 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
assert(aux_info[AT_PHENT] != NULL);
assert(aux_info[AT_PHENT]->a_un.a_val == sizeof(Elf_Phdr));
assert(aux_info[AT_ENTRY] != NULL);
- entry = (caddr_t) aux_info[AT_ENTRY]->a_un.a_ptr;
- if ((obj_main = digest_phdr(phdr, phnum, entry, argv0)) == NULL)
+ imgentry = (caddr_t) aux_info[AT_ENTRY]->a_un.a_ptr;
+ if ((obj_main = digest_phdr(phdr, phnum, imgentry, argv0)) == NULL)
rtld_die();
}
- if (aux_info[AT_EXECPATH] != NULL) {
- char *kexecpath;
- char buf[MAXPATHLEN];
-
+ if (aux_info[AT_EXECPATH] != NULL && fd == -1) {
kexecpath = aux_info[AT_EXECPATH]->a_un.a_ptr;
dbg("AT_EXECPATH %p %s", kexecpath, kexecpath);
if (kexecpath[0] == '/')
@@ -517,7 +556,7 @@ _rtld(Elf_Addr *sp, func_ptr_type *exit_proc, Obj_Entry **objp)
else
obj_main->path = xstrdup(buf);
} else {
- dbg("No AT_EXECPATH");
+ dbg("No AT_EXECPATH or direct exec");
obj_main->path = xstrdup(argv0);
}
dbg("obj_main path %s", obj_main->path);
@@ -2994,9 +3033,12 @@ search_library_pathfds(const char *name, const char *path, int *fdp)
envcopy = xstrdup(path);
for (fdstr = strtok_r(envcopy, ":", &last_token); fdstr != NULL;
fdstr = strtok_r(NULL, ":", &last_token)) {
- dirfd = parse_libdir(fdstr);
- if (dirfd < 0)
+ dirfd = parse_integer(fdstr);
+ if (dirfd < 0) {
+ _rtld_error("failed to parse directory FD: '%s'",
+ fdstr);
break;
+ }
fd = __sys_openat(dirfd, name, O_RDONLY | O_CLOEXEC | O_VERIFY);
if (fd >= 0) {
*fdp = fd;
@@ -5197,29 +5239,27 @@ symlook_init_from_req(SymLook *dst, const SymLook *src)
* Parse a file descriptor number without pulling in more of libc (e.g. atoi).
*/
static int
-parse_libdir(const char *str)
+parse_integer(const char *str)
{
static const int RADIX = 10; /* XXXJA: possibly support hex? */
const char *orig;
- int fd;
+ int n;
char c;
orig = str;
- fd = 0;
+ n = 0;
for (c = *str; c != '\0'; c = *++str) {
if (c < '0' || c > '9')
return (-1);
- fd *= RADIX;
- fd += c - '0';
+ n *= RADIX;
+ n += c - '0';
}
/* Make sure we actually parsed something. */
- if (str == orig) {
- _rtld_error("failed to parse directory FD from '%s'", str);
+ if (str == orig)
return (-1);
- }
- return (fd);
+ return (n);
}
/*
diff --git a/release/scripts/atlas-upload.sh b/release/scripts/atlas-upload.sh
index bf1dbf116dbc..cf8b282bd690 100755
--- a/release/scripts/atlas-upload.sh
+++ b/release/scripts/atlas-upload.sh
@@ -132,20 +132,20 @@ main () {
echo "Failed to get the token from the API"
exit 2;
fi
- echo ${TOKENRESULT} | grep "\"token\":" > /dev/null
+ echo ${TOKENRESULT} | grep -E "\"(token|upload_path)\":" > /dev/null
if [ $? != 0 ]; then
echo "No token found from the API"
exit 2
else
- TOKEN=$(echo $TOKENRESULT | sed -e 's/.*token":"//' -e 's/".*//')
+ TOKEN=$(echo $TOKENRESULT | sed -e 's/.*token":"//' -e 's/.*upload_path":"//' -e 's/}$//g' -e 's/"//g')
echo "Uploading to Atlas"
- UPLOADRESULT=$(/usr/local/bin/curl -s -X PUT --upload-file ${FILE} ${ATLAS_UPLOAD_URL}/${TOKEN})
+ UPLOADRESULT=$(/usr/local/bin/curl -s -X PUT --upload-file ${FILE} ${TOKEN})
# Validate the Upload
echo "Validating"
VALIDRESULT=$(/usr/local/bin/curl -s "https://atlas.hashicorp.com/api/v1/box/${USERNAME}/${BOX}/version/${VERSION}/provider/${PROVIDER}?access_token=${KEY}")
- HOSTED_TOKEN=$(echo $VALIDRESULT | sed -e 's/.*hosted_token":"//' -e 's/".*//')
- if [ ! -z ${HOSTED_TOKEN} -a ! -z ${TOKEN} -a ${HOSTED_TOKEN} != ${TOKEN} ]; then
+ HOSTED_TOKEN=$(echo $VALIDRESULT | sed -e 's/.*"hosted"://' -e 's/,.*$//')
+ if [ ! -z ${TOKEN} -a "${HOSTED_TOKEN}" != "true" ]; then
echo "Upload failed, try again."
exit 2
fi
diff --git a/rescue/rescue/Makefile.depend b/rescue/rescue/Makefile.depend
index 5debdae2f668..3af6cf1fc661 100644
--- a/rescue/rescue/Makefile.depend
+++ b/rescue/rescue/Makefile.depend
@@ -39,13 +39,13 @@ DIRDEPS = \
lib/liblzma \
lib/libmd \
lib/libmt \
- lib/libnetgraph \
lib/libsbuf \
lib/libthr \
lib/libufs \
lib/libutil \
lib/libxo \
lib/libz \
+ lib/libzstd \
lib/msun \
lib/ncurses/ncursesw \
rescue/librescue \
diff --git a/sbin/decryptcore/Makefile.depend b/sbin/decryptcore/Makefile.depend
new file mode 100644
index 000000000000..ff3df3c14de0
--- /dev/null
+++ b/sbin/decryptcore/Makefile.depend
@@ -0,0 +1,21 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libpjdlog \
+ lib/libutil \
+ secure/lib/libcrypto \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/sbin/dumpon/Makefile.depend b/sbin/dumpon/Makefile.depend
index 3646e2e2b1af..fc0b63320671 100644
--- a/sbin/dumpon/Makefile.depend
+++ b/sbin/dumpon/Makefile.depend
@@ -9,6 +9,7 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ secure/lib/libcrypto \
.include <dirdeps.mk>
diff --git a/sbin/hastctl/Makefile.depend b/sbin/hastctl/Makefile.depend
index ae4bdce838c4..cedd9669cacf 100644
--- a/sbin/hastctl/Makefile.depend
+++ b/sbin/hastctl/Makefile.depend
@@ -10,8 +10,8 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ lib/libmd \
lib/libutil \
- secure/lib/libcrypto \
usr.bin/yacc.host \
diff --git a/sbin/hastd/Makefile.depend b/sbin/hastd/Makefile.depend
index ed7392f7589b..9394623beea3 100644
--- a/sbin/hastd/Makefile.depend
+++ b/sbin/hastd/Makefile.depend
@@ -12,10 +12,10 @@ DIRDEPS = \
lib/libcompiler_rt \
lib/libexpat \
lib/libgeom \
+ lib/libmd \
lib/libsbuf \
lib/libthr \
lib/libutil \
- secure/lib/libcrypto \
usr.bin/yacc.host \
diff --git a/sbin/ifconfig/af_link.c b/sbin/ifconfig/af_link.c
index 1f1c3c4b70bb..372d2fb59ea7 100644
--- a/sbin/ifconfig/af_link.c
+++ b/sbin/ifconfig/af_link.c
@@ -42,6 +42,7 @@ static const char rcsid[] =
#include <stdlib.h>
#include <string.h>
#include <ifaddrs.h>
+#include <unistd.h>
#include <net/if_dl.h>
#include <net/if_types.h>
@@ -67,7 +68,7 @@ link_status(int s __unused, const struct ifaddrs *ifa)
sdl->sdl_alen == ETHER_ADDR_LEN) {
ether_format = ether_ntoa((struct ether_addr *)LLADDR(sdl));
if (f_ether != NULL && strcmp(f_ether, "dash") == 0) {
- for (format_char = strchr(ether_format, ':');
+ for (format_char = strchr(ether_format, ':');
format_char != NULL;
format_char = strchr(ether_format, ':'))
*format_char = '-';
@@ -78,6 +79,48 @@ link_status(int s __unused, const struct ifaddrs *ifa)
printf("\tlladdr %s\n", link_ntoa(sdl) + n);
}
+ /* Best-effort (i.e. failures are silent) to get original
+ * hardware address, as read by NIC driver at attach time. Only
+ * applies to Ethernet NICs (IFT_ETHER). However, laggX
+ * interfaces claim to be IFT_ETHER, and re-type their component
+ * Ethernet NICs as IFT_IEEE8023ADLAG. So, check for both. If
+ * the MAC is zeroed, then it's actually a lagg.
+ */
+ if ((sdl->sdl_type == IFT_ETHER ||
+ sdl->sdl_type == IFT_IEEE8023ADLAG) &&
+ sdl->sdl_alen == ETHER_ADDR_LEN) {
+ struct ifreq ifr;
+ int sock_hw;
+ int rc;
+ static const u_char laggaddr[6] = {0};
+
+ strncpy(ifr.ifr_name, ifa->ifa_name,
+ sizeof(ifr.ifr_name));
+ memcpy(&ifr.ifr_addr, ifa->ifa_addr,
+ sizeof(ifa->ifa_addr->sa_len));
+ ifr.ifr_addr.sa_family = AF_LOCAL;
+ if ((sock_hw = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0) {
+ warn("socket(AF_LOCAL,SOCK_DGRAM)");
+ return;
+ }
+ rc = ioctl(sock_hw, SIOCGHWADDR, &ifr);
+ close(sock_hw);
+ if (rc != 0) {
+ return;
+ }
+ if (memcmp(ifr.ifr_addr.sa_data, laggaddr, sdl->sdl_alen) == 0) {
+ return;
+ }
+ ether_format = ether_ntoa((const struct ether_addr *)
+ &ifr.ifr_addr.sa_data);
+ if (f_ether != NULL && strcmp(f_ether, "dash") == 0) {
+ for (format_char = strchr(ether_format, ':');
+ format_char != NULL;
+ format_char = strchr(ether_format, ':'))
+ *format_char = '-';
+ }
+ printf("\thwaddr %s\n", ether_format);
+ }
}
}
diff --git a/sbin/newfs_msdos/mkfs_msdos.c b/sbin/newfs_msdos/mkfs_msdos.c
index b961e25c431c..5a6406ce4224 100644
--- a/sbin/newfs_msdos/mkfs_msdos.c
+++ b/sbin/newfs_msdos/mkfs_msdos.c
@@ -566,9 +566,17 @@ mkfs_msdos(const char *fname, const char *dtype, const struct msdos_options *op)
}
print_bpb(&bpb);
if (!o.no_create) {
- gettimeofday(&tv, NULL);
- now = tv.tv_sec;
- tm = localtime(&now);
+ if (o.timestamp_set) {
+ tv.tv_sec = now = o.timestamp;
+ tv.tv_usec = 0;
+ tm = gmtime(&now);
+ } else {
+ gettimeofday(&tv, NULL);
+ now = tv.tv_sec;
+ tm = localtime(&now);
+ }
+
+
if (!(img = malloc(bpb.bpbBytesPerSec))) {
warn(NULL);
goto done;
diff --git a/sbin/newfs_msdos/mkfs_msdos.h b/sbin/newfs_msdos/mkfs_msdos.h
index 970af3612c98..2f5d7dcb12af 100644
--- a/sbin/newfs_msdos/mkfs_msdos.h
+++ b/sbin/newfs_msdos/mkfs_msdos.h
@@ -42,6 +42,7 @@ AOPT('L', const char *, volume_label, -1, "Volume Label") \
AOPT('N', bool, no_create, -2, "Don't create filesystem, print params only") \
AOPT('O', const char *, OEM_string, -1, "OEM string") \
AOPT('S', uint16_t, bytes_per_sector, 1, "Bytes per sector") \
+AOPT('T', time_t, timestamp, 0, "Timestamp") \
AOPT('a', uint32_t, sectors_per_fat, 1, "Sectors per FAT") \
AOPT('b', uint32_t, block_size, 1, "Block size") \
AOPT('c', uint8_t, sectors_per_cluster, 1, "Sectors per cluster") \
@@ -61,6 +62,7 @@ struct msdos_options {
#define AOPT(_opt, _type, _name, _min, _desc) _type _name;
ALLOPTS
#undef AOPT
+ uint32_t timestamp_set:1;
uint32_t volume_id_set:1;
uint32_t media_descriptor_set:1;
uint32_t hidden_sectors_set:1;
diff --git a/sbin/newfs_msdos/newfs_msdos.8 b/sbin/newfs_msdos/newfs_msdos.8
index 967e1513556e..a5e9b956b5f8 100644
--- a/sbin/newfs_msdos/newfs_msdos.8
+++ b/sbin/newfs_msdos/newfs_msdos.8
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 9, 2015
+.Dd May 16, 2017
.Dt NEWFS_MSDOS 8
.Os
.Sh NAME
@@ -38,10 +38,11 @@
.Op Fl B Ar boot
.Op Fl C Ar create-size
.Op Fl F Ar FAT-type
-.Op Fl I Ar VolumeId
+.Op Fl I Ar VolumeID
.Op Fl L Ar label
.Op Fl O Ar OEM
.Op Fl S Ar sector-size
+.Op Fl T Ar timestamp
.Op Fl a Ar FAT-size
.Op Fl b Ar block-size
.Op Fl c Ar cluster-size
@@ -117,6 +118,14 @@ The default is
Number of bytes per sector.
Acceptable values are powers of 2
in the range 512 through 32768, inclusive.
+.It Fl T Ar timestamp
+Create the filesystem as though the current time is
+.Ar timestamp .
+The default filesystem volume ID is derived from the time.
+.Ar timestamp
+can be a pathname (where the timestamp is derived from
+that file) or an integer value interpreted
+as the number of seconds since the Epoch.
.It Fl a Ar FAT-size
Number of sectors per FAT.
.It Fl b Ar block-size
@@ -163,7 +172,7 @@ File system size.
Number of sectors per track.
.El
.Sh NOTES
-If some parameters (e.g. size, number of sectors, etc.) are not specified
+If some parameters (e.g., size, number of sectors, etc.) are not specified
through options or disktype, the program tries to generate them automatically.
In particular, the size is determined as the device or file size minus the
offset specified with the
diff --git a/sbin/newfs_msdos/newfs_msdos.c b/sbin/newfs_msdos/newfs_msdos.c
index 0d3340d0c3fa..5677568c97e6 100644
--- a/sbin/newfs_msdos/newfs_msdos.c
+++ b/sbin/newfs_msdos/newfs_msdos.c
@@ -31,7 +31,7 @@ static const char rcsid[] =
#endif /* not lint */
#include <sys/param.h>
-
+#include <sys/stat.h>
#include <err.h>
#include <errno.h>
#include <paths.h>
@@ -51,13 +51,30 @@ static u_int argtou(const char *, u_int, u_int, const char *);
static off_t argtooff(const char *, const char *);
static void usage(void);
+static time_t
+get_tstamp(const char *b)
+{
+ struct stat st;
+ char *eb;
+ long long l;
+
+ if (stat(b, &st) != -1)
+ return (time_t)st.st_mtime;
+
+ errno = 0;
+ l = strtoll(b, &eb, 0);
+ if (b == eb || *eb || errno)
+ errx(EXIT_FAILURE, "Can't parse timestamp '%s'", b);
+ return (time_t)l;
+}
+
/*
* Construct a FAT12, FAT16, or FAT32 file system.
*/
int
main(int argc, char *argv[])
{
- static const char opts[] = "@:NB:C:F:I:L:O:S:a:b:c:e:f:h:i:k:m:n:o:r:s:u:";
+ static const char opts[] = "@:NB:C:F:I:L:O:S:a:b:c:e:f:h:i:k:m:n:o:r:s:T:u:";
struct msdos_options o;
const char *fname, *dtype;
char buf[MAXPATHLEN];
@@ -142,6 +159,10 @@ main(int argc, char *argv[])
case 's':
o.size = argto4(optarg, 1, "file system size");
break;
+ case 'T':
+ o.timestamp_set = 1;
+ o.timestamp = get_tstamp(optarg);
+ break;
case 'u':
o.sectors_per_track = argto2(optarg, 1, "sectors/track");
break;
diff --git a/secure/lib/libssh/Makefile b/secure/lib/libssh/Makefile
index f3c65ffac41c..562c1690c6c1 100644
--- a/secure/lib/libssh/Makefile
+++ b/secure/lib/libssh/Makefile
@@ -13,7 +13,7 @@ SRCS+= authfd.c authfile.c bufaux.c bufbn.c bufec.c buffer.c \
compat.c crc32.c deattack.c fatal.c hostfile.c \
log.c match.c md-sha256.c moduli.c nchan.c packet.c opacket.c \
readpass.c rsa.c ttymodes.c xmalloc.c addrmatch.c \
- atomicio.c key.c dispatch.c mac.c uidswap.c uuencode.c misc.c utf8.o \
+ atomicio.c key.c dispatch.c mac.c uidswap.c uuencode.c misc.c utf8.c \
monitor_fdpass.c rijndael.c ssh-dss.c ssh-ecdsa.c ssh-rsa.c dh.c \
msg.c progressmeter.c dns.c entropy.c umac.c umac128.c \
ssh-pkcs11.c smult_curve25519_ref.c \
@@ -23,7 +23,7 @@ SRCS+= authfd.c authfile.c bufaux.c bufbn.c bufec.c buffer.c \
kex.c kexdh.c kexgex.c kexecdh.c kexc25519.c \
kexdhc.c kexgexc.c kexecdhc.c kexc25519c.c \
kexdhs.c kexgexs.c kexecdhs.c kexc25519s.c \
- platform-pledge.c platform-tracing.o
+ platform-pledge.c platform-tracing.c
PACKAGE= ssh
# gss-genr.c should be in $SRCS but causes linking problems, so it is
diff --git a/share/doc/pjdfstest/Makefile.depend b/share/doc/pjdfstest/Makefile.depend
new file mode 100644
index 000000000000..f80275d86ab1
--- /dev/null
+++ b/share/doc/pjdfstest/Makefile.depend
@@ -0,0 +1,11 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
index 492e78f218fd..2d4efa810f32 100644
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -528,6 +528,8 @@ MAN= aac.4 \
tws.4 \
tx.4 \
txp.4 \
+ udp.4 \
+ udplite.4 \
ure.4 \
vale.4 \
vga.4 \
@@ -924,8 +926,6 @@ MAN+= \
ucycom.4 \
udav.4 \
udbp.4 \
- udp.4 \
- udplite.4 \
udl.4 \
uep.4 \
ufm.4 \
diff --git a/share/man/man4/bnxt.4 b/share/man/man4/bnxt.4
index 4b8f6e3e7f94..62c3867354c7 100644
--- a/share/man/man4/bnxt.4
+++ b/share/man/man4/bnxt.4
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 16, 2016
+.Dd May 9, 2017
.Dt BNXT 4
.Os
.Sh NAME
@@ -213,7 +213,7 @@ As of this writing, the system must be rebooted to initiate a PCI device reset.
The
.Nm
device driver first appeared in
-.Fx 12.0 .
+.Fx 11.1 .
.Sh AUTHORS
.An -nosplit
The
diff --git a/share/man/man4/bytgpio.4 b/share/man/man4/bytgpio.4
index 50609535f2a5..e6a7fac54977 100644
--- a/share/man/man4/bytgpio.4
+++ b/share/man/man4/bytgpio.4
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 20, 2016
+.Dd May 9, 2017
.Dt BYTGPIO 4
.Os
.Sh NAME
@@ -49,7 +49,7 @@ on boards schematics: GPIO_S0_SCnn, GPIO_S0_NCnn, and GPIO_S5_nn.
The
.Nm
manual page first appeared in
-.Fx 12.0 .
+.Fx 11.1 .
.Sh AUTHORS
This driver and man page was written by
.An Oleksandr Tymoshenko Aq Mt gonzo@FreeBSD.org .
diff --git a/share/man/man4/cxgbev.4 b/share/man/man4/cxgbev.4
index a442d145848c..9dc3421eaea3 100644
--- a/share/man/man4/cxgbev.4
+++ b/share/man/man4/cxgbev.4
@@ -31,7 +31,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 22, 2016
+.Dd May 9, 2017
.Dt CXGBEV 4
.Os
.Sh NAME
@@ -312,7 +312,7 @@ The
device driver first appeared in
.Fx 11.1
and
-.Fx 12.0 .
+.Fx 11.1 .
.Sh AUTHORS
.An -nosplit
The
diff --git a/share/man/man4/jedec_ts.4 b/share/man/man4/jedec_ts.4
index 567beb66b58b..91632e5c7b6b 100644
--- a/share/man/man4/jedec_ts.4
+++ b/share/man/man4/jedec_ts.4
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 13, 2016
+.Dd May 9, 2017
.Dt JEDEC_TS 4
.Os
.Sh NAME
@@ -121,7 +121,7 @@ dev.jedec_ts.1.temp: 40.7500C
The
.Nm
driver first appeared in
-.Fx 12.0 .
+.Fx 11.1 .
.Sh AUTHORS
.An -nosplit
The
diff --git a/share/man/man4/qlnxe.4 b/share/man/man4/qlnxe.4
index 5820a4f28365..0f3e0a552159 100644
--- a/share/man/man4/qlnxe.4
+++ b/share/man/man4/qlnxe.4
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 24, 2017
+.Dd May 9, 2017
.Dt QLNXE 4
.Os
.Sh NAME
@@ -80,7 +80,7 @@ or by E-mail at
The
.Nm
device driver first appeared in
-.Fx 12.0 .
+.Fx 11.1 .
.Sh AUTHORS
.An -nosplit
The
diff --git a/share/man/man4/u3g.4 b/share/man/man4/u3g.4
index 7df2a8c2cfc7..b3a77fdd71ce 100644
--- a/share/man/man4/u3g.4
+++ b/share/man/man4/u3g.4
@@ -98,17 +98,17 @@ See
and
.Xr usb_quirk 4 .
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.?.init" -compact
-.It Pa /dev/ttyU?.?
+.Bl -tag -width "/dev/ttyU*.*.init" -compact
+.It Pa /dev/ttyU*.*
for callin ports
-.It Pa /dev/ttyU?.?.init
-.It Pa /dev/ttyU?.?.lock
+.It Pa /dev/ttyU*.*.init
+.It Pa /dev/ttyU*.*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?.?
+.It Pa /dev/cuaU*.*
for callout ports
-.It Pa /dev/cuaU?.?.init
-.It Pa /dev/cuaU?.?.lock
+.It Pa /dev/cuaU*.*.init
+.It Pa /dev/cuaU*.*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/uark.4 b/share/man/man4/uark.4
index f09b3c5d27b6..77d2d9d6c638 100644
--- a/share/man/man4/uark.4
+++ b/share/man/man4/uark.4
@@ -58,17 +58,17 @@ KQ-U8A Data Cable
Skymaster USB to RS232
.El
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.init" -compact
-.It Pa /dev/ttyU?
+.Bl -tag -width "/dev/ttyU*.init" -compact
+.It Pa /dev/ttyU*
for callin ports
-.It Pa /dev/ttyU?.init
-.It Pa /dev/ttyU?.lock
+.It Pa /dev/ttyU*.init
+.It Pa /dev/ttyU*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?
+.It Pa /dev/cuaU*
for callout ports
-.It Pa /dev/cuaU?.init
-.It Pa /dev/cuaU?.lock
+.It Pa /dev/cuaU*.init
+.It Pa /dev/cuaU*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/uart.4 b/share/man/man4/uart.4
index faa8ff0024cf..20724dda0229 100644
--- a/share/man/man4/uart.4
+++ b/share/man/man4/uart.4
@@ -233,7 +233,7 @@ for callin ports
.It Pa /dev/ttyu?.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuau*
+.It Pa /dev/cuau?
for callout ports
.It Pa /dev/cuau?.init
.It Pa /dev/cuau?.lock
diff --git a/share/man/man4/ubsa.4 b/share/man/man4/ubsa.4
index 98bc69c6fc5f..ddc492a9bde5 100644
--- a/share/man/man4/ubsa.4
+++ b/share/man/man4/ubsa.4
@@ -82,17 +82,17 @@ GoHubs GoCOM232
Peracom single port serial adapter
.El
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.init" -compact
-.It Pa /dev/ttyU?
+.Bl -tag -width "/dev/ttyU*.init" -compact
+.It Pa /dev/ttyU*
for callin ports
-.It Pa /dev/ttyU?.init
-.It Pa /dev/ttyU?.lock
+.It Pa /dev/ttyU*.init
+.It Pa /dev/ttyU*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?
+.It Pa /dev/cuaU*
for callout ports
-.It Pa /dev/cuaU?.init
-.It Pa /dev/cuaU?.lock
+.It Pa /dev/cuaU*.init
+.It Pa /dev/cuaU*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/ubser.4 b/share/man/man4/ubser.4
index 780e1c227d62..d4b8bc7cb6e2 100644
--- a/share/man/man4/ubser.4
+++ b/share/man/man4/ubser.4
@@ -55,17 +55,17 @@ The
.Nm
driver provides support for the BWCT console management serial adapters.
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.?.init" -compact
-.It Pa /dev/ttyU?.?
+.Bl -tag -width "/dev/ttyU*.*.init" -compact
+.It Pa /dev/ttyU*.*
for callin ports
-.It Pa /dev/ttyU?.?.init
-.It Pa /dev/ttyU?.?.lock
+.It Pa /dev/ttyU*.*.init
+.It Pa /dev/ttyU*.*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?.?
+.It Pa /dev/cuaU*.*
for callout ports
-.It Pa /dev/cuaU?.?.init
-.It Pa /dev/cuaU?.?.lock
+.It Pa /dev/cuaU*.*.init
+.It Pa /dev/cuaU*.*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/uchcom.4 b/share/man/man4/uchcom.4
index 957d84f8ae86..d55f116a354c 100644
--- a/share/man/man4/uchcom.4
+++ b/share/man/man4/uchcom.4
@@ -71,17 +71,17 @@ driver supports the following adapters:
HL USB-RS232
.El
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.init" -compact
-.It Pa /dev/ttyU?
+.Bl -tag -width "/dev/ttyU*.init" -compact
+.It Pa /dev/ttyU*
for callin ports
-.It Pa /dev/ttyU?.init
-.It Pa /dev/ttyU?.lock
+.It Pa /dev/ttyU*.init
+.It Pa /dev/ttyU*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?
+.It Pa /dev/cuaU*
for callout ports
-.It Pa /dev/cuaU?.init
-.It Pa /dev/cuaU?.lock
+.It Pa /dev/cuaU*.init
+.It Pa /dev/cuaU*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/ucom.4 b/share/man/man4/ucom.4
index 9984503e073f..8dc34360c1db 100644
--- a/share/man/man4/ucom.4
+++ b/share/man/man4/ucom.4
@@ -92,17 +92,17 @@ Capture pulses on the CTS line.
Capture pulses on the DCD line.
.El
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.init" -compact
-.It Pa /dev/ttyU?
+.Bl -tag -width "/dev/ttyU*.init" -compact
+.It Pa /dev/ttyU*
for callin ports
-.It Pa /dev/ttyU?.init
-.It Pa /dev/ttyU?.lock
+.It Pa /dev/ttyU*.init
+.It Pa /dev/ttyU*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?
+.It Pa /dev/cuaU*
for callout ports
-.It Pa /dev/cuaU?.init
-.It Pa /dev/cuaU?.lock
+.It Pa /dev/cuaU*.init
+.It Pa /dev/cuaU*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/ucycom.4 b/share/man/man4/ucycom.4
index b20cbeb7e5c9..c5764cbe9a58 100644
--- a/share/man/man4/ucycom.4
+++ b/share/man/man4/ucycom.4
@@ -72,17 +72,17 @@ Cypress USB to RS232 bridge chips:
DeLorme Earthmate USB GPS receiver
.El
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.init" -compact
-.It Pa /dev/ttyU?
+.Bl -tag -width "/dev/ttyU*.init" -compact
+.It Pa /dev/ttyU*
for callin ports
-.It Pa /dev/ttyU?.init
-.It Pa /dev/ttyU?.lock
+.It Pa /dev/ttyU*.init
+.It Pa /dev/ttyU*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?
+.It Pa /dev/cuaU*
for callout ports
-.It Pa /dev/cuaU?.init
-.It Pa /dev/cuaU?.lock
+.It Pa /dev/cuaU*.init
+.It Pa /dev/cuaU*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/uftdi.4 b/share/man/man4/uftdi.4
index afe0fa6c0023..ddddce5deccd 100644
--- a/share/man/man4/uftdi.4
+++ b/share/man/man4/uftdi.4
@@ -243,17 +243,17 @@ Buffalo PC-OP-RS / Kurouto-shikou KURO-RS universal remote
Prologix GPIB-USB Controller
.El
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.init" -compact
-.It Pa /dev/ttyU?
+.Bl -tag -width "/dev/ttyU*.init" -compact
+.It Pa /dev/ttyU*
for callin ports
-.It Pa /dev/ttyU?.init
-.It Pa /dev/ttyU?.lock
+.It Pa /dev/ttyU*.init
+.It Pa /dev/ttyU*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?
+.It Pa /dev/cuaU*
for callout ports
-.It Pa /dev/cuaU?.init
-.It Pa /dev/cuaU?.lock
+.It Pa /dev/cuaU*.init
+.It Pa /dev/cuaU*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/uipaq.4 b/share/man/man4/uipaq.4
index 8a6d539c2071..26bf35bf2d7e 100644
--- a/share/man/man4/uipaq.4
+++ b/share/man/man4/uipaq.4
@@ -80,17 +80,17 @@ The device is accessed through the
driver which makes it behave like a
.Xr tty 4 .
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.init" -compact
-.It Pa /dev/ttyU?
+.Bl -tag -width "/dev/ttyU*.init" -compact
+.It Pa /dev/ttyU*
for callin ports
-.It Pa /dev/ttyU?.init
-.It Pa /dev/ttyU?.lock
+.It Pa /dev/ttyU*.init
+.It Pa /dev/ttyU*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?
+.It Pa /dev/cuaU*
for callout ports
-.It Pa /dev/cuaU?.init
-.It Pa /dev/cuaU?.lock
+.It Pa /dev/cuaU*.init
+.It Pa /dev/cuaU*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/umcs.4 b/share/man/man4/umcs.4
index 42e89a69980f..5586e90a489f 100644
--- a/share/man/man4/umcs.4
+++ b/share/man/man4/umcs.4
@@ -81,17 +81,17 @@ ST Lab U-360 two-port serial USB adapter
ST Lab U-400 four-port serial USB adapter
.El
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.?.init" -compact
-.It Pa /dev/ttyU?.?
+.Bl -tag -width "/dev/ttyU*.*.init" -compact
+.It Pa /dev/ttyU*.*
for callin ports
-.It Pa /dev/ttyU?.?.init
-.It Pa /dev/ttyU?.?.lock
+.It Pa /dev/ttyU*.*.init
+.It Pa /dev/ttyU*.*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?.?
+.It Pa /dev/cuaU*.*
for callout ports
-.It Pa /dev/cuaU?.?.init
-.It Pa /dev/cuaU?.?.lock
+.It Pa /dev/cuaU*.*.init
+.It Pa /dev/cuaU*.*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/umct.4 b/share/man/man4/umct.4
index 893711ef6d5a..35676c64cf40 100644
--- a/share/man/man4/umct.4
+++ b/share/man/man4/umct.4
@@ -79,17 +79,17 @@ Magic Control Technology USB-232
Sitecom USB-232
.El
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.init" -compact
-.It Pa /dev/ttyU?
+.Bl -tag -width "/dev/ttyU*.init" -compact
+.It Pa /dev/ttyU*
for callin ports
-.It Pa /dev/ttyU?.init
-.It Pa /dev/ttyU?.lock
+.It Pa /dev/ttyU*.init
+.It Pa /dev/ttyU*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?
+.It Pa /dev/cuaU*
for callout ports
-.It Pa /dev/cuaU?.init
-.It Pa /dev/cuaU?.lock
+.It Pa /dev/cuaU*.init
+.It Pa /dev/cuaU*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/umodem.4 b/share/man/man4/umodem.4
index aaa1f99738b1..89dc0a3fba5b 100644
--- a/share/man/man4/umodem.4
+++ b/share/man/man4/umodem.4
@@ -96,17 +96,17 @@ Sony Ericsson W810i phone
Sonim XP5300 Force
.El
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.init" -compact
-.It Pa /dev/ttyU?
+.Bl -tag -width "/dev/ttyU*.init" -compact
+.It Pa /dev/ttyU*
for callin ports
-.It Pa /dev/ttyU?.init
-.It Pa /dev/ttyU?.lock
+.It Pa /dev/ttyU*.init
+.It Pa /dev/ttyU*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?
+.It Pa /dev/cuaU*
for callout ports
-.It Pa /dev/cuaU?.init
-.It Pa /dev/cuaU?.lock
+.It Pa /dev/cuaU*.init
+.It Pa /dev/cuaU*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/umoscom.4 b/share/man/man4/umoscom.4
index 11f638ffb118..8361615dd77d 100644
--- a/share/man/man4/umoscom.4
+++ b/share/man/man4/umoscom.4
@@ -57,17 +57,17 @@ The device is accessed through the
driver which makes it behave like a
.Xr tty 4 .
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.init" -compact
-.It Pa /dev/ttyU?
+.Bl -tag -width "/dev/ttyU*.init" -compact
+.It Pa /dev/ttyU*
for callin ports
-.It Pa /dev/ttyU?.init
-.It Pa /dev/ttyU?.lock
+.It Pa /dev/ttyU*.init
+.It Pa /dev/ttyU*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?
+.It Pa /dev/cuaU*
for callout ports
-.It Pa /dev/cuaU?.init
-.It Pa /dev/cuaU?.lock
+.It Pa /dev/cuaU*.init
+.It Pa /dev/cuaU*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/uplcom.4 b/share/man/man4/uplcom.4
index 164703431789..b3f1fbb3ff18 100644
--- a/share/man/man4/uplcom.4
+++ b/share/man/man4/uplcom.4
@@ -181,17 +181,17 @@ YC-Cable USB-Serial Adapter
Zeagle N2iTion3 Diving Computer
.El
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.init" -compact
-.It Pa /dev/ttyU?
+.Bl -tag -width "/dev/ttyU*.init" -compact
+.It Pa /dev/ttyU*
for callin ports
-.It Pa /dev/ttyU?.init
-.It Pa /dev/ttyU?.lock
+.It Pa /dev/ttyU*.init
+.It Pa /dev/ttyU*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?
+.It Pa /dev/cuaU*
for callout ports
-.It Pa /dev/cuaU?.init
-.It Pa /dev/cuaU?.lock
+.It Pa /dev/cuaU*.init
+.It Pa /dev/cuaU*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/uslcom.4 b/share/man/man4/uslcom.4
index c24920ddbeff..29e301068ae8 100644
--- a/share/man/man4/uslcom.4
+++ b/share/man/man4/uslcom.4
@@ -193,17 +193,17 @@ WMR RIGblaster Plug&Play and RIGtalk RT1
Zephyr Bioharness
.El
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.init" -compact
-.It Pa /dev/ttyU?
+.Bl -tag -width "/dev/ttyU*.init" -compact
+.It Pa /dev/ttyU*
for callin ports
-.It Pa /dev/ttyU?.init
-.It Pa /dev/ttyU?.lock
+.It Pa /dev/ttyU*.init
+.It Pa /dev/ttyU*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?
+.It Pa /dev/cuaU*
for callout ports
-.It Pa /dev/cuaU?.init
-.It Pa /dev/cuaU?.lock
+.It Pa /dev/cuaU*.init
+.It Pa /dev/cuaU*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/uvisor.4 b/share/man/man4/uvisor.4
index 368f218626b8..4412dd6bdc9d 100644
--- a/share/man/man4/uvisor.4
+++ b/share/man/man4/uvisor.4
@@ -119,17 +119,17 @@ Sony Clie S360
Sony Clie TJ37
.El
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.init" -compact
-.It Pa /dev/ttyU?
+.Bl -tag -width "/dev/ttyU*.init" -compact
+.It Pa /dev/ttyU*
for callin ports
-.It Pa /dev/ttyU?.init
-.It Pa /dev/ttyU?.lock
+.It Pa /dev/ttyU*.init
+.It Pa /dev/ttyU*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?
+.It Pa /dev/cuaU*
for callout ports
-.It Pa /dev/cuaU?.init
-.It Pa /dev/cuaU?.lock
+.It Pa /dev/cuaU*.init
+.It Pa /dev/cuaU*.lock
corresponding callout initial-state and lock-state devices
.El
.Sh SEE ALSO
diff --git a/share/man/man4/uvscom.4 b/share/man/man4/uvscom.4
index 119d6c41e440..43f4fda14d5a 100644
--- a/share/man/man4/uvscom.4
+++ b/share/man/man4/uvscom.4
@@ -78,17 +78,17 @@ The device is accessed through the
driver which makes it behave like a
.Xr tty 4 .
.Sh FILES
-.Bl -tag -width "/dev/ttyU?.init" -compact
-.It Pa /dev/ttyU?
+.Bl -tag -width "/dev/ttyU*.init" -compact
+.It Pa /dev/ttyU*
for callin ports
-.It Pa /dev/ttyU?.init
-.It Pa /dev/ttyU?.lock
+.It Pa /dev/ttyU*.init
+.It Pa /dev/ttyU*.lock
corresponding callin initial-state and lock-state devices
.Pp
-.It Pa /dev/cuaU?
+.It Pa /dev/cuaU*
for callout ports
-.It Pa /dev/cuaU?.init
-.It Pa /dev/cuaU?.lock
+.It Pa /dev/cuaU*.init
+.It Pa /dev/cuaU*.lock
corresponding callout initial-state and lock-state devices
.Sh SEE ALSO
.Xr tty 4 ,
diff --git a/share/man/man7/build.7 b/share/man/man7/build.7
index 31927f8ab987..d5036daf87b5 100644
--- a/share/man/man7/build.7
+++ b/share/man/man7/build.7
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 22, 2017
+.Dd May 11, 2017
.Dt BUILD 7
.Os
.Sh NAME
@@ -499,6 +499,11 @@ If combined with
.Cm buildworld
then all libraries and includes, and some of the build tools will still build
as well.
+Specifying
+.Cm -DNO_LIBS ,
+and
+.Cm -DWORLDFAST
+will only build the specified directory as was done historically.
When combined with
.Cm buildworld
it is necesarry to override
@@ -523,7 +528,10 @@ and
.Va TARGET Ns = Ns Li arm64 .
If not set,
.Va TARGET
-defaults to the current hardware platform.
+defaults to the current hardware platform, unless
+.Va TARGET_ARCH
+is also set, in which case it defaults to the appropriate
+value for that architecture.
.It Va TARGET_ARCH
The target machine processor architecture.
This is analogous to the
@@ -605,6 +613,12 @@ If set, the update process does not update the source of the
documentation as part of the
.Dq make update
target.
+.It Va NO_LIBS
+If set, the libraries phase will be skipped.
+.It Va NO_OBJ
+If set, no object directories will be created.
+This should only be used if object directories were created in a
+previous build and no new directories are connected.
.It Va NO_PORTSUPDATE
If set, the update process does not update the Ports tree as part of the
.Dq make update
@@ -613,6 +627,16 @@ target.
If set, the update process does not update the www tree as part of the
.Dq make update
target.
+.It Va WORLDFAST
+If set, the build target
+.Cm buildworld
+defaults to setting
+.Va NO_CLEAN ,
+.Va NO_OBJ ,
+and will skip most bootstrap phases.
+It will only bootstrap libraries and build all of userland.
+This option should be used only when it is known that none of the bootstrap
+needs changed and that no new directories have been connected to the build.
.El
.Pp
Builds under directory
@@ -668,11 +692,11 @@ section in
.Pa src/UPDATING .
.Pp
The following sequence of commands can be used to cross-build the
-system for the sparc64 architecture on an i386 host:
+system for the armv6 architecture on an amd64 host:
.Bd -literal -offset indent
cd /usr/src
-make TARGET=sparc64 buildworld
-make TARGET=sparc64 DESTDIR=/clients/sparc64 installworld
+make TARGET_ARCH=armv6 buildworld buildkernel
+make TARGET_ARCH=armv6 DESTDIR=/clients/arm64 installworld installkernel
.Ed
.Sh SEE ALSO
.Xr cc 1 ,
@@ -681,6 +705,7 @@ make TARGET=sparc64 DESTDIR=/clients/sparc64 installworld
.Xr svn 1 ,
.Xr make.conf 5 ,
.Xr src.conf 5 ,
+.Xr arch 7 ,
.Xr ports 7 ,
.Xr release 7 ,
.Xr tests 7 ,
diff --git a/share/mk/bsd.progs.mk b/share/mk/bsd.progs.mk
index 3254bdadc061..c50410dfc82e 100644
--- a/share/mk/bsd.progs.mk
+++ b/share/mk/bsd.progs.mk
@@ -87,11 +87,7 @@ $v =
# handle being called [bsd.]progs.mk
.include <bsd.prog.mk>
-.if !empty(PROGS) && !defined(_RECURSING_PROGS) && !defined(PROG)
-# tell progs.mk we might want to install things
-PROGS_TARGETS+= checkdpadd clean cleandepend cleandir depend install
-
-# Find common sources among the PROGS and depend on them before building
+# Find common sources among the PROGS to depend on them before building
# anything. This allows parallelization without them each fighting over
# the same objects.
_PROGS_COMMON_SRCS=
@@ -110,6 +106,20 @@ _PROGS_COMMON_OBJS= ${_PROGS_COMMON_SRCS:M*.[dhly]}
.if !empty(_PROGS_COMMON_SRCS:N*.[dhly])
_PROGS_COMMON_OBJS+= ${_PROGS_COMMON_SRCS:N*.[dhly]:R:S/$/.o/g}
.endif
+.endif
+
+# When recursing, ensure common sources are not rebuilt in META_MODE.
+.if defined(_RECURSING_PROGS) && !empty(_PROGS_COMMON_OBJS) && \
+ !empty(.MAKE.MODE:Mmeta)
+${_PROGS_COMMON_OBJS}: .NOMETA
+.endif
+
+.if !empty(PROGS) && !defined(_RECURSING_PROGS) && !defined(PROG)
+# tell progs.mk we might want to install things
+PROGS_TARGETS+= checkdpadd clean cleandepend cleandir depend install
+
+# Ensure common objects are built before recursing.
+.if !empty(_PROGS_COMMON_OBJS)
${PROGS}: ${_PROGS_COMMON_OBJS}
.endif
diff --git a/share/mk/local.meta.sys.mk b/share/mk/local.meta.sys.mk
index 2706683f210b..82de954945aa 100644
--- a/share/mk/local.meta.sys.mk
+++ b/share/mk/local.meta.sys.mk
@@ -283,3 +283,6 @@ META_MODE+= missing-meta=yes
.if empty(META_MODE:Mnofilemon)
META_MODE+= missing-filemon=yes
.endif
+# We do not want everything out-of-date just because
+# some unrelated shared lib updated this.
+.MAKE.META.IGNORE_PATHS+= /usr/local/etc/libmap.d
diff --git a/share/mk/meta2deps.py b/share/mk/meta2deps.py
index 00eccc1d8d43..1f1cd8642631 100755
--- a/share/mk/meta2deps.py
+++ b/share/mk/meta2deps.py
@@ -143,7 +143,7 @@ def sort_unique(list, cmp=None, key=None, reverse=False):
for e in list:
if e == le:
continue
- le = e
+ le = e
nl.append(e)
return nl
@@ -535,7 +535,7 @@ class MetaFile:
# to the src dir, we may need to add dependencies for each
rdir = dir
dir = abspath(dir, cwd, self.last_dir, self.debug, self.debug_out)
- rdir = os.path.realpath(dir)
+ rdir = os.path.realpath(dir)
if rdir == dir:
rdir = None
# now put path back together
diff --git a/sys/amd64/acpica/acpi_wakecode.S b/sys/amd64/acpica/acpi_wakecode.S
index 6b36d55e7d26..a63b5b8b7692 100644
--- a/sys/amd64/acpica/acpi_wakecode.S
+++ b/sys/amd64/acpica/acpi_wakecode.S
@@ -156,11 +156,12 @@ wakeup_32:
/*
* Enable EFER.LME so that we get long mode when all the prereqs are
* in place. In this case, it turns on when CR0_PG is finally enabled.
- * Pick up a few other EFER bits that we'll use need we're here.
+ * Also it picks up a few other EFER bits that we'll use need we're
+ * here, like SYSCALL and NX enable.
*/
movl $MSR_EFER, %ecx
- rdmsr
- orl $EFER_LME | EFER_SCE, %eax
+ movl wakeup_efer - wakeup_start(%ebx), %eax
+ movl wakeup_efer + 4 - wakeup_start(%ebx), %edx
wrmsr
/*
@@ -276,6 +277,8 @@ wakeup_pcb:
.quad 0
wakeup_ret:
.quad 0
+wakeup_efer:
+ .quad 0
wakeup_gdt:
.word 0
.quad 0
diff --git a/sys/amd64/amd64/cpu_switch.S b/sys/amd64/amd64/cpu_switch.S
index 33437ad16e6f..86198ab1a8c2 100644
--- a/sys/amd64/amd64/cpu_switch.S
+++ b/sys/amd64/amd64/cpu_switch.S
@@ -396,7 +396,7 @@ ENTRY(resumectx)
movl 4 + PCB_KGSBASE(%rdi),%edx
wrmsr
- /* Restore EFER. */
+ /* Restore EFER one more time. */
movl $MSR_EFER,%ecx
movl PCB_EFER(%rdi),%eax
wrmsr
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index f1ef4058a165..cfb146313e94 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -6691,7 +6691,7 @@ pmap_change_attr_locked(vm_offset_t va, vm_size_t size, int mode)
changed = TRUE;
}
if (tmpva >= VM_MIN_KERNEL_ADDRESS &&
- (*pte & PG_PS_FRAME) < dmaplimit) {
+ (*pte & PG_FRAME) < dmaplimit) {
if (pa_start == pa_end) {
/* Start physical address run. */
pa_start = *pte & PG_FRAME;
diff --git a/sys/arm/arm/busdma_machdep-v4.c b/sys/arm/arm/busdma_machdep-v4.c
index f7e0e261a097..9e98b4ac2bb6 100644
--- a/sys/arm/arm/busdma_machdep-v4.c
+++ b/sys/arm/arm/busdma_machdep-v4.c
@@ -736,8 +736,10 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void **vaddr, int flags,
if (bufzone != NULL && dmat->alignment <= bufzone->size &&
!_bus_dma_can_bounce(dmat->lowaddr, dmat->highaddr)) {
*vaddr = uma_zalloc(bufzone->umazone, mflags);
- } else if (dmat->nsegments >= btoc(dmat->maxsize) &&
- dmat->alignment <= PAGE_SIZE && dmat->boundary == 0) {
+ } else if (dmat->nsegments >=
+ howmany(dmat->maxsize, MIN(dmat->maxsegsz, PAGE_SIZE)) &&
+ dmat->alignment <= PAGE_SIZE &&
+ (dmat->boundary % PAGE_SIZE) == 0) {
*vaddr = (void *)kmem_alloc_attr(kernel_arena, dmat->maxsize,
mflags, 0, dmat->lowaddr, memattr);
} else {
diff --git a/sys/arm/arm/busdma_machdep-v6.c b/sys/arm/arm/busdma_machdep-v6.c
index 5bf46269afa0..58e2012e44e0 100644
--- a/sys/arm/arm/busdma_machdep-v6.c
+++ b/sys/arm/arm/busdma_machdep-v6.c
@@ -779,7 +779,9 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void **vaddr, int flags,
* (the allocator aligns buffers to their size boundaries).
* - There's no need to handle lowaddr/highaddr exclusion zones.
* else allocate non-contiguous pages if...
- * - The page count that could get allocated doesn't exceed nsegments.
+ * - The page count that could get allocated doesn't exceed
+ * nsegments also when the maximum segment size is less
+ * than PAGE_SIZE.
* - The alignment constraint isn't larger than a page boundary.
* - There are no boundary-crossing constraints.
* else allocate a block of contiguous pages because one or more of the
@@ -788,8 +790,10 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void **vaddr, int flags,
if (bufzone != NULL && dmat->alignment <= bufzone->size &&
!exclusion_bounce(dmat)) {
*vaddr = uma_zalloc(bufzone->umazone, mflags);
- } else if (dmat->nsegments >= btoc(dmat->maxsize) &&
- dmat->alignment <= PAGE_SIZE && dmat->boundary == 0) {
+ } else if (dmat->nsegments >=
+ howmany(dmat->maxsize, MIN(dmat->maxsegsz, PAGE_SIZE)) &&
+ dmat->alignment <= PAGE_SIZE &&
+ (dmat->boundary % PAGE_SIZE) == 0) {
*vaddr = (void *)kmem_alloc_attr(kernel_arena, dmat->maxsize,
mflags, 0, dmat->lowaddr, memattr);
} else {
diff --git a/sys/arm/arm/pmap-v6.c b/sys/arm/arm/pmap-v6.c
index 28ef09652077..047c419861cc 100644
--- a/sys/arm/arm/pmap-v6.c
+++ b/sys/arm/arm/pmap-v6.c
@@ -498,6 +498,42 @@ pmap_set_tex(void)
}
/*
+ * Remap one vm_meattr class to another one. This can be useful as
+ * workaround for SOC errata, e.g. if devices must be accessed using
+ * SO memory class.
+ *
+ * !!! Please note that this function is absolutely last resort thing.
+ * It should not be used under normal circumstances. !!!
+ *
+ * Usage rules:
+ * - it shall be called after pmap_bootstrap_prepare() and before
+ * cpu_mp_start() (thus only on boot CPU). In practice, it's expected
+ * to be called from platform_attach() or platform_late_init().
+ *
+ * - if remapping doesn't change caching mode, or until uncached class
+ * is remapped to any kind of cached one, then no other restriction exists.
+ *
+ * - if pmap_remap_vm_attr() changes caching mode, but both (original and
+ * remapped) remain cached, then caller is resposible for calling
+ * of dcache_wbinv_poc_all().
+ *
+ * - remapping of any kind of cached class to uncached is not permitted.
+ */
+void
+pmap_remap_vm_attr(vm_memattr_t old_attr, vm_memattr_t new_attr)
+{
+ int old_idx, new_idx;
+
+ /* Map VM memattrs to indexes to tex_class table. */
+ old_idx = pte2_attr_tab[(int)old_attr];
+ new_idx = pte2_attr_tab[(int)new_attr];
+
+ /* Replace TEX attribute and apply it. */
+ tex_class[old_idx] = tex_class[new_idx];
+ pmap_set_tex();
+}
+
+/*
* KERNBASE must be multiple of NPT2_IN_PG * PTE1_SIZE. In other words,
* KERNBASE is mapped by first L2 page table in L2 page table page. It
* meets same constrain due to PT2MAP being placed just under KERNBASE.
diff --git a/sys/arm/conf/ARMADA38X b/sys/arm/conf/ARMADA38X
index fc91afc72eaa..4351874620aa 100644
--- a/sys/arm/conf/ARMADA38X
+++ b/sys/arm/conf/ARMADA38X
@@ -12,6 +12,7 @@ ident ARMADA38X
options SOC_MV_ARMADA38X
makeoptions WERROR="-Werror"
+makeoptions MODULES_EXTRA="dtb/mv"
options MD_ROOT
#makeoptions MFS_IMAGE=/path/to/miniroot
@@ -62,6 +63,11 @@ device scbus
device pass
device da
+# MMC/SD/SDIO Card slot support
+device mmc # mmc/sd bus
+device mmcsd # mmc/sd flash cards
+device sdhci # mmc/sd host controller
+
# SATA
device ahci
@@ -78,7 +84,5 @@ device cryptodev
# L2 Cache
device pl310
-#FDT
+# FDT
options FDT
-options FDT_DTB_STATIC
-makeoptions FDT_DTS_FILE=armada-388-gp.dts
diff --git a/sys/arm/include/pmap-v6.h b/sys/arm/include/pmap-v6.h
index 9c586155c121..0aaaa5c955b6 100644
--- a/sys/arm/include/pmap-v6.h
+++ b/sys/arm/include/pmap-v6.h
@@ -188,6 +188,7 @@ vm_offset_t pmap_preboot_reserve_pages(u_int);
vm_offset_t pmap_preboot_get_vpages(u_int);
void pmap_preboot_map_attr(vm_paddr_t, vm_offset_t, vm_size_t, vm_prot_t,
vm_memattr_t);
+void pmap_remap_vm_attr(vm_memattr_t old_attr, vm_memattr_t new_attr);
#endif /* _KERNEL */
#endif /* !_MACHINE_PMAP_V6_H_ */
diff --git a/sys/arm/mv/armada38x/files.armada38x b/sys/arm/mv/armada38x/files.armada38x
index 8b105b55cd64..e78da6b3ace2 100644
--- a/sys/arm/mv/armada38x/files.armada38x
+++ b/sys/arm/mv/armada38x/files.armada38x
@@ -8,3 +8,4 @@ arm/mv/armada38x/armada38x_mp.c optional smp
arm/mv/armada38x/pmsu.c standard
arm/mv/armada38x/rtc.c standard
arm/mv/armada38x/armada38x_pl310.c optional pl310
+dev/sdhci/sdhci_fdt.c optional sdhci
diff --git a/sys/arm/mv/mv_common.c b/sys/arm/mv/mv_common.c
index e683fdcb8570..773272cb80fa 100644
--- a/sys/arm/mv/mv_common.c
+++ b/sys/arm/mv/mv_common.c
@@ -82,6 +82,7 @@ static int decode_win_usb3_valid(void);
static int decode_win_eth_valid(void);
static int decode_win_pcie_valid(void);
static int decode_win_sata_valid(void);
+static int decode_win_sdhci_valid(void);
static int decode_win_idma_valid(void);
static int decode_win_xor_valid(void);
@@ -95,6 +96,7 @@ static void decode_win_usb3_setup(u_long);
static void decode_win_eth_setup(u_long);
static void decode_win_sata_setup(u_long);
static void decode_win_ahci_setup(u_long);
+static void decode_win_sdhci_setup(u_long);
static void decode_win_idma_setup(u_long);
static void decode_win_xor_setup(u_long);
@@ -105,6 +107,7 @@ static void decode_win_eth_dump(u_long base);
static void decode_win_idma_dump(u_long base);
static void decode_win_xor_dump(u_long base);
static void decode_win_ahci_dump(u_long base);
+static void decode_win_sdhci_dump(u_long);
static int fdt_get_ranges(const char *, void *, int, int *, int *);
#ifdef SOC_MV_ARMADA38X
@@ -138,6 +141,7 @@ static struct soc_node_spec soc_nodes[] = {
{ "mrvl,usb-ehci", &decode_win_usb_setup, &decode_win_usb_dump },
{ "marvell,armada-380-xhci", &decode_win_usb3_setup, &decode_win_usb3_dump },
{ "marvell,armada-380-ahci", &decode_win_ahci_setup, &decode_win_ahci_dump },
+ { "marvell,armada-380-sdhci", &decode_win_sdhci_setup, &decode_win_sdhci_dump },
{ "mrvl,sata", &decode_win_sata_setup, NULL },
{ "mrvl,xor", &decode_win_xor_setup, &decode_win_xor_dump },
{ "mrvl,idma", &decode_win_idma_setup, &decode_win_idma_dump },
@@ -568,7 +572,8 @@ soc_decode_win(void)
if (!decode_win_cpu_valid() || !decode_win_usb_valid() ||
!decode_win_eth_valid() || !decode_win_idma_valid() ||
!decode_win_pcie_valid() || !decode_win_sata_valid() ||
- !decode_win_xor_valid() || !decode_win_usb3_valid())
+ !decode_win_xor_valid() || !decode_win_usb3_valid() ||
+ !decode_win_sdhci_valid())
return (EINVAL);
decode_win_cpu_setup();
@@ -659,6 +664,11 @@ WIN_REG_BASE_IDX_RD(win_sata, sz, MV_WIN_SATA_SIZE);
WIN_REG_BASE_IDX_WR(win_sata, sz, MV_WIN_SATA_SIZE);
#endif
+WIN_REG_BASE_IDX_RD(win_sdhci, cr, MV_WIN_SDHCI_CTRL);
+WIN_REG_BASE_IDX_RD(win_sdhci, br, MV_WIN_SDHCI_BASE);
+WIN_REG_BASE_IDX_WR(win_sdhci, cr, MV_WIN_SDHCI_CTRL);
+WIN_REG_BASE_IDX_WR(win_sdhci, br, MV_WIN_SDHCI_BASE);
+
#ifndef SOC_MV_DOVE
WIN_REG_IDX_RD(ddr, br, MV_WIN_DDR_BASE, MV_DDR_CADR_BASE)
WIN_REG_IDX_RD(ddr, sz, MV_WIN_DDR_SIZE, MV_DDR_CADR_BASE)
@@ -2073,6 +2083,60 @@ decode_win_sata_valid(void)
return (decode_win_can_cover_ddr(MV_WIN_SATA_MAX));
}
+static void
+decode_win_sdhci_setup(u_long base)
+{
+ uint32_t cr, br;
+ int i, j;
+
+ for (i = 0; i < MV_WIN_SDHCI_MAX; i++) {
+ win_sdhci_cr_write(base, i, 0);
+ win_sdhci_br_write(base, i, 0);
+ }
+
+ for (i = 0; i < MV_WIN_DDR_MAX; i++)
+ if (ddr_is_active(i)) {
+ br = ddr_base(i);
+ cr = (((ddr_size(i) - 1) &
+ (IO_WIN_SIZE_MASK << IO_WIN_SIZE_SHIFT)) |
+ (ddr_attr(i) << IO_WIN_ATTR_SHIFT) |
+ (ddr_target(i) << IO_WIN_TGT_SHIFT) |
+ IO_WIN_ENA_MASK);
+
+ /* Use the first available SDHCI window */
+ for (j = 0; j < MV_WIN_SDHCI_MAX; j++) {
+ if (win_sdhci_cr_read(base, j) & IO_WIN_ENA_MASK)
+ continue;
+
+ win_sdhci_cr_write(base, j, cr);
+ win_sdhci_br_write(base, j, br);
+ break;
+ }
+ }
+}
+
+static void
+decode_win_sdhci_dump(u_long base)
+{
+ int i;
+
+ for (i = 0; i < MV_WIN_SDHCI_MAX; i++)
+ printf("SDHCI window#%d: c 0x%08x, b 0x%08x\n", i,
+ win_sdhci_cr_read(base, i), win_sdhci_br_read(base, i));
+}
+
+static int
+decode_win_sdhci_valid(void)
+{
+
+#ifdef SOC_MV_ARMADA38X
+ return (decode_win_can_cover_ddr(MV_WIN_SDHCI_MAX));
+#endif
+
+ /* Satisfy platforms not equipped with this controller. */
+ return (1);
+}
+
/**************************************************************************
* FDT parsing routines.
**************************************************************************/
diff --git a/sys/arm/mv/mvwin.h b/sys/arm/mv/mvwin.h
index 1bf508974109..64e3914f47ed 100644
--- a/sys/arm/mv/mvwin.h
+++ b/sys/arm/mv/mvwin.h
@@ -296,6 +296,10 @@
#define MV_WIN_SATA_MAX 4
#endif
+#define MV_WIN_SDHCI_CTRL(n) (0x8 * (n) + 0x4080)
+#define MV_WIN_SDHCI_BASE(n) (0x8 * (n) + 0x4084)
+#define MV_WIN_SDHCI_MAX 8
+
#if defined(SOC_MV_ARMADA38X)
#define MV_BOOTROM_MEM_ADDR 0xFFF00000
#define MV_BOOTROM_WIN_SIZE 0xF
diff --git a/sys/arm64/arm64/busdma_bounce.c b/sys/arm64/arm64/busdma_bounce.c
index aff1e2323d74..31eaf05370b6 100644
--- a/sys/arm64/arm64/busdma_bounce.c
+++ b/sys/arm64/arm64/busdma_bounce.c
@@ -461,22 +461,35 @@ bounce_bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
(*mapp)->flags = DMAMAP_FROM_DMAMEM;
/*
- * XXX:
- * (dmat->alignment <= dmat->maxsize) is just a quick hack; the exact
- * alignment guarantees of malloc need to be nailed down, and the
- * code below should be rewritten to take that into account.
+ * Allocate the buffer from the malloc(9) allocator if...
+ * - It's small enough to fit into a single power of two sized bucket.
+ * - The alignment is less than or equal to the maximum size
+ * - The low address requirement is fulfilled.
+ * else allocate non-contiguous pages if...
+ * - The page count that could get allocated doesn't exceed
+ * nsegments also when the maximum segment size is less
+ * than PAGE_SIZE.
+ * - The alignment constraint isn't larger than a page boundary.
+ * - There are no boundary-crossing constraints.
+ * else allocate a block of contiguous pages because one or more of the
+ * constraints is something that only the contig allocator can fulfill.
*
- * In the meantime, we'll warn the user if malloc gets it wrong.
+ * NOTE: The (dmat->common.alignment <= dmat->maxsize) check
+ * below is just a quick hack. The exact alignment guarantees
+ * of malloc(9) need to be nailed down, and the code below
+ * should be rewritten to take that into account.
+ *
+ * In the meantime warn the user if malloc gets it wrong.
*/
if ((dmat->common.maxsize <= PAGE_SIZE) &&
(dmat->common.alignment <= dmat->common.maxsize) &&
dmat->common.lowaddr >= ptoa((vm_paddr_t)Maxmem) &&
attr == VM_MEMATTR_DEFAULT) {
*vaddr = malloc(dmat->common.maxsize, M_DEVBUF, mflags);
- } else if (dmat->common.nsegments >= btoc(dmat->common.maxsize) &&
+ } else if (dmat->common.nsegments >=
+ howmany(dmat->common.maxsize, MIN(dmat->common.maxsegsz, PAGE_SIZE)) &&
dmat->common.alignment <= PAGE_SIZE &&
- (dmat->common.boundary == 0 ||
- dmat->common.boundary >= dmat->common.lowaddr)) {
+ (dmat->common.boundary % PAGE_SIZE) == 0) {
/* Page-based multi-segment allocations allowed */
*vaddr = (void *)kmem_alloc_attr(kernel_arena,
dmat->common.maxsize, mflags, 0ul, dmat->common.lowaddr,
diff --git a/sys/arm64/include/armreg.h b/sys/arm64/include/armreg.h
index 6a5fde64ef0d..9175bacacd96 100644
--- a/sys/arm64/include/armreg.h
+++ b/sys/arm64/include/armreg.h
@@ -360,7 +360,7 @@
#define MAIR_ATTR(attr, idx) ((attr) << ((idx) * 8))
#define MAIR_DEVICE_nGnRnE 0x00
#define MAIR_NORMAL_NC 0x44
-#define MAIR_NORMAL_WT 0x88
+#define MAIR_NORMAL_WT 0xbb
#define MAIR_NORMAL_WB 0xff
/* PAR_EL1 - Physical Address Register */
diff --git a/sys/arm64/include/vm.h b/sys/arm64/include/vm.h
index 182313ef5d5c..dac13980060e 100644
--- a/sys/arm64/include/vm.h
+++ b/sys/arm64/include/vm.h
@@ -30,9 +30,15 @@
#define _MACHINE_VM_H_
/* Memory attribute configuration. */
-#define VM_MEMATTR_DEVICE 0
-#define VM_MEMATTR_UNCACHEABLE 1
-#define VM_MEMATTR_WRITE_BACK 2
+#define VM_MEMATTR_DEVICE 0
+#define VM_MEMATTR_UNCACHEABLE 1
+#define VM_MEMATTR_WRITE_BACK 2
+#define VM_MEMATTR_WRITE_THROUGH 3
+
+#ifdef _KERNEL
+/* If defined vmstat will try to use both of these in a switch statement */
+#define VM_MEMATTR_WRITE_COMBINING VM_MEMATTR_WRITE_THROUGH
+#endif
#define VM_MEMATTR_DEFAULT VM_MEMATTR_WRITE_BACK
diff --git a/sys/boot/efi/loader/main.c b/sys/boot/efi/loader/main.c
index 24cafa64c522..043306f69139 100644
--- a/sys/boot/efi/loader/main.c
+++ b/sys/boot/efi/loader/main.c
@@ -391,7 +391,7 @@ main(int argc, CHAR16 *argv[])
} else {
cpy16to8(&argv[i + 1][0], var,
sizeof(var));
- setenv("comconsole_speedspeed", var, 1);
+ setenv("comconsole_speed", var, 1);
}
i++;
break;
diff --git a/sys/boot/i386/loader/Makefile.depend b/sys/boot/i386/loader/Makefile.depend
index 89d542286eee..bbed7789c011 100644
--- a/sys/boot/i386/loader/Makefile.depend
+++ b/sys/boot/i386/loader/Makefile.depend
@@ -4,7 +4,6 @@
DIRDEPS = \
include \
include/xlocale \
- lib/libstand \
sys/boot/ficl32 \
sys/boot/geli \
sys/boot/i386/btx/btx \
diff --git a/sys/boot/i386/pxeldr/pxeboot.8 b/sys/boot/i386/pxeldr/pxeboot.8
index 7f57d5a087bb..91fca6d5c812 100644
--- a/sys/boot/i386/pxeldr/pxeboot.8
+++ b/sys/boot/i386/pxeldr/pxeboot.8
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 1, 2000
+.Dd May 16, 2017
.Dt PXEBOOT 8
.Os
.Sh NAME
@@ -91,7 +91,7 @@ This may be changed by setting the
.Va nfs.read_size
variable in
.Pa /boot/loader.conf .
-Valid values range from 1024 to 4096 bytes.
+Valid values range from 1024 to 16384 bytes.
.Pp
In all other respects,
.Nm
diff --git a/sys/boot/i386/zfsloader/Makefile.depend b/sys/boot/i386/zfsloader/Makefile.depend
index 15b0c98bfa45..49bb014d176a 100644
--- a/sys/boot/i386/zfsloader/Makefile.depend
+++ b/sys/boot/i386/zfsloader/Makefile.depend
@@ -4,7 +4,6 @@
DIRDEPS = \
include \
include/xlocale \
- lib/libstand \
sys/boot/ficl32 \
sys/boot/geli \
sys/boot/i386/btx/btx \
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
index 22b48e823060..c6e30301c623 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c
@@ -49,6 +49,16 @@ struct g_class zfs_vdev_class = {
.attrchanged = vdev_geom_attrchanged,
};
+struct consumer_vdev_elem {
+ SLIST_ENTRY(consumer_vdev_elem) elems;
+ vdev_t *vd;
+};
+
+SLIST_HEAD(consumer_priv_t, consumer_vdev_elem);
+_Static_assert(sizeof(((struct g_consumer*)NULL)->private)
+ == sizeof(struct consumer_priv_t*),
+ "consumer_priv_t* can't be stored in g_consumer.private");
+
DECLARE_GEOM_CLASS(zfs_vdev_class, zfs_vdev);
SYSCTL_DECL(_vfs_zfs_vdev);
@@ -85,21 +95,16 @@ vdev_geom_set_rotation_rate(vdev_t *vd, struct g_consumer *cp)
}
static void
-vdev_geom_set_physpath(struct g_consumer *cp, boolean_t do_null_update)
+vdev_geom_set_physpath(vdev_t *vd, struct g_consumer *cp,
+ boolean_t do_null_update)
{
boolean_t needs_update = B_FALSE;
- vdev_t *vd;
char *physpath;
int error, physpath_len;
- if (g_access(cp, 1, 0, 0) != 0)
- return;
-
- vd = cp->private;
physpath_len = MAXPATHLEN;
physpath = g_malloc(physpath_len, M_WAITOK|M_ZERO);
error = g_io_getattr("GEOM::physpath", cp, &physpath_len, physpath);
- g_access(cp, -1, 0, 0);
if (error == 0) {
char *old_physpath;
@@ -130,37 +135,40 @@ vdev_geom_set_physpath(struct g_consumer *cp, boolean_t do_null_update)
static void
vdev_geom_attrchanged(struct g_consumer *cp, const char *attr)
{
- vdev_t *vd;
char *old_physpath;
+ struct consumer_priv_t *priv;
+ struct consumer_vdev_elem *elem;
int error;
- vd = cp->private;
- if (vd == NULL)
+ priv = (struct consumer_priv_t*)&cp->private;
+ if (SLIST_EMPTY(priv))
return;
- if (strcmp(attr, "GEOM::rotation_rate") == 0) {
- vdev_geom_set_rotation_rate(vd, cp);
- return;
- }
-
- if (strcmp(attr, "GEOM::physpath") == 0) {
- vdev_geom_set_physpath(cp, /*do_null_update*/B_TRUE);
- return;
+ SLIST_FOREACH(elem, priv, elems) {
+ vdev_t *vd = elem->vd;
+ if (strcmp(attr, "GEOM::rotation_rate") == 0) {
+ vdev_geom_set_rotation_rate(vd, cp);
+ return;
+ }
+ if (strcmp(attr, "GEOM::physpath") == 0) {
+ vdev_geom_set_physpath(vd, cp, /*null_update*/B_TRUE);
+ return;
+ }
}
}
static void
vdev_geom_orphan(struct g_consumer *cp)
{
- vdev_t *vd;
+ struct consumer_priv_t *priv;
+ struct consumer_vdev_elem *elem;
g_topology_assert();
- vd = cp->private;
- if (vd == NULL) {
+ priv = (struct consumer_priv_t*)&cp->private;
+ if (SLIST_EMPTY(priv))
/* Vdev close in progress. Ignore the event. */
return;
- }
/*
* Orphan callbacks occur from the GEOM event thread.
@@ -176,8 +184,12 @@ vdev_geom_orphan(struct g_consumer *cp)
* async removal support to invoke a close on this
* vdev once it is safe to do so.
*/
- vd->vdev_remove_wanted = B_TRUE;
- spa_async_request(vd->vdev_spa, SPA_ASYNC_REMOVE);
+ SLIST_FOREACH(elem, priv, elems) {
+ vdev_t *vd = elem->vd;
+
+ vd->vdev_remove_wanted = B_TRUE;
+ spa_async_request(vd->vdev_spa, SPA_ASYNC_REMOVE);
+ }
}
static struct g_consumer *
@@ -265,21 +277,8 @@ vdev_geom_attach(struct g_provider *pp, vdev_t *vd)
}
}
- /*
- * BUG: cp may already belong to a vdev. This could happen if:
- * 1) That vdev is a shared spare, or
- * 2) We are trying to reopen a missing vdev and we are scanning by
- * guid. In that case, we'll ultimately fail to open this consumer,
- * but not until after setting the private field.
- * The solution is to:
- * 1) Don't set the private field until after the open succeeds, and
- * 2) Set it to a linked list of vdevs, not just a single vdev
- */
- cp->private = vd;
- if (vd != NULL) {
+ if (vd != NULL)
vd->vdev_tsd = cp;
- vdev_geom_set_physpath(cp, /*do_null_update*/B_FALSE);
- }
cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
return (cp);
@@ -289,16 +288,12 @@ static void
vdev_geom_detach(struct g_consumer *cp, boolean_t open_for_read)
{
struct g_geom *gp;
- vdev_t *vd;
g_topology_assert();
ZFS_LOG(1, "Detaching from %s.",
cp->provider && cp->provider->name ? cp->provider->name : "NULL");
- vd = cp->private;
- cp->private = NULL;
-
gp = cp->geom;
if (open_for_read)
g_access(cp, -1, 0, -1);
@@ -324,16 +319,26 @@ static void
vdev_geom_close_locked(vdev_t *vd)
{
struct g_consumer *cp;
+ struct consumer_priv_t *priv;
+ struct consumer_vdev_elem *elem, *elem_temp;
g_topology_assert();
cp = vd->vdev_tsd;
- vd->vdev_tsd = NULL;
vd->vdev_delayed_close = B_FALSE;
if (cp == NULL)
return;
ZFS_LOG(1, "Closing access to %s.", cp->provider->name);
+ KASSERT(cp->private != NULL, ("%s: cp->private is NULL", __func__));
+ priv = (struct consumer_priv_t*)&cp->private;
+ vd->vdev_tsd = NULL;
+ SLIST_FOREACH_SAFE(elem, priv, elems, elem_temp) {
+ if (elem->vd == vd) {
+ SLIST_REMOVE(priv, elem, consumer_vdev_elem, elems);
+ g_free(elem);
+ }
+ }
vdev_geom_detach(cp, B_TRUE);
}
@@ -870,11 +875,27 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
cp = NULL;
}
}
+ if (cp != NULL) {
+ struct consumer_priv_t *priv;
+ struct consumer_vdev_elem *elem;
+
+ priv = (struct consumer_priv_t*)&cp->private;
+ if (cp->private == NULL)
+ SLIST_INIT(priv);
+ elem = g_malloc(sizeof(*elem), M_WAITOK|M_ZERO);
+ elem->vd = vd;
+ SLIST_INSERT_HEAD(priv, elem, elems);
+ }
/* Fetch initial physical path information for this device. */
- if (cp != NULL)
+ if (cp != NULL) {
vdev_geom_attrchanged(cp, "GEOM::physpath");
+ /* Set other GEOM characteristics */
+ vdev_geom_set_physpath(vd, cp, /*do_null_update*/B_FALSE);
+ vdev_geom_set_rotation_rate(vd, cp);
+ }
+
g_topology_unlock();
PICKUP_GIANT();
if (cp == NULL) {
@@ -905,11 +926,6 @@ skip_open:
*/
vd->vdev_nowritecache = B_FALSE;
- /*
- * Determine the device's rotation rate.
- */
- vdev_geom_set_rotation_rate(vd, cp);
-
return (0);
}
diff --git a/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c b/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c
index 950e9ac60987..c6c72a3ceb1f 100644
--- a/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c
+++ b/sys/cddl/dev/dtrace/powerpc/dtrace_isa.c
@@ -38,6 +38,7 @@
#include <machine/frame.h>
#include <machine/md_var.h>
+#include <machine/psl.h>
#include <machine/reg.h>
#include <machine/stack.h>
@@ -54,16 +55,19 @@
#ifdef __powerpc64__
#define OFFSET 4 /* Account for the TOC reload slot */
+#define FRAME_OFFSET 48
#else
#define OFFSET 0
+#define FRAME_OFFSET 8
#endif
#define INKERNEL(x) ((x) <= VM_MAX_KERNEL_ADDRESS && \
(x) >= VM_MIN_KERNEL_ADDRESS)
static __inline int
-dtrace_sp_inkernel(uintptr_t sp, int aframes)
+dtrace_sp_inkernel(uintptr_t sp)
{
+ struct trapframe *frame;
vm_offset_t callpc;
#ifdef __powerpc64__
@@ -77,14 +81,15 @@ dtrace_sp_inkernel(uintptr_t sp, int aframes)
/*
* trapexit() and asttrapexit() are sentinels
* for kernel stack tracing.
- *
- * Special-case this for 'aframes == 0', because fbt sets aframes to the
- * trap callchain depth, so we want to break out of it.
*/
- if ((callpc + OFFSET == (vm_offset_t) &trapexit ||
- callpc + OFFSET == (vm_offset_t) &asttrapexit) &&
- aframes != 0)
- return (0);
+ if (callpc + OFFSET == (vm_offset_t) &trapexit ||
+ callpc + OFFSET == (vm_offset_t) &asttrapexit) {
+ if (sp == 0)
+ return (0);
+ frame = (struct trapframe *)(sp + FRAME_OFFSET);
+
+ return ((frame->srr1 & PSL_PR) == 0);
+ }
return (1);
}
@@ -93,6 +98,7 @@ static __inline uintptr_t
dtrace_next_sp(uintptr_t sp)
{
vm_offset_t callpc;
+ struct trapframe *frame;
#ifdef __powerpc64__
callpc = *(vm_offset_t *)(sp + RETURN_OFFSET64);
@@ -103,18 +109,13 @@ dtrace_next_sp(uintptr_t sp)
/*
* trapexit() and asttrapexit() are sentinels
* for kernel stack tracing.
- *
- * Special-case this for 'aframes == 0', because fbt sets aframes to the
- * trap callchain depth, so we want to break out of it.
*/
if ((callpc + OFFSET == (vm_offset_t) &trapexit ||
- callpc + OFFSET == (vm_offset_t) &asttrapexit))
- /* Access the trap frame */
-#ifdef __powerpc64__
- return (*(uintptr_t *)sp + 48 + sizeof(register_t));
-#else
- return (*(uintptr_t *)sp + 8 + sizeof(register_t));
-#endif
+ callpc + OFFSET == (vm_offset_t) &asttrapexit)) {
+ /* Access the trap frame */
+ frame = (struct trapframe *)(sp + FRAME_OFFSET);
+ return (*(uintptr_t *)(frame->fixreg[1]));
+ }
return (*(uintptr_t*)sp);
}
@@ -122,6 +123,7 @@ dtrace_next_sp(uintptr_t sp)
static __inline uintptr_t
dtrace_get_pc(uintptr_t sp)
{
+ struct trapframe *frame;
vm_offset_t callpc;
#ifdef __powerpc64__
@@ -133,18 +135,13 @@ dtrace_get_pc(uintptr_t sp)
/*
* trapexit() and asttrapexit() are sentinels
* for kernel stack tracing.
- *
- * Special-case this for 'aframes == 0', because fbt sets aframes to the
- * trap callchain depth, so we want to break out of it.
*/
if ((callpc + OFFSET == (vm_offset_t) &trapexit ||
- callpc + OFFSET == (vm_offset_t) &asttrapexit))
- /* Access the trap frame */
-#ifdef __powerpc64__
- return (*(uintptr_t *)sp + 48 + offsetof(struct trapframe, lr));
-#else
- return (*(uintptr_t *)sp + 8 + offsetof(struct trapframe, lr));
-#endif
+ callpc + OFFSET == (vm_offset_t) &asttrapexit)) {
+ /* Access the trap frame */
+ frame = (struct trapframe *)(sp + FRAME_OFFSET);
+ return (frame->srr0);
+ }
return (callpc);
}
@@ -176,7 +173,7 @@ dtrace_getpcstack(pc_t *pcstack, int pcstack_limit, int aframes,
if (sp <= osp)
break;
- if (!dtrace_sp_inkernel(sp, aframes))
+ if (!dtrace_sp_inkernel(sp))
break;
callpc = dtrace_get_pc(sp);
@@ -537,7 +534,7 @@ dtrace_getstackdepth(int aframes)
if (sp <= osp)
break;
- if (!dtrace_sp_inkernel(sp, aframes))
+ if (!dtrace_sp_inkernel(sp))
break;
if (aframes == 0)
diff --git a/sys/cddl/dev/fbt/powerpc/fbt_isa.c b/sys/cddl/dev/fbt/powerpc/fbt_isa.c
index cea849e31d36..502d427da57a 100644
--- a/sys/cddl/dev/fbt/powerpc/fbt_isa.c
+++ b/sys/cddl/dev/fbt/powerpc/fbt_isa.c
@@ -37,7 +37,7 @@
#include "fbt.h"
-#define FBT_PATCHVAL 0x7c810808
+#define FBT_PATCHVAL 0x7ffff808
#define FBT_MFLR_R0 0x7c0802a6
#define FBT_MTLR_R0 0x7c0803a6
#define FBT_BLR 0x4e800020
@@ -127,7 +127,7 @@ fbt_provide_module_function(linker_file_t lf, int symindx,
return (0);
#endif
- if (fbt_excluded(name) == 0)
+ if (fbt_excluded(name))
return (0);
instr = (uint32_t *) symval->value;
diff --git a/sys/cddl/dev/profile/profile.c b/sys/cddl/dev/profile/profile.c
index 3b584246d14e..55ea9850e26d 100644
--- a/sys/cddl/dev/profile/profile.c
+++ b/sys/cddl/dev/profile/profile.c
@@ -266,37 +266,43 @@ sbt_to_nsec(sbintime_t sbt)
}
static void
-profile_fire(void *arg)
+profile_probe(profile_probe_t *prof, hrtime_t late)
{
- profile_probe_percpu_t *pcpu = arg;
- profile_probe_t *prof = pcpu->profc_probe;
- hrtime_t late;
+ struct thread *td;
struct trapframe *frame;
uintfptr_t pc, upc;
-#ifdef illumos
- late = gethrtime() - pcpu->profc_expected;
-#else
- late = sbt_to_nsec(sbinuptime() - pcpu->profc_expected);
-#endif
-
- pc = 0;
- upc = 0;
+ td = curthread;
+ pc = upc = 0;
/*
- * td_intr_frame can be unset if this is a catch up event
- * after waking up from idle sleep.
- * This can only happen on a CPU idle thread.
+ * td_intr_frame can be unset if this is a catch-up event upon waking up
+ * from idle sleep. This can only happen on a CPU idle thread. Use a
+ * representative arg0 value in this case so that one of the probe
+ * arguments is non-zero.
*/
- frame = curthread->td_intr_frame;
+ frame = td->td_intr_frame;
if (frame != NULL) {
if (TRAPF_USERMODE(frame))
upc = TRAPF_PC(frame);
else
pc = TRAPF_PC(frame);
- }
+ } else if (TD_IS_IDLETHREAD(td))
+ pc = (uintfptr_t)&cpu_idle;
+
dtrace_probe(prof->prof_id, pc, upc, late, 0, 0);
+}
+static void
+profile_fire(void *arg)
+{
+ profile_probe_percpu_t *pcpu = arg;
+ profile_probe_t *prof = pcpu->profc_probe;
+ hrtime_t late;
+
+ late = sbt_to_nsec(sbinuptime() - pcpu->profc_expected);
+
+ profile_probe(prof, late);
pcpu->profc_expected += pcpu->profc_interval;
callout_schedule_sbt_curcpu(&pcpu->profc_cyclic,
pcpu->profc_expected, 0, C_DIRECT_EXEC | C_ABSOLUTE);
@@ -306,26 +312,8 @@ static void
profile_tick(void *arg)
{
profile_probe_t *prof = arg;
- struct trapframe *frame;
- uintfptr_t pc, upc;
-
- pc = 0;
- upc = 0;
-
- /*
- * td_intr_frame can be unset if this is a catch up event
- * after waking up from idle sleep.
- * This can only happen on a CPU idle thread.
- */
- frame = curthread->td_intr_frame;
- if (frame != NULL) {
- if (TRAPF_USERMODE(frame))
- upc = TRAPF_PC(frame);
- else
- pc = TRAPF_PC(frame);
- }
- dtrace_probe(prof->prof_id, pc, upc, 0, 0, 0);
+ profile_probe(prof, 0);
prof->prof_expected += prof->prof_interval;
callout_schedule_sbt(&prof->prof_cyclic,
prof->prof_expected, 0, C_DIRECT_EXEC | C_ABSOLUTE);
diff --git a/sys/compat/linuxkpi/common/src/linux_rcu.c b/sys/compat/linuxkpi/common/src/linux_rcu.c
index 123f1b287064..bb43707ec290 100644
--- a/sys/compat/linuxkpi/common/src/linux_rcu.c
+++ b/sys/compat/linuxkpi/common/src/linux_rcu.c
@@ -119,7 +119,7 @@ linux_rcu_runtime_init(void *arg __unused)
TAILQ_INIT(&record->ts_head);
}
}
-SYSINIT(linux_rcu_runtime, SI_SUB_LOCK, SI_ORDER_SECOND, linux_rcu_runtime_init, NULL);
+SYSINIT(linux_rcu_runtime, SI_SUB_CPU, SI_ORDER_ANY, linux_rcu_runtime_init, NULL);
static void
linux_rcu_runtime_uninit(void *arg __unused)
diff --git a/sys/conf/files b/sys/conf/files
index c63c4e17711a..e0ed1c12c278 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -673,6 +673,7 @@ dev/acpica/acpi_perf.c optional acpi
dev/acpica/acpi_powerres.c optional acpi
dev/acpica/acpi_quirk.c optional acpi
dev/acpica/acpi_resource.c optional acpi
+dev/acpica/acpi_container.c optional acpi
dev/acpica/acpi_smbat.c optional acpi
dev/acpica/acpi_thermal.c optional acpi
dev/acpica/acpi_throttle.c optional acpi
@@ -1854,6 +1855,7 @@ dev/iwm/if_iwm_phy_ctxt.c optional iwm
dev/iwm/if_iwm_phy_db.c optional iwm
dev/iwm/if_iwm_power.c optional iwm
dev/iwm/if_iwm_scan.c optional iwm
+dev/iwm/if_iwm_sta.c optional iwm
dev/iwm/if_iwm_time_event.c optional iwm
dev/iwm/if_iwm_util.c optional iwm
iwm3160fw.c optional iwm3160fw | iwmfw \
diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64
index f0c46128176f..b50f5fe0ffea 100644
--- a/sys/conf/files.amd64
+++ b/sys/conf/files.amd64
@@ -323,6 +323,7 @@ dev/hyperv/vmbus/vmbus_br.c optional hyperv
dev/hyperv/vmbus/vmbus_chan.c optional hyperv
dev/hyperv/vmbus/vmbus_et.c optional hyperv
dev/hyperv/vmbus/vmbus_if.m optional hyperv
+dev/hyperv/vmbus/vmbus_res.c optional hyperv
dev/hyperv/vmbus/vmbus_xact.c optional hyperv
dev/hyperv/vmbus/amd64/hyperv_machdep.c optional hyperv
dev/hyperv/vmbus/amd64/vmbus_vector.S optional hyperv
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index e51ee82ee23e..3784d87f44b5 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -244,6 +244,7 @@ dev/hyperv/vmbus/vmbus_br.c optional hyperv
dev/hyperv/vmbus/vmbus_chan.c optional hyperv
dev/hyperv/vmbus/vmbus_et.c optional hyperv
dev/hyperv/vmbus/vmbus_if.m optional hyperv
+dev/hyperv/vmbus/vmbus_res.c optional hyperv
dev/hyperv/vmbus/vmbus_xact.c optional hyperv
dev/hyperv/vmbus/i386/hyperv_machdep.c optional hyperv
dev/hyperv/vmbus/i386/vmbus_vector.S optional hyperv
diff --git a/sys/conf/kern.opts.mk b/sys/conf/kern.opts.mk
index 1e661186c9d9..72420eebac19 100644
--- a/sys/conf/kern.opts.mk
+++ b/sys/conf/kern.opts.mk
@@ -41,6 +41,7 @@ __DEFAULT_YES_OPTIONS = \
PF \
SOURCELESS_HOST \
SOURCELESS_UCODE \
+ TESTS \
USB_GADGET_EXAMPLES \
ZFS
diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk
index aa6cc60202ec..6d0587ba12e5 100644
--- a/sys/conf/kern.post.mk
+++ b/sys/conf/kern.post.mk
@@ -35,7 +35,7 @@ KERN_DEBUGDIR?= ${DEBUGDIR}
.MAIN: all
.for target in all clean cleandepend cleandir clobber depend install \
- obj reinstall tags
+ ${_obj} reinstall tags
${target}: kernel-${target}
.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
${target}: modules-${target}
diff --git a/sys/conf/kern.pre.mk b/sys/conf/kern.pre.mk
index 95118dee0794..a443de7b71b8 100644
--- a/sys/conf/kern.pre.mk
+++ b/sys/conf/kern.pre.mk
@@ -24,6 +24,14 @@ _srcconf_included_:
.MAKE.MODE+= curdirOk=yes
.endif
+.if defined(NO_OBJ) || ${MK_AUTO_OBJ} == "yes"
+NO_OBJ= t
+NO_MODULES_OBJ= t
+.endif
+.if !defined(NO_OBJ)
+_obj= obj
+.endif
+
# Can be overridden by makeoptions or /etc/make.conf
KERNEL_KO?= kernel
KERNEL?= kernel
diff --git a/sys/dev/acpica/acpi_container.c b/sys/dev/acpica/acpi_container.c
new file mode 100644
index 000000000000..26855bd732d7
--- /dev/null
+++ b/sys/dev/acpica/acpi_container.c
@@ -0,0 +1,166 @@
+/*-
+ * Copyright (c) 2017 Microsoft Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/module.h>
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <dev/acpica/acpivar.h>
+
+#include "pcib_if.h"
+
+ACPI_MODULE_NAME("CONTAINER")
+
+static int acpi_syscont_probe(device_t);
+static int acpi_syscont_attach(device_t);
+static int acpi_syscont_detach(device_t);
+static int acpi_syscont_alloc_msi(device_t, device_t,
+ int count, int maxcount, int *irqs);
+static int acpi_syscont_release_msi(device_t bus, device_t dev,
+ int count, int *irqs);
+static int acpi_syscont_alloc_msix(device_t bus, device_t dev,
+ int *irq);
+static int acpi_syscont_release_msix(device_t bus, device_t dev,
+ int irq);
+static int acpi_syscont_map_msi(device_t bus, device_t dev,
+ int irq, uint64_t *addr, uint32_t *data);
+
+static device_method_t acpi_syscont_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, acpi_syscont_probe),
+ DEVMETHOD(device_attach, acpi_syscont_attach),
+ DEVMETHOD(device_detach, acpi_syscont_detach),
+
+ /* Bus interface */
+ DEVMETHOD(bus_add_child, bus_generic_add_child),
+ DEVMETHOD(bus_print_child, bus_generic_print_child),
+ DEVMETHOD(bus_alloc_resource, bus_generic_alloc_resource),
+ DEVMETHOD(bus_release_resource, bus_generic_release_resource),
+ DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
+ DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
+ DEVMETHOD(bus_setup_intr, bus_generic_setup_intr),
+ DEVMETHOD(bus_teardown_intr, bus_generic_teardown_intr),
+#if __FreeBSD_version >= 1100000
+ DEVMETHOD(bus_get_cpus, bus_generic_get_cpus),
+#endif
+
+ /* pcib interface */
+ DEVMETHOD(pcib_alloc_msi, acpi_syscont_alloc_msi),
+ DEVMETHOD(pcib_release_msi, acpi_syscont_release_msi),
+ DEVMETHOD(pcib_alloc_msix, acpi_syscont_alloc_msix),
+ DEVMETHOD(pcib_release_msix, acpi_syscont_release_msix),
+ DEVMETHOD(pcib_map_msi, acpi_syscont_map_msi),
+
+ DEVMETHOD_END
+};
+
+static driver_t acpi_syscont_driver = {
+ "acpi_syscontainer",
+ acpi_syscont_methods,
+ 0,
+};
+
+static devclass_t acpi_syscont_devclass;
+
+DRIVER_MODULE(acpi_syscontainer, acpi, acpi_syscont_driver,
+ acpi_syscont_devclass, NULL, NULL);
+MODULE_DEPEND(acpi_syscontainer, acpi, 1, 1, 1);
+
+static int
+acpi_syscont_probe(device_t dev)
+{
+ static char *syscont_ids[] = { "ACPI0004", "PNP0A05", "PNP0A06", NULL };
+
+ if (acpi_disabled("syscontainer") ||
+ ACPI_ID_PROBE(device_get_parent(dev), dev, syscont_ids) == NULL)
+ return (ENXIO);
+
+ device_set_desc(dev, "System Container");
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+acpi_syscont_attach(device_t dev)
+{
+
+ bus_generic_probe(dev);
+ return (bus_generic_attach(dev));
+}
+
+static int
+acpi_syscont_detach(device_t dev)
+{
+
+ return (bus_generic_detach(dev));
+}
+
+static int
+acpi_syscont_alloc_msi(device_t bus, device_t dev, int count, int maxcount,
+ int *irqs)
+{
+ device_t parent = device_get_parent(bus);
+
+ return (PCIB_ALLOC_MSI(device_get_parent(parent), dev, count, maxcount,
+ irqs));
+}
+
+static int
+acpi_syscont_release_msi(device_t bus, device_t dev, int count, int *irqs)
+{
+ device_t parent = device_get_parent(bus);
+
+ return (PCIB_RELEASE_MSI(device_get_parent(parent), dev, count, irqs));
+}
+
+static int
+acpi_syscont_alloc_msix(device_t bus, device_t dev, int *irq)
+{
+ device_t parent = device_get_parent(bus);
+
+ return (PCIB_ALLOC_MSIX(device_get_parent(parent), dev, irq));
+}
+
+static int
+acpi_syscont_release_msix(device_t bus, device_t dev, int irq)
+{
+ device_t parent = device_get_parent(bus);
+
+ return (PCIB_RELEASE_MSIX(device_get_parent(parent), dev, irq));
+}
+
+static int
+acpi_syscont_map_msi(device_t bus, device_t dev, int irq, uint64_t *addr,
+ uint32_t *data)
+{
+ device_t parent = device_get_parent(bus);
+
+ return (PCIB_MAP_MSI(device_get_parent(parent), dev, irq, addr, data));
+}
diff --git a/sys/dev/acpica/acpi_pcib_acpi.c b/sys/dev/acpica/acpi_pcib_acpi.c
index d26ee0c37cd6..a1c94fb66c8a 100644
--- a/sys/dev/acpica/acpi_pcib_acpi.c
+++ b/sys/dev/acpica/acpi_pcib_acpi.c
@@ -537,6 +537,7 @@ acpi_pcib_acpi_attach(device_t dev)
acpi_pcib_fetch_prt(dev, &sc->ap_prt);
+ bus_generic_probe(dev);
if (device_add_child(dev, "pci", -1) == NULL) {
device_printf(device_get_parent(dev), "couldn't attach pci bus\n");
#if defined(NEW_PCIB) && defined(PCI_RES_BUS)
diff --git a/sys/dev/bnxt/if_bnxt.c b/sys/dev/bnxt/if_bnxt.c
index 1c6c66f14271..e0675045ab67 100644
--- a/sys/dev/bnxt/if_bnxt.c
+++ b/sys/dev/bnxt/if_bnxt.c
@@ -287,7 +287,8 @@ static driver_t bnxt_iflib_driver = {
* iflib shared context
*/
-char bnxt_driver_version[] = "FreeBSD base";
+#define BNXT_DRIVER_VERSION "1.0.0.0"
+char bnxt_driver_version[] = BNXT_DRIVER_VERSION;
extern struct if_txrx bnxt_txrx;
static struct if_shared_ctx bnxt_sctx_init = {
.isc_magic = IFLIB_MAGIC,
diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h
index e71afdd6b14f..02453c299007 100644
--- a/sys/dev/cxgbe/adapter.h
+++ b/sys/dev/cxgbe/adapter.h
@@ -204,11 +204,11 @@ struct vi_info {
int first_intr;
/* These need to be int as they are used in sysctl */
- int ntxq; /* # of tx queues */
- int first_txq; /* index of first tx queue */
- int rsrv_noflowq; /* Reserve queue 0 for non-flowid packets */
- int nrxq; /* # of rx queues */
- int first_rxq; /* index of first rx queue */
+ int ntxq; /* # of tx queues */
+ int first_txq; /* index of first tx queue */
+ int rsrv_noflowq; /* Reserve queue 0 for non-flowid packets */
+ int nrxq; /* # of rx queues */
+ int first_rxq; /* index of first rx queue */
int nofldtxq; /* # of offload tx queues */
int first_ofld_txq; /* index of first offload tx queue */
int nofldrxq; /* # of offload rx queues */
@@ -399,6 +399,7 @@ enum {
EQ_TYPEMASK = 0x3, /* 2 lsbits hold the type (see above) */
EQ_ALLOCATED = (1 << 2), /* firmware resources allocated */
EQ_ENABLED = (1 << 3), /* open for business */
+ EQ_QFLUSH = (1 << 4), /* if_qflush in progress */
};
/* Listed in order of preference. Update t4_sysctls too if you change these */
@@ -704,7 +705,7 @@ struct sge_nm_txq {
struct sge {
int nrxq; /* total # of Ethernet rx queues */
- int ntxq; /* total # of Ethernet tx tx queues */
+ int ntxq; /* total # of Ethernet tx queues */
int nofldrxq; /* total # of TOE rx queues */
int nofldtxq; /* total # of TOE tx queues */
int nnmrxq; /* total # of netmap rx queues */
@@ -1086,6 +1087,24 @@ port_top_speed(const struct port_info *pi)
}
static inline int
+port_top_speed_raw(const struct port_info *pi)
+{
+
+ if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_100G)
+ return (FW_PORT_CAP_SPEED_100G);
+ if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_40G)
+ return (FW_PORT_CAP_SPEED_40G);
+ if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_25G)
+ return (FW_PORT_CAP_SPEED_25G);
+ if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_10G)
+ return (FW_PORT_CAP_SPEED_10G);
+ if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_1G)
+ return (FW_PORT_CAP_SPEED_1G);
+
+ return (0);
+}
+
+static inline int
tx_resume_threshold(struct sge_eq *eq)
{
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
index 02146f3aae24..9b5e4ff09a11 100644
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -995,6 +995,7 @@ t4_attach(device_t dev)
lc->autoneg = t4_autoneg ? AUTONEG_ENABLE :
AUTONEG_DISABLE;
}
+ lc->requested_speed = port_top_speed_raw(pi);
rc = -t4_link_l1cfg(sc, sc->mbox, pi->tx_chan, lc);
if (rc != 0) {
@@ -1868,12 +1869,15 @@ cxgbe_qflush(struct ifnet *ifp)
if (vi->flags & VI_INIT_DONE) {
for_each_txq(vi, i, txq) {
TXQ_LOCK(txq);
- txq->eq.flags &= ~EQ_ENABLED;
+ txq->eq.flags |= EQ_QFLUSH;
TXQ_UNLOCK(txq);
while (!mp_ring_is_idle(txq->r)) {
mp_ring_check_drainage(txq->r, 0);
pause("qflush", 1);
}
+ TXQ_LOCK(txq);
+ txq->eq.flags &= ~EQ_QFLUSH;
+ TXQ_UNLOCK(txq);
}
}
if_qflush(ifp);
@@ -5883,7 +5887,12 @@ sysctl_autoneg(SYSCTL_HANDLER_ARGS)
if ((lc->supported & FW_PORT_CAP_ANEG) == 0)
return (ENOTSUP);
- val = val ? AUTONEG_ENABLE : AUTONEG_DISABLE;
+ if (val == 0)
+ val = AUTONEG_DISABLE;
+ else if (val == 1)
+ val = AUTONEG_ENABLE;
+ else
+ return (EINVAL);
if (lc->autoneg == val)
return (0); /* no change */
@@ -5896,6 +5905,7 @@ sysctl_autoneg(SYSCTL_HANDLER_ARGS)
rc = -t4_link_l1cfg(sc, sc->mbox, pi->tx_chan, lc);
if (rc != 0)
lc->autoneg = old;
+ end_synchronized_op(sc, 0);
return (rc);
}
diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
index 496b91dbbaa4..527bf46f4f8c 100644
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -969,6 +969,11 @@ vi_intr_iq(struct vi_info *vi, int idx)
return (&sc->sge.fwq);
nintr = vi->nintr;
+#ifdef DEV_NETMAP
+ /* Do not consider any netmap-only interrupts */
+ if (vi->flags & INTR_RXQ && vi->nnmrxq > vi->nrxq)
+ nintr -= vi->nnmrxq - vi->nrxq;
+#endif
KASSERT(nintr != 0,
("%s: vi %p has no exclusive interrupts, total interrupts = %d",
__func__, vi, sc->intr_count));
@@ -2452,6 +2457,13 @@ cannot_use_txpkts(struct mbuf *m)
return (needs_tso(m));
}
+static inline int
+discard_tx(struct sge_eq *eq)
+{
+
+ return ((eq->flags & (EQ_ENABLED | EQ_QFLUSH)) != EQ_ENABLED);
+}
+
/*
* r->items[cidx] to r->items[pidx], with a wraparound at r->size, are ready to
* be consumed. Return the actual number consumed. 0 indicates a stall.
@@ -2477,7 +2489,7 @@ eth_tx(struct mp_ring *r, u_int cidx, u_int pidx)
total = 0;
TXQ_LOCK(txq);
- if (__predict_false((eq->flags & EQ_ENABLED) == 0)) {
+ if (__predict_false(discard_tx(eq))) {
while (cidx != pidx) {
m0 = r->items[cidx];
m_freem(m0);
@@ -5311,7 +5323,7 @@ sysctl_tc(SYSCTL_HANDLER_ARGS)
tc->refcount--;
}
txq->tc_idx = tc_idx;
- } else {
+ } else if (tc_idx != -1) {
tc = &pi->sched_params->cl_rl[tc_idx];
MPASS(tc->refcount > 0);
tc->refcount--;
diff --git a/sys/dev/dpaa/if_dtsec_rm.c b/sys/dev/dpaa/if_dtsec_rm.c
index 66c20e3175ae..7939ae10648e 100644
--- a/sys/dev/dpaa/if_dtsec_rm.c
+++ b/sys/dev/dpaa/if_dtsec_rm.c
@@ -115,7 +115,7 @@ dtsec_rm_fi_pool_init(struct dtsec_softc *sc)
sc->sc_fi_zone = uma_zcreate(sc->sc_fi_zname,
sizeof(struct dtsec_rm_frame_info), NULL, NULL, NULL, NULL,
- sizeof(void *), 0);
+ UMA_ALIGN_PTR, 0);
if (sc->sc_fi_zone == NULL)
return (EIO);
@@ -312,7 +312,7 @@ dtsec_rm_pool_rx_init(struct dtsec_softc *sc)
device_get_nameunit(sc->sc_dev));
sc->sc_rx_zone = uma_zcreate(sc->sc_rx_zname, FM_PORT_BUFFER_SIZE, NULL,
- NULL, NULL, NULL, FM_PORT_BUFFER_SIZE, 0);
+ NULL, NULL, NULL, FM_PORT_BUFFER_SIZE - 1, 0);
if (sc->sc_rx_zone == NULL)
return (EIO);
diff --git a/sys/dev/e1000/e1000_ich8lan.c b/sys/dev/e1000/e1000_ich8lan.c
index 0d8485ff3fa0..9be9ac799d94 100644
--- a/sys/dev/e1000/e1000_ich8lan.c
+++ b/sys/dev/e1000/e1000_ich8lan.c
@@ -1496,24 +1496,24 @@ s32 e1000_disable_ulp_lpt_lp(struct e1000_hw *hw, bool force)
ret_val = e1000_read_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, &phy_reg);
if (ret_val)
goto release;
- phy_reg &= ~(I218_ULP_CONFIG1_IND |
- I218_ULP_CONFIG1_STICKY_ULP |
- I218_ULP_CONFIG1_RESET_TO_SMBUS |
- I218_ULP_CONFIG1_WOL_HOST |
- I218_ULP_CONFIG1_INBAND_EXIT |
- I218_ULP_CONFIG1_EN_ULP_LANPHYPC |
- I218_ULP_CONFIG1_DIS_CLR_STICKY_ON_PERST |
- I218_ULP_CONFIG1_DISABLE_SMB_PERST);
- e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
-
- /* Commit ULP changes by starting auto ULP configuration */
- phy_reg |= I218_ULP_CONFIG1_START;
- e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
-
- /* Clear Disable SMBus Release on PERST# in MAC */
- mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM7);
- mac_reg &= ~E1000_FEXTNVM7_DISABLE_SMB_PERST;
- E1000_WRITE_REG(hw, E1000_FEXTNVM7, mac_reg);
+ phy_reg &= ~(I218_ULP_CONFIG1_IND |
+ I218_ULP_CONFIG1_STICKY_ULP |
+ I218_ULP_CONFIG1_RESET_TO_SMBUS |
+ I218_ULP_CONFIG1_WOL_HOST |
+ I218_ULP_CONFIG1_INBAND_EXIT |
+ I218_ULP_CONFIG1_EN_ULP_LANPHYPC |
+ I218_ULP_CONFIG1_DIS_CLR_STICKY_ON_PERST |
+ I218_ULP_CONFIG1_DISABLE_SMB_PERST);
+ e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
+
+ /* Commit ULP changes by starting auto ULP configuration */
+ phy_reg |= I218_ULP_CONFIG1_START;
+ e1000_write_phy_reg_hv_locked(hw, I218_ULP_CONFIG1, phy_reg);
+
+ /* Clear Disable SMBus Release on PERST# in MAC */
+ mac_reg = E1000_READ_REG(hw, E1000_FEXTNVM7);
+ mac_reg &= ~E1000_FEXTNVM7_DISABLE_SMB_PERST;
+ E1000_WRITE_REG(hw, E1000_FEXTNVM7, mac_reg);
release:
hw->phy.ops.release(hw);
@@ -1556,13 +1556,13 @@ static s32 e1000_check_for_copper_link_ich8lan(struct e1000_hw *hw)
if (!mac->get_link_status)
return E1000_SUCCESS;
- /* First we want to see if the MII Status Register reports
- * link. If so, then we want to get the current speed/duplex
- * of the PHY.
- */
- ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
- if (ret_val)
- return ret_val;
+ /* First we want to see if the MII Status Register reports
+ * link. If so, then we want to get the current speed/duplex
+ * of the PHY.
+ */
+ ret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);
+ if (ret_val)
+ return ret_val;
if (hw->mac.type == e1000_pchlan) {
ret_val = e1000_k1_gig_workaround_hv(hw, link);
diff --git a/sys/dev/hyperv/vmbus/vmbus.c b/sys/dev/hyperv/vmbus/vmbus.c
index 23ae6ed592c9..999990182239 100644
--- a/sys/dev/hyperv/vmbus/vmbus.c
+++ b/sys/dev/hyperv/vmbus/vmbus.c
@@ -71,6 +71,7 @@ struct vmbus_msghc {
struct hypercall_postmsg_in mh_inprm_save;
};
+static void vmbus_identify(driver_t *, device_t);
static int vmbus_probe(device_t);
static int vmbus_attach(device_t);
static int vmbus_detach(device_t);
@@ -144,6 +145,7 @@ vmbus_chanmsg_handlers[VMBUS_CHANMSG_TYPE_MAX] = {
static device_method_t vmbus_methods[] = {
/* Device interface */
+ DEVMETHOD(device_identify, vmbus_identify),
DEVMETHOD(device_probe, vmbus_probe),
DEVMETHOD(device_attach, vmbus_attach),
DEVMETHOD(device_detach, vmbus_detach),
@@ -190,7 +192,10 @@ static driver_t vmbus_driver = {
static devclass_t vmbus_devclass;
-DRIVER_MODULE(vmbus, acpi, vmbus_driver, vmbus_devclass, NULL, NULL);
+DRIVER_MODULE(vmbus, pcib, vmbus_driver, vmbus_devclass, NULL, NULL);
+DRIVER_MODULE(vmbus, acpi_syscontainer, vmbus_driver, vmbus_devclass,
+ NULL, NULL);
+
MODULE_DEPEND(vmbus, acpi, 1, 1, 1);
MODULE_DEPEND(vmbus, pci, 1, 1, 1);
MODULE_VERSION(vmbus, 1);
@@ -1066,43 +1071,41 @@ vmbus_alloc_resource(device_t dev, device_t child, int type, int *rid,
return (res);
}
-static device_t
-get_nexus(device_t vmbus)
-{
- device_t acpi = device_get_parent(vmbus);
- device_t nexus = device_get_parent(acpi);
- return (nexus);
-}
-
static int
vmbus_alloc_msi(device_t bus, device_t dev, int count, int maxcount, int *irqs)
{
- return (PCIB_ALLOC_MSI(get_nexus(bus), dev, count, maxcount, irqs));
+
+ return (PCIB_ALLOC_MSI(device_get_parent(bus), dev, count, maxcount,
+ irqs));
}
static int
vmbus_release_msi(device_t bus, device_t dev, int count, int *irqs)
{
- return (PCIB_RELEASE_MSI(get_nexus(bus), dev, count, irqs));
+
+ return (PCIB_RELEASE_MSI(device_get_parent(bus), dev, count, irqs));
}
static int
vmbus_alloc_msix(device_t bus, device_t dev, int *irq)
{
- return (PCIB_ALLOC_MSIX(get_nexus(bus), dev, irq));
+
+ return (PCIB_ALLOC_MSIX(device_get_parent(bus), dev, irq));
}
static int
vmbus_release_msix(device_t bus, device_t dev, int irq)
{
- return (PCIB_RELEASE_MSIX(get_nexus(bus), dev, irq));
+
+ return (PCIB_RELEASE_MSIX(device_get_parent(bus), dev, irq));
}
static int
vmbus_map_msi(device_t bus, device_t dev, int irq, uint64_t *addr,
uint32_t *data)
{
- return (PCIB_MAP_MSI(get_nexus(bus), dev, irq, addr, data));
+
+ return (PCIB_MAP_MSI(device_get_parent(bus), dev, irq, addr, data));
}
static uint32_t
@@ -1216,36 +1219,44 @@ vmbus_get_crs(device_t dev, device_t vmbus_dev, enum parse_pass pass)
static void
vmbus_get_mmio_res_pass(device_t dev, enum parse_pass pass)
{
- device_t acpi0, pcib0 = NULL;
- device_t *children;
- int i, count;
-
- /* Try to find _CRS on VMBus device */
- vmbus_get_crs(dev, dev, pass);
+ device_t acpi0, parent;
- /* Try to find _CRS on VMBus device's parent */
- acpi0 = device_get_parent(dev);
- vmbus_get_crs(acpi0, dev, pass);
-
- /* Try to locate pcib0 and find _CRS on it */
- if (device_get_children(acpi0, &children, &count) != 0)
- return;
+ parent = device_get_parent(dev);
- for (i = 0; i < count; i++) {
- if (!device_is_attached(children[i]))
- continue;
+ acpi0 = device_get_parent(parent);
+ if (strcmp("acpi0", device_get_nameunit(acpi0)) == 0) {
+ device_t *children;
+ int count;
- if (strcmp("pcib0", device_get_nameunit(children[i])))
- continue;
+ /*
+ * Try to locate VMBUS resources and find _CRS on them.
+ */
+ if (device_get_children(acpi0, &children, &count) == 0) {
+ int i;
+
+ for (i = 0; i < count; ++i) {
+ if (!device_is_attached(children[i]))
+ continue;
+
+ if (strcmp("vmbus_res",
+ device_get_name(children[i])) == 0)
+ vmbus_get_crs(children[i], dev, pass);
+ }
+ free(children, M_TEMP);
+ }
- pcib0 = children[i];
- break;
+ /*
+ * Try to find _CRS on acpi.
+ */
+ vmbus_get_crs(acpi0, dev, pass);
+ } else {
+ device_printf(dev, "not grandchild of acpi\n");
}
- if (pcib0)
- vmbus_get_crs(pcib0, dev, pass);
-
- free(children, M_TEMP);
+ /*
+ * Try to find _CRS on parent.
+ */
+ vmbus_get_crs(parent, dev, pass);
}
static void
@@ -1275,18 +1286,25 @@ vmbus_free_mmio_res(device_t dev)
}
#endif /* NEW_PCIB */
+static void
+vmbus_identify(driver_t *driver, device_t parent)
+{
+
+ if (device_get_unit(parent) != 0 || vm_guest != VM_GUEST_HV ||
+ (hyperv_features & CPUID_HV_MSR_SYNIC) == 0)
+ return;
+ device_add_child(parent, "vmbus", -1);
+}
+
static int
vmbus_probe(device_t dev)
{
- char *id[] = { "VMBUS", NULL };
- if (ACPI_ID_PROBE(device_get_parent(dev), dev, id) == NULL ||
- device_get_unit(dev) != 0 || vm_guest != VM_GUEST_HV ||
+ if (device_get_unit(dev) != 0 || vm_guest != VM_GUEST_HV ||
(hyperv_features & CPUID_HV_MSR_SYNIC) == 0)
return (ENXIO);
device_set_desc(dev, "Hyper-V Vmbus");
-
return (BUS_PROBE_DEFAULT);
}
diff --git a/sys/dev/hyperv/vmbus/vmbus_res.c b/sys/dev/hyperv/vmbus/vmbus_res.c
new file mode 100644
index 000000000000..164ebeb9175e
--- /dev/null
+++ b/sys/dev/hyperv/vmbus/vmbus_res.c
@@ -0,0 +1,98 @@
+/*-
+ * Copyright (c) 2017 Microsoft Corp.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice unmodified, this list of conditions, and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/module.h>
+
+#include <contrib/dev/acpica/include/acpi.h>
+#include <dev/acpica/acpivar.h>
+
+#include <dev/hyperv/include/hyperv.h>
+
+#include "acpi_if.h"
+#include "bus_if.h"
+
+static int vmbus_res_probe(device_t);
+static int vmbus_res_attach(device_t);
+static int vmbus_res_detach(device_t);
+
+static device_method_t vmbus_res_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, vmbus_res_probe),
+ DEVMETHOD(device_attach, vmbus_res_attach),
+ DEVMETHOD(device_detach, vmbus_res_detach),
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
+ DEVMETHOD(device_suspend, bus_generic_suspend),
+ DEVMETHOD(device_resume, bus_generic_resume),
+
+ DEVMETHOD_END
+};
+
+static driver_t vmbus_res_driver = {
+ "vmbus_res",
+ vmbus_res_methods,
+ 1
+};
+
+static devclass_t vmbus_res_devclass;
+
+DRIVER_MODULE(vmbus_res, acpi, vmbus_res_driver, vmbus_res_devclass,
+ NULL, NULL);
+MODULE_DEPEND(vmbus_res, acpi, 1, 1, 1);
+MODULE_VERSION(vmbus_res, 1);
+
+static int
+vmbus_res_probe(device_t dev)
+{
+ char *id[] = { "VMBUS", NULL };
+
+ if (ACPI_ID_PROBE(device_get_parent(dev), dev, id) == NULL ||
+ device_get_unit(dev) != 0 || vm_guest != VM_GUEST_HV ||
+ (hyperv_features & CPUID_HV_MSR_SYNIC) == 0)
+ return (ENXIO);
+
+ device_set_desc(dev, "Hyper-V Vmbus Resource");
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+vmbus_res_attach(device_t dev __unused)
+{
+
+ return (0);
+}
+
+static int
+vmbus_res_detach(device_t dev __unused)
+{
+
+ return (0);
+}
diff --git a/sys/dev/iwm/if_iwm.c b/sys/dev/iwm/if_iwm.c
index ed64b50acd15..e6a21f9fba25 100644
--- a/sys/dev/iwm/if_iwm.c
+++ b/sys/dev/iwm/if_iwm.c
@@ -106,6 +106,7 @@
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
+#include "opt_iwm.h"
#include <sys/param.h>
#include <sys/bus.h>
@@ -163,11 +164,15 @@ __FBSDID("$FreeBSD$");
#include <dev/iwm/if_iwm_time_event.h>
#include <dev/iwm/if_iwm_power.h>
#include <dev/iwm/if_iwm_scan.h>
+#include <dev/iwm/if_iwm_sta.h>
#include <dev/iwm/if_iwm_pcie_trans.h>
#include <dev/iwm/if_iwm_led.h>
#include <dev/iwm/if_iwm_fw.h>
+/* From DragonflyBSD */
+#define mtodoff(m, t, off) ((t)((m)->m_data + (off)))
+
const uint8_t iwm_nvm_channels[] = {
/* 2.4 GHz */
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
@@ -261,7 +266,6 @@ static void iwm_mvm_nic_config(struct iwm_softc *);
static int iwm_nic_rx_init(struct iwm_softc *);
static int iwm_nic_tx_init(struct iwm_softc *);
static int iwm_nic_init(struct iwm_softc *);
-static int iwm_enable_txq(struct iwm_softc *, int, int, int);
static int iwm_trans_pcie_fw_alive(struct iwm_softc *, uint32_t);
static int iwm_nvm_read_chunk(struct iwm_softc *, uint16_t, uint16_t,
uint16_t, uint8_t *, uint16_t *);
@@ -319,16 +323,15 @@ static int iwm_rx_addbuf(struct iwm_softc *, int, int);
static int iwm_mvm_get_signal_strength(struct iwm_softc *,
struct iwm_rx_phy_info *);
static void iwm_mvm_rx_rx_phy_cmd(struct iwm_softc *,
- struct iwm_rx_packet *,
- struct iwm_rx_data *);
+ struct iwm_rx_packet *);
static int iwm_get_noise(struct iwm_softc *sc,
const struct iwm_mvm_statistics_rx_non_phy *);
-static void iwm_mvm_rx_rx_mpdu(struct iwm_softc *, struct mbuf *);
+static boolean_t iwm_mvm_rx_rx_mpdu(struct iwm_softc *, struct mbuf *,
+ uint32_t, boolean_t);
static int iwm_mvm_rx_tx_cmd_single(struct iwm_softc *,
struct iwm_rx_packet *,
struct iwm_node *);
-static void iwm_mvm_rx_tx_cmd(struct iwm_softc *, struct iwm_rx_packet *,
- struct iwm_rx_data *);
+static void iwm_mvm_rx_tx_cmd(struct iwm_softc *, struct iwm_rx_packet *);
static void iwm_cmd_done(struct iwm_softc *, struct iwm_rx_packet *);
#if 0
static void iwm_update_sched(struct iwm_softc *, int, int, uint8_t,
@@ -341,22 +344,8 @@ static int iwm_tx(struct iwm_softc *, struct mbuf *,
struct ieee80211_node *, int);
static int iwm_raw_xmit(struct ieee80211_node *, struct mbuf *,
const struct ieee80211_bpf_params *);
-static int iwm_mvm_flush_tx_path(struct iwm_softc *sc,
- uint32_t tfd_msk, uint32_t flags);
-static int iwm_mvm_send_add_sta_cmd_status(struct iwm_softc *,
- struct iwm_mvm_add_sta_cmd *,
- int *);
-static int iwm_mvm_sta_send_to_fw(struct iwm_softc *, struct iwm_node *,
- int);
-static int iwm_mvm_add_sta(struct iwm_softc *, struct iwm_node *);
-static int iwm_mvm_update_sta(struct iwm_softc *, struct iwm_node *);
-static int iwm_mvm_add_int_sta_common(struct iwm_softc *,
- struct iwm_int_sta *,
- const uint8_t *, uint16_t, uint16_t);
-static int iwm_mvm_add_aux_sta(struct iwm_softc *);
-static int iwm_mvm_update_quotas(struct iwm_softc *, struct iwm_node *);
+static int iwm_mvm_update_quotas(struct iwm_softc *, struct iwm_vap *);
static int iwm_auth(struct ieee80211vap *, struct iwm_softc *);
-static int iwm_assoc(struct ieee80211vap *, struct iwm_softc *);
static int iwm_release(struct iwm_softc *, struct iwm_node *);
static struct ieee80211_node *
iwm_node_alloc(struct ieee80211vap *,
@@ -384,6 +373,7 @@ static const char *
static void iwm_nic_error(struct iwm_softc *);
static void iwm_nic_umac_error(struct iwm_softc *);
#endif
+static void iwm_handle_rxb(struct iwm_softc *, struct mbuf *);
static void iwm_notif_intr(struct iwm_softc *);
static void iwm_intr(void *);
static int iwm_attach(device_t);
@@ -548,12 +538,14 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type)
{
struct iwm_fw_info *fw = &sc->sc_fw;
const struct iwm_tlv_ucode_header *uhdr;
- struct iwm_ucode_tlv tlv;
+ const struct iwm_ucode_tlv *tlv;
struct iwm_ucode_capabilities *capa = &sc->ucode_capa;
enum iwm_ucode_tlv_type tlv_type;
const struct firmware *fwp;
const uint8_t *data;
+ uint32_t tlv_len;
uint32_t usniffer_img;
+ const uint8_t *tlv_data;
uint32_t paging_mem_size;
int num_of_cpus;
int error = 0;
@@ -606,24 +598,20 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type)
goto out;
}
- snprintf(sc->sc_fwver, sizeof(sc->sc_fwver), "%d.%d (API ver %d)",
+ snprintf(sc->sc_fwver, sizeof(sc->sc_fwver), "%u.%u (API ver %u)",
IWM_UCODE_MAJOR(le32toh(uhdr->ver)),
IWM_UCODE_MINOR(le32toh(uhdr->ver)),
IWM_UCODE_API(le32toh(uhdr->ver)));
data = uhdr->data;
len = fw->fw_fp->datasize - sizeof(*uhdr);
- while (len >= sizeof(tlv)) {
- size_t tlv_len;
- const void *tlv_data;
-
- memcpy(&tlv, data, sizeof(tlv));
- tlv_len = le32toh(tlv.length);
- tlv_type = le32toh(tlv.type);
+ while (len >= sizeof(*tlv)) {
+ len -= sizeof(*tlv);
+ tlv = (const void *)data;
- len -= sizeof(tlv);
- data += sizeof(tlv);
- tlv_data = data;
+ tlv_len = le32toh(tlv->length);
+ tlv_type = le32toh(tlv->type);
+ tlv_data = tlv->data;
if (len < tlv_len) {
device_printf(sc->sc_dev,
@@ -632,19 +620,21 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type)
error = EINVAL;
goto parse_out;
}
+ len -= roundup2(tlv_len, 4);
+ data += sizeof(tlv) + roundup2(tlv_len, 4);
switch ((int)tlv_type) {
case IWM_UCODE_TLV_PROBE_MAX_LEN:
- if (tlv_len < sizeof(uint32_t)) {
+ if (tlv_len != sizeof(uint32_t)) {
device_printf(sc->sc_dev,
- "%s: PROBE_MAX_LEN (%d) < sizeof(uint32_t)\n",
+ "%s: PROBE_MAX_LEN (%d) != sizeof(uint32_t)\n",
__func__,
(int) tlv_len);
error = EINVAL;
goto parse_out;
}
capa->max_probe_length =
- le32toh(*(const uint32_t *)tlv_data);
+ le32_to_cpup((const uint32_t *)tlv_data);
/* limit it to something sensible */
if (capa->max_probe_length >
IWM_SCAN_OFFLOAD_PROBE_REQ_SIZE) {
@@ -675,6 +665,14 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type)
error = EINVAL;
goto parse_out;
}
+ if (tlv_len % sizeof(uint32_t)) {
+ device_printf(sc->sc_dev,
+ "%s: IWM_UCODE_TLV_FLAGS: tlv_len (%d) %% sizeof(uint32_t)\n",
+ __func__,
+ (int) tlv_len);
+ error = EINVAL;
+ goto parse_out;
+ }
/*
* Apparently there can be many flags, but Linux driver
* parses only the first one, and so do we.
@@ -686,7 +684,7 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type)
* 2) TLV_FLAGS contains TLV_FLAGS_PAN
* ==> this resets TLV_PAN to itself... hnnnk
*/
- capa->flags = le32toh(*(const uint32_t *)tlv_data);
+ capa->flags = le32_to_cpup((const uint32_t *)tlv_data);
break;
case IWM_UCODE_TLV_CSCHEME:
if ((error = iwm_store_cscheme(sc,
@@ -707,7 +705,7 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type)
error = EINVAL;
goto parse_out;
}
- num_of_cpus = le32toh(*(const uint32_t *)tlv_data);
+ num_of_cpus = le32_to_cpup((const uint32_t *)tlv_data);
if (num_of_cpus == 2) {
fw->fw_sects[IWM_UCODE_REGULAR].is_dual_cpus =
TRUE;
@@ -781,7 +779,7 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type)
goto parse_out;
}
sc->sc_fw.phy_config =
- le32toh(*(const uint32_t *)tlv_data);
+ le32_to_cpup((const uint32_t *)tlv_data);
sc->sc_fw.valid_tx_ant = (sc->sc_fw.phy_config &
IWM_FW_PHY_CFG_TX_CHAIN) >>
IWM_FW_PHY_CFG_TX_CHAIN_POS;
@@ -832,7 +830,7 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type)
error = EINVAL;
goto parse_out;
}
- paging_mem_size = le32toh(*(const uint32_t *)tlv_data);
+ paging_mem_size = le32_to_cpup((const uint32_t *)tlv_data);
IWM_DPRINTF(sc, IWM_DEBUG_FIRMWARE_TLV,
"%s: Paging: paging enabled (size = %u bytes)\n",
@@ -865,7 +863,7 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type)
goto parse_out;
}
capa->n_scan_channels =
- le32toh(*(const uint32_t *)tlv_data);
+ le32_to_cpup((const uint32_t *)tlv_data);
break;
case IWM_UCODE_TLV_FW_VERSION:
@@ -890,9 +888,6 @@ iwm_read_firmware(struct iwm_softc *sc, enum iwm_ucode_type ucode_type)
error = EINVAL;
goto parse_out;
}
-
- len -= roundup(tlv_len, 4);
- data += roundup(tlv_len, 4);
}
KASSERT(error == 0, ("unhandled error"));
@@ -1285,6 +1280,7 @@ iwm_stop_device(struct iwm_softc *sc)
*/
if (vap) {
struct iwm_vap *iv = IWM_VAP(vap);
+ iv->phy_ctxt = NULL;
iv->is_uploaded = 0;
}
@@ -1293,9 +1289,9 @@ iwm_stop_device(struct iwm_softc *sc)
/* stop tx and rx. tx and rx bits, as usual, are from if_iwn */
- iwm_write_prph(sc, IWM_SCD_TXFACT, 0);
-
if (iwm_nic_lock(sc)) {
+ iwm_write_prph(sc, IWM_SCD_TXFACT, 0);
+
/* Stop each Tx DMA channel */
for (chnl = 0; chnl < IWM_FH_TCSR_CHNL_NUM; chnl++) {
IWM_WRITE(sc,
@@ -1323,8 +1319,11 @@ iwm_stop_device(struct iwm_softc *sc)
if (sc->cfg->device_family == IWM_DEVICE_FAMILY_7000) {
/* Power-down device's busmaster DMA clocks */
- iwm_write_prph(sc, IWM_APMG_CLK_DIS_REG,
- IWM_APMG_CLK_VAL_DMA_CLK_RQT);
+ if (iwm_nic_lock(sc)) {
+ iwm_write_prph(sc, IWM_APMG_CLK_DIS_REG,
+ IWM_APMG_CLK_VAL_DMA_CLK_RQT);
+ iwm_nic_unlock(sc);
+ }
DELAY(5);
}
@@ -1422,14 +1421,21 @@ iwm_nic_rx_init(struct iwm_softc *sc)
IWM_WRITE(sc,
IWM_FH_RSCSR_CHNL0_STTS_WPTR_REG, sc->rxq.stat_dma.paddr >> 4);
- /* Enable RX. */
+ /* Enable Rx DMA
+ * XXX 5000 HW isn't supported by the iwm(4) driver.
+ * IWM_FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY is set because of HW bug in
+ * the credit mechanism in 5000 HW RX FIFO
+ * Direct rx interrupts to hosts
+ * Rx buffer size 4 or 8k or 12k
+ * RB timeout 0x10
+ * 256 RBDs
+ */
IWM_WRITE(sc, IWM_FH_MEM_RCSR_CHNL0_CONFIG_REG,
IWM_FH_RCSR_RX_CONFIG_CHNL_EN_ENABLE_VAL |
IWM_FH_RCSR_CHNL0_RX_IGNORE_RXF_EMPTY | /* HW bug */
IWM_FH_RCSR_CHNL0_RX_CONFIG_IRQ_DEST_INT_HOST_VAL |
- IWM_FH_RCSR_CHNL0_RX_CONFIG_SINGLE_FRAME_MSK |
- (IWM_RX_RB_TIMEOUT << IWM_FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS) |
IWM_FH_RCSR_RX_CONFIG_REG_VAL_RB_SIZE_4K |
+ (IWM_RX_RB_TIMEOUT << IWM_FH_RCSR_RX_CONFIG_REG_IRQ_RBTH_POS) |
IWM_RX_QUEUE_SIZE_LOG << IWM_FH_RCSR_RX_CONFIG_RBDCB_SIZE_POS);
IWM_WRITE_1(sc, IWM_CSR_INT_COALESCING, IWM_HOST_INT_TIMEOUT_DEF);
@@ -1513,14 +1519,7 @@ iwm_nic_init(struct iwm_softc *sc)
return 0;
}
-const uint8_t iwm_mvm_ac_to_tx_fifo[] = {
- IWM_MVM_TX_FIFO_VO,
- IWM_MVM_TX_FIFO_VI,
- IWM_MVM_TX_FIFO_BE,
- IWM_MVM_TX_FIFO_BK,
-};
-
-static int
+int
iwm_enable_txq(struct iwm_softc *sc, int sta_id, int qid, int fifo)
{
if (!iwm_nic_lock(sc)) {
@@ -1621,8 +1620,6 @@ iwm_trans_pcie_fw_alive(struct iwm_softc *sc, uint32_t scd_base_addr)
iwm_ict_reset(sc);
- iwm_nic_unlock(sc);
-
sc->scd_base_addr = iwm_read_prph(sc, IWM_SCD_SRAM_BASE_ADDR);
if (scd_base_addr != 0 &&
scd_base_addr != sc->scd_base_addr) {
@@ -1631,6 +1628,8 @@ iwm_trans_pcie_fw_alive(struct iwm_softc *sc, uint32_t scd_base_addr)
__func__, sc->scd_base_addr, scd_base_addr);
}
+ iwm_nic_unlock(sc);
+
/* reset context data, TX status and translation data */
error = iwm_write_mem(sc,
sc->scd_base_addr + IWM_SCD_CONTEXT_MEM_LOWER_BOUND,
@@ -2590,9 +2589,12 @@ iwm_pcie_load_given_ucode(struct iwm_softc *sc,
if (image->is_dual_cpus) {
/* set CPU2 header address */
- iwm_write_prph(sc,
- IWM_LMPM_SECURE_UCODE_LOAD_CPU2_HDR_ADDR,
- IWM_LMPM_SECURE_CPU2_HDR_MEM_SPACE);
+ if (iwm_nic_lock(sc)) {
+ iwm_write_prph(sc,
+ IWM_LMPM_SECURE_UCODE_LOAD_CPU2_HDR_ADDR,
+ IWM_LMPM_SECURE_CPU2_HDR_MEM_SPACE);
+ iwm_nic_unlock(sc);
+ }
/* load to FW the binary sections of CPU2 */
ret = iwm_pcie_load_cpu_sections(sc, image, 2,
@@ -2621,7 +2623,11 @@ iwm_pcie_load_given_ucode_8000(struct iwm_softc *sc,
/* configure the ucode to be ready to get the secured image */
/* release CPU reset */
- iwm_write_prph(sc, IWM_RELEASE_CPU_RESET, IWM_RELEASE_CPU_RESET_BIT);
+ if (iwm_nic_lock(sc)) {
+ iwm_write_prph(sc, IWM_RELEASE_CPU_RESET,
+ IWM_RELEASE_CPU_RESET_BIT);
+ iwm_nic_unlock(sc);
+ }
/* load to FW the binary Secured sections of CPU1 */
ret = iwm_pcie_load_cpu_sections_8000(sc, image, 1,
@@ -2875,10 +2881,15 @@ iwm_mvm_load_ucode_wait_alive(struct iwm_softc *sc,
IWM_LOCK(sc);
if (error) {
if (sc->cfg->device_family == IWM_DEVICE_FAMILY_8000) {
+ uint32_t a = 0x5a5a5a5a, b = 0x5a5a5a5a;
+ if (iwm_nic_lock(sc)) {
+ a = iwm_read_prph(sc, IWM_SB_CPU_1_STATUS);
+ b = iwm_read_prph(sc, IWM_SB_CPU_2_STATUS);
+ iwm_nic_unlock(sc);
+ }
device_printf(sc->sc_dev,
"SecBoot CPU1 Status: 0x%x, CPU2 Status: 0x%x\n",
- iwm_read_prph(sc, IWM_SB_CPU_1_STATUS),
- iwm_read_prph(sc, IWM_SB_CPU_2_STATUS));
+ a, b);
}
sc->cur_ucode = old_type;
return error;
@@ -3104,13 +3115,11 @@ iwm_mvm_get_signal_strength(struct iwm_softc *sc, struct iwm_rx_phy_info *phy_in
}
static void
-iwm_mvm_rx_rx_phy_cmd(struct iwm_softc *sc,
- struct iwm_rx_packet *pkt, struct iwm_rx_data *data)
+iwm_mvm_rx_rx_phy_cmd(struct iwm_softc *sc, struct iwm_rx_packet *pkt)
{
struct iwm_rx_phy_info *phy_info = (void *)pkt->data;
IWM_DPRINTF(sc, IWM_DEBUG_RECV, "received PHY stats\n");
- bus_dmamap_sync(sc->rxq.data_dmat, data->map, BUS_DMASYNC_POSTREAD);
memcpy(&sc->sc_last_phy_info, phy_info, sizeof(sc->sc_last_phy_info));
}
@@ -3154,8 +3163,9 @@ iwm_get_noise(struct iwm_softc *sc,
*
* Handles the actual data of the Rx packet from the fw
*/
-static void
-iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc, struct mbuf *m)
+static boolean_t
+iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc, struct mbuf *m, uint32_t offset,
+ boolean_t stolen)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
@@ -3164,7 +3174,7 @@ iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc, struct mbuf *m)
struct ieee80211_rx_stats rxs;
struct iwm_rx_phy_info *phy_info;
struct iwm_rx_mpdu_res_start *rx_res;
- struct iwm_rx_packet *pkt = mtod(m, struct iwm_rx_packet *);
+ struct iwm_rx_packet *pkt = mtodoff(m, struct iwm_rx_packet *, offset);
uint32_t len;
uint32_t rx_pkt_status;
int rssi;
@@ -3195,7 +3205,7 @@ iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc, struct mbuf *m)
rssi = rssi - sc->sc_noise;
/* replenish ring for the buffer we're going to feed to the sharks */
- if (iwm_rx_addbuf(sc, IWM_RBUF_SIZE, sc->rxq.cur) != 0) {
+ if (!stolen && iwm_rx_addbuf(sc, IWM_RBUF_SIZE, sc->rxq.cur) != 0) {
device_printf(sc->sc_dev, "%s: unable to add more buffers\n",
__func__);
goto fail;
@@ -3280,10 +3290,11 @@ iwm_mvm_rx_rx_mpdu(struct iwm_softc *sc, struct mbuf *m)
}
IWM_LOCK(sc);
- return;
+ return TRUE;
fail:
counter_u64_add(ic->ic_ierrors, 1);
+ return FALSE;
}
static int
@@ -3338,8 +3349,7 @@ iwm_mvm_rx_tx_cmd_single(struct iwm_softc *sc, struct iwm_rx_packet *pkt,
}
static void
-iwm_mvm_rx_tx_cmd(struct iwm_softc *sc,
- struct iwm_rx_packet *pkt, struct iwm_rx_data *data)
+iwm_mvm_rx_tx_cmd(struct iwm_softc *sc, struct iwm_rx_packet *pkt)
{
struct iwm_cmd_header *cmd_hdr = &pkt->hdr;
int idx = cmd_hdr->idx;
@@ -3354,8 +3364,6 @@ iwm_mvm_rx_tx_cmd(struct iwm_softc *sc,
KASSERT(txd->in != NULL, ("txd without node"));
KASSERT(txd->m != NULL, ("txd without mbuf"));
- bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_POSTREAD);
-
sc->sc_tx_timer = 0;
status = iwm_mvm_rx_tx_cmd_single(sc, pkt, in);
@@ -3863,142 +3871,11 @@ iwm_mvm_flush_tx_path(struct iwm_softc *sc, uint32_t tfd_msk, uint32_t flags)
}
/*
- * BEGIN mvm/sta.c
- */
-
-static int
-iwm_mvm_send_add_sta_cmd_status(struct iwm_softc *sc,
- struct iwm_mvm_add_sta_cmd *cmd, int *status)
-{
- return iwm_mvm_send_cmd_pdu_status(sc, IWM_ADD_STA, sizeof(*cmd),
- cmd, status);
-}
-
-/* send station add/update command to firmware */
-static int
-iwm_mvm_sta_send_to_fw(struct iwm_softc *sc, struct iwm_node *in, int update)
-{
- struct iwm_mvm_add_sta_cmd add_sta_cmd;
- int ret;
- uint32_t status;
-
- memset(&add_sta_cmd, 0, sizeof(add_sta_cmd));
-
- add_sta_cmd.sta_id = IWM_STATION_ID;
- add_sta_cmd.mac_id_n_color
- = htole32(IWM_FW_CMD_ID_AND_COLOR(IWM_DEFAULT_MACID,
- IWM_DEFAULT_COLOR));
- if (!update) {
- int ac;
- for (ac = 0; ac < WME_NUM_AC; ac++) {
- add_sta_cmd.tfd_queue_msk |=
- htole32(1 << iwm_mvm_ac_to_tx_fifo[ac]);
- }
- IEEE80211_ADDR_COPY(&add_sta_cmd.addr, in->in_ni.ni_bssid);
- }
- add_sta_cmd.add_modify = update ? 1 : 0;
- add_sta_cmd.station_flags_msk
- |= htole32(IWM_STA_FLG_FAT_EN_MSK | IWM_STA_FLG_MIMO_EN_MSK);
- add_sta_cmd.tid_disable_tx = htole16(0xffff);
- if (update)
- add_sta_cmd.modify_mask |= (IWM_STA_MODIFY_TID_DISABLE_TX);
-
- status = IWM_ADD_STA_SUCCESS;
- ret = iwm_mvm_send_add_sta_cmd_status(sc, &add_sta_cmd, &status);
- if (ret)
- return ret;
-
- switch (status) {
- case IWM_ADD_STA_SUCCESS:
- break;
- default:
- ret = EIO;
- device_printf(sc->sc_dev, "IWM_ADD_STA failed\n");
- break;
- }
-
- return ret;
-}
-
-static int
-iwm_mvm_add_sta(struct iwm_softc *sc, struct iwm_node *in)
-{
- return iwm_mvm_sta_send_to_fw(sc, in, 0);
-}
-
-static int
-iwm_mvm_update_sta(struct iwm_softc *sc, struct iwm_node *in)
-{
- return iwm_mvm_sta_send_to_fw(sc, in, 1);
-}
-
-static int
-iwm_mvm_add_int_sta_common(struct iwm_softc *sc, struct iwm_int_sta *sta,
- const uint8_t *addr, uint16_t mac_id, uint16_t color)
-{
- struct iwm_mvm_add_sta_cmd cmd;
- int ret;
- uint32_t status;
-
- memset(&cmd, 0, sizeof(cmd));
- cmd.sta_id = sta->sta_id;
- cmd.mac_id_n_color = htole32(IWM_FW_CMD_ID_AND_COLOR(mac_id, color));
-
- cmd.tfd_queue_msk = htole32(sta->tfd_queue_msk);
- cmd.tid_disable_tx = htole16(0xffff);
-
- if (addr)
- IEEE80211_ADDR_COPY(cmd.addr, addr);
-
- ret = iwm_mvm_send_add_sta_cmd_status(sc, &cmd, &status);
- if (ret)
- return ret;
-
- switch (status) {
- case IWM_ADD_STA_SUCCESS:
- IWM_DPRINTF(sc, IWM_DEBUG_RESET,
- "%s: Internal station added.\n", __func__);
- return 0;
- default:
- device_printf(sc->sc_dev,
- "%s: Add internal station failed, status=0x%x\n",
- __func__, status);
- ret = EIO;
- break;
- }
- return ret;
-}
-
-static int
-iwm_mvm_add_aux_sta(struct iwm_softc *sc)
-{
- int ret;
-
- sc->sc_aux_sta.sta_id = IWM_AUX_STA_ID;
- sc->sc_aux_sta.tfd_queue_msk = (1 << IWM_MVM_AUX_QUEUE);
-
- ret = iwm_enable_txq(sc, 0, IWM_MVM_AUX_QUEUE, IWM_MVM_TX_FIFO_MCAST);
- if (ret)
- return ret;
-
- ret = iwm_mvm_add_int_sta_common(sc,
- &sc->sc_aux_sta, NULL, IWM_MAC_INDEX_AUX, 0);
-
- if (ret)
- memset(&sc->sc_aux_sta, 0, sizeof(sc->sc_aux_sta));
- return ret;
-}
-
-/*
- * END mvm/sta.c
- */
-
-/*
* BEGIN mvm/quota.c
*/
static int
-iwm_mvm_update_quotas(struct iwm_softc *sc, struct iwm_node *in)
+iwm_mvm_update_quotas(struct iwm_softc *sc, struct iwm_vap *ivp)
{
struct iwm_time_quota_cmd cmd;
int i, idx, ret, num_active_macs, quota, quota_rem;
@@ -4009,10 +3886,10 @@ iwm_mvm_update_quotas(struct iwm_softc *sc, struct iwm_node *in)
memset(&cmd, 0, sizeof(cmd));
/* currently, PHY ID == binding ID */
- if (in) {
- id = in->in_phyctxt->id;
+ if (ivp) {
+ id = ivp->phy_ctxt->id;
KASSERT(id < IWM_MAX_BINDINGS, ("invalid id"));
- colors[id] = in->in_phyctxt->color;
+ colors[id] = ivp->phy_ctxt->color;
if (1)
n_ifs[id] = 1;
@@ -4099,6 +3976,21 @@ iwm_auth(struct ieee80211vap *vap, struct iwm_softc *sc)
in->in_assoc = 0;
+ /*
+ * Firmware bug - it'll crash if the beacon interval is less
+ * than 16. We can't avoid connecting at all, so refuse the
+ * station state change, this will cause net80211 to abandon
+ * attempts to connect to this AP, and eventually wpa_s will
+ * blacklist the AP...
+ */
+ if (ni->ni_intval < 16) {
+ device_printf(sc->sc_dev,
+ "AP %s beacon interval is %d, refusing due to firmware bug!\n",
+ ether_sprintf(ni->ni_bssid), ni->ni_intval);
+ error = EINVAL;
+ goto out;
+ }
+
error = iwm_mvm_sf_config(sc, IWM_SF_FULL_ON);
if (error != 0)
return error;
@@ -4131,49 +4023,45 @@ iwm_auth(struct ieee80211vap *vap, struct iwm_softc *sc)
"%s: failed to update MAC\n", __func__);
goto out;
}
- if ((error = iwm_mvm_phy_ctxt_changed(sc, &sc->sc_phyctxt[0],
- in->in_ni.ni_chan, 1, 1)) != 0) {
- device_printf(sc->sc_dev,
- "%s: failed update phy ctxt\n", __func__);
- goto out;
- }
- in->in_phyctxt = &sc->sc_phyctxt[0];
-
- if ((error = iwm_mvm_binding_update(sc, in)) != 0) {
- device_printf(sc->sc_dev,
- "%s: binding update cmd\n", __func__);
- goto out;
- }
- if ((error = iwm_mvm_update_sta(sc, in)) != 0) {
- device_printf(sc->sc_dev,
- "%s: failed to update sta\n", __func__);
- goto out;
- }
} else {
if ((error = iwm_mvm_mac_ctxt_add(sc, vap)) != 0) {
device_printf(sc->sc_dev,
"%s: failed to add MAC\n", __func__);
goto out;
}
- if ((error = iwm_mvm_phy_ctxt_changed(sc, &sc->sc_phyctxt[0],
- in->in_ni.ni_chan, 1, 1)) != 0) {
- device_printf(sc->sc_dev,
- "%s: failed add phy ctxt!\n", __func__);
- error = ETIMEDOUT;
- goto out;
- }
- in->in_phyctxt = &sc->sc_phyctxt[0];
+ }
- if ((error = iwm_mvm_binding_add_vif(sc, in)) != 0) {
- device_printf(sc->sc_dev,
- "%s: binding add cmd\n", __func__);
- goto out;
- }
- if ((error = iwm_mvm_add_sta(sc, in)) != 0) {
- device_printf(sc->sc_dev,
- "%s: failed to add sta\n", __func__);
- goto out;
- }
+ if ((error = iwm_mvm_phy_ctxt_changed(sc, &sc->sc_phyctxt[0],
+ in->in_ni.ni_chan, 1, 1)) != 0) {
+ device_printf(sc->sc_dev,
+ "%s: failed update phy ctxt\n", __func__);
+ goto out;
+ }
+ iv->phy_ctxt = &sc->sc_phyctxt[0];
+
+ if ((error = iwm_mvm_binding_add_vif(sc, iv)) != 0) {
+ device_printf(sc->sc_dev,
+ "%s: binding update cmd\n", __func__);
+ goto out;
+ }
+ /*
+ * Authentication becomes unreliable when powersaving is left enabled
+ * here. Powersaving will be activated again when association has
+ * finished or is aborted.
+ */
+ iv->ps_disabled = TRUE;
+ error = iwm_mvm_power_update_mac(sc);
+ iv->ps_disabled = FALSE;
+ if (error != 0) {
+ device_printf(sc->sc_dev,
+ "%s: failed to update power management\n",
+ __func__);
+ goto out;
+ }
+ if ((error = iwm_mvm_add_sta(sc, in)) != 0) {
+ device_printf(sc->sc_dev,
+ "%s: failed to add sta\n", __func__);
+ goto out;
}
/*
@@ -4182,7 +4070,7 @@ iwm_auth(struct ieee80211vap *vap, struct iwm_softc *sc)
*/
/* XXX duration is in units of TU, not MS */
duration = IWM_MVM_TE_SESSION_PROTECTION_MAX_TIME_MS;
- iwm_mvm_protect_session(sc, in, duration, 500 /* XXX magic number */);
+ iwm_mvm_protect_session(sc, iv, duration, 500 /* XXX magic number */);
DELAY(100);
error = 0;
@@ -4192,28 +4080,6 @@ out:
}
static int
-iwm_assoc(struct ieee80211vap *vap, struct iwm_softc *sc)
-{
- struct iwm_node *in = IWM_NODE(vap->iv_bss);
- int error;
-
- if ((error = iwm_mvm_update_sta(sc, in)) != 0) {
- device_printf(sc->sc_dev,
- "%s: failed to update STA\n", __func__);
- return error;
- }
-
- in->in_assoc = 1;
- if ((error = iwm_mvm_mac_ctxt_changed(sc, vap)) != 0) {
- device_printf(sc->sc_dev,
- "%s: failed to update MAC\n", __func__);
- return error;
- }
-
- return 0;
-}
-
-static int
iwm_release(struct iwm_softc *sc, struct iwm_node *in)
{
uint32_t tfd_msk;
@@ -4223,11 +4089,11 @@ iwm_release(struct iwm_softc *sc, struct iwm_node *in)
* from RUN back to SCAN is:
*
* iwm_mvm_power_mac_disable(sc, in);
- * iwm_mvm_mac_ctxt_changed(sc, in);
+ * iwm_mvm_mac_ctxt_changed(sc, vap);
* iwm_mvm_rm_sta(sc, in);
* iwm_mvm_update_quotas(sc, NULL);
* iwm_mvm_mac_ctxt_changed(sc, in);
- * iwm_mvm_binding_remove_vif(sc, in);
+ * iwm_mvm_binding_remove_vif(sc, IWM_VAP(in->in_ni.ni_vap));
* iwm_mvm_mac_ctxt_remove(sc, in);
*
* However, that freezes the device not matter which permutations
@@ -4260,7 +4126,7 @@ iwm_release(struct iwm_softc *sc, struct iwm_node *in)
iwm_mvm_power_mac_disable(sc, in);
- if ((error = iwm_mvm_mac_ctxt_changed(sc, in)) != 0) {
+ if ((error = iwm_mvm_mac_ctxt_changed(sc, vap)) != 0) {
device_printf(sc->sc_dev, "mac ctxt change fail 1 %d\n", error);
return error;
}
@@ -4272,11 +4138,11 @@ iwm_release(struct iwm_softc *sc, struct iwm_node *in)
error = iwm_mvm_rm_sta(sc, in);
in->in_assoc = 0;
iwm_mvm_update_quotas(sc, NULL);
- if ((error = iwm_mvm_mac_ctxt_changed(sc, in)) != 0) {
+ if ((error = iwm_mvm_mac_ctxt_changed(sc, vap)) != 0) {
device_printf(sc->sc_dev, "mac ctxt change fail 2 %d\n", error);
return error;
}
- iwm_mvm_binding_remove_vif(sc, in);
+ iwm_mvm_binding_remove_vif(sc, IWM_VAP(in->in_ni.ni_vap));
iwm_mvm_mac_ctxt_remove(sc, in);
@@ -4521,6 +4387,44 @@ iwm_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
switch (nstate) {
case IEEE80211_S_INIT:
+ case IEEE80211_S_SCAN:
+ if (vap->iv_state == IEEE80211_S_AUTH ||
+ vap->iv_state == IEEE80211_S_ASSOC) {
+ int myerr;
+ IWM_UNLOCK(sc);
+ IEEE80211_LOCK(ic);
+ myerr = ivp->iv_newstate(vap, nstate, arg);
+ IEEE80211_UNLOCK(ic);
+ IWM_LOCK(sc);
+ error = iwm_mvm_rm_sta(sc, vap, FALSE);
+ if (error) {
+ device_printf(sc->sc_dev,
+ "%s: Failed to remove station: %d\n",
+ __func__, error);
+ }
+ error = iwm_mvm_mac_ctxt_changed(sc, vap);
+ if (error) {
+ device_printf(sc->sc_dev,
+ "%s: Failed to change mac context: %d\n",
+ __func__, error);
+ }
+ error = iwm_mvm_binding_remove_vif(sc, ivp);
+ if (error) {
+ device_printf(sc->sc_dev,
+ "%s: Failed to remove channel ctx: %d\n",
+ __func__, error);
+ }
+ ivp->phy_ctxt = NULL;
+ error = iwm_mvm_power_update_mac(sc);
+ if (error != 0) {
+ device_printf(sc->sc_dev,
+ "%s: failed to update power management\n",
+ __func__);
+ }
+ IWM_UNLOCK(sc);
+ IEEE80211_LOCK(ic);
+ return myerr;
+ }
break;
case IEEE80211_S_AUTH:
@@ -4528,7 +4432,6 @@ iwm_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
device_printf(sc->sc_dev,
"%s: could not move to auth state: %d\n",
__func__, error);
- break;
}
break;
@@ -4537,13 +4440,7 @@ iwm_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
* EBS may be disabled due to previous failures reported by FW.
* Reset EBS status here assuming environment has been changed.
*/
- sc->last_ebs_successful = TRUE;
- if ((error = iwm_assoc(vap, sc)) != 0) {
- device_printf(sc->sc_dev,
- "%s: failed to associate: %d\n", __func__,
- error);
- break;
- }
+ sc->last_ebs_successful = TRUE;
break;
case IEEE80211_S_RUN:
@@ -4554,21 +4451,27 @@ iwm_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
.flags = IWM_CMD_SYNC,
};
+ in = IWM_NODE(vap->iv_bss);
/* Update the association state, now we have it all */
/* (eg associd comes in at this point */
- error = iwm_assoc(vap, sc);
+ error = iwm_mvm_update_sta(sc, in);
if (error != 0) {
device_printf(sc->sc_dev,
- "%s: failed to update association state: %d\n",
- __func__,
- error);
- break;
+ "%s: failed to update STA\n", __func__);
+ IWM_UNLOCK(sc);
+ IEEE80211_LOCK(ic);
+ return error;
+ }
+ in->in_assoc = 1;
+ error = iwm_mvm_mac_ctxt_changed(sc, vap);
+ if (error != 0) {
+ device_printf(sc->sc_dev,
+ "%s: failed to update MAC: %d\n", __func__, error);
}
- in = IWM_NODE(vap->iv_bss);
- iwm_mvm_power_mac_update_mode(sc, in);
- iwm_mvm_enable_beacon_filter(sc, in);
- iwm_mvm_update_quotas(sc, in);
+ iwm_mvm_enable_beacon_filter(sc, ivp);
+ iwm_mvm_power_update_mac(sc);
+ iwm_mvm_update_quotas(sc, ivp);
iwm_setrates(sc, in);
cmd.data[0] = &in->in_lq;
@@ -4855,6 +4758,7 @@ iwm_init_hw(struct iwm_softc *sc)
* image just loaded
*/
iwm_stop_device(sc);
+ sc->sc_ps_disabled = FALSE;
if ((error = iwm_start_hw(sc)) != 0) {
device_printf(sc->sc_dev, "could not initialize hardware\n");
return error;
@@ -5350,68 +5254,95 @@ iwm_nic_error(struct iwm_softc *sc)
}
#endif
-#define ADVANCE_RXQ(sc) (sc->rxq.cur = (sc->rxq.cur + 1) % IWM_RX_RING_COUNT);
-
-/*
- * Process an IWM_CSR_INT_BIT_FH_RX or IWM_CSR_INT_BIT_SW_RX interrupt.
- * Basic structure from if_iwn
- */
static void
-iwm_notif_intr(struct iwm_softc *sc)
+iwm_handle_rxb(struct iwm_softc *sc, struct mbuf *m)
{
struct ieee80211com *ic = &sc->sc_ic;
- uint16_t hw;
-
- bus_dmamap_sync(sc->rxq.stat_dma.tag, sc->rxq.stat_dma.map,
- BUS_DMASYNC_POSTREAD);
-
- hw = le16toh(sc->rxq.stat->closed_rb_num) & 0xfff;
+ struct iwm_cmd_response *cresp;
+ struct mbuf *m1;
+ uint32_t offset = 0;
+ uint32_t maxoff = IWM_RBUF_SIZE;
+ uint32_t nextoff;
+ boolean_t stolen = FALSE;
- /*
- * Process responses
- */
- while (sc->rxq.cur != hw) {
- struct iwm_rx_ring *ring = &sc->rxq;
- struct iwm_rx_data *data = &ring->data[ring->cur];
- struct iwm_rx_packet *pkt;
- struct iwm_cmd_response *cresp;
- int qid, idx, code;
+#define HAVEROOM(a) \
+ ((a) + sizeof(uint32_t) + sizeof(struct iwm_cmd_header) < maxoff)
- bus_dmamap_sync(ring->data_dmat, data->map,
- BUS_DMASYNC_POSTREAD);
- pkt = mtod(data->m, struct iwm_rx_packet *);
+ while (HAVEROOM(offset)) {
+ struct iwm_rx_packet *pkt = mtodoff(m, struct iwm_rx_packet *,
+ offset);
+ int qid, idx, code, len;
- qid = pkt->hdr.qid & ~0x80;
+ qid = pkt->hdr.qid;
idx = pkt->hdr.idx;
code = IWM_WIDE_ID(pkt->hdr.flags, pkt->hdr.code);
- IWM_DPRINTF(sc, IWM_DEBUG_INTR,
- "rx packet qid=%d idx=%d type=%x %d %d\n",
- pkt->hdr.qid & ~0x80, pkt->hdr.idx, code, ring->cur, hw);
/*
* randomly get these from the firmware, no idea why.
* they at least seem harmless, so just ignore them for now
*/
- if (__predict_false((pkt->hdr.code == 0 && qid == 0 && idx == 0)
- || pkt->len_n_flags == htole32(0x55550000))) {
- ADVANCE_RXQ(sc);
- continue;
+ if ((pkt->hdr.code == 0 && (qid & ~0x80) == 0 && idx == 0) ||
+ pkt->len_n_flags == htole32(IWM_FH_RSCSR_FRAME_INVALID)) {
+ break;
}
+ IWM_DPRINTF(sc, IWM_DEBUG_INTR,
+ "rx packet qid=%d idx=%d type=%x\n",
+ qid & ~0x80, pkt->hdr.idx, code);
+
+ len = le32toh(pkt->len_n_flags) & IWM_FH_RSCSR_FRAME_SIZE_MSK;
+ len += sizeof(uint32_t); /* account for status word */
+ nextoff = offset + roundup2(len, IWM_FH_RSCSR_FRAME_ALIGN);
+
iwm_notification_wait_notify(sc->sc_notif_wait, code, pkt);
switch (code) {
case IWM_REPLY_RX_PHY_CMD:
- iwm_mvm_rx_rx_phy_cmd(sc, pkt, data);
+ iwm_mvm_rx_rx_phy_cmd(sc, pkt);
break;
- case IWM_REPLY_RX_MPDU_CMD:
- iwm_mvm_rx_rx_mpdu(sc, data->m);
+ case IWM_REPLY_RX_MPDU_CMD: {
+ /*
+ * If this is the last frame in the RX buffer, we
+ * can directly feed the mbuf to the sharks here.
+ */
+ struct iwm_rx_packet *nextpkt = mtodoff(m,
+ struct iwm_rx_packet *, nextoff);
+ if (!HAVEROOM(nextoff) ||
+ (nextpkt->hdr.code == 0 &&
+ (nextpkt->hdr.qid & ~0x80) == 0 &&
+ nextpkt->hdr.idx == 0) ||
+ (nextpkt->len_n_flags ==
+ htole32(IWM_FH_RSCSR_FRAME_INVALID))) {
+ if (iwm_mvm_rx_rx_mpdu(sc, m, offset, stolen)) {
+ stolen = FALSE;
+ /* Make sure we abort the loop */
+ nextoff = maxoff;
+ }
+ break;
+ }
+
+ /*
+ * Use m_copym instead of m_split, because that
+ * makes it easier to keep a valid rx buffer in
+ * the ring, when iwm_mvm_rx_rx_mpdu() fails.
+ *
+ * We need to start m_copym() at offset 0, to get the
+ * M_PKTHDR flag preserved.
+ */
+ m1 = m_copym(m, 0, M_COPYALL, M_NOWAIT);
+ if (m1) {
+ if (iwm_mvm_rx_rx_mpdu(sc, m1, offset, stolen))
+ stolen = TRUE;
+ else
+ m_freem(m1);
+ }
break;
+ }
case IWM_TX_CMD:
- iwm_mvm_rx_tx_cmd(sc, pkt, data);
+ iwm_mvm_rx_tx_cmd(sc, pkt);
break;
case IWM_MISSED_BEACONS_NOTIFICATION: {
@@ -5472,7 +5403,7 @@ iwm_notif_intr(struct iwm_softc *sc)
case IWM_NVM_ACCESS_CMD:
case IWM_MCC_UPDATE_CMD:
- if (sc->sc_wantresp == ((qid << 16) | idx)) {
+ if (sc->sc_wantresp == (((qid & ~0x80) << 16) | idx)) {
memcpy(sc->sc_cmd_resp,
pkt, sizeof(sc->sc_cmd_resp));
}
@@ -5519,7 +5450,7 @@ iwm_notif_intr(struct iwm_softc *sc)
case IWM_TIME_EVENT_CMD:
case IWM_WIDE_ID(IWM_ALWAYS_LONG_GROUP, IWM_SCAN_CFG_CMD):
case IWM_WIDE_ID(IWM_ALWAYS_LONG_GROUP, IWM_SCAN_REQ_UMAC):
- case IWM_SCAN_ABORT_UMAC:
+ case IWM_WIDE_ID(IWM_ALWAYS_LONG_GROUP, IWM_SCAN_ABORT_UMAC):
case IWM_SCAN_OFFLOAD_REQUEST_CMD:
case IWM_SCAN_OFFLOAD_ABORT_CMD:
case IWM_REPLY_BEACON_FILTERING_CMD:
@@ -5528,11 +5459,12 @@ iwm_notif_intr(struct iwm_softc *sc)
case IWM_REMOVE_STA:
case IWM_TXPATH_FLUSH:
case IWM_LQ_CMD:
- case IWM_FW_PAGING_BLOCK_CMD:
+ case IWM_WIDE_ID(IWM_ALWAYS_LONG_GROUP,
+ IWM_FW_PAGING_BLOCK_CMD):
case IWM_BT_CONFIG:
case IWM_REPLY_THERMAL_MNG_BACKOFF:
cresp = (void *)pkt->data;
- if (sc->sc_wantresp == ((qid << 16) | idx)) {
+ if (sc->sc_wantresp == (((qid & ~0x80) << 16) | idx)) {
memcpy(sc->sc_cmd_resp,
pkt, sizeof(*pkt)+sizeof(*cresp));
}
@@ -5616,7 +5548,7 @@ iwm_notif_intr(struct iwm_softc *sc)
default:
device_printf(sc->sc_dev,
"frame %d/%d %x UNHANDLED (this should "
- "not happen)\n", qid, idx,
+ "not happen)\n", qid & ~0x80, idx,
pkt->len_n_flags);
break;
}
@@ -5635,20 +5567,55 @@ iwm_notif_intr(struct iwm_softc *sc)
* uses a slightly different format for pkt->hdr, and "qid"
* is actually the upper byte of a two-byte field.
*/
- if (!(pkt->hdr.qid & (1 << 7))) {
+ if (!(qid & (1 << 7)))
iwm_cmd_done(sc, pkt);
- }
- ADVANCE_RXQ(sc);
+ offset = nextoff;
+ }
+ if (stolen)
+ m_freem(m);
+#undef HAVEROOM
+}
+
+/*
+ * Process an IWM_CSR_INT_BIT_FH_RX or IWM_CSR_INT_BIT_SW_RX interrupt.
+ * Basic structure from if_iwn
+ */
+static void
+iwm_notif_intr(struct iwm_softc *sc)
+{
+ uint16_t hw;
+
+ bus_dmamap_sync(sc->rxq.stat_dma.tag, sc->rxq.stat_dma.map,
+ BUS_DMASYNC_POSTREAD);
+
+ hw = le16toh(sc->rxq.stat->closed_rb_num) & 0xfff;
+
+ /*
+ * Process responses
+ */
+ while (sc->rxq.cur != hw) {
+ struct iwm_rx_ring *ring = &sc->rxq;
+ struct iwm_rx_data *data = &ring->data[ring->cur];
+
+ bus_dmamap_sync(ring->data_dmat, data->map,
+ BUS_DMASYNC_POSTREAD);
+
+ IWM_DPRINTF(sc, IWM_DEBUG_INTR,
+ "%s: hw = %d cur = %d\n", __func__, hw, ring->cur);
+ iwm_handle_rxb(sc, data->m);
+
+ ring->cur = (ring->cur + 1) % IWM_RX_RING_COUNT;
}
/*
- * Tell the firmware what we have processed.
+ * Tell the firmware that it can reuse the ring entries that
+ * we have just processed.
* Seems like the hardware gets upset unless we align
* the write by 8??
*/
hw = (hw == 0) ? IWM_RX_RING_COUNT - 1 : hw - 1;
- IWM_WRITE(sc, IWM_FH_RSCSR_CHNL0_WPTR, hw & ~7);
+ IWM_WRITE(sc, IWM_FH_RSCSR_CHNL0_WPTR, rounddown2(hw, 8));
}
static void
@@ -5738,7 +5705,6 @@ iwm_intr(void *arg)
device_printf(sc->sc_dev, "%s: controller panicked, iv_state = %d; "
"restarting\n", __func__, vap->iv_state);
- /* XXX TODO: turn this into a callout/taskqueue */
ieee80211_restart_all(ic);
return;
}
@@ -6106,6 +6072,7 @@ iwm_attach(device_t dev)
IEEE80211_C_STA |
IEEE80211_C_WPA | /* WPA/RSN */
IEEE80211_C_WME |
+ IEEE80211_C_PMGT |
IEEE80211_C_SHSLOT | /* short slot time supported */
IEEE80211_C_SHPREAMBLE /* short preamble supported */
// IEEE80211_C_BGSCAN /* capable of bg scanning */
@@ -6162,12 +6129,47 @@ iwm_is_valid_ether_addr(uint8_t *addr)
}
static int
-iwm_update_edca(struct ieee80211com *ic)
+iwm_wme_update(struct ieee80211com *ic)
{
+#define IWM_EXP2(x) ((1 << (x)) - 1) /* CWmin = 2^ECWmin - 1 */
struct iwm_softc *sc = ic->ic_softc;
+ struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
+ struct iwm_vap *ivp = IWM_VAP(vap);
+ struct iwm_node *in;
+ struct wmeParams tmp[WME_NUM_AC];
+ int aci, error;
+
+ if (vap == NULL)
+ return (0);
+
+ IEEE80211_LOCK(ic);
+ for (aci = 0; aci < WME_NUM_AC; aci++)
+ tmp[aci] = ic->ic_wme.wme_chanParams.cap_wmeParams[aci];
+ IEEE80211_UNLOCK(ic);
+
+ IWM_LOCK(sc);
+ for (aci = 0; aci < WME_NUM_AC; aci++) {
+ const struct wmeParams *ac = &tmp[aci];
+ ivp->queue_params[aci].aifsn = ac->wmep_aifsn;
+ ivp->queue_params[aci].cw_min = IWM_EXP2(ac->wmep_logcwmin);
+ ivp->queue_params[aci].cw_max = IWM_EXP2(ac->wmep_logcwmax);
+ ivp->queue_params[aci].edca_txop =
+ IEEE80211_TXOP_TO_US(ac->wmep_txopLimit);
+ }
+ ivp->have_wme = TRUE;
+ if (ivp->is_uploaded && vap->iv_bss != NULL) {
+ in = IWM_NODE(vap->iv_bss);
+ if (in->in_assoc) {
+ if ((error = iwm_mvm_mac_ctxt_changed(sc, vap)) != 0) {
+ device_printf(sc->sc_dev,
+ "%s: failed to update MAC\n", __func__);
+ }
+ }
+ }
+ IWM_UNLOCK(sc);
- device_printf(sc->sc_dev, "%s: called\n", __func__);
return (0);
+#undef IWM_EXP2
}
static void
@@ -6224,7 +6226,7 @@ iwm_preinit(void *arg)
ic->ic_set_channel = iwm_set_channel;
ic->ic_scan_curchan = iwm_scan_curchan;
ic->ic_scan_mindwell = iwm_scan_mindwell;
- ic->ic_wme.wme_update = iwm_update_edca;
+ ic->ic_wme.wme_update = iwm_wme_update;
ic->ic_parent = iwm_parent;
ic->ic_transmit = iwm_transmit;
iwm_radiotap_attach(sc);
@@ -6279,6 +6281,12 @@ iwm_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
ivp->iv_newstate = vap->iv_newstate;
vap->iv_newstate = iwm_newstate;
+ ivp->id = IWM_DEFAULT_MACID;
+ ivp->color = IWM_DEFAULT_COLOR;
+
+ ivp->have_wme = FALSE;
+ ivp->ps_disabled = FALSE;
+
ieee80211_ratectl_init(vap);
/* Complete setup. */
ieee80211_vap_attach(vap, iwm_media_change, ieee80211_media_status,
diff --git a/sys/dev/iwm/if_iwm_7000.c b/sys/dev/iwm/if_iwm_7000.c
index 3bcb1724e72b..f571d6943fa0 100644
--- a/sys/dev/iwm/if_iwm_7000.c
+++ b/sys/dev/iwm/if_iwm_7000.c
@@ -72,6 +72,9 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_wlan.h"
+#include "opt_iwm.h"
+
#include <sys/param.h>
#include "if_iwm_config.h"
diff --git a/sys/dev/iwm/if_iwm_8000.c b/sys/dev/iwm/if_iwm_8000.c
index e567e73939a7..440936707918 100644
--- a/sys/dev/iwm/if_iwm_8000.c
+++ b/sys/dev/iwm/if_iwm_8000.c
@@ -71,6 +71,9 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_wlan.h"
+#include "opt_iwm.h"
+
#include <sys/param.h>
#include "if_iwm_config.h"
diff --git a/sys/dev/iwm/if_iwm_binding.c b/sys/dev/iwm/if_iwm_binding.c
index 27b0e5945436..624fe9c4fdf0 100644
--- a/sys/dev/iwm/if_iwm_binding.c
+++ b/sys/dev/iwm/if_iwm_binding.c
@@ -31,7 +31,7 @@
*
* GPL LICENSE SUMMARY
*
- * Copyright(c) 2007 - 2013 Intel Corporation. All rights reserved.
+ * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of version 2 of the GNU General Public License as
@@ -51,13 +51,12 @@
* in the file called COPYING.
*
* Contact Information:
- * Intel Linux Wireless <ilw@linux.intel.com>
+ * Intel Linux Wireless <linuxwifi@intel.com>
* Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
*
- *
* BSD LICENSE
*
- * Copyright(c) 2005 - 2013 Intel Corporation. All rights reserved.
+ * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -87,25 +86,11 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-/*-
- * Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
+#include "opt_iwm.h"
#include <sys/param.h>
#include <sys/bus.h>
@@ -160,11 +145,21 @@ __FBSDID("$FreeBSD$");
* BEGIN iwlwifi/mvm/binding.c
*/
-int
-iwm_mvm_binding_cmd(struct iwm_softc *sc, struct iwm_node *in, uint32_t action)
+struct iwm_mvm_iface_iterator_data {
+ int idx;
+
+ struct iwm_mvm_phy_ctxt *phyctxt;
+
+ uint16_t ids[IWM_MAX_MACS_IN_BINDING];
+ int16_t colors[IWM_MAX_MACS_IN_BINDING];
+};
+
+static int
+iwm_mvm_binding_cmd(struct iwm_softc *sc, uint32_t action,
+ struct iwm_mvm_iface_iterator_data *data)
{
struct iwm_binding_cmd cmd;
- struct iwm_mvm_phy_ctxt *phyctxt = in->in_phyctxt;
+ struct iwm_mvm_phy_ctxt *phyctxt = data->phyctxt;
int i, ret;
uint32_t status;
@@ -175,41 +170,88 @@ iwm_mvm_binding_cmd(struct iwm_softc *sc, struct iwm_node *in, uint32_t action)
cmd.action = htole32(action);
cmd.phy = htole32(IWM_FW_CMD_ID_AND_COLOR(phyctxt->id, phyctxt->color));
- cmd.macs[0] = htole32(IWM_FW_CMD_ID_AND_COLOR(IWM_DEFAULT_MACID,
- IWM_DEFAULT_COLOR));
- /* We use MACID 0 here.. */
- for (i = 1; i < IWM_MAX_MACS_IN_BINDING; i++)
+ for (i = 0; i < IWM_MAX_MACS_IN_BINDING; i++)
cmd.macs[i] = htole32(IWM_FW_CTXT_INVALID);
+ for (i = 0; i < data->idx; i++)
+ cmd.macs[i] = htole32(IWM_FW_CMD_ID_AND_COLOR(data->ids[i],
+ data->colors[i]));
status = 0;
ret = iwm_mvm_send_cmd_pdu_status(sc, IWM_BINDING_CONTEXT_CMD,
sizeof(cmd), &cmd, &status);
if (ret) {
- IWM_DPRINTF(sc, IWM_DEBUG_CMD | IWM_DEBUG_RESET,
- "%s: Failed to send binding (action:%d): %d\n",
- __func__, action, ret);
+ device_printf(sc->sc_dev,
+ "Failed to send binding (action:%d): %d\n", action, ret);
return ret;
}
if (status) {
- IWM_DPRINTF(sc, IWM_DEBUG_CMD | IWM_DEBUG_RESET,
- "%s: Binding command failed: %u\n",
- __func__,
- status);
+ device_printf(sc->sc_dev,
+ "Binding command failed: %u\n", status);
ret = EIO;
}
return ret;
}
+static int
+iwm_mvm_binding_update(struct iwm_softc *sc, struct iwm_vap *ivp,
+ struct iwm_mvm_phy_ctxt *phyctxt, boolean_t add)
+{
+ struct iwm_mvm_iface_iterator_data data = {
+ .phyctxt = phyctxt,
+ };
+ uint32_t action;
+
+ if (add)
+ action = IWM_FW_CTXT_ACTION_ADD;
+ else
+ action = IWM_FW_CTXT_ACTION_REMOVE;
+
+ if (add) {
+ data.ids[0] = ivp->id;
+ data.colors[0] = ivp->color;
+ data.idx++;
+ }
+
+ return iwm_mvm_binding_cmd(sc, action, &data);
+}
+
int
-iwm_mvm_binding_update(struct iwm_softc *sc, struct iwm_node *in)
+iwm_mvm_binding_add_vif(struct iwm_softc *sc, struct iwm_vap *ivp)
{
- return iwm_mvm_binding_cmd(sc, in, IWM_FW_CTXT_ACTION_MODIFY);
+ if (!ivp->phy_ctxt)
+ return EINVAL;
+
+#ifdef notyet
+ /*
+ * Update SF - Disable if needed. if this fails, SF might still be on
+ * while many macs are bound, which is forbidden - so fail the binding.
+ */
+ if (iwm_mvm_sf_update(sc, ivp, FALSE))
+ return EINVAL;
+#endif
+
+ return iwm_mvm_binding_update(sc, ivp, ivp->phy_ctxt, TRUE);
}
int
-iwm_mvm_binding_add_vif(struct iwm_softc *sc, struct iwm_node *in)
+iwm_mvm_binding_remove_vif(struct iwm_softc *sc, struct iwm_vap *ivp)
{
- return iwm_mvm_binding_cmd(sc, in, IWM_FW_CTXT_ACTION_ADD);
+ int ret;
+
+ if (!ivp->phy_ctxt)
+ return EINVAL;
+
+ ret = iwm_mvm_binding_update(sc, ivp, ivp->phy_ctxt, FALSE);
+
+#ifdef notyet
+ if (!ret) {
+ if (iwm_mvm_sf_update(sc, ivp, TRUE))
+ device_printf(sc->sc_dev,
+ "Failed to update SF state\n");
+ }
+#endif
+
+ return ret;
}
diff --git a/sys/dev/iwm/if_iwm_binding.h b/sys/dev/iwm/if_iwm_binding.h
index 933738455049..3a44492d0330 100644
--- a/sys/dev/iwm/if_iwm_binding.h
+++ b/sys/dev/iwm/if_iwm_binding.h
@@ -105,9 +105,7 @@
#ifndef __IF_IWM_BINDING_H__
#define __IF_IWM_BINDING_H__
-extern int iwm_mvm_binding_cmd(struct iwm_softc *sc, struct iwm_node *in,
- uint32_t action);
-extern int iwm_mvm_binding_update(struct iwm_softc *sc, struct iwm_node *in);
-extern int iwm_mvm_binding_add_vif(struct iwm_softc *sc, struct iwm_node *in);
+extern int iwm_mvm_binding_add_vif(struct iwm_softc *sc, struct iwm_vap *ivp);
+extern int iwm_mvm_binding_remove_vif(struct iwm_softc *sc, struct iwm_vap *ivp);
#endif /* __IF_IWM_BINDING_H__ */
diff --git a/sys/dev/iwm/if_iwm_constants.h b/sys/dev/iwm/if_iwm_constants.h
new file mode 100644
index 000000000000..ed8755442cee
--- /dev/null
+++ b/sys/dev/iwm/if_iwm_constants.h
@@ -0,0 +1,154 @@
+/*-
+ * Based on BSD-licensed source modules in the Linux iwlwifi driver,
+ * which were used as the reference documentation for this implementation.
+ *
+ ******************************************************************************
+ *
+ * This file is provided under a dual BSD/GPLv2 license. When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
+ * Copyright(c) 2015 Intel Deutschland GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called COPYING.
+ *
+ * Contact Information:
+ * Intel Linux Wireless <linuxwifi@intel.com>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2013 - 2014 Intel Corporation. All rights reserved.
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
+ * Copyright(c) 2015 Intel Deutschland GmbH
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *****************************************************************************/
+
+/* $FreeBSD$ */
+
+#ifndef __IF_IWM_CONSTANTS_H
+#define __IF_IWM_CONSTANTS_H
+
+/* <netproto/802_11/ieee80211_var.h> */
+
+#define IWM_MVM_DEFAULT_PS_TX_DATA_TIMEOUT (100 * 1000)
+#define IWM_MVM_DEFAULT_PS_RX_DATA_TIMEOUT (100 * 1000)
+#define IWM_MVM_WOWLAN_PS_TX_DATA_TIMEOUT (10 * 1000)
+#define IWM_MVM_WOWLAN_PS_RX_DATA_TIMEOUT (10 * 1000)
+#define IWM_MVM_SHORT_PS_TX_DATA_TIMEOUT (2 * 1024) /* defined in TU */
+#define IWM_MVM_SHORT_PS_RX_DATA_TIMEOUT (40 * 1024) /* defined in TU */
+#define IWM_MVM_P2P_LOWLATENCY_PS_ENABLE 0
+#define IWM_MVM_UAPSD_RX_DATA_TIMEOUT (50 * 1000)
+#define IWM_MVM_UAPSD_TX_DATA_TIMEOUT (50 * 1000)
+#ifdef notyet
+/* XXX Find corresponding values from net80211 */
+#define IWM_MVM_UAPSD_QUEUES (IEEE80211_WMM_IE_STA_QOSINFO_AC_VO |\
+ IEEE80211_WMM_IE_STA_QOSINFO_AC_VI |\
+ IEEE80211_WMM_IE_STA_QOSINFO_AC_BK |\
+ IEEE80211_WMM_IE_STA_QOSINFO_AC_BE)
+#endif
+#define IWM_MVM_PS_HEAVY_TX_THLD_PACKETS 20
+#define IWM_MVM_PS_HEAVY_RX_THLD_PACKETS 8
+#define IWM_MVM_PS_SNOOZE_HEAVY_TX_THLD_PACKETS 30
+#define IWM_MVM_PS_SNOOZE_HEAVY_RX_THLD_PACKETS 20
+#define IWM_MVM_PS_HEAVY_TX_THLD_PERCENT 50
+#define IWM_MVM_PS_HEAVY_RX_THLD_PERCENT 50
+#define IWM_MVM_PS_SNOOZE_INTERVAL 25
+#define IWM_MVM_PS_SNOOZE_WINDOW 50
+#define IWM_MVM_WOWLAN_PS_SNOOZE_WINDOW 25
+#define IWM_MVM_LOWLAT_QUOTA_MIN_PERCENT 64
+#define IWM_MVM_BT_COEX_EN_RED_TXP_THRESH 62
+#define IWM_MVM_BT_COEX_DIS_RED_TXP_THRESH 65
+#define IWM_MVM_BT_COEX_SYNC2SCO 1
+#define IWM_MVM_BT_COEX_CORUNNING 0
+#define IWM_MVM_BT_COEX_MPLUT 1
+#define IWM_MVM_BT_COEX_RRC 1
+#define IWM_MVM_BT_COEX_TTC 1
+#define IWM_MVM_BT_COEX_MPLUT_REG0 0x22002200
+#define IWM_MVM_BT_COEX_MPLUT_REG1 0x11118451
+#define IWM_MVM_BT_COEX_ANTENNA_COUPLING_THRS 30
+#define IWM_MVM_FW_MCAST_FILTER_PASS_ALL 0
+#define IWM_MVM_FW_BCAST_FILTER_PASS_ALL 0
+#define IWM_MVM_QUOTA_THRESHOLD 4
+#define IWM_MVM_RS_RSSI_BASED_INIT_RATE 0
+#define IWM_MVM_RS_80_20_FAR_RANGE_TWEAK 1
+#define IWM_MVM_TOF_IS_RESPONDER 0
+#define IWM_MVM_SW_TX_CSUM_OFFLOAD 0
+#define IWM_MVM_HW_CSUM_DISABLE 0
+#define IWM_MVM_COLLECT_FW_ERR_DUMP 1
+#define IWM_MVM_RS_NUM_TRY_BEFORE_ANT_TOGGLE 1
+#define IWM_MVM_RS_HT_VHT_RETRIES_PER_RATE 2
+#define IWM_MVM_RS_HT_VHT_RETRIES_PER_RATE_TW 1
+#define IWM_MVM_RS_INITIAL_MIMO_NUM_RATES 3
+#define IWM_MVM_RS_INITIAL_SISO_NUM_RATES 3
+#define IWM_MVM_RS_INITIAL_LEGACY_NUM_RATES 2
+#define IWM_MVM_RS_INITIAL_LEGACY_RETRIES 2
+#define IWM_MVM_RS_SECONDARY_LEGACY_RETRIES 1
+#define IWM_MVM_RS_SECONDARY_LEGACY_NUM_RATES 16
+#define IWM_MVM_RS_SECONDARY_SISO_NUM_RATES 3
+#define IWM_MVM_RS_SECONDARY_SISO_RETRIES 1
+#define IWM_MVM_RS_RATE_MIN_FAILURE_TH 3
+#define IWM_MVM_RS_RATE_MIN_SUCCESS_TH 8
+#define IWM_MVM_RS_STAY_IN_COLUMN_TIMEOUT 5 /* Seconds */
+#define IWM_MVM_RS_IDLE_TIMEOUT 5 /* Seconds */
+#define IWM_MVM_RS_MISSED_RATE_MAX 15
+#define IWM_MVM_RS_LEGACY_FAILURE_LIMIT 160
+#define IWM_MVM_RS_LEGACY_SUCCESS_LIMIT 480
+#define IWM_MVM_RS_LEGACY_TABLE_COUNT 160
+#define IWM_MVM_RS_NON_LEGACY_FAILURE_LIMIT 400
+#define IWM_MVM_RS_NON_LEGACY_SUCCESS_LIMIT 4500
+#define IWM_MVM_RS_NON_LEGACY_TABLE_COUNT 1500
+#define IWM_MVM_RS_SR_FORCE_DECREASE 15 /* percent */
+#define IWM_MVM_RS_SR_NO_DECREASE 85 /* percent */
+#define IWM_MVM_RS_AGG_TIME_LIMIT 4000 /* 4 msecs. valid 100-8000 */
+#define IWM_MVM_RS_AGG_DISABLE_START 3
+#define IWM_MVM_RS_TPC_SR_FORCE_INCREASE 75 /* percent */
+#define IWM_MVM_RS_TPC_SR_NO_INCREASE 85 /* percent */
+#define IWM_MVM_RS_TPC_TX_POWER_STEP 3
+
+#endif /* __IF_IWM_CONSTANTS_H */
diff --git a/sys/dev/iwm/if_iwm_fw.c b/sys/dev/iwm/if_iwm_fw.c
index 9a2a026d8c4c..280fe5558b0c 100644
--- a/sys/dev/iwm/if_iwm_fw.c
+++ b/sys/dev/iwm/if_iwm_fw.c
@@ -74,6 +74,7 @@
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
+#include "opt_iwm.h"
#include <sys/param.h>
#include <sys/bus.h>
diff --git a/sys/dev/iwm/if_iwm_led.c b/sys/dev/iwm/if_iwm_led.c
index dce4e8d1aa49..1114d4ef8cee 100644
--- a/sys/dev/iwm/if_iwm_led.c
+++ b/sys/dev/iwm/if_iwm_led.c
@@ -89,6 +89,9 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_wlan.h"
+#include "opt_iwm.h"
+
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/endian.h>
diff --git a/sys/dev/iwm/if_iwm_mac_ctxt.c b/sys/dev/iwm/if_iwm_mac_ctxt.c
index b8d4182660df..37725e79fb55 100644
--- a/sys/dev/iwm/if_iwm_mac_ctxt.c
+++ b/sys/dev/iwm/if_iwm_mac_ctxt.c
@@ -106,6 +106,7 @@
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
+#include "opt_iwm.h"
#include <sys/param.h>
#include <sys/bus.h>
@@ -160,6 +161,13 @@ __FBSDID("$FreeBSD$");
* BEGIN mvm/mac-ctxt.c
*/
+const uint8_t iwm_mvm_ac_to_tx_fifo[] = {
+ IWM_MVM_TX_FIFO_BE,
+ IWM_MVM_TX_FIFO_BK,
+ IWM_MVM_TX_FIFO_VI,
+ IWM_MVM_TX_FIFO_VO,
+};
+
static void
iwm_mvm_ack_rates(struct iwm_softc *sc, int is2ghz,
int *cck_rates, int *ofdm_rates, struct iwm_node *in)
@@ -251,6 +259,7 @@ iwm_mvm_mac_ctxt_cmd_common(struct iwm_softc *sc, struct iwm_node *in,
struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
struct ieee80211_node *ni = vap->iv_bss;
+ struct iwm_vap *ivp = IWM_VAP(vap);
int cck_ack_rates, ofdm_ack_rates;
int i;
int is2ghz;
@@ -262,8 +271,8 @@ iwm_mvm_mac_ctxt_cmd_common(struct iwm_softc *sc, struct iwm_node *in,
* These are both functions of the vap, not of the node.
* So, for now, hard-code both to 0 (default).
*/
- cmd->id_and_color = htole32(IWM_FW_CMD_ID_AND_COLOR(IWM_DEFAULT_MACID,
- IWM_DEFAULT_COLOR));
+ cmd->id_and_color = htole32(IWM_FW_CMD_ID_AND_COLOR(ivp->id,
+ ivp->color));
cmd->action = htole32(action);
cmd->mac_type = htole32(IWM_FW_MAC_TYPE_BSS_STA);
@@ -306,7 +315,7 @@ iwm_mvm_mac_ctxt_cmd_common(struct iwm_softc *sc, struct iwm_node *in,
/*
* Default to 2ghz if no node information is given.
*/
- if (in) {
+ if (in && in->in_ni.ni_chan != IEEE80211_CHAN_ANYC) {
is2ghz = !! IEEE80211_IS_CHAN_2GHZ(in->in_ni.ni_chan);
} else {
is2ghz = 1;
@@ -327,17 +336,20 @@ iwm_mvm_mac_ctxt_cmd_common(struct iwm_softc *sc, struct iwm_node *in,
* cmd->qos_flags |= cpu_to_le32(MAC_QOS_FLG_UPDATE_EDCA)
*/
- /* XXX TODO: set wme parameters; also handle getting updated wme parameters */
- for (i = 0; i < IWM_AC_NUM+1; i++) {
- int txf = i;
+ for (i = 0; i < WME_NUM_AC; i++) {
+ uint8_t txf = iwm_mvm_ac_to_tx_fifo[i];
- cmd->ac[txf].cw_min = htole16(0x0f);
- cmd->ac[txf].cw_max = htole16(0x3f);
- cmd->ac[txf].aifsn = 1;
+ cmd->ac[txf].cw_min = htole16(ivp->queue_params[i].cw_min);
+ cmd->ac[txf].cw_max = htole16(ivp->queue_params[i].cw_max);
+ cmd->ac[txf].edca_txop =
+ htole16(ivp->queue_params[i].edca_txop);
+ cmd->ac[txf].aifsn = ivp->queue_params[i].aifsn;
cmd->ac[txf].fifos_mask = (1 << txf);
- cmd->ac[txf].edca_txop = 0;
}
+ if (ivp->have_wme)
+ cmd->qos_flags |= htole32(IWM_MAC_QOS_FLG_UPDATE_EDCA);
+
if (ic->ic_flags & IEEE80211_F_USEPROT)
cmd->protection_flags |= htole32(IWM_MAC_PROT_FLG_TGG_PROTECT);
diff --git a/sys/dev/iwm/if_iwm_mac_ctxt.h b/sys/dev/iwm/if_iwm_mac_ctxt.h
index 00940536ea0f..3abcc20579fa 100644
--- a/sys/dev/iwm/if_iwm_mac_ctxt.h
+++ b/sys/dev/iwm/if_iwm_mac_ctxt.h
@@ -106,6 +106,8 @@
#ifndef __IF_IWM_MAC_CTXT_H__
#define __IF_IWM_MAC_CTXT_H__
+extern const uint8_t iwm_mvm_ac_to_tx_fifo[];
+
extern int iwm_mvm_mac_ctxt_add(struct iwm_softc *sc, struct ieee80211vap *vap);
extern int iwm_mvm_mac_ctxt_changed(struct iwm_softc *sc, struct ieee80211vap *vap);
extern int iwm_mvm_mac_ctxt_remove(struct iwm_softc *sc, struct ieee80211vap *vap);
diff --git a/sys/dev/iwm/if_iwm_notif_wait.c b/sys/dev/iwm/if_iwm_notif_wait.c
index 94daa1d7a087..71061d740c52 100644
--- a/sys/dev/iwm/if_iwm_notif_wait.c
+++ b/sys/dev/iwm/if_iwm_notif_wait.c
@@ -70,6 +70,7 @@
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
+#include "opt_iwm.h"
#include <sys/param.h>
#include <sys/systm.h>
diff --git a/sys/dev/iwm/if_iwm_pcie_trans.c b/sys/dev/iwm/if_iwm_pcie_trans.c
index c9dae6680e56..e65c81e54c00 100644
--- a/sys/dev/iwm/if_iwm_pcie_trans.c
+++ b/sys/dev/iwm/if_iwm_pcie_trans.c
@@ -106,6 +106,7 @@
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
+#include "opt_iwm.h"
#include <sys/param.h>
#include <sys/bus.h>
@@ -498,11 +499,17 @@ iwm_apm_init(struct iwm_softc *sc)
* just to discard the value. But that's the way the hardware
* seems to like it.
*/
- iwm_read_prph(sc, IWM_OSC_CLK);
- iwm_read_prph(sc, IWM_OSC_CLK);
+ if (iwm_nic_lock(sc)) {
+ iwm_read_prph(sc, IWM_OSC_CLK);
+ iwm_read_prph(sc, IWM_OSC_CLK);
+ iwm_nic_unlock(sc);
+ }
iwm_set_bits_prph(sc, IWM_OSC_CLK, IWM_OSC_CLK_FORCE_CONTROL);
- iwm_read_prph(sc, IWM_OSC_CLK);
- iwm_read_prph(sc, IWM_OSC_CLK);
+ if (iwm_nic_lock(sc)) {
+ iwm_read_prph(sc, IWM_OSC_CLK);
+ iwm_read_prph(sc, IWM_OSC_CLK);
+ iwm_nic_unlock(sc);
+ }
}
/*
@@ -513,8 +520,11 @@ iwm_apm_init(struct iwm_softc *sc)
* set by default in "CLK_CTRL_REG" after reset.
*/
if (sc->cfg->device_family == IWM_DEVICE_FAMILY_7000) {
- iwm_write_prph(sc, IWM_APMG_CLK_EN_REG,
- IWM_APMG_CLK_VAL_DMA_CLK_RQT);
+ if (iwm_nic_lock(sc)) {
+ iwm_write_prph(sc, IWM_APMG_CLK_EN_REG,
+ IWM_APMG_CLK_VAL_DMA_CLK_RQT);
+ iwm_nic_unlock(sc);
+ }
DELAY(20);
/* Disable L1-Active */
@@ -522,8 +532,11 @@ iwm_apm_init(struct iwm_softc *sc)
IWM_APMG_PCIDEV_STT_VAL_L1_ACT_DIS);
/* Clear the interrupt in APMG if the NIC is in RFKILL */
- iwm_write_prph(sc, IWM_APMG_RTC_INT_STT_REG,
- IWM_APMG_RTC_INT_STT_RFKILL);
+ if (iwm_nic_lock(sc)) {
+ iwm_write_prph(sc, IWM_APMG_RTC_INT_STT_REG,
+ IWM_APMG_RTC_INT_STT_RFKILL);
+ iwm_nic_unlock(sc);
+ }
}
out:
if (error)
@@ -625,12 +638,12 @@ iwm_pcie_set_cmd_in_flight(struct iwm_softc *sc)
IWM_SETBITS(sc, IWM_CSR_GP_CNTRL,
IWM_CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
- ret = iwm_poll_bit(sc, IWM_CSR_GP_CNTRL,
+ ret = iwm_poll_bit(sc, IWM_CSR_GP_CNTRL,
IWM_CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN,
(IWM_CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY |
IWM_CSR_GP_CNTRL_REG_FLAG_GOING_TO_SLEEP),
15000);
- if (ret == 0) {
+ if (ret == 0) {
IWM_CLRBITS(sc, IWM_CSR_GP_CNTRL,
IWM_CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ);
device_printf(sc->sc_dev,
diff --git a/sys/dev/iwm/if_iwm_phy_ctxt.c b/sys/dev/iwm/if_iwm_phy_ctxt.c
index df266e15c14b..242e3abc388b 100644
--- a/sys/dev/iwm/if_iwm_phy_ctxt.c
+++ b/sys/dev/iwm/if_iwm_phy_ctxt.c
@@ -106,6 +106,7 @@
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
+#include "opt_iwm.h"
#include <sys/param.h>
#include <sys/bus.h>
@@ -217,6 +218,18 @@ iwm_mvm_phy_ctxt_cmd_data(struct iwm_softc *sc,
idle_cnt = chains_static;
active_cnt = chains_dynamic;
+ /* In scenarios where we only ever use a single-stream rates,
+ * i.e. legacy 11b/g/a associations, single-stream APs or even
+ * static SMPS, enable both chains to get diversity, improving
+ * the case where we're far enough from the AP that attenuation
+ * between the two antennas is sufficiently different to impact
+ * performance.
+ */
+ if (active_cnt == 1 && iwm_mvm_rx_diversity_allowed(sc)) {
+ idle_cnt = 2;
+ active_cnt = 2;
+ }
+
cmd->rxchain_info = htole32(iwm_mvm_get_valid_rx_ant(sc) <<
IWM_PHY_RX_CHAIN_VALID_POS);
cmd->rxchain_info |= htole32(idle_cnt << IWM_PHY_RX_CHAIN_CNT_POS);
diff --git a/sys/dev/iwm/if_iwm_phy_db.c b/sys/dev/iwm/if_iwm_phy_db.c
index 6cd2465c59c8..f20046083bfd 100644
--- a/sys/dev/iwm/if_iwm_phy_db.c
+++ b/sys/dev/iwm/if_iwm_phy_db.c
@@ -106,6 +106,7 @@
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
+#include "opt_iwm.h"
#include <sys/param.h>
#include <sys/bus.h>
diff --git a/sys/dev/iwm/if_iwm_power.c b/sys/dev/iwm/if_iwm_power.c
index b99d49ed5096..75fe146b40a6 100644
--- a/sys/dev/iwm/if_iwm_power.c
+++ b/sys/dev/iwm/if_iwm_power.c
@@ -90,6 +90,7 @@
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
+#include "opt_iwm.h"
#include <sys/param.h>
#include <sys/bus.h>
@@ -137,9 +138,14 @@ __FBSDID("$FreeBSD$");
#include <dev/iwm/if_iwmreg.h>
#include <dev/iwm/if_iwmvar.h>
#include <dev/iwm/if_iwm_debug.h>
+#include <dev/iwm/if_iwm_constants.h>
#include <dev/iwm/if_iwm_util.h>
#include <dev/iwm/if_iwm_power.h>
+static int iwm_power_scheme = IWM_POWER_SCHEME_BPS;
+
+TUNABLE_INT("hw.iwm.power_scheme", &iwm_power_scheme);
+
/*
* BEGIN mvm/power.c
*/
@@ -153,7 +159,7 @@ iwm_mvm_beacon_filter_send_cmd(struct iwm_softc *sc,
int ret;
ret = iwm_mvm_send_cmd_pdu(sc, IWM_REPLY_BEACON_FILTERING_CMD,
- IWM_CMD_SYNC, sizeof(struct iwm_beacon_filter_cmd), cmd);
+ 0, sizeof(struct iwm_beacon_filter_cmd), cmd);
if (!ret) {
IWM_DPRINTF(sc, IWM_DEBUG_PWRSAVE | IWM_DEBUG_CMD,
@@ -195,36 +201,18 @@ iwm_mvm_beacon_filter_send_cmd(struct iwm_softc *sc,
static void
iwm_mvm_beacon_filter_set_cqm_params(struct iwm_softc *sc,
- struct iwm_node *in, struct iwm_beacon_filter_cmd *cmd)
+ struct iwm_vap *ivp, struct iwm_beacon_filter_cmd *cmd)
{
cmd->ba_enable_beacon_abort = htole32(sc->sc_bf.ba_enabled);
}
-static int
-iwm_mvm_update_beacon_abort(struct iwm_softc *sc, struct iwm_node *in,
- int enable)
-{
- struct iwm_beacon_filter_cmd cmd = {
- IWM_BF_CMD_CONFIG_DEFAULTS,
- .bf_enable_beacon_filter = htole32(1),
- .ba_enable_beacon_abort = htole32(enable),
- };
-
- if (!sc->sc_bf.bf_enabled)
- return 0;
-
- sc->sc_bf.ba_enabled = enable;
- iwm_mvm_beacon_filter_set_cqm_params(sc, in, &cmd);
- return iwm_mvm_beacon_filter_send_cmd(sc, &cmd);
-}
-
static void
iwm_mvm_power_log(struct iwm_softc *sc, struct iwm_mac_power_cmd *cmd)
{
IWM_DPRINTF(sc, IWM_DEBUG_PWRSAVE | IWM_DEBUG_CMD,
"Sending power table command on mac id 0x%X for "
"power level %d, flags = 0x%X\n",
- cmd->id_and_color, IWM_POWER_SCHEME_CAM, le16toh(cmd->flags));
+ cmd->id_and_color, iwm_power_scheme, le16toh(cmd->flags));
IWM_DPRINTF(sc, IWM_DEBUG_PWRSAVE | IWM_DEBUG_CMD,
"Keep alive = %u sec\n", le16toh(cmd->keep_alive_seconds));
@@ -233,20 +221,74 @@ iwm_mvm_power_log(struct iwm_softc *sc, struct iwm_mac_power_cmd *cmd)
"Disable power management\n");
return;
}
+
+ IWM_DPRINTF(sc, IWM_DEBUG_PWRSAVE | IWM_DEBUG_CMD,
+ "Rx timeout = %u usec\n", le32toh(cmd->rx_data_timeout));
+ IWM_DPRINTF(sc, IWM_DEBUG_PWRSAVE | IWM_DEBUG_CMD,
+ "Tx timeout = %u usec\n", le32toh(cmd->tx_data_timeout));
+ if (cmd->flags & htole16(IWM_POWER_FLAGS_SKIP_OVER_DTIM_MSK))
+ IWM_DPRINTF(sc, IWM_DEBUG_PWRSAVE | IWM_DEBUG_CMD,
+ "DTIM periods to skip = %u\n", cmd->skip_dtim_periods);
+}
+
+static boolean_t
+iwm_mvm_power_is_radar(struct iwm_softc *sc)
+{
+ struct ieee80211com *ic = &sc->sc_ic;
+ struct ieee80211_channel *chan;
+ boolean_t radar_detect = FALSE;
+
+ chan = ic->ic_bsschan;
+ if (chan == IEEE80211_CHAN_ANYC ||
+ (chan->ic_flags & IEEE80211_CHAN_DFS) != 0) {
+ radar_detect = TRUE;
+ }
+
+ return radar_detect;
}
static void
-iwm_mvm_power_build_cmd(struct iwm_softc *sc, struct iwm_node *in,
+iwm_mvm_power_config_skip_dtim(struct iwm_softc *sc,
struct iwm_mac_power_cmd *cmd)
{
- struct ieee80211_node *ni = &in->in_ni;
- int dtimper, dtimper_msec;
- int keep_alive;
struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
+ int dtimper = vap->iv_dtim_period ?: 1;
+ int skip;
+
+ /* disable, in case we're supposed to override */
+ cmd->skip_dtim_periods = 0;
+ cmd->flags &= ~htole16(IWM_POWER_FLAGS_SKIP_OVER_DTIM_MSK);
+
+ if (iwm_mvm_power_is_radar(sc))
+ return;
+
+ if (dtimper >= 10)
+ return;
+
+ /* TODO: check that multicast wake lock is off */
+
+ if (iwm_power_scheme != IWM_POWER_SCHEME_LP)
+ return;
+ skip = 2;
- cmd->id_and_color = htole32(IWM_FW_CMD_ID_AND_COLOR(IWM_DEFAULT_MACID,
- IWM_DEFAULT_COLOR));
+ /* the firmware really expects "look at every X DTIMs", so add 1 */
+ cmd->skip_dtim_periods = 1 + skip;
+ cmd->flags |= htole16(IWM_POWER_FLAGS_SKIP_OVER_DTIM_MSK);
+}
+
+static void
+iwm_mvm_power_build_cmd(struct iwm_softc *sc, struct iwm_vap *ivp,
+ struct iwm_mac_power_cmd *cmd)
+{
+ struct ieee80211vap *vap = &ivp->iv_vap;
+ struct ieee80211_node *ni = vap->iv_bss;
+ int dtimper, dtimper_msec;
+ int keep_alive;
+ boolean_t bss_conf_ps = FALSE;
+
+ cmd->id_and_color = htole32(IWM_FW_CMD_ID_AND_COLOR(ivp->id,
+ ivp->color));
dtimper = vap->iv_dtim_period ?: 1;
/*
@@ -257,63 +299,68 @@ iwm_mvm_power_build_cmd(struct iwm_softc *sc, struct iwm_node *in,
*/
dtimper_msec = dtimper * ni->ni_intval;
keep_alive
- = MAX(3 * dtimper_msec, 1000 * IWM_POWER_KEEP_ALIVE_PERIOD_SEC);
+ = imax(3 * dtimper_msec, 1000 * IWM_POWER_KEEP_ALIVE_PERIOD_SEC);
keep_alive = roundup(keep_alive, 1000) / 1000;
cmd->keep_alive_seconds = htole16(keep_alive);
+
+ if (sc->sc_ps_disabled)
+ return;
+
+ cmd->flags |= htole16(IWM_POWER_FLAGS_POWER_SAVE_ENA_MSK);
+
+ if (IWM_NODE(ni)->in_assoc &&
+ (vap->iv_flags & IEEE80211_F_PMGTON) != 0) {
+ bss_conf_ps = TRUE;
+ }
+ if (!bss_conf_ps)
+ return;
+
+ cmd->flags |= htole16(IWM_POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK);
+
+ iwm_mvm_power_config_skip_dtim(sc, cmd);
+
+ cmd->rx_data_timeout =
+ htole32(IWM_MVM_DEFAULT_PS_RX_DATA_TIMEOUT);
+ cmd->tx_data_timeout =
+ htole32(IWM_MVM_DEFAULT_PS_TX_DATA_TIMEOUT);
}
-int
-iwm_mvm_power_mac_update_mode(struct iwm_softc *sc, struct iwm_node *in)
+static int
+iwm_mvm_power_send_cmd(struct iwm_softc *sc, struct iwm_vap *ivp)
{
- int ret;
- int ba_enable;
- struct iwm_mac_power_cmd cmd;
+ struct iwm_mac_power_cmd cmd = {};
- memset(&cmd, 0, sizeof(cmd));
-
- iwm_mvm_power_build_cmd(sc, in, &cmd);
+ iwm_mvm_power_build_cmd(sc, ivp, &cmd);
iwm_mvm_power_log(sc, &cmd);
- if ((ret = iwm_mvm_send_cmd_pdu(sc, IWM_MAC_PM_POWER_TABLE,
- IWM_CMD_SYNC, sizeof(cmd), &cmd)) != 0)
- return ret;
-
- ba_enable = !!(cmd.flags &
- htole16(IWM_POWER_FLAGS_POWER_MANAGEMENT_ENA_MSK));
- return iwm_mvm_update_beacon_abort(sc, in, ba_enable);
+ return iwm_mvm_send_cmd_pdu(sc, IWM_MAC_PM_POWER_TABLE, 0,
+ sizeof(cmd), &cmd);
}
-int
-iwm_mvm_power_update_device(struct iwm_softc *sc)
+static int
+_iwm_mvm_enable_beacon_filter(struct iwm_softc *sc, struct iwm_vap *ivp,
+ struct iwm_beacon_filter_cmd *cmd)
{
- struct iwm_device_power_cmd cmd = {
- .flags = htole16(IWM_DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK),
- };
+ int ret;
- cmd.flags |= htole16(IWM_DEVICE_POWER_FLAGS_CAM_MSK);
- IWM_DPRINTF(sc, IWM_DEBUG_PWRSAVE | IWM_DEBUG_CMD,
- "Sending device power command with flags = 0x%X\n", cmd.flags);
+ iwm_mvm_beacon_filter_set_cqm_params(sc, ivp, cmd);
+ ret = iwm_mvm_beacon_filter_send_cmd(sc, cmd);
- return iwm_mvm_send_cmd_pdu(sc,
- IWM_POWER_TABLE_CMD, IWM_CMD_SYNC, sizeof(cmd), &cmd);
+ if (!ret)
+ sc->sc_bf.bf_enabled = 1;
+
+ return ret;
}
int
-iwm_mvm_enable_beacon_filter(struct iwm_softc *sc, struct iwm_node *in)
+iwm_mvm_enable_beacon_filter(struct iwm_softc *sc, struct iwm_vap *ivp)
{
struct iwm_beacon_filter_cmd cmd = {
IWM_BF_CMD_CONFIG_DEFAULTS,
.bf_enable_beacon_filter = htole32(1),
};
- int ret;
-
- iwm_mvm_beacon_filter_set_cqm_params(sc, in, &cmd);
- ret = iwm_mvm_beacon_filter_send_cmd(sc, &cmd);
- if (ret == 0)
- sc->sc_bf.bf_enabled = 1;
-
- return ret;
+ return _iwm_mvm_enable_beacon_filter(sc, ivp, &cmd);
}
int
@@ -328,3 +375,115 @@ iwm_mvm_disable_beacon_filter(struct iwm_softc *sc)
return ret;
}
+
+static int
+iwm_mvm_power_set_ps(struct iwm_softc *sc)
+{
+ struct ieee80211vap *vap;
+ boolean_t disable_ps;
+ int ret;
+
+ /* disable PS if CAM */
+ disable_ps = (iwm_power_scheme == IWM_POWER_SCHEME_CAM);
+ /* ...or if any of the vifs require PS to be off */
+ TAILQ_FOREACH(vap, &sc->sc_ic.ic_vaps, iv_next) {
+ struct iwm_vap *ivp = IWM_VAP(vap);
+ if (ivp->phy_ctxt != NULL && ivp->ps_disabled)
+ disable_ps = TRUE;
+ }
+
+ /* update device power state if it has changed */
+ if (sc->sc_ps_disabled != disable_ps) {
+ boolean_t old_ps_disabled = sc->sc_ps_disabled;
+
+ sc->sc_ps_disabled = disable_ps;
+ ret = iwm_mvm_power_update_device(sc);
+ if (ret) {
+ sc->sc_ps_disabled = old_ps_disabled;
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int
+iwm_mvm_power_set_ba(struct iwm_softc *sc, struct iwm_vap *ivp)
+{
+ struct iwm_beacon_filter_cmd cmd = {
+ IWM_BF_CMD_CONFIG_DEFAULTS,
+ .bf_enable_beacon_filter = htole32(1),
+ };
+ struct ieee80211vap *vap = &ivp->iv_vap;
+ struct ieee80211_node *ni = vap->iv_bss;
+ boolean_t bss_conf_ps = FALSE;
+
+ if (!sc->sc_bf.bf_enabled)
+ return 0;
+
+ if (ni != NULL && IWM_NODE(ni)->in_assoc &&
+ (vap->iv_flags & IEEE80211_F_PMGTON) != 0) {
+ bss_conf_ps = TRUE;
+ }
+ sc->sc_bf.ba_enabled = !sc->sc_ps_disabled && bss_conf_ps;
+
+ return _iwm_mvm_enable_beacon_filter(sc, ivp, &cmd);
+}
+
+int
+iwm_mvm_power_update_ps(struct iwm_softc *sc)
+{
+ struct ieee80211vap *vap = TAILQ_FIRST(&sc->sc_ic.ic_vaps);
+ int ret;
+
+ ret = iwm_mvm_power_set_ps(sc);
+ if (ret)
+ return ret;
+
+ if (vap != NULL)
+ return iwm_mvm_power_set_ba(sc, IWM_VAP(vap));
+
+ return 0;
+}
+
+int
+iwm_mvm_power_update_mac(struct iwm_softc *sc)
+{
+ struct ieee80211vap *vap = TAILQ_FIRST(&sc->sc_ic.ic_vaps);
+ int ret;
+
+ ret = iwm_mvm_power_set_ps(sc);
+ if (ret)
+ return ret;
+
+ if (vap != NULL) {
+ ret = iwm_mvm_power_send_cmd(sc, IWM_VAP(vap));
+ if (ret)
+ return ret;
+ }
+
+ if (vap != NULL)
+ return iwm_mvm_power_set_ba(sc, IWM_VAP(vap));
+
+ return 0;
+}
+
+int
+iwm_mvm_power_update_device(struct iwm_softc *sc)
+{
+ struct iwm_device_power_cmd cmd = {
+ .flags = 0,
+ };
+
+ if (iwm_power_scheme == IWM_POWER_SCHEME_CAM)
+ sc->sc_ps_disabled = TRUE;
+
+ if (!sc->sc_ps_disabled)
+ cmd.flags |= htole16(IWM_DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK);
+
+ IWM_DPRINTF(sc, IWM_DEBUG_PWRSAVE | IWM_DEBUG_CMD,
+ "Sending device power command with flags = 0x%X\n", cmd.flags);
+
+ return iwm_mvm_send_cmd_pdu(sc,
+ IWM_POWER_TABLE_CMD, 0, sizeof(cmd), &cmd);
+}
diff --git a/sys/dev/iwm/if_iwm_power.h b/sys/dev/iwm/if_iwm_power.h
index d34c4445a910..69c5f80f769c 100644
--- a/sys/dev/iwm/if_iwm_power.h
+++ b/sys/dev/iwm/if_iwm_power.h
@@ -90,11 +90,11 @@
#ifndef __IF_IWM_POWER_H__
#define __IF_IWM_POWER_H__
-extern int iwm_mvm_power_mac_update_mode(struct iwm_softc *sc,
- struct iwm_node *in);
extern int iwm_mvm_power_update_device(struct iwm_softc *sc);
+extern int iwm_mvm_power_update_mac(struct iwm_softc *sc);
+extern int iwm_mvm_power_update_ps(struct iwm_softc *sc);
extern int iwm_mvm_enable_beacon_filter(struct iwm_softc *sc,
- struct iwm_node *in);
+ struct iwm_vap *ivp);
extern int iwm_mvm_disable_beacon_filter(struct iwm_softc *sc);
#endif /* __IF_IWM_POWER_H__ */
diff --git a/sys/dev/iwm/if_iwm_scan.c b/sys/dev/iwm/if_iwm_scan.c
index 682511f5bc85..de041b9a5f01 100644
--- a/sys/dev/iwm/if_iwm_scan.c
+++ b/sys/dev/iwm/if_iwm_scan.c
@@ -106,6 +106,7 @@
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
+#include "opt_iwm.h"
#include <sys/param.h>
#include <sys/bus.h>
diff --git a/sys/dev/iwm/if_iwm_sta.c b/sys/dev/iwm/if_iwm_sta.c
new file mode 100644
index 000000000000..f740035b1fdd
--- /dev/null
+++ b/sys/dev/iwm/if_iwm_sta.c
@@ -0,0 +1,384 @@
+/*-
+ * Based on BSD-licensed source modules in the Linux iwlwifi driver,
+ * which were used as the reference documentation for this implementation.
+ *
+ * Driver version we are currently based off of is
+ * Linux 4.7.3 (tag id d7f6728f57e3ecbb7ef34eb7d9f564d514775d75)
+ *
+ ***********************************************************************
+ *
+ * This file is provided under a dual BSD/GPLv2 license. When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2012 - 2015 Intel Corporation. All rights reserved.
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
+ * Copyright(c) 2016 Intel Deutschland GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called COPYING.
+ *
+ * Contact Information:
+ * Intel Linux Wireless <linuxwifi@intel.com>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2012 - 2015 Intel Corporation. All rights reserved.
+ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
+ * Copyright(c) 2016 Intel Deutschland GmbH
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *****************************************************************************/
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include "opt_wlan.h"
+#include "opt_iwm.h"
+
+#include <sys/param.h>
+#include <sys/bus.h>
+#include <sys/conf.h>
+#include <sys/endian.h>
+#include <sys/firmware.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/mutex.h>
+#include <sys/module.h>
+#include <sys/proc.h>
+#include <sys/rman.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+#include <sys/sysctl.h>
+#include <sys/linker.h>
+
+#include <machine/bus.h>
+#include <machine/endian.h>
+#include <machine/resource.h>
+
+#include <dev/pci/pcivar.h>
+#include <dev/pci/pcireg.h>
+
+#include <net/bpf.h>
+
+#include <net/if.h>
+#include <net/if_var.h>
+#include <net/if_arp.h>
+#include <net/if_dl.h>
+#include <net/if_media.h>
+#include <net/if_types.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+#include <netinet/if_ether.h>
+#include <netinet/ip.h>
+
+#include <net80211/ieee80211_var.h>
+#include <net80211/ieee80211_regdomain.h>
+#include <net80211/ieee80211_ratectl.h>
+#include <net80211/ieee80211_radiotap.h>
+
+#include <dev/iwm/if_iwmreg.h>
+#include <dev/iwm/if_iwmvar.h>
+#include <dev/iwm/if_iwm_config.h>
+#include <dev/iwm/if_iwm_debug.h>
+#include <dev/iwm/if_iwm_constants.h>
+#include <dev/iwm/if_iwm_util.h>
+#include <dev/iwm/if_iwm_mac_ctxt.h>
+#include <dev/iwm/if_iwm_sta.h>
+
+/*
+ * New version of ADD_STA_sta command added new fields at the end of the
+ * structure, so sending the size of the relevant API's structure is enough to
+ * support both API versions.
+ */
+static inline int
+iwm_mvm_add_sta_cmd_size(struct iwm_softc *sc)
+{
+#ifdef notyet
+ return iwm_mvm_has_new_rx_api(mvm) ?
+ sizeof(struct iwm_mvm_add_sta_cmd) :
+ sizeof(struct iwm_mvm_add_sta_cmd_v7);
+#else
+ return sizeof(struct iwm_mvm_add_sta_cmd);
+#endif
+}
+
+/* send station add/update command to firmware */
+int
+iwm_mvm_sta_send_to_fw(struct iwm_softc *sc, struct iwm_node *in,
+ boolean_t update)
+{
+ struct iwm_vap *ivp = IWM_VAP(in->in_ni.ni_vap);
+ struct iwm_mvm_add_sta_cmd add_sta_cmd = {
+ .sta_id = IWM_STATION_ID,
+ .mac_id_n_color =
+ htole32(IWM_FW_CMD_ID_AND_COLOR(ivp->id, ivp->color)),
+ .add_modify = update ? 1 : 0,
+ .station_flags_msk = htole32(IWM_STA_FLG_FAT_EN_MSK |
+ IWM_STA_FLG_MIMO_EN_MSK),
+ .tid_disable_tx = htole16(0xffff),
+ };
+ int ret;
+ uint32_t status;
+ uint32_t agg_size = 0, mpdu_dens = 0;
+
+ if (!update) {
+ int ac;
+ for (ac = 0; ac < WME_NUM_AC; ac++) {
+ add_sta_cmd.tfd_queue_msk |=
+ htole32(1 << iwm_mvm_ac_to_tx_fifo[ac]);
+ }
+ IEEE80211_ADDR_COPY(&add_sta_cmd.addr, in->in_ni.ni_bssid);
+ }
+
+ add_sta_cmd.station_flags |=
+ htole32(agg_size << IWM_STA_FLG_MAX_AGG_SIZE_SHIFT);
+ add_sta_cmd.station_flags |=
+ htole32(mpdu_dens << IWM_STA_FLG_AGG_MPDU_DENS_SHIFT);
+
+ status = IWM_ADD_STA_SUCCESS;
+ ret = iwm_mvm_send_cmd_pdu_status(sc, IWM_ADD_STA,
+ iwm_mvm_add_sta_cmd_size(sc),
+ &add_sta_cmd, &status);
+ if (ret)
+ return ret;
+
+ switch (status & IWM_ADD_STA_STATUS_MASK) {
+ case IWM_ADD_STA_SUCCESS:
+ IWM_DPRINTF(sc, IWM_DEBUG_NODE, "IWM_ADD_STA PASSED\n");
+ break;
+ default:
+ ret = EIO;
+ device_printf(sc->sc_dev, "IWM_ADD_STA failed\n");
+ break;
+ }
+
+ return ret;
+}
+
+int
+iwm_mvm_add_sta(struct iwm_softc *sc, struct iwm_node *in)
+{
+ return iwm_mvm_sta_send_to_fw(sc, in, FALSE);
+}
+
+int
+iwm_mvm_update_sta(struct iwm_softc *sc, struct iwm_node *in)
+{
+ return iwm_mvm_sta_send_to_fw(sc, in, TRUE);
+}
+
+int
+iwm_mvm_drain_sta(struct iwm_softc *sc, struct iwm_vap *ivp, boolean_t drain)
+{
+ struct iwm_mvm_add_sta_cmd cmd = {};
+ int ret;
+ uint32_t status;
+
+ cmd.mac_id_n_color =
+ htole32(IWM_FW_CMD_ID_AND_COLOR(ivp->id, ivp->color));
+ cmd.sta_id = IWM_STATION_ID;
+ cmd.add_modify = IWM_STA_MODE_MODIFY;
+ cmd.station_flags = drain ? htole32(IWM_STA_FLG_DRAIN_FLOW) : 0;
+ cmd.station_flags_msk = htole32(IWM_STA_FLG_DRAIN_FLOW);
+
+ status = IWM_ADD_STA_SUCCESS;
+ ret = iwm_mvm_send_cmd_pdu_status(sc, IWM_ADD_STA,
+ iwm_mvm_add_sta_cmd_size(sc),
+ &cmd, &status);
+ if (ret)
+ return ret;
+
+ switch (status & IWM_ADD_STA_STATUS_MASK) {
+ case IWM_ADD_STA_SUCCESS:
+ IWM_DPRINTF(sc, IWM_DEBUG_NODE,
+ "Frames for staid %d will drained in fw\n", IWM_STATION_ID);
+ break;
+ default:
+ ret = EIO;
+ device_printf(sc->sc_dev,
+ "Couldn't drain frames for staid %d\n", IWM_STATION_ID);
+ break;
+ }
+
+ return ret;
+}
+
+/*
+ * Remove a station from the FW table. Before sending the command to remove
+ * the station validate that the station is indeed known to the driver (sanity
+ * only).
+ */
+static int
+iwm_mvm_rm_sta_common(struct iwm_softc *sc)
+{
+ struct iwm_mvm_rm_sta_cmd rm_sta_cmd = {
+ .sta_id = IWM_STATION_ID,
+ };
+ int ret;
+
+ ret = iwm_mvm_send_cmd_pdu(sc, IWM_REMOVE_STA, 0,
+ sizeof(rm_sta_cmd), &rm_sta_cmd);
+ if (ret) {
+ device_printf(sc->sc_dev,
+ "Failed to remove station. Id=%d\n", IWM_STATION_ID);
+ return ret;
+ }
+
+ return 0;
+}
+
+int
+iwm_mvm_rm_sta(struct iwm_softc *sc, struct ieee80211vap *vap,
+ boolean_t is_assoc)
+{
+ uint32_t tfd_queue_msk = 0;
+ int ret;
+ int ac;
+
+ ret = iwm_mvm_drain_sta(sc, IWM_VAP(vap), TRUE);
+ if (ret)
+ return ret;
+ mbufq_drain(&sc->sc_snd); /* XXX needed ? */
+ for (ac = 0; ac < WME_NUM_AC; ac++) {
+ tfd_queue_msk |= htole32(1 << iwm_mvm_ac_to_tx_fifo[ac]);
+ }
+ ret = iwm_mvm_flush_tx_path(sc, tfd_queue_msk, 0);
+ if (ret)
+ return ret;
+#ifdef notyet /* function not yet implemented */
+ ret = iwl_trans_wait_tx_queue_empty(mvm->trans,
+ mvm_sta->tfd_queue_msk);
+ if (ret)
+ return ret;
+#endif
+ ret = iwm_mvm_drain_sta(sc, IWM_VAP(vap), FALSE);
+
+ /* if we are associated - we can't remove the AP STA now */
+ if (is_assoc)
+ return ret;
+
+ /* XXX wait until STA is drained */
+
+ ret = iwm_mvm_rm_sta_common(sc);
+
+ return ret;
+}
+
+int
+iwm_mvm_rm_sta_id(struct iwm_softc *sc, struct ieee80211vap *vap)
+{
+ /* XXX wait until STA is drained */
+
+ return iwm_mvm_rm_sta_common(sc);
+}
+
+static int
+iwm_mvm_add_int_sta_common(struct iwm_softc *sc, struct iwm_int_sta *sta,
+ const uint8_t *addr, uint16_t mac_id, uint16_t color)
+{
+ struct iwm_mvm_add_sta_cmd cmd;
+ int ret;
+ uint32_t status;
+
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.sta_id = sta->sta_id;
+ cmd.mac_id_n_color = htole32(IWM_FW_CMD_ID_AND_COLOR(mac_id, color));
+
+ cmd.tfd_queue_msk = htole32(sta->tfd_queue_msk);
+ cmd.tid_disable_tx = htole16(0xffff);
+
+ if (addr)
+ IEEE80211_ADDR_COPY(cmd.addr, addr);
+
+ ret = iwm_mvm_send_cmd_pdu_status(sc, IWM_ADD_STA,
+ iwm_mvm_add_sta_cmd_size(sc),
+ &cmd, &status);
+ if (ret)
+ return ret;
+
+ switch (status & IWM_ADD_STA_STATUS_MASK) {
+ case IWM_ADD_STA_SUCCESS:
+ IWM_DPRINTF(sc, IWM_DEBUG_NODE, "Internal station added.\n");
+ return 0;
+ default:
+ ret = EIO;
+ device_printf(sc->sc_dev,
+ "Add internal station failed, status=0x%x\n", status);
+ break;
+ }
+ return ret;
+}
+
+int
+iwm_mvm_add_aux_sta(struct iwm_softc *sc)
+{
+ int ret;
+
+ sc->sc_aux_sta.sta_id = IWM_AUX_STA_ID;
+ sc->sc_aux_sta.tfd_queue_msk = (1 << IWM_MVM_AUX_QUEUE);
+
+ /* Map Aux queue to fifo - needs to happen before adding Aux station */
+ ret = iwm_enable_txq(sc, 0, IWM_MVM_AUX_QUEUE, IWM_MVM_TX_FIFO_MCAST);
+ if (ret)
+ return ret;
+
+ ret = iwm_mvm_add_int_sta_common(sc, &sc->sc_aux_sta, NULL,
+ IWM_MAC_INDEX_AUX, 0);
+
+ if (ret) {
+ memset(&sc->sc_aux_sta, 0, sizeof(sc->sc_aux_sta));
+ sc->sc_aux_sta.sta_id = IWM_MVM_STATION_COUNT;
+ }
+ return ret;
+}
+
+void iwm_mvm_del_aux_sta(struct iwm_softc *sc)
+{
+ memset(&sc->sc_aux_sta, 0, sizeof(sc->sc_aux_sta));
+ sc->sc_aux_sta.sta_id = IWM_MVM_STATION_COUNT;
+}
diff --git a/sys/dev/iwm/if_iwm_sta.h b/sys/dev/iwm/if_iwm_sta.h
new file mode 100644
index 000000000000..7de9d87804c9
--- /dev/null
+++ b/sys/dev/iwm/if_iwm_sta.h
@@ -0,0 +1,223 @@
+/*-
+ * Based on BSD-licensed source modules in the Linux iwlwifi driver,
+ * which were used as the reference documentation for this implementation.
+ *
+ * Driver version we are currently based off of is
+ * Linux 4.7.3 (tag id d7f6728f57e3ecbb7ef34eb7d9f564d514775d75)
+ *
+ ***********************************************************************
+ *
+ *
+ * This file is provided under a dual BSD/GPLv2 license. When using or
+ * redistributing this file, you may do so under either license.
+ *
+ * GPL LICENSE SUMMARY
+ *
+ * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
+ * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
+ * USA
+ *
+ * The full GNU General Public License is included in this distribution
+ * in the file called COPYING.
+ *
+ * Contact Information:
+ * Intel Linux Wireless <linuxwifi@intel.com>
+ * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
+ *
+ * BSD LICENSE
+ *
+ * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
+ * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH
+ * Copyright(c) 2015 - 2016 Intel Deutschland GmbH
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name Intel Corporation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ *****************************************************************************/
+
+/* $FreeBSD$ */
+
+#ifndef __IF_IWM_STA_H__
+#define __IF_IWM_STA_H__
+
+/**
+ * DOC: station table - introduction
+ *
+ * The station table is a list of data structure that reprensent the stations.
+ * In STA/P2P client mode, the driver will hold one station for the AP/ GO.
+ * In GO/AP mode, the driver will have as many stations as associated clients.
+ * All these stations are reflected in the fw's station table. The driver
+ * keeps the fw's station table up to date with the ADD_STA command. Stations
+ * can be removed by the REMOVE_STA command.
+ *
+ * All the data related to a station is held in the structure %iwl_mvm_sta
+ * which is embed in the mac80211's %ieee80211_sta (in the drv_priv) area.
+ * This data includes the index of the station in the fw, per tid information
+ * (sequence numbers, Block-ack state machine, etc...). The stations are
+ * created and deleted by the %sta_state callback from %ieee80211_ops.
+ *
+ * The driver holds a map: %fw_id_to_mac_id that allows to fetch a
+ * %ieee80211_sta (and the %iwl_mvm_sta embedded into it) based on a fw
+ * station index. That way, the driver is able to get the tid related data in
+ * O(1) in time sensitive paths (Tx / Tx response / BA notification). These
+ * paths are triggered by the fw, and the driver needs to get a pointer to the
+ * %ieee80211 structure. This map helps to get that pointer quickly.
+ */
+
+/**
+ * DOC: station table - locking
+ *
+ * As stated before, the station is created / deleted by mac80211's %sta_state
+ * callback from %ieee80211_ops which can sleep. The next paragraph explains
+ * the locking of a single stations, the next ones relates to the station
+ * table.
+ *
+ * The station holds the sequence number per tid. So this data needs to be
+ * accessed in the Tx path (which is softIRQ). It also holds the Block-Ack
+ * information (the state machine / and the logic that checks if the queues
+ * were drained), so it also needs to be accessible from the Tx response flow.
+ * In short, the station needs to be access from sleepable context as well as
+ * from tasklets, so the station itself needs a spinlock.
+ *
+ * The writers of %fw_id_to_mac_id map are serialized by the global mutex of
+ * the mvm op_mode. This is possible since %sta_state can sleep.
+ * The pointers in this map are RCU protected, hence we won't replace the
+ * station while we have Tx / Tx response / BA notification running.
+ *
+ * If a station is deleted while it still has packets in its A-MPDU queues,
+ * then the reclaim flow will notice that there is no station in the map for
+ * sta_id and it will dump the responses.
+ */
+
+/**
+ * DOC: station table - internal stations
+ *
+ * The FW needs a few internal stations that are not reflected in
+ * mac80211, such as broadcast station in AP / GO mode, or AUX sta for
+ * scanning and P2P device (during the GO negotiation).
+ * For these kind of stations we have %iwl_mvm_int_sta struct which holds the
+ * data relevant for them from both %iwl_mvm_sta and %ieee80211_sta.
+ * Usually the data for these stations is static, so no locking is required,
+ * and no TID data as this is also not needed.
+ * One thing to note, is that these stations have an ID in the fw, but not
+ * in mac80211. In order to "reserve" them a sta_id in %fw_id_to_mac_id
+ * we fill ERR_PTR(EINVAL) in this mapping and all other dereferencing of
+ * pointers from this mapping need to check that the value is not error
+ * or NULL.
+ *
+ * Currently there is only one auxiliary station for scanning, initialized
+ * on init.
+ */
+
+/**
+ * DOC: station table - AP Station in STA mode
+ *
+ * %iwl_mvm_vif includes the index of the AP station in the fw's STA table:
+ * %ap_sta_id. To get the point to the corresponding %ieee80211_sta,
+ * &fw_id_to_mac_id can be used. Due to the way the fw works, we must not remove
+ * the AP station from the fw before setting the MAC context as unassociated.
+ * Hence, %fw_id_to_mac_id[%ap_sta_id] will be NULLed when the AP station is
+ * removed by mac80211, but the station won't be removed in the fw until the
+ * VIF is set as unassociated. Then, %ap_sta_id will be invalidated.
+ */
+
+/**
+ * DOC: station table - Drain vs. Flush
+ *
+ * Flush means that all the frames in the SCD queue are dumped regardless the
+ * station to which they were sent. We do that when we disassociate and before
+ * we remove the STA of the AP. The flush can be done synchronously against the
+ * fw.
+ * Drain means that the fw will drop all the frames sent to a specific station.
+ * This is useful when a client (if we are IBSS / GO or AP) disassociates. In
+ * that case, we need to drain all the frames for that client from the AC queues
+ * that are shared with the other clients. Only then, we can remove the STA in
+ * the fw. In order to do so, we track the non-AMPDU packets for each station.
+ * If mac80211 removes a STA and if it still has non-AMPDU packets pending in
+ * the queues, we mark this station as %EBUSY in %fw_id_to_mac_id, and drop all
+ * the frames for this STA (%iwl_mvm_rm_sta). When the last frame is dropped
+ * (we know about it with its Tx response), we remove the station in fw and set
+ * it as %NULL in %fw_id_to_mac_id: this is the purpose of
+ * %iwl_mvm_sta_drained_wk.
+ */
+
+/**
+ * DOC: station table - fw restart
+ *
+ * When the fw asserts, or we have any other issue that requires to reset the
+ * driver, we require mac80211 to reconfigure the driver. Since the private
+ * data of the stations is embed in mac80211's %ieee80211_sta, that data will
+ * not be zeroed and needs to be reinitialized manually.
+ * %IWL_MVM_STATUS_IN_HW_RESTART is set during restart and that will hint us
+ * that we must not allocate a new sta_id but reuse the previous one. This
+ * means that the stations being re-added after the reset will have the same
+ * place in the fw as before the reset. We do need to zero the %fw_id_to_mac_id
+ * map, since the stations aren't in the fw any more. Internal stations that
+ * are not added by mac80211 will be re-added in the init flow that is called
+ * after the restart: mac80211 call's %iwl_mvm_mac_start which calls to
+ * %iwl_mvm_up.
+ */
+
+/**
+ * Send the STA info to the FW.
+ *
+ * @sc: the iwm_softc* to use
+ * @sta: the STA
+ * @update: this is true if the FW is being updated about a STA it already knows
+ * about. Otherwise (if this is a new STA), this should be false.
+ * @flags: if update==true, this marks what is being changed via ORs of values
+ * from enum iwm_sta_modify_flag. Otherwise, this is ignored.
+ */
+extern int iwm_mvm_sta_send_to_fw(struct iwm_softc *sc, struct iwm_node *in,
+ boolean_t update);
+extern int iwm_mvm_add_sta(struct iwm_softc *sc, struct iwm_node *in);
+extern int iwm_mvm_update_sta(struct iwm_softc *sc, struct iwm_node *in);
+extern int iwm_mvm_rm_sta(struct iwm_softc *sc, struct ieee80211vap *vap,
+ boolean_t is_assoc);
+extern int iwm_mvm_rm_sta_id(struct iwm_softc *sc, struct ieee80211vap *vap);
+
+extern int iwm_mvm_add_aux_sta(struct iwm_softc *sc);
+extern void iwm_mvm_del_aux_sta(struct iwm_softc *sc);
+
+extern int iwm_mvm_drain_sta(struct iwm_softc *sc, struct iwm_vap *ivp,
+ boolean_t drain);
+
+#endif /* __IF_IWM_STA_H__ */
diff --git a/sys/dev/iwm/if_iwm_time_event.c b/sys/dev/iwm/if_iwm_time_event.c
index 9b3400554fba..db24ea986fe4 100644
--- a/sys/dev/iwm/if_iwm_time_event.c
+++ b/sys/dev/iwm/if_iwm_time_event.c
@@ -106,6 +106,7 @@
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
+#include "opt_iwm.h"
#include <sys/param.h>
#include <sys/bus.h>
@@ -165,7 +166,7 @@ __FBSDID("$FreeBSD$");
#define IWM_MVM_ROC_TE_TYPE_MGMT_TX IWM_TE_P2P_CLIENT_ASSOC
static int
-iwm_mvm_time_event_send_add(struct iwm_softc *sc, struct iwm_node *in,
+iwm_mvm_time_event_send_add(struct iwm_softc *sc, struct iwm_vap *ivp,
void *te_data, struct iwm_time_event_cmd *te_cmd)
{
int ret;
@@ -185,14 +186,14 @@ iwm_mvm_time_event_send_add(struct iwm_softc *sc, struct iwm_node *in,
}
void
-iwm_mvm_protect_session(struct iwm_softc *sc, struct iwm_node *in,
+iwm_mvm_protect_session(struct iwm_softc *sc, struct iwm_vap *ivp,
uint32_t duration, uint32_t max_delay)
{
struct iwm_time_event_cmd time_cmd = {};
time_cmd.action = htole32(IWM_FW_CTXT_ACTION_ADD);
time_cmd.id_and_color =
- htole32(IWM_FW_CMD_ID_AND_COLOR(IWM_DEFAULT_MACID, IWM_DEFAULT_COLOR));
+ htole32(IWM_FW_CMD_ID_AND_COLOR(ivp->id, ivp->color));
time_cmd.id = htole32(IWM_TE_BSS_STA_AGGRESSIVE_ASSOC);
time_cmd.apply_time = htole32(0);
@@ -208,5 +209,5 @@ iwm_mvm_protect_session(struct iwm_softc *sc, struct iwm_node *in,
IWM_TE_V2_NOTIF_HOST_EVENT_END |
IWM_T2_V2_START_IMMEDIATELY);
- iwm_mvm_time_event_send_add(sc, in, /*te_data*/NULL, &time_cmd);
+ iwm_mvm_time_event_send_add(sc, ivp, /*te_data*/NULL, &time_cmd);
}
diff --git a/sys/dev/iwm/if_iwm_time_event.h b/sys/dev/iwm/if_iwm_time_event.h
index 015652ece32b..4c741428e1ea 100644
--- a/sys/dev/iwm/if_iwm_time_event.h
+++ b/sys/dev/iwm/if_iwm_time_event.h
@@ -107,7 +107,7 @@
#ifndef __IF_IWM_TIME_EVENT_H__
#define __IF_IWM_TIME_EVENT_H__
-extern void iwm_mvm_protect_session(struct iwm_softc *sc, struct iwm_node *in,
+extern void iwm_mvm_protect_session(struct iwm_softc *sc, struct iwm_vap *ivp,
uint32_t duration, uint32_t max_delay);
#endif /* __IF_IWM_TIME_EVENT_H__ */
diff --git a/sys/dev/iwm/if_iwm_util.c b/sys/dev/iwm/if_iwm_util.c
index 206021a77fc2..a090aeb5f65f 100644
--- a/sys/dev/iwm/if_iwm_util.c
+++ b/sys/dev/iwm/if_iwm_util.c
@@ -106,6 +106,7 @@
__FBSDID("$FreeBSD$");
#include "opt_wlan.h"
+#include "opt_iwm.h"
#include <sys/param.h>
#include <sys/bus.h>
@@ -152,6 +153,7 @@ __FBSDID("$FreeBSD$");
#include <dev/iwm/if_iwmreg.h>
#include <dev/iwm/if_iwmvar.h>
+#include <dev/iwm/if_iwm_config.h>
#include <dev/iwm/if_iwm_debug.h>
#include <dev/iwm/if_iwm_binding.h>
#include <dev/iwm/if_iwm_util.h>
@@ -344,7 +346,7 @@ iwm_send_cmd(struct iwm_softc *sc, struct iwm_host_cmd *hcmd)
/* iwlwifi: mvm/utils.c */
int
-iwm_mvm_send_cmd_pdu(struct iwm_softc *sc, uint8_t id,
+iwm_mvm_send_cmd_pdu(struct iwm_softc *sc, uint32_t id,
uint32_t flags, uint16_t len, const void *data)
{
struct iwm_host_cmd cmd = {
@@ -400,7 +402,7 @@ iwm_mvm_send_cmd_status(struct iwm_softc *sc,
/* iwlwifi/mvm/utils.c */
int
-iwm_mvm_send_cmd_pdu_status(struct iwm_softc *sc, uint8_t id,
+iwm_mvm_send_cmd_pdu_status(struct iwm_softc *sc, uint32_t id,
uint16_t len, const void *data, uint32_t *status)
{
struct iwm_host_cmd cmd = {
@@ -486,3 +488,17 @@ iwm_dma_contig_free(struct iwm_dma_info *dma)
dma->tag = NULL;
}
}
+
+boolean_t
+iwm_mvm_rx_diversity_allowed(struct iwm_softc *sc)
+{
+ if (num_of_ant(iwm_mvm_get_valid_rx_ant(sc)) == 1)
+ return FALSE;
+
+ /*
+ * XXX Also return FALSE when SMPS (Spatial Multiplexing Powersave)
+ * is used on any vap (in the future).
+ */
+
+ return TRUE;
+}
diff --git a/sys/dev/iwm/if_iwm_util.h b/sys/dev/iwm/if_iwm_util.h
index 460c660877cf..b46877d31ee1 100644
--- a/sys/dev/iwm/if_iwm_util.h
+++ b/sys/dev/iwm/if_iwm_util.h
@@ -107,12 +107,12 @@
#define __IF_IWM_UTIL_H__
extern int iwm_send_cmd(struct iwm_softc *sc, struct iwm_host_cmd *hcmd);
-extern int iwm_mvm_send_cmd_pdu(struct iwm_softc *sc, uint8_t id,
+extern int iwm_mvm_send_cmd_pdu(struct iwm_softc *sc, uint32_t id,
uint32_t flags, uint16_t len, const void *data);
extern int iwm_mvm_send_cmd_status(struct iwm_softc *sc,
struct iwm_host_cmd *cmd, uint32_t *status);
-extern int iwm_mvm_send_cmd_pdu_status(struct iwm_softc *sc, uint8_t id,
+extern int iwm_mvm_send_cmd_pdu_status(struct iwm_softc *sc, uint32_t id,
uint16_t len, const void *data, uint32_t *status);
extern void iwm_free_resp(struct iwm_softc *sc, struct iwm_host_cmd *hcmd);
@@ -120,7 +120,12 @@ extern int iwm_dma_contig_alloc(bus_dma_tag_t tag, struct iwm_dma_info *dma,
bus_size_t size, bus_size_t alignment);
extern void iwm_dma_contig_free(struct iwm_dma_info *);
+extern boolean_t iwm_mvm_rx_diversity_allowed(struct iwm_softc *sc);
+
extern uint8_t iwm_ridx2rate(struct ieee80211_rateset *rs, int ridx);
+extern int iwm_enable_txq(struct iwm_softc *sc, int sta_id, int qid, int fifo);
+extern int iwm_mvm_flush_tx_path(struct iwm_softc *sc, uint32_t tfd_msk,
+ uint32_t flags);
static inline uint8_t
iwm_mvm_get_valid_tx_ant(struct iwm_softc *sc)
diff --git a/sys/dev/iwm/if_iwmreg.h b/sys/dev/iwm/if_iwmreg.h
index bce0e370bdc7..fceb50a20395 100644
--- a/sys/dev/iwm/if_iwmreg.h
+++ b/sys/dev/iwm/if_iwmreg.h
@@ -669,12 +669,12 @@ P2P_PS_SCM\31UAPSD_SUPPORT\32EBS\33P2P_PS_UAPSD\36BCAST_FILTERING\37GO_UAPSD\40L
* @IWM_NUM_UCODE_TLV_API: number of bits used
*/
enum iwm_ucode_tlv_api {
- IWM_UCODE_TLV_API_FRAGMENTED_SCAN = (1 << 8),
- IWM_UCODE_TLV_API_WIFI_MCC_UPDATE = (1 << 9),
- IWM_UCODE_TLV_API_WIDE_CMD_HDR = (1 << 14),
- IWM_UCODE_TLV_API_LQ_SS_PARAMS = (1 << 18),
- IWM_UCODE_TLV_API_EXT_SCAN_PRIORITY = (1 << 24),
- IWM_UCODE_TLV_API_TX_POWER_CHAIN = (1 << 27),
+ IWM_UCODE_TLV_API_FRAGMENTED_SCAN = 8,
+ IWM_UCODE_TLV_API_WIFI_MCC_UPDATE = 9,
+ IWM_UCODE_TLV_API_WIDE_CMD_HDR = 14,
+ IWM_UCODE_TLV_API_LQ_SS_PARAMS = 18,
+ IWM_UCODE_TLV_API_EXT_SCAN_PRIORITY = 24,
+ IWM_UCODE_TLV_API_TX_POWER_CHAIN = 27,
IWM_NUM_UCODE_TLV_API = 32
};
@@ -3620,17 +3620,11 @@ struct iwm_powertable_cmd {
/**
* enum iwm_device_power_flags - masks for device power command flags
- * @DEVIC_POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off
- * receiver and transmitter. '0' - does not allow. This flag should be
- * always set to '1' unless one need to disable actual power down for debug
- * purposes.
- * @IWM_DEVICE_POWER_FLAGS_CAM_MSK: '1' CAM (Continuous Active Mode) is set, meaning
- * that power management is disabled. '0' Power management is enabled, one
- * of power schemes is applied.
-*/
+ * @IWM_DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK: '1' Allow to save power by turning off
+ * receiver and transmitter. '0' - does not allow.
+ */
enum iwm_device_power_flags {
IWM_DEVICE_POWER_FLAGS_POWER_SAVE_ENA_MSK = (1 << 0),
- IWM_DEVICE_POWER_FLAGS_CAM_MSK = (1 << 13),
};
/**
@@ -5985,16 +5979,9 @@ struct iwm_dts_measurement_notif_v2 {
#define IWM_FRAME_LIMIT 64
/*
- * From Linux commit ab02165ccec4c78162501acedeef1a768acdb811:
- * As the firmware is slowly running out of command IDs and grouping of
- * commands is desirable anyway, the firmware is extending the command
- * header from 4 bytes to 8 bytes to introduce a group (in place of the
- * former flags field, since that's always 0 on commands and thus can
- * be easily used to distinguish between the two).
- *
* These functions retrieve specific information from the id field in
* the iwm_host_cmd struct which contains the command id, the group id,
- * and the version of the command.
+ * and the version of the command and vice versa.
*/
static inline uint8_t
iwm_cmd_opcode(uint32_t cmdid)
@@ -6005,7 +5992,7 @@ iwm_cmd_opcode(uint32_t cmdid)
static inline uint8_t
iwm_cmd_groupid(uint32_t cmdid)
{
- return ((cmdid & 0Xff00) >> 8);
+ return ((cmdid & 0xff00) >> 8);
}
static inline uint8_t
@@ -6043,6 +6030,12 @@ struct iwm_cmd_header_wide {
uint8_t version;
} __packed;
+/**
+ * enum iwm_power_scheme
+ * @IWM_POWER_LEVEL_CAM - Continuously Active Mode
+ * @IWM_POWER_LEVEL_BPS - Balanced Power Save (default)
+ * @IWM_POWER_LEVEL_LP - Low Power
+ */
enum iwm_power_scheme {
IWM_POWER_SCHEME_CAM = 1,
IWM_POWER_SCHEME_BPS,
@@ -6092,6 +6085,8 @@ struct iwm_rx_packet {
} __packed;
#define IWM_FH_RSCSR_FRAME_SIZE_MSK 0x00003fff
+#define IWM_FH_RSCSR_FRAME_INVALID 0x55550000
+#define IWM_FH_RSCSR_FRAME_ALIGN 0x40
static inline uint32_t
iwm_rx_packet_len(const struct iwm_rx_packet *pkt)
diff --git a/sys/dev/iwm/if_iwmvar.h b/sys/dev/iwm/if_iwmvar.h
index b15f123d6e0f..160566c04352 100644
--- a/sys/dev/iwm/if_iwmvar.h
+++ b/sys/dev/iwm/if_iwmvar.h
@@ -304,7 +304,6 @@ struct iwm_tx_ring {
};
#define IWM_RX_RING_COUNT 256
-#define IWM_RBUF_COUNT (IWM_RX_RING_COUNT + 32)
/* Linux driver optionally uses 8k buffer */
#define IWM_RBUF_SIZE 4096
@@ -373,12 +372,32 @@ struct iwm_vap {
int (*iv_newstate)(struct ieee80211vap *,
enum ieee80211_state, int);
+
+ struct iwm_mvm_phy_ctxt *phy_ctxt;
+
+ uint16_t id;
+ uint16_t color;
+
+ boolean_t have_wme;
+ /*
+ * QoS data from net80211, need to store this here
+ * as net80211 has a separate callback but we need
+ * to have the data for the MAC context
+ */
+ struct {
+ uint16_t cw_min;
+ uint16_t cw_max;
+ uint16_t edca_txop;
+ uint8_t aifsn;
+ } queue_params[WME_NUM_AC];
+
+ /* indicates that this interface requires PS to be disabled */
+ boolean_t ps_disabled;
};
#define IWM_VAP(_vap) ((struct iwm_vap *)(_vap))
struct iwm_node {
struct ieee80211_node in_ni;
- struct iwm_mvm_phy_ctxt *in_phyctxt;
/* status "bits" */
int in_assoc;
@@ -538,6 +557,9 @@ struct iwm_softc {
uint16_t num_of_pages_in_last_blk;
boolean_t last_ebs_successful;
+
+ /* Indicate if device power save is allowed */
+ boolean_t sc_ps_disabled;
};
#define IWM_LOCK_INIT(_sc) \
diff --git a/sys/dev/mpr/mpr_sas.c b/sys/dev/mpr/mpr_sas.c
index 09971faa6b03..2974e06a64a8 100644
--- a/sys/dev/mpr/mpr_sas.c
+++ b/sys/dev/mpr/mpr_sas.c
@@ -1562,7 +1562,7 @@ mprsas_send_abort(struct mpr_softc *sc, struct mpr_command *tm,
return -1;
}
- mprsas_log_command(tm, MPR_RECOVERY|MPR_INFO,
+ mprsas_log_command(cm, MPR_RECOVERY|MPR_INFO,
"Aborting command %p\n", cm);
req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)tm->cm_req;
@@ -1594,7 +1594,7 @@ mprsas_send_abort(struct mpr_softc *sc, struct mpr_command *tm,
err = mpr_map_command(sc, tm);
if (err)
- mprsas_log_command(tm, MPR_RECOVERY,
+ mpr_dprint(sc, MPR_RECOVERY,
"error %d sending abort for cm %p SMID %u\n",
err, cm, req->TaskMID);
return err;
@@ -1635,8 +1635,9 @@ mprsas_scsiio_timeout(void *data)
targ = cm->cm_targ;
targ->timeouts++;
- mprsas_log_command(cm, MPR_ERROR, "command timeout cm %p ccb %p target "
- "%u, handle(0x%04x)\n", cm, cm->cm_ccb, targ->tid, targ->handle);
+ mprsas_log_command(cm, MPR_ERROR, "command timeout %d cm %p target "
+ "%u, handle(0x%04x)\n", cm->cm_ccb->ccb_h.timeout, cm, targ->tid,
+ targ->handle);
if (targ->encl_level_valid) {
mpr_dprint(sc, MPR_ERROR, "At enclosure level %d, slot %d, "
"connector name (%4s)\n", targ->encl_level, targ->encl_slot,
diff --git a/sys/dev/mps/mps_sas.c b/sys/dev/mps/mps_sas.c
index ac7b5e2dc534..24c5a8adeb02 100644
--- a/sys/dev/mps/mps_sas.c
+++ b/sys/dev/mps/mps_sas.c
@@ -1505,7 +1505,7 @@ mpssas_send_abort(struct mps_softc *sc, struct mps_command *tm, struct mps_comma
return -1;
}
- mpssas_log_command(tm, MPS_RECOVERY|MPS_INFO,
+ mpssas_log_command(cm, MPS_RECOVERY|MPS_INFO,
"Aborting command %p\n", cm);
req = (MPI2_SCSI_TASK_MANAGE_REQUEST *)tm->cm_req;
@@ -1536,7 +1536,7 @@ mpssas_send_abort(struct mps_softc *sc, struct mps_command *tm, struct mps_comma
err = mps_map_command(sc, tm);
if (err)
- mpssas_log_command(tm, MPS_RECOVERY,
+ mps_dprint(sc, MPS_RECOVERY,
"error %d sending abort for cm %p SMID %u\n",
err, cm, req->TaskMID);
return err;
@@ -1574,12 +1574,13 @@ mpssas_scsiio_timeout(void *data)
return;
}
- mpssas_log_command(cm, MPS_INFO, "command timeout cm %p ccb %p\n",
- cm, cm->cm_ccb);
-
targ = cm->cm_targ;
targ->timeouts++;
+ mpssas_log_command(cm, MPS_ERROR, "command timeout %d cm %p target "
+ "%u, handle(0x%04x)\n", cm->cm_ccb->ccb_h.timeout, cm, targ->tid,
+ targ->handle);
+
/* XXX first, check the firmware state, to see if it's still
* operational. if not, do a diag reset.
*/
diff --git a/sys/dev/qlnx/qlnxe/ecore_dev.c b/sys/dev/qlnx/qlnxe/ecore_dev.c
index d6726ca53cc6..1840b8785be2 100644
--- a/sys/dev/qlnx/qlnxe/ecore_dev.c
+++ b/sys/dev/qlnx/qlnxe/ecore_dev.c
@@ -1986,6 +1986,15 @@ static enum _ecore_status_t ecore_hw_init_pf(struct ecore_hwfn *p_hwfn,
}
}
#endif
+ /* Add an LLH filter with the primary MAC address. */
+ if (p_hwfn->p_dev->num_hwfns > 1 && IS_LEAD_HWFN(p_hwfn)) {
+ rc = ecore_llh_add_mac_filter(p_hwfn, p_ptt,
+ p_hwfn->hw_info.hw_mac_addr);
+ if (rc != ECORE_SUCCESS)
+ DP_NOTICE(p_hwfn, false,
+ "Failed to add an LLH filter with the primary MAC\n");
+ }
+
if (b_hw_start) {
/* enable interrupts */
rc = ecore_int_igu_enable(p_hwfn, p_ptt, int_mode);
@@ -2473,6 +2482,11 @@ enum _ecore_status_t ecore_hw_stop(struct ecore_dev *p_dev)
rc2 = ECORE_UNKNOWN_ERROR;
}
}
+
+ /* remove the LLH filter with the primary MAC addres */
+ if (p_hwfn->p_dev->num_hwfns > 1 && IS_LEAD_HWFN(p_hwfn))
+ ecore_llh_remove_mac_filter(p_hwfn, p_ptt,
+ p_hwfn->hw_info.hw_mac_addr);
} /* hwfn loop */
if (IS_PF(p_dev)) {
@@ -4569,7 +4583,7 @@ enum _ecore_status_t ecore_llh_add_mac_filter(struct ecore_hwfn *p_hwfn,
}
DP_VERBOSE(p_hwfn, ECORE_MSG_HW,
- "MAC: %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx is added at %d\n",
+ "MAC: %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx is added at LLH entry %d\n",
p_filter[0], p_filter[1], p_filter[2], p_filter[3],
p_filter[4], p_filter[5], entry_num);
@@ -4651,7 +4665,7 @@ void ecore_llh_remove_mac_filter(struct ecore_hwfn *p_hwfn,
}
DP_VERBOSE(p_hwfn, ECORE_MSG_HW,
- "MAC: %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx was removed from %d\n",
+ "MAC: %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx was removed from LLH entry %d\n",
p_filter[0], p_filter[1], p_filter[2], p_filter[3],
p_filter[4], p_filter[5], entry_num);
}
@@ -4760,37 +4774,37 @@ ecore_llh_add_protocol_filter(struct ecore_hwfn *p_hwfn,
switch (type) {
case ECORE_LLH_FILTER_ETHERTYPE:
DP_VERBOSE(p_hwfn, ECORE_MSG_HW,
- "ETH type %x is added at %d\n",
+ "ETH type %x is added at LLH entry %d\n",
source_port_or_eth_type, entry_num);
break;
case ECORE_LLH_FILTER_TCP_SRC_PORT:
DP_VERBOSE(p_hwfn, ECORE_MSG_HW,
- "TCP src port %x is added at %d\n",
+ "TCP src port %x is added at LLH entry %d\n",
source_port_or_eth_type, entry_num);
break;
case ECORE_LLH_FILTER_UDP_SRC_PORT:
DP_VERBOSE(p_hwfn, ECORE_MSG_HW,
- "UDP src port %x is added at %d\n",
+ "UDP src port %x is added at LLH entry %d\n",
source_port_or_eth_type, entry_num);
break;
case ECORE_LLH_FILTER_TCP_DEST_PORT:
DP_VERBOSE(p_hwfn, ECORE_MSG_HW,
- "TCP dst port %x is added at %d\n",
+ "TCP dst port %x is added at LLH entry %d\n",
dest_port, entry_num);
break;
case ECORE_LLH_FILTER_UDP_DEST_PORT:
DP_VERBOSE(p_hwfn, ECORE_MSG_HW,
- "UDP dst port %x is added at %d\n",
+ "UDP dst port %x is added at LLH entry %d\n",
dest_port, entry_num);
break;
case ECORE_LLH_FILTER_TCP_SRC_AND_DEST_PORT:
DP_VERBOSE(p_hwfn, ECORE_MSG_HW,
- "TCP src/dst ports %x/%x are added at %d\n",
+ "TCP src/dst ports %x/%x are added at LLH entry %d\n",
source_port_or_eth_type, dest_port, entry_num);
break;
case ECORE_LLH_FILTER_UDP_SRC_AND_DEST_PORT:
DP_VERBOSE(p_hwfn, ECORE_MSG_HW,
- "UDP src/dst ports %x/%x are added at %d\n",
+ "UDP src/dst ports %x/%x are added at LLH entry %d\n",
source_port_or_eth_type, dest_port, entry_num);
break;
}
@@ -4917,7 +4931,7 @@ ecore_llh_remove_protocol_filter(struct ecore_hwfn *p_hwfn,
}
DP_VERBOSE(p_hwfn, ECORE_MSG_HW,
- "Protocol filter [type %d, source_port_or_eth_type 0x%x, dest_port 0x%x] was removed from %d\n",
+ "Protocol filter [type %d, source_port_or_eth_type 0x%x, dest_port 0x%x] was removed from LLH entry %d\n",
type, source_port_or_eth_type, dest_port, entry_num);
}
diff --git a/sys/dev/qlxgbe/ql_isr.c b/sys/dev/qlxgbe/ql_isr.c
index de8c7f16b9af..84799566b097 100644
--- a/sys/dev/qlxgbe/ql_isr.c
+++ b/sys/dev/qlxgbe/ql_isr.c
@@ -987,7 +987,8 @@ ql_isr(void *arg)
fp = &ha->tx_fp[idx];
- if (fp->fp_taskqueue != NULL)
+ if ((fp->fp_taskqueue != NULL) &&
+ (ifp->if_drv_flags & IFF_DRV_RUNNING))
taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task);
return;
diff --git a/sys/dev/qlxgbe/ql_os.c b/sys/dev/qlxgbe/ql_os.c
index 931d7e4ce1c5..735035d3d572 100644
--- a/sys/dev/qlxgbe/ql_os.c
+++ b/sys/dev/qlxgbe/ql_os.c
@@ -925,7 +925,9 @@ qla_set_multi(qla_host_t *ha, uint32_t add_multi)
if_maddr_runlock(ifp);
QLA_LOCK(ha);
- ret = ql_hw_set_multi(ha, mta, mcnt, add_multi);
+ if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
+ ret = ql_hw_set_multi(ha, mta, mcnt, add_multi);
+ }
QLA_UNLOCK(ha);
return (ret);
@@ -1031,20 +1033,16 @@ qla_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
QL_DPRINT4(ha, (ha->pci_dev,
"%s: %s (0x%lx)\n", __func__, "SIOCADDMULTI", cmd));
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
- if (qla_set_multi(ha, 1))
- ret = EINVAL;
- }
+ if (qla_set_multi(ha, 1))
+ ret = EINVAL;
break;
case SIOCDELMULTI:
QL_DPRINT4(ha, (ha->pci_dev,
"%s: %s (0x%lx)\n", __func__, "SIOCDELMULTI", cmd));
- if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
- if (qla_set_multi(ha, 0))
- ret = EINVAL;
- }
+ if (qla_set_multi(ha, 0))
+ ret = EINVAL;
break;
case SIOCSIFMEDIA:
@@ -1529,9 +1527,9 @@ qla_stop(qla_host_t *ha)
ha->flags.qla_interface_up = 0;
+ QLA_UNLOCK(ha);
qla_drain_fp_taskqueues(ha);
-
- ql_hw_stop_rcv(ha);
+ QLA_LOCK(ha);
ql_del_hw_if(ha);
@@ -1922,8 +1920,6 @@ qla_error_recovery(void *context, int pending)
ha->hw.imd_compl = 1;
qla_mdelay(__func__, 300);
- ql_hw_stop_rcv(ha);
-
ifp->if_drv_flags &= ~(IFF_DRV_OACTIVE | IFF_DRV_RUNNING);
for (i = 0; i < ha->hw.num_sds_rings; i++) {
@@ -1943,6 +1939,8 @@ qla_error_recovery(void *context, int pending)
QLA_UNLOCK(ha);
+ qla_drain_fp_taskqueues(ha);
+
if ((ha->pci_func & 0x1) == 0) {
if (!ha->msg_from_peer) {
diff --git a/sys/dev/sdhci/sdhci.c b/sys/dev/sdhci/sdhci.c
index 26602ec57b4c..68ff1db715b1 100644
--- a/sys/dev/sdhci/sdhci.c
+++ b/sys/dev/sdhci/sdhci.c
@@ -1060,7 +1060,7 @@ sdhci_set_transfer_mode(struct sdhci_slot *slot, struct mmc_data *data)
mode |= SDHCI_TRNS_MULTI;
if (data->flags & MMC_DATA_READ)
mode |= SDHCI_TRNS_READ;
- if (slot->req->stop)
+ if (slot->req->stop && !(slot->quirks & SDHCI_QUIRK_BROKEN_AUTO_STOP))
mode |= SDHCI_TRNS_ACMD12;
if (slot->flags & SDHCI_USE_DMA)
mode |= SDHCI_TRNS_DMA;
@@ -1305,7 +1305,8 @@ sdhci_finish_data(struct sdhci_slot *slot)
slot->intmask |= SDHCI_INT_RESPONSE);
}
/* Unload rest of data from DMA buffer. */
- if (!slot->data_done && (slot->flags & SDHCI_USE_DMA)) {
+ if (!slot->data_done && (slot->flags & SDHCI_USE_DMA) &&
+ slot->curcmd->data != NULL) {
if (data->flags & MMC_DATA_READ) {
left = data->len - slot->offset;
bus_dmamap_sync(slot->dmatag, slot->dmamap,
@@ -1343,17 +1344,18 @@ sdhci_start(struct sdhci_slot *slot)
sdhci_start_command(slot, req->cmd);
return;
}
-/* We don't need this until using Auto-CMD12 feature
- if (!(slot->flags & STOP_STARTED) && req->stop) {
+ if ((slot->quirks & SDHCI_QUIRK_BROKEN_AUTO_STOP) &&
+ !(slot->flags & STOP_STARTED) && req->stop) {
slot->flags |= STOP_STARTED;
sdhci_start_command(slot, req->stop);
return;
}
-*/
if (sdhci_debug > 1)
slot_printf(slot, "result: %d\n", req->cmd->error);
if (!req->cmd->error &&
- (slot->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST)) {
+ ((slot->curcmd == req->stop &&
+ (slot->quirks & SDHCI_QUIRK_BROKEN_AUTO_STOP)) ||
+ (slot->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))) {
sdhci_reset(slot, SDHCI_RESET_CMD);
sdhci_reset(slot, SDHCI_RESET_DATA);
}
diff --git a/sys/dev/sdhci/sdhci.h b/sys/dev/sdhci/sdhci.h
index 0b299150b990..814f81ed5407 100644
--- a/sys/dev/sdhci/sdhci.h
+++ b/sys/dev/sdhci/sdhci.h
@@ -87,6 +87,8 @@
#define SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 (1 << 26)
/* Controller support for SDHCI_CTRL2_PRESET_VALUE is broken. */
#define SDHCI_QUIRK_PRESET_VALUE_BROKEN (1 << 27)
+/* Controller does not support or the support for ACMD12 is broken. */
+#define SDHCI_QUIRK_BROKEN_AUTO_STOP (1 << 28)
/*
* Controller registers
diff --git a/sys/dev/sdhci/sdhci_acpi.c b/sys/dev/sdhci/sdhci_acpi.c
index 54c2c56cc81a..ea5ed70b0877 100644
--- a/sys/dev/sdhci/sdhci_acpi.c
+++ b/sys/dev/sdhci/sdhci_acpi.c
@@ -57,25 +57,39 @@ static const struct sdhci_acpi_device {
const char *desc;
u_int quirks;
} sdhci_acpi_devices[] = {
- { "80860F14", 1, "Intel Bay Trail eMMC 4.5 Controller",
+ { "80860F14", 1, "Intel Bay Trail/Braswell eMMC 4.5/4.5.1 Controller",
SDHCI_QUIRK_ALL_SLOTS_NON_REMOVABLE |
SDHCI_QUIRK_INTEL_POWER_UP_RESET |
SDHCI_QUIRK_WAIT_WHILE_BUSY |
SDHCI_QUIRK_MMC_DDR52 |
SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
- { "80860F14", 3, "Intel Bay Trail SDXC Controller",
+ { "80860F14", 3, "Intel Bay Trail/Braswell SDXC Controller",
SDHCI_QUIRK_WAIT_WHILE_BUSY |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
- { "80860F16", 0, "Intel Bay Trail SDXC Controller",
+ { "80860F16", 0, "Intel Bay Trail/Braswell SDXC Controller",
SDHCI_QUIRK_WAIT_WHILE_BUSY |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
+ { "80865ACA", 0, "Intel Apollo Lake SDXC Controller",
+ SDHCI_QUIRK_BROKEN_DMA | /* APL18 erratum */
+ SDHCI_QUIRK_WAIT_WHILE_BUSY |
+ SDHCI_QUIRK_PRESET_VALUE_BROKEN },
+ { "80865ACC", 0, "Intel Apollo Lake eMMC 5.0 Controller",
+ SDHCI_QUIRK_BROKEN_DMA | /* APL18 erratum */
+ SDHCI_QUIRK_ALL_SLOTS_NON_REMOVABLE |
+ SDHCI_QUIRK_INTEL_POWER_UP_RESET |
+ SDHCI_QUIRK_WAIT_WHILE_BUSY |
+ SDHCI_QUIRK_MMC_DDR52 |
+ SDHCI_QUIRK_CAPS_BIT63_FOR_MMC_HS400 |
+ SDHCI_QUIRK_PRESET_VALUE_BROKEN },
{ NULL, 0, NULL, 0}
};
static char *sdhci_ids[] = {
"80860F14",
"80860F16",
+ "80865ACA",
+ "80865ACC",
NULL
};
@@ -249,6 +263,11 @@ sdhci_acpi_attach(device_t dev)
return (ENOMEM);
}
+ /* Intel Braswell eMMC 4.5.1 controller quirk */
+ if (strcmp(acpi_dev->hid, "80860F14") == 0 && acpi_dev->uid == 1 &&
+ SDHCI_READ_4(dev, &sc->slot, SDHCI_CAPABILITIES) == 0x446cc8b2 &&
+ SDHCI_READ_4(dev, &sc->slot, SDHCI_CAPABILITIES2) == 0x00000807)
+ sc->quirks |= SDHCI_QUIRK_DATA_TIMEOUT_1MHZ;
sc->quirks &= ~sdhci_quirk_clear;
sc->quirks |= sdhci_quirk_set;
sc->slot.quirks = sc->quirks;
diff --git a/sys/dev/sdhci/sdhci_fdt.c b/sys/dev/sdhci/sdhci_fdt.c
index c5c300a2774d..165ac3eed728 100644
--- a/sys/dev/sdhci/sdhci_fdt.c
+++ b/sys/dev/sdhci/sdhci_fdt.c
@@ -57,7 +57,17 @@ __FBSDID("$FreeBSD$");
#include "mmcbr_if.h"
#include "sdhci_if.h"
-#define MAX_SLOTS 6
+#define MAX_SLOTS 6
+#define SDHCI_FDT_ARMADA38X 1
+#define SDHCI_FDT_GENERIC 2
+#define SDHCI_FDT_XLNX_ZY7 3
+
+static struct ofw_compat_data compat_data[] = {
+ { "marvell,armada-380-sdhci", SDHCI_FDT_ARMADA38X },
+ { "sdhci_generic", SDHCI_FDT_GENERIC },
+ { "xlnx,zy7_sdhci", SDHCI_FDT_XLNX_ZY7 },
+ { NULL, 0 }
+};
struct sdhci_fdt_softc {
device_t dev; /* Controller device */
@@ -181,13 +191,21 @@ sdhci_fdt_probe(device_t dev)
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (ofw_bus_is_compatible(dev, "sdhci_generic")) {
+ switch (ofw_bus_search_compatible(dev, compat_data)->ocd_data) {
+ case SDHCI_FDT_ARMADA38X:
+ sc->quirks = SDHCI_QUIRK_BROKEN_AUTO_STOP;
+ device_set_desc(dev, "ARMADA38X SDHCI controller");
+ break;
+ case SDHCI_FDT_GENERIC:
device_set_desc(dev, "generic fdt SDHCI controller");
- } else if (ofw_bus_is_compatible(dev, "xlnx,zy7_sdhci")) {
+ break;
+ case SDHCI_FDT_XLNX_ZY7:
sc->quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK;
device_set_desc(dev, "Zynq-7000 generic fdt SDHCI controller");
- } else
+ break;
+ default:
return (ENXIO);
+ }
node = ofw_bus_get_node(dev);
diff --git a/sys/dev/sdhci/sdhci_pci.c b/sys/dev/sdhci/sdhci_pci.c
index 7063ea5c2624..9c59d322d6e6 100644
--- a/sys/dev/sdhci/sdhci_pci.c
+++ b/sys/dev/sdhci/sdhci_pci.c
@@ -132,9 +132,11 @@ static const struct sdhci_device {
SDHCI_QUIRK_WAIT_WHILE_BUSY |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
{ 0x5aca8086, 0xffff, "Intel Apollo Lake SDXC Controller",
+ SDHCI_QUIRK_BROKEN_DMA | /* APL18 erratum */
SDHCI_QUIRK_WAIT_WHILE_BUSY |
SDHCI_QUIRK_PRESET_VALUE_BROKEN },
{ 0x5acc8086, 0xffff, "Intel Apollo Lake eMMC 5.0 Controller",
+ SDHCI_QUIRK_BROKEN_DMA | /* APL18 erratum */
SDHCI_QUIRK_ALL_SLOTS_NON_REMOVABLE |
SDHCI_QUIRK_INTEL_POWER_UP_RESET |
SDHCI_QUIRK_WAIT_WHILE_BUSY |
@@ -340,6 +342,7 @@ sdhci_pci_attach(device_t dev)
}
sc->quirks &= ~sdhci_quirk_clear;
sc->quirks |= sdhci_quirk_set;
+
/* Some controllers need to be bumped into the right mode. */
if (sc->quirks & SDHCI_QUIRK_LOWER_FREQUENCY)
sdhci_lower_frequency(dev);
diff --git a/sys/dev/usb/controller/xhci_pci.c b/sys/dev/usb/controller/xhci_pci.c
index 643807e07e59..d615f55fdfe0 100644
--- a/sys/dev/usb/controller/xhci_pci.c
+++ b/sys/dev/usb/controller/xhci_pci.c
@@ -116,6 +116,10 @@ xhci_pci_match(device_t self)
case 0x9c318086:
case 0x1e318086:
return ("Intel Panther Point USB 3.0 controller");
+ case 0x22b58086:
+ return ("Intel Braswell USB 3.0 controller");
+ case 0x5aa88086:
+ return ("Intel Apollo Lake USB 3.0 controller");
case 0x8c318086:
return ("Intel Lynx Point USB 3.0 controller");
case 0x8cb18086:
diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c
index 8320231fc12e..47eafdc0a3bd 100644
--- a/sys/dev/vt/vt_core.c
+++ b/sys/dev/vt/vt_core.c
@@ -1150,30 +1150,33 @@ vt_mark_mouse_position_as_dirty(struct vt_device *vd)
#endif
static void
-vt_set_border(struct vt_device *vd, term_color_t c)
+vt_set_border(struct vt_device *vd, const term_rect_t *area,
+ const term_color_t c)
{
- term_rect_t *tarea = &vd->vd_curwindow->vw_draw_area;
- int x, y;
+ vd_drawrect_t *drawrect = vd->vd_driver->vd_drawrect;
+
+ if (drawrect == NULL)
+ return;
- /* Top bar. */
- for (y = 0; y < tarea->tr_begin.tp_row; y++)
- for (x = 0; x < vd->vd_width; x++)
- vd->vd_driver->vd_setpixel(vd, x, y, c);
+ /* Top bar */
+ if (area->tr_begin.tp_row > 0)
+ drawrect(vd, 0, 0, vd->vd_width - 1,
+ area->tr_begin.tp_row - 1, 1, c);
- for (y = tarea->tr_begin.tp_row; y < tarea->tr_end.tp_row; y++) {
- /* Left bar. */
- for (x = 0; x < tarea->tr_begin.tp_col; x++)
- vd->vd_driver->vd_setpixel(vd, x, y, c);
+ /* Left bar */
+ if (area->tr_begin.tp_col > 0)
+ drawrect(vd, 0, area->tr_begin.tp_row,
+ area->tr_begin.tp_col - 1, area->tr_end.tp_row - 1, 1, c);
- /* Right bar. */
- for (x = tarea->tr_end.tp_col; x < vd->vd_width; x++)
- vd->vd_driver->vd_setpixel(vd, x, y, c);
- }
+ /* Right bar */
+ if (area->tr_end.tp_col < vd->vd_width)
+ drawrect(vd, area->tr_end.tp_col, area->tr_begin.tp_row,
+ vd->vd_width - 1, area->tr_end.tp_row - 1, 1, c);
- /* Bottom bar. */
- for (y = tarea->tr_end.tp_row; y < vd->vd_height; y++)
- for (x = 0; x < vd->vd_width; x++)
- vd->vd_driver->vd_setpixel(vd, x, y, c);
+ /* Bottom bar */
+ if (area->tr_end.tp_row < vd->vd_height)
+ drawrect(vd, 0, area->tr_end.tp_row, vd->vd_width - 1,
+ vd->vd_height - 1, 1, c);
}
static int
@@ -1241,7 +1244,7 @@ vt_flush(struct vt_device *vd)
if (vd->vd_flags & VDF_INVALID) {
vd->vd_flags &= ~VDF_INVALID;
- vt_set_border(vd, TC_BLACK);
+ vt_set_border(vd, &vw->vw_draw_area, TC_BLACK);
vt_termrect(vd, vf, &tarea);
if (vt_draw_logo_cpus)
vtterm_draw_cpu_logos(vd);
diff --git a/sys/fs/nfsclient/nfs_clcomsubs.c b/sys/fs/nfsclient/nfs_clcomsubs.c
index 0c6ec2dc4323..c16a3402946d 100644
--- a/sys/fs/nfsclient/nfs_clcomsubs.c
+++ b/sys/fs/nfsclient/nfs_clcomsubs.c
@@ -475,6 +475,7 @@ nfscl_mtofh(struct nfsrv_descript *nd, struct nfsfh **nfhpp,
if (*++tl != 0) {
nd->nd_flag |= ND_NOMOREDATA;
flag = 0;
+ error = ENXIO; /* Return ENXIO so *nfhpp isn't used. */
}
}
if (flag) {
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index fe9a2e4c4d02..d2596985090e 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -2477,6 +2477,7 @@ sig_suspend_threads(struct thread *td, struct proc *p, int sending)
PROC_LOCK_ASSERT(p, MA_OWNED);
PROC_SLOCK_ASSERT(p, MA_OWNED);
+ MPASS(sending || td == curthread);
wakeup_swapper = 0;
FOREACH_THREAD_IN_PROC(p, td2) {
@@ -2493,10 +2494,9 @@ sig_suspend_threads(struct thread *td, struct proc *p, int sending)
*/
KASSERT(!TD_IS_SUSPENDED(td2),
("thread with deferred stops suspended"));
- if (TD_SBDRY_INTR(td2) && sending) {
+ if (TD_SBDRY_INTR(td2))
wakeup_swapper |= sleepq_abort(td2,
TD_SBDRY_ERRNO(td2));
- }
} else if (!TD_IS_SUSPENDED(td2)) {
thread_suspend_one(td2);
}
@@ -2646,7 +2646,9 @@ reschedule_signals(struct proc *p, sigset_t block, int flags)
signotify(td);
if (!(flags & SIGPROCMASK_PS_LOCKED))
mtx_lock(&ps->ps_mtx);
- if (p->p_flag & P_TRACED || SIGISMEMBER(ps->ps_sigcatch, sig))
+ if (p->p_flag & P_TRACED ||
+ (SIGISMEMBER(ps->ps_sigcatch, sig) &&
+ !SIGISMEMBER(td->td_sigmask, sig)))
tdsigwakeup(td, sig, SIG_CATCH,
(SIGISMEMBER(ps->ps_sigintr, sig) ? EINTR :
ERESTART));
diff --git a/sys/kern/subr_kobj.c b/sys/kern/subr_kobj.c
index 5be746ad00a7..15a7b8ac35f7 100644
--- a/sys/kern/subr_kobj.c
+++ b/sys/kern/subr_kobj.c
@@ -213,19 +213,11 @@ kobj_lookup_method(kobj_class_t cls,
{
kobj_method_t *ce;
-#ifdef KOBJ_STATS
- /*
- * Correct for the 'hit' assumption in KOBJOPLOOKUP and record
- * a 'miss'.
- */
- kobj_lookup_hits--;
- kobj_lookup_misses++;
-#endif
-
ce = kobj_lookup_method_mi(cls, desc);
if (!ce)
ce = &desc->deflt;
- *cep = ce;
+ if (cep)
+ *cep = ce;
return ce;
}
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index 9edce97fc009..2ca95a8bbb34 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -5362,6 +5362,84 @@ mnt_vnode_markerfree_active(struct vnode **mvp, struct mount *mp)
*mvp = NULL;
}
+/*
+ * Relock the mp mount vnode list lock with the vp vnode interlock in the
+ * conventional lock order during mnt_vnode_next_active iteration.
+ *
+ * On entry, the mount vnode list lock is held and the vnode interlock is not.
+ * The list lock is dropped and reacquired. On success, both locks are held.
+ * On failure, the mount vnode list lock is held but the vnode interlock is
+ * not, and the procedure may have yielded.
+ */
+static bool
+mnt_vnode_next_active_relock(struct vnode *mvp, struct mount *mp,
+ struct vnode *vp)
+{
+ const struct vnode *tmp;
+ bool held, ret;
+
+ VNASSERT(mvp->v_mount == mp && mvp->v_type == VMARKER &&
+ TAILQ_NEXT(mvp, v_actfreelist) != NULL, mvp,
+ ("%s: bad marker", __func__));
+ VNASSERT(vp->v_mount == mp && vp->v_type != VMARKER, vp,
+ ("%s: inappropriate vnode", __func__));
+ ASSERT_VI_UNLOCKED(vp, __func__);
+ mtx_assert(&mp->mnt_listmtx, MA_OWNED);
+
+ ret = false;
+
+ TAILQ_REMOVE(&mp->mnt_activevnodelist, mvp, v_actfreelist);
+ TAILQ_INSERT_BEFORE(vp, mvp, v_actfreelist);
+
+ /*
+ * Use a hold to prevent vp from disappearing while the mount vnode
+ * list lock is dropped and reacquired. Normally a hold would be
+ * acquired with vhold(), but that might try to acquire the vnode
+ * interlock, which would be a LOR with the mount vnode list lock.
+ */
+ held = vfs_refcount_acquire_if_not_zero(&vp->v_holdcnt);
+ mtx_unlock(&mp->mnt_listmtx);
+ if (!held)
+ goto abort;
+ VI_LOCK(vp);
+ if (!vfs_refcount_release_if_not_last(&vp->v_holdcnt)) {
+ vdropl(vp);
+ goto abort;
+ }
+ mtx_lock(&mp->mnt_listmtx);
+
+ /*
+ * Determine whether the vnode is still the next one after the marker,
+ * excepting any other markers. If the vnode has not been doomed by
+ * vgone() then the hold should have ensured that it remained on the
+ * active list. If it has been doomed but is still on the active list,
+ * don't abort, but rather skip over it (avoid spinning on doomed
+ * vnodes).
+ */
+ tmp = mvp;
+ do {
+ tmp = TAILQ_NEXT(tmp, v_actfreelist);
+ } while (tmp != NULL && tmp->v_type == VMARKER);
+ if (tmp != vp) {
+ mtx_unlock(&mp->mnt_listmtx);
+ VI_UNLOCK(vp);
+ goto abort;
+ }
+
+ ret = true;
+ goto out;
+abort:
+ maybe_yield();
+ mtx_lock(&mp->mnt_listmtx);
+out:
+ if (ret)
+ ASSERT_VI_LOCKED(vp, __func__);
+ else
+ ASSERT_VI_UNLOCKED(vp, __func__);
+ mtx_assert(&mp->mnt_listmtx, MA_OWNED);
+ return (ret);
+}
+
static struct vnode *
mnt_vnode_next_active(struct vnode **mvp, struct mount *mp)
{
@@ -5371,22 +5449,19 @@ mnt_vnode_next_active(struct vnode **mvp, struct mount *mp)
KASSERT((*mvp)->v_mount == mp, ("marker vnode mount list mismatch"));
restart:
vp = TAILQ_NEXT(*mvp, v_actfreelist);
- TAILQ_REMOVE(&mp->mnt_activevnodelist, *mvp, v_actfreelist);
while (vp != NULL) {
if (vp->v_type == VMARKER) {
vp = TAILQ_NEXT(vp, v_actfreelist);
continue;
}
- if (!VI_TRYLOCK(vp)) {
- if (mp_ncpus == 1 || should_yield()) {
- TAILQ_INSERT_BEFORE(vp, *mvp, v_actfreelist);
- mtx_unlock(&mp->mnt_listmtx);
- pause("vnacti", 1);
- mtx_lock(&mp->mnt_listmtx);
- goto restart;
- }
- continue;
- }
+ /*
+ * Try-lock because this is the wrong lock order. If that does
+ * not succeed, drop the mount vnode list lock and try to
+ * reacquire it and the vnode interlock in the right order.
+ */
+ if (!VI_TRYLOCK(vp) &&
+ !mnt_vnode_next_active_relock(*mvp, mp, vp))
+ goto restart;
KASSERT(vp->v_type != VMARKER, ("locked marker %p", vp));
KASSERT(vp->v_mount == mp || vp->v_mount == NULL,
("alien vnode on the active list %p %p", vp, mp));
@@ -5396,6 +5471,7 @@ restart:
VI_UNLOCK(vp);
vp = nvp;
}
+ TAILQ_REMOVE(&mp->mnt_activevnodelist, *mvp, v_actfreelist);
/* Check if we are done */
if (vp == NULL) {
diff --git a/sys/mips/include/cpuinfo.h b/sys/mips/include/cpuinfo.h
index ec746140b2d0..5111f65f4973 100644
--- a/sys/mips/include/cpuinfo.h
+++ b/sys/mips/include/cpuinfo.h
@@ -75,6 +75,7 @@ struct mips_cpuinfo {
u_int8_t dc_nways;
u_int16_t dc_nsets;
} l2;
+ u_int32_t fpu_id;
};
extern struct mips_cpuinfo cpuinfo;
diff --git a/sys/mips/include/frame.h b/sys/mips/include/frame.h
index c04888e1b5ac..902c4b3ffac0 100644
--- a/sys/mips/include/frame.h
+++ b/sys/mips/include/frame.h
@@ -134,7 +134,7 @@ struct trapframe {
f_register_t f30;
f_register_t f31;
register_t fsr;
- register_t fdummy;
+ register_t fir;
};
#endif /* !_MACHINE_FRAME_H_ */
diff --git a/sys/mips/include/md_var.h b/sys/mips/include/md_var.h
index 622781d11b12..ad0df026429b 100644
--- a/sys/mips/include/md_var.h
+++ b/sys/mips/include/md_var.h
@@ -52,6 +52,7 @@ extern int vm_page_dump_size;
extern vm_offset_t kstack0;
extern vm_offset_t kernel_kseg0_end;
+uint32_t MipsFPID(void);
void MipsSaveCurFPState(struct thread *);
void fork_trampoline(void);
uintptr_t MipsEmulateBranch(struct trapframe *, uintptr_t, int, uintptr_t);
diff --git a/sys/mips/include/regnum.h b/sys/mips/include/regnum.h
index fcbed8dc1e19..a4056b0cd881 100644
--- a/sys/mips/include/regnum.h
+++ b/sys/mips/include/regnum.h
@@ -160,7 +160,7 @@
#define F30 (FPBASE+30)
#define F31 (FPBASE+31)
#define FSR (FPBASE+32)
-#define FSR_DUMMY (FPBASE+33) /* For 8 byte alignment */
+#define FIR (FPBASE+33)
#define NUMFPREGS 34
@@ -204,5 +204,6 @@
#define F30_NUM (30)
#define F31_NUM (31)
#define FSR_NUM (32)
+#define FIR_NUM (33)
#endif /* !_MACHINE_REGNUM_H_ */
diff --git a/sys/mips/mips/busdma_machdep.c b/sys/mips/mips/busdma_machdep.c
index 9105fe6dce95..789a3297f5ef 100644
--- a/sys/mips/mips/busdma_machdep.c
+++ b/sys/mips/mips/busdma_machdep.c
@@ -690,7 +690,9 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddrp, int flags,
* (the allocator aligns buffers to their size boundaries).
* - There's no need to handle lowaddr/highaddr exclusion zones.
* else allocate non-contiguous pages if...
- * - The page count that could get allocated doesn't exceed nsegments.
+ * - The page count that could get allocated doesn't exceed
+ * nsegments also when the maximum segment size is less
+ * than PAGE_SIZE.
* - The alignment constraint isn't larger than a page boundary.
* - There are no boundary-crossing constraints.
* else allocate a block of contiguous pages because one or more of the
@@ -699,8 +701,10 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddrp, int flags,
if (bufzone != NULL && dmat->alignment <= bufzone->size &&
!_bus_dma_can_bounce(dmat->lowaddr, dmat->highaddr)) {
vaddr = uma_zalloc(bufzone->umazone, mflags);
- } else if (dmat->nsegments >= btoc(dmat->maxsize) &&
- dmat->alignment <= PAGE_SIZE && dmat->boundary == 0) {
+ } else if (dmat->nsegments >=
+ howmany(dmat->maxsize, MIN(dmat->maxsegsz, PAGE_SIZE)) &&
+ dmat->alignment <= PAGE_SIZE &&
+ (dmat->boundary % PAGE_SIZE) == 0) {
vaddr = (void *)kmem_alloc_attr(kernel_arena, dmat->maxsize,
mflags, 0, dmat->lowaddr, memattr);
} else {
diff --git a/sys/mips/mips/cpu.c b/sys/mips/mips/cpu.c
index 149bec32f927..36e51525a440 100644
--- a/sys/mips/mips/cpu.c
+++ b/sys/mips/mips/cpu.c
@@ -184,6 +184,10 @@ mips_get_identity(struct mips_cpuinfo *cpuinfo)
cfg3 = mips_rd_config3();
}
+ /* Save FP implementation revision if FP is present. */
+ if (cfg1 & MIPS_CONFIG1_FP)
+ cpuinfo->fpu_id = MipsFPID();
+
/* Check to see if UserLocal register is implemented. */
if (cfg3 & MIPS_CONFIG3_ULR) {
/* UserLocal register is implemented, enable it. */
@@ -474,6 +478,19 @@ cpu_identify(void)
printf(" Config1=0x%b\n", cfg1,
"\20\7COP2\6MDMX\5PerfCount\4WatchRegs\3MIPS16\2EJTAG\1FPU");
+ if (cpuinfo.fpu_id != 0)
+ printf(" FPU ID=0x%b\n", cpuinfo.fpu_id,
+ "\020"
+ "\020S"
+ "\021D"
+ "\022PS"
+ "\0233D"
+ "\024W"
+ "\025L"
+ "\026F64"
+ "\0272008"
+ "\034UFRP");
+
/* If config register selection 2 does not exist, exit. */
if (!(cfg1 & MIPS_CONFIG_CM))
return;
diff --git a/sys/mips/mips/pm_machdep.c b/sys/mips/mips/pm_machdep.c
index 86003d23f7a3..aa6f59f8c457 100644
--- a/sys/mips/mips/pm_machdep.c
+++ b/sys/mips/mips/pm_machdep.c
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#include <vm/vm_extern.h>
#include <sys/user.h>
#include <sys/uio.h>
+#include <machine/cpuinfo.h>
#include <machine/reg.h>
#include <machine/md_var.h>
#include <machine/sigframe.h>
@@ -378,7 +379,8 @@ fill_fpregs(struct thread *td, struct fpreg *fpregs)
{
if (td == PCPU_GET(fpcurthread))
MipsSaveCurFPState(td);
- memcpy(fpregs, &td->td_frame->f0, sizeof(struct fpreg));
+ memcpy(fpregs, &td->td_frame->f0, sizeof(struct fpreg));
+ fpregs->r_regs[FIR_NUM] = cpuinfo.fpu_id;
return 0;
}
diff --git a/sys/mips/mips/swtch.S b/sys/mips/mips/swtch.S
index ed38aa405104..6fced0bc4b8a 100644
--- a/sys/mips/mips/swtch.S
+++ b/sys/mips/mips/swtch.S
@@ -526,6 +526,44 @@ END(MipsSwitchFPState)
/*----------------------------------------------------------------------------
*
+ * MipsFPID --
+ *
+ * Read and return the floating point implementation register.
+ *
+ * uint32_t
+ * MipsFPID(void)
+ *
+ * Results:
+ * Floating point implementation register.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------------
+ */
+LEAF(MipsFPID)
+ .set push
+ .set hardfloat
+ mfc0 t1, MIPS_COP_0_STATUS # Save the status register.
+ HAZARD_DELAY
+#if defined(__mips_n64)
+ or t0, t1, MIPS_SR_COP_1_BIT | MIPS_SR_FR
+#else
+ or t0, t1, MIPS_SR_COP_1_BIT
+#endif
+ mtc0 t0, MIPS_COP_0_STATUS # Enable the coprocessor
+ HAZARD_DELAY
+ ITLBNOPFIX
+ cfc1 v0, MIPS_FPU_ID
+ mtc0 t1, MIPS_COP_0_STATUS # Restore the status register.
+ ITLBNOPFIX
+ j ra
+ nop
+ .set pop
+END(MipsFPID)
+
+/*----------------------------------------------------------------------------
+ *
* MipsSaveCurFPState --
*
* Save the current floating point coprocessor state.
diff --git a/sys/modules/Makefile b/sys/modules/Makefile
index 73c35f6bac80..ce843a51adaa 100644
--- a/sys/modules/Makefile
+++ b/sys/modules/Makefile
@@ -356,8 +356,6 @@ SUBDIR= \
sysvipc \
tcp \
${_ti} \
- tests/framework \
- tests/callout_test \
tl \
tmpfs \
${_toecore} \
@@ -516,6 +514,10 @@ _rtwnfw= rtwnfw
_cxgbe= cxgbe
.endif
+.if ${MK_TESTS} != "no" || defined(ALL_MODULES)
+SUBDIR+= tests
+.endif
+
.if ${MK_ZFS} != "no" || defined(ALL_MODULES)
SUBDIR+= zfs
.endif
diff --git a/sys/modules/dtb/mv/Makefile b/sys/modules/dtb/mv/Makefile
new file mode 100644
index 000000000000..8086f3397ade
--- /dev/null
+++ b/sys/modules/dtb/mv/Makefile
@@ -0,0 +1,7 @@
+# $FreeBSD$
+# All the dts files for Marvell systems we support.
+DTS= \
+ armada-388-clearfog.dts \
+ armada-388-gp.dts
+
+.include <bsd.dtb.mk>
diff --git a/sys/modules/hyperv/vmbus/Makefile b/sys/modules/hyperv/vmbus/Makefile
index e05ce851a4f8..944bf75b0e7b 100644
--- a/sys/modules/hyperv/vmbus/Makefile
+++ b/sys/modules/hyperv/vmbus/Makefile
@@ -12,6 +12,7 @@ SRCS= hyperv.c \
vmbus_chan.c \
vmbus_et.c \
vmbus_if.c \
+ vmbus_res.c \
vmbus_xact.c
SRCS+= acpi_if.h bus_if.h device_if.h opt_acpi.h pci_if.h pcib_if.h vmbus_if.h
diff --git a/sys/modules/iwm/Makefile b/sys/modules/iwm/Makefile
index 2952af086e1b..264580b14851 100644
--- a/sys/modules/iwm/Makefile
+++ b/sys/modules/iwm/Makefile
@@ -7,10 +7,10 @@ KMOD= if_iwm
SRCS= if_iwm.c if_iwm_binding.c if_iwm_util.c if_iwm_phy_db.c
SRCS+= if_iwm_mac_ctxt.c if_iwm_phy_ctxt.c if_iwm_time_event.c
SRCS+= if_iwm_power.c if_iwm_scan.c if_iwm_led.c if_iwm_notif_wait.c
-SRCS+= if_iwm_7000.c if_iwm_8000.c if_iwm_fw.c
+SRCS+= if_iwm_7000.c if_iwm_8000.c if_iwm_fw.c if_iwm_sta.c
# bus layer
SRCS+= if_iwm_pcie_trans.c
-SRCS+= device_if.h bus_if.h pci_if.h opt_wlan.h
+SRCS+= device_if.h bus_if.h pci_if.h opt_wlan.h opt_iwm.h
CFLAGS+= -DIWM_DEBUG
diff --git a/sys/modules/mmcsd/Makefile b/sys/modules/mmcsd/Makefile
index 4573fc37dc22..4294c593b755 100644
--- a/sys/modules/mmcsd/Makefile
+++ b/sys/modules/mmcsd/Makefile
@@ -3,6 +3,6 @@
.PATH: ${SRCTOP}/sys/dev/mmc
KMOD= mmcsd
-SRCS= bus_if.h device_if.h mmc_subr.c mmcbr_if.h mmcbus_if.h mmcsd.c
+SRCS= bus_if.h device_if.h mmcbr_if.h mmcbus_if.h mmcsd.c
.include <bsd.kmod.mk>
diff --git a/sys/modules/tests/Makefile b/sys/modules/tests/Makefile
new file mode 100644
index 000000000000..8b5bf36f63fc
--- /dev/null
+++ b/sys/modules/tests/Makefile
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+SUBDIR+= framework
+SUBDIR+= .WAIT
+SUBDIR+= callout_test
+
+SUBDIR_PARALLEL=
+
+.include <bsd.subdir.mk>
diff --git a/sys/net/ieee8023ad_lacp.c b/sys/net/ieee8023ad_lacp.c
index 277139edd089..740294d7df27 100644
--- a/sys/net/ieee8023ad_lacp.c
+++ b/sys/net/ieee8023ad_lacp.c
@@ -1121,6 +1121,7 @@ lacp_compose_key(struct lacp_port *lp)
case IFM_10G_CR1:
case IFM_10G_ER:
case IFM_10G_SFI:
+ case IFM_10G_AOC:
key = IFM_10G_LR;
break;
case IFM_20G_KR2:
@@ -1145,6 +1146,9 @@ lacp_compose_key(struct lacp_port *lp)
case IFM_25G_CR:
case IFM_25G_KR:
case IFM_25G_SR:
+ case IFM_25G_LR:
+ case IFM_25G_ACC:
+ case IFM_25G_AOC:
key = IFM_25G_PCIE;
break;
case IFM_40G_CR4:
diff --git a/sys/net/if.c b/sys/net/if.c
index a7e60eb35e31..3e018a61f28d 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -744,6 +744,11 @@ if_attach_internal(struct ifnet *ifp, int vmove, struct if_clone *ifc)
/* Reliably crash if used uninitialized. */
ifp->if_broadcastaddr = NULL;
+ if (ifp->if_type == IFT_ETHER) {
+ ifp->if_hw_addr = malloc(ifp->if_addrlen, M_IFADDR,
+ M_WAITOK | M_ZERO);
+ }
+
#if defined(INET) || defined(INET6)
/* Use defaults for TSO, if nothing is set */
if (ifp->if_hw_tsomax == 0 &&
@@ -1059,6 +1064,8 @@ if_detach_internal(struct ifnet *ifp, int vmove, struct if_clone **ifcp)
* Remove link ifaddr pointer and maybe decrement if_index.
* Clean up all addresses.
*/
+ free(ifp->if_hw_addr, M_IFADDR);
+ ifp->if_hw_addr = NULL;
ifp->if_addr = NULL;
/* We can now free link ifaddr. */
@@ -2667,6 +2674,10 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
ifr->ifr_addr.sa_data, ifr->ifr_addr.sa_len);
break;
+ case SIOCGHWADDR:
+ error = if_gethwaddr(ifp, ifr);
+ break;
+
case SIOCAIFGROUP:
{
struct ifgroupreq *ifgr = (struct ifgroupreq *)ifr;
@@ -3584,6 +3595,29 @@ if_requestencap_default(struct ifnet *ifp, struct if_encap_req *req)
}
/*
+ * Get the link layer address that was read from the hardware at attach.
+ *
+ * This is only set by Ethernet NICs (IFT_ETHER), but laggX interfaces re-type
+ * their component interfaces as IFT_IEEE8023ADLAG.
+ */
+int
+if_gethwaddr(struct ifnet *ifp, struct ifreq *ifr)
+{
+
+ if (ifp->if_hw_addr == NULL)
+ return (ENODEV);
+
+ switch (ifp->if_type) {
+ case IFT_ETHER:
+ case IFT_IEEE8023ADLAG:
+ bcopy(ifp->if_hw_addr, ifr->ifr_addr.sa_data, ifp->if_addrlen);
+ return (0);
+ default:
+ return (ENODEV);
+ }
+}
+
+/*
* The name argument must be a pointer to storage which will last as
* long as the interface does. For physical devices, the result of
* device_get_name(dev) is a good choice and for pseudo-devices a
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 7956fcfa28ed..7b1ba85c617f 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -916,6 +916,9 @@ ether_ifattach(struct ifnet *ifp, const u_int8_t *lla)
sdl->sdl_alen = ifp->if_addrlen;
bcopy(lla, LLADDR(sdl), ifp->if_addrlen);
+ if (ifp->if_hw_addr != NULL)
+ bcopy(lla, ifp->if_hw_addr, ifp->if_addrlen);
+
bpfattach(ifp, DLT_EN10MB, ETHER_HDR_LEN);
if (ng_ether_attach_p != NULL)
(*ng_ether_attach_p)(ifp);
diff --git a/sys/net/if_media.h b/sys/net/if_media.h
index b6c999d3522d..d1080dd67394 100644
--- a/sys/net/if_media.h
+++ b/sys/net/if_media.h
@@ -196,6 +196,10 @@ uint64_t ifmedia_baudrate(int);
#define IFM_25G_SR IFM_X(55) /* 25GBase-SR */
#define IFM_50G_CR2 IFM_X(56) /* 50GBase-CR2 */
#define IFM_50G_KR2 IFM_X(57) /* 50GBase-KR2 */
+#define IFM_25G_LR IFM_X(58) /* 25GBase-LR */
+#define IFM_10G_AOC IFM_X(59) /* 10G active optical cable */
+#define IFM_25G_ACC IFM_X(60) /* 25G active copper cable */
+#define IFM_25G_AOC IFM_X(61) /* 25G active optical cable */
/*
* Please update ieee8023ad_lacp.c:lacp_compose_key()
@@ -450,6 +454,10 @@ struct ifmedia_description {
{ IFM_25G_SR, "25GBase-SR" }, \
{ IFM_50G_CR2, "50GBase-CR2" }, \
{ IFM_50G_KR2, "50GBase-KR2" }, \
+ { IFM_25G_LR, "25GBase-LR" }, \
+ { IFM_10G_AOC, "10GBase-AOC" }, \
+ { IFM_25G_ACC, "25GBase-ACC" }, \
+ { IFM_25G_AOC, "25GBase-AOC" }, \
{ 0, NULL }, \
}
@@ -782,6 +790,10 @@ struct ifmedia_baudrate {
{ IFM_ETHER | IFM_25G_SR, IF_Gbps(25ULL) }, \
{ IFM_ETHER | IFM_50G_CR2, IF_Gbps(50ULL) }, \
{ IFM_ETHER | IFM_50G_KR2, IF_Gbps(50ULL) }, \
+ { IFM_ETHER | IFM_25G_LR, IF_Gbps(25ULL) }, \
+ { IFM_ETHER | IFM_10G_AOC, IF_Gbps(10ULL) }, \
+ { IFM_ETHER | IFM_25G_ACC, IF_Gbps(25ULL) }, \
+ { IFM_ETHER | IFM_25G_AOC, IF_Gbps(25ULL) }, \
\
{ IFM_TOKEN | IFM_TOK_STP4, IF_Mbps(4) }, \
{ IFM_TOKEN | IFM_TOK_STP16, IF_Mbps(16) }, \
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index e5d5c7604585..d4d2ddceeff1 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -281,6 +281,7 @@ struct ifnet {
struct ifmultihead if_multiaddrs; /* multicast addresses configured */
int if_amcount; /* number of all-multicast requests */
struct ifaddr *if_addr; /* pointer to link-level address */
+ void *if_hw_addr; /* hardware link-level address */
const u_int8_t *if_broadcastaddr; /* linklevel broadcast bytestring */
struct rwlock if_afdata_lock;
void *if_afdata[AF_MAX];
@@ -650,6 +651,7 @@ int if_gethwassist(if_t ifp);
int if_setsoftc(if_t ifp, void *softc);
void *if_getsoftc(if_t ifp);
int if_setflags(if_t ifp, int flags);
+int if_gethwaddr(if_t ifp, struct ifreq *);
int if_setmtu(if_t ifp, int mtu);
int if_getmtu(if_t ifp);
int if_getmtu_family(if_t ifp, int family);
diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index 7f65714be407..af659a20f366 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -5214,7 +5214,6 @@ iflib_msix_init(if_ctx_t ctx)
/*
* bar == -1 => "trust me I know what I'm doing"
- * https://www.youtube.com/watch?v=nnwWKkNau4I
* Some drivers are for hardware that is so shoddily
* documented that no one knows which bars are which
* so the developer has to map all bars. This hack
diff --git a/sys/netinet/in_mcast.c b/sys/netinet/in_mcast.c
index c7fff9463128..78eddfe7d987 100644
--- a/sys/netinet/in_mcast.c
+++ b/sys/netinet/in_mcast.c
@@ -1047,9 +1047,10 @@ inm_merge(struct in_multi *inm, /*const*/ struct in_mfilter *imf)
/* Decrement ASM listener count on transition out of ASM mode. */
if (imf->imf_st[0] == MCAST_EXCLUDE && nsrc0 == 0) {
if ((imf->imf_st[1] != MCAST_EXCLUDE) ||
- (imf->imf_st[1] == MCAST_EXCLUDE && nsrc1 > 0))
+ (imf->imf_st[1] == MCAST_EXCLUDE && nsrc1 > 0)) {
CTR1(KTR_IGMPV3, "%s: --asm on inm at t1", __func__);
--inm->inm_st[1].iss_asm;
+ }
}
/* Increment ASM listener count on transition to ASM mode. */
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c
index 3c88d1cf5f29..685d4f6828a5 100644
--- a/sys/netinet/in_pcb.c
+++ b/sys/netinet/in_pcb.c
@@ -212,14 +212,25 @@ SYSCTL_INT(_net_inet_ip_portrange, OID_AUTO, randomtime,
*/
/*
+ * Different protocols initialize their inpcbs differently - giving
+ * different name to the lock. But they all are disposed the same.
+ */
+static void
+inpcb_fini(void *mem, int size)
+{
+ struct inpcb *inp = mem;
+
+ INP_LOCK_DESTROY(inp);
+}
+
+/*
* Initialize an inpcbinfo -- we should be able to reduce the number of
* arguments in time.
*/
void
in_pcbinfo_init(struct inpcbinfo *pcbinfo, const char *name,
struct inpcbhead *listhead, int hash_nelements, int porthash_nelements,
- char *inpcbzone_name, uma_init inpcbzone_init, uma_fini inpcbzone_fini,
- uint32_t inpcbzone_flags, u_int hashfields)
+ char *inpcbzone_name, uma_init inpcbzone_init, u_int hashfields)
{
INP_INFO_LOCK_INIT(pcbinfo, name);
@@ -239,8 +250,7 @@ in_pcbinfo_init(struct inpcbinfo *pcbinfo, const char *name,
in_pcbgroup_init(pcbinfo, hashfields, hash_nelements);
#endif
pcbinfo->ipi_zone = uma_zcreate(inpcbzone_name, sizeof(struct inpcb),
- NULL, NULL, inpcbzone_init, inpcbzone_fini, UMA_ALIGN_PTR,
- inpcbzone_flags);
+ NULL, NULL, inpcbzone_init, inpcb_fini, UMA_ALIGN_PTR, 0);
uma_zone_set_max(pcbinfo->ipi_zone, maxsockets);
uma_zone_set_warning(pcbinfo->ipi_zone,
"kern.ipc.maxsockets limit reached");
diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h
index 59de3b0f0aa5..e70749ca410a 100644
--- a/sys/netinet/in_pcb.h
+++ b/sys/netinet/in_pcb.h
@@ -690,7 +690,7 @@ VNET_DECLARE(int, ipport_tcpallocs);
void in_pcbinfo_destroy(struct inpcbinfo *);
void in_pcbinfo_init(struct inpcbinfo *, const char *, struct inpcbhead *,
- int, int, char *, uma_init, uma_fini, uint32_t, u_int);
+ int, int, char *, uma_init, u_int);
int in_pcbbind_check_bindmulti(const struct inpcb *ni,
const struct inpcb *oi);
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index be0bbf7f5648..8c1960d14eef 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -141,14 +141,6 @@ div_inpcb_init(void *mem, int size, int flags)
}
static void
-div_inpcb_fini(void *mem, int size)
-{
- struct inpcb *inp = mem;
-
- INP_LOCK_DESTROY(inp);
-}
-
-static void
div_init(void)
{
@@ -158,7 +150,7 @@ div_init(void)
* place for hashbase == NULL.
*/
in_pcbinfo_init(&V_divcbinfo, "div", &V_divcb, 1, 1, "divcb",
- div_inpcb_init, div_inpcb_fini, 0, IPI_HASHFIELDS_NONE);
+ div_inpcb_init, IPI_HASHFIELDS_NONE);
}
static void
diff --git a/sys/netinet/libalias/alias.c b/sys/netinet/libalias/alias.c
index bd36604b349c..dc46d4de143b 100644
--- a/sys/netinet/libalias/alias.c
+++ b/sys/netinet/libalias/alias.c
@@ -699,12 +699,14 @@ ProtoAliasOut(struct libalias *la, struct in_addr *ip_src,
struct alias_link *lnk;
LIBALIAS_LOCK_ASSERT(la);
- (void)create;
/* Return if proxy-only mode is enabled */
if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY)
return (PKT_ALIAS_OK);
+ if (!create)
+ return (PKT_ALIAS_IGNORED);
+
lnk = FindProtoOut(la, *ip_src, ip_dst, ip_p);
if (lnk != NULL) {
struct in_addr alias_address;
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index f36a8a936207..2e38b4d6e7c9 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -210,7 +210,7 @@ rip_init(void)
{
in_pcbinfo_init(&V_ripcbinfo, "rip", &V_ripcb, INP_PCBHASH_RAW_SIZE,
- 1, "ripcb", rip_inpcb_init, NULL, 0, IPI_HASHFIELDS_NONE);
+ 1, "ripcb", rip_inpcb_init, IPI_HASHFIELDS_NONE);
EVENTHANDLER_REGISTER(maxsockets_change, rip_zone_change, NULL,
EVENTHANDLER_PRI_ANY);
}
diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c
index 163dba3d6490..7f73a240e9cc 100644
--- a/sys/netinet/tcp_reass.c
+++ b/sys/netinet/tcp_reass.c
@@ -108,7 +108,7 @@ tcp_reass_global_init(void)
TUNABLE_INT_FETCH("net.inet.tcp.reass.maxsegments",
&tcp_reass_maxseg);
tcp_reass_zone = uma_zcreate("tcpreass", sizeof (struct tseg_qent),
- NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
+ NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
/* Set the zone limit and read back the effective value. */
tcp_reass_maxseg = uma_zone_set_max(tcp_reass_zone,
tcp_reass_maxseg);
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index de11684a40f4..3f44dff13ad7 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -647,7 +647,7 @@ tcp_init(void)
hashsize);
}
in_pcbinfo_init(&V_tcbinfo, "tcp", &V_tcb, hashsize, hashsize,
- "tcp_inpcb", tcp_inpcb_init, NULL, 0, IPI_HASHFIELDS_4TUPLE);
+ "tcp_inpcb", tcp_inpcb_init, IPI_HASHFIELDS_4TUPLE);
/*
* These have to be type stable for the benefit of the timers.
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index f7507dc13811..74ca2f39eac6 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -203,8 +203,7 @@ udp_init(void)
* a 4-tuple, flip this to 4-tuple.
*/
in_pcbinfo_init(&V_udbinfo, "udp", &V_udb, UDBHASHSIZE, UDBHASHSIZE,
- "udp_inpcb", udp_inpcb_init, NULL, 0,
- IPI_HASHFIELDS_2TUPLE);
+ "udp_inpcb", udp_inpcb_init, IPI_HASHFIELDS_2TUPLE);
V_udpcb_zone = uma_zcreate("udpcb", sizeof(struct udpcb),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
uma_zone_set_max(V_udpcb_zone, maxsockets);
@@ -218,8 +217,8 @@ udplite_init(void)
{
in_pcbinfo_init(&V_ulitecbinfo, "udplite", &V_ulitecb, UDBHASHSIZE,
- UDBHASHSIZE, "udplite_inpcb", udplite_inpcb_init, NULL,
- 0, IPI_HASHFIELDS_2TUPLE);
+ UDBHASHSIZE, "udplite_inpcb", udplite_inpcb_init,
+ IPI_HASHFIELDS_2TUPLE);
}
/*
diff --git a/sys/netinet6/in6_mcast.c b/sys/netinet6/in6_mcast.c
index 4effb57d0391..b34d02cf35ad 100644
--- a/sys/netinet6/in6_mcast.c
+++ b/sys/netinet6/in6_mcast.c
@@ -999,9 +999,10 @@ in6m_merge(struct in6_multi *inm, /*const*/ struct in6_mfilter *imf)
/* Decrement ASM listener count on transition out of ASM mode. */
if (imf->im6f_st[0] == MCAST_EXCLUDE && nsrc0 == 0) {
if ((imf->im6f_st[1] != MCAST_EXCLUDE) ||
- (imf->im6f_st[1] == MCAST_EXCLUDE && nsrc1 > 0))
+ (imf->im6f_st[1] == MCAST_EXCLUDE && nsrc1 > 0)) {
CTR1(KTR_MLD, "%s: --asm on inm at t1", __func__);
--inm->in6m_st[1].iss_asm;
+ }
}
/* Increment ASM listener count on transition to ASM mode. */
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index 092f1ecc242d..c714a5c1a7ca 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -325,6 +325,7 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt,
uint32_t id;
if (inp != NULL) {
+ INP_LOCK_ASSERT(inp);
M_SETFIB(m, inp->inp_inc.inc_fibnum);
if ((flags & IP_NODEFAULTFLOWID) == 0) {
/* unconditionally set flowid */
diff --git a/sys/opencrypto/criov.c b/sys/opencrypto/criov.c
index 499bfe34e08c..71e395a910e0 100644
--- a/sys/opencrypto/criov.c
+++ b/sys/opencrypto/criov.c
@@ -79,7 +79,7 @@ cuio_copydata(struct uio* uio, int off, int len, caddr_t cp)
}
void
-cuio_copyback(struct uio* uio, int off, int len, caddr_t cp)
+cuio_copyback(struct uio* uio, int off, int len, c_caddr_t cp)
{
struct iovec *iov = uio->uio_iov;
int iol = uio->uio_iovcnt;
@@ -155,7 +155,7 @@ cuio_apply(struct uio *uio, int off, int len, int (*f)(void *, void *, u_int),
}
void
-crypto_copyback(int flags, caddr_t buf, int off, int size, caddr_t in)
+crypto_copyback(int flags, caddr_t buf, int off, int size, c_caddr_t in)
{
if ((flags & CRYPTO_F_IMBUF) != 0)
diff --git a/sys/opencrypto/cryptodev.h b/sys/opencrypto/cryptodev.h
index d14fb3a81376..ca584694b7c5 100644
--- a/sys/opencrypto/cryptodev.h
+++ b/sys/opencrypto/cryptodev.h
@@ -211,9 +211,9 @@ struct session_op {
u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */
u_int32_t keylen; /* cipher key */
- caddr_t key;
+ c_caddr_t key;
int mackeylen; /* mac key */
- caddr_t mackey;
+ c_caddr_t mackey;
u_int32_t ses; /* returns: session # */
};
@@ -223,9 +223,9 @@ struct session2_op {
u_int32_t mac; /* ie. CRYPTO_MD5_HMAC */
u_int32_t keylen; /* cipher key */
- caddr_t key;
+ c_caddr_t key;
int mackeylen; /* mac key */
- caddr_t mackey;
+ c_caddr_t mackey;
u_int32_t ses; /* returns: session # */
int crid; /* driver id + flags (rw) */
@@ -240,9 +240,10 @@ struct crypt_op {
u_int16_t flags;
#define COP_F_BATCH 0x0008 /* Batch op if possible */
u_int len;
- caddr_t src, dst; /* become iov[] inside kernel */
+ c_caddr_t src; /* become iov[] inside kernel */
+ caddr_t dst;
caddr_t mac; /* must be big enough for chosen MAC */
- caddr_t iv;
+ c_caddr_t iv;
};
/* op and flags the same as crypt_op */
@@ -253,10 +254,11 @@ struct crypt_aead {
u_int len;
u_int aadlen;
u_int ivlen;
- caddr_t src, dst; /* become iov[] inside kernel */
- caddr_t aad; /* additional authenticated data */
+ c_caddr_t src; /* become iov[] inside kernel */
+ caddr_t dst;
+ c_caddr_t aad; /* additional authenticated data */
caddr_t tag; /* must fit for chosen TAG length */
- caddr_t iv;
+ c_caddr_t iv;
};
/*
@@ -503,7 +505,7 @@ extern int crypto_devallowsoft; /* only use hardware crypto */
*/
struct uio;
extern void cuio_copydata(struct uio* uio, int off, int len, caddr_t cp);
-extern void cuio_copyback(struct uio* uio, int off, int len, caddr_t cp);
+extern void cuio_copyback(struct uio* uio, int off, int len, c_caddr_t cp);
extern int cuio_getptr(struct uio *uio, int loc, int *off);
extern int cuio_apply(struct uio *uio, int off, int len,
int (*f)(void *, void *, u_int), void *arg);
@@ -514,7 +516,7 @@ extern int crypto_mbuftoiov(struct mbuf *mbuf, struct iovec **iovptr,
int *cnt, int *allocated);
extern void crypto_copyback(int flags, caddr_t buf, int off, int size,
- caddr_t in);
+ c_caddr_t in);
extern void crypto_copydata(int flags, caddr_t buf, int off, int size,
caddr_t out);
extern int crypto_apply(int flags, caddr_t buf, int off, int len,
diff --git a/sys/powerpc/booke/trap_subr.S b/sys/powerpc/booke/trap_subr.S
index a0d95b5fb335..55b8f1a7de3c 100644
--- a/sys/powerpc/booke/trap_subr.S
+++ b/sys/powerpc/booke/trap_subr.S
@@ -981,12 +981,12 @@ int_debug_int:
LOAD %r4,0(%r5) /* interrupt_vector_base in r4 */
add %r4,%r4,%r5
CMPL cr0, %r3, %r4
- blt 1f
+ blt trap_common
LOAD %r4,4(%r5) /* interrupt_vector_top in r4 */
add %r4,%r4,%r5
addi %r4,%r4,4
CMPL cr0, %r3, %r4
- bge 1f
+ bge trap_common
/* Disable single-stepping for the interrupt handlers. */
LOAD %r3, FRAME_SRR1+CALLSIZE(%r1);
rlwinm %r3, %r3, 0, 23, 21
@@ -999,16 +999,6 @@ int_debug_int:
mtspr SPR_SRR1, %r4
mtlr %r14
blr
-1:
- GET_TOCBASE(%r2)
- addi %r3, %r1, CALLSIZE
- bl CNAME(trap)
- TOC_RESTORE
- /*
- * Handle ASTs, needed for proper support of single-stepping.
- * We actually need to return to the process with an rfi.
- */
- b trapexit
/*****************************************************************************
* Common trap code
diff --git a/sys/powerpc/include/pmap.h b/sys/powerpc/include/pmap.h
index a5bb72a0c4f1..32b0e6e5d438 100644
--- a/sys/powerpc/include/pmap.h
+++ b/sys/powerpc/include/pmap.h
@@ -251,7 +251,7 @@ extern struct pmap kernel_pmap_store;
void pmap_bootstrap(vm_offset_t, vm_offset_t);
void pmap_kenter(vm_offset_t va, vm_paddr_t pa);
-void pmap_kenter_attr(vm_offset_t va, vm_offset_t pa, vm_memattr_t);
+void pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, vm_memattr_t);
void pmap_kremove(vm_offset_t);
void *pmap_mapdev(vm_paddr_t, vm_size_t);
void *pmap_mapdev_attr(vm_paddr_t, vm_size_t, vm_memattr_t);
diff --git a/sys/powerpc/powerpc/bus_machdep.c b/sys/powerpc/powerpc/bus_machdep.c
index bde0219bebd5..292d30806bc9 100644
--- a/sys/powerpc/powerpc/bus_machdep.c
+++ b/sys/powerpc/powerpc/bus_machdep.c
@@ -105,8 +105,9 @@ bs_gen_map(bus_addr_t addr, bus_size_t size, int flags,
void
bs_remap_earlyboot(void)
{
+ vm_paddr_t pa, spa;
+ vm_offset_t va;
int i;
- vm_offset_t pa, spa, va;
vm_memattr_t ma;
for (i = 0; i < earlyboot_map_idx; i++) {
diff --git a/sys/powerpc/powerpc/pmap_dispatch.c b/sys/powerpc/powerpc/pmap_dispatch.c
index 960133bccb16..4cca9e5089ed 100644
--- a/sys/powerpc/powerpc/pmap_dispatch.c
+++ b/sys/powerpc/powerpc/pmap_dispatch.c
@@ -495,7 +495,7 @@ pmap_kenter(vm_offset_t va, vm_paddr_t pa)
}
void
-pmap_kenter_attr(vm_offset_t va, vm_offset_t pa, vm_memattr_t ma)
+pmap_kenter_attr(vm_offset_t va, vm_paddr_t pa, vm_memattr_t ma)
{
CTR4(KTR_PMAP, "%s(%#x, %#x, %#x)", __func__, va, pa, ma);
diff --git a/sys/sys/kobj.h b/sys/sys/kobj.h
index 36d8d2a76a8b..862e79f0e238 100644
--- a/sys/sys/kobj.h
+++ b/sys/sys/kobj.h
@@ -226,10 +226,12 @@ extern u_int kobj_lookup_misses;
kobj_method_t **_cep = \
&OPS->cache[_desc->id & (KOBJ_CACHE_SIZE-1)]; \
kobj_method_t *_ce = *_cep; \
- kobj_lookup_hits++; /* assume hit */ \
- if (_ce->desc != _desc) \
+ if (_ce->desc != _desc) { \
_ce = kobj_lookup_method(OPS->cls, \
_cep, _desc); \
+ kobj_lookup_misses++; \
+ } else \
+ kobj_lookup_hits++; \
_m = _ce->func; \
} while(0)
#else
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 0362552cf923..e826278ef31f 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -624,13 +624,13 @@ struct proc {
pid_t p_reapsubtree; /* (e) Pid of the direct child of the
reaper which spawned
our subtree. */
- u_int p_xexit; /* (c) Exit code. */
- u_int p_xsig; /* (c) Stop/kill sig. */
uint16_t p_elf_machine; /* (x) ELF machine type */
uint64_t p_elf_flags; /* (x) ELF flags */
-
/* End area that is copied on creation. */
-#define p_endcopy p_elf_flags
+#define p_endcopy p_xexit
+
+ u_int p_xexit; /* (c) Exit code. */
+ u_int p_xsig; /* (c) Stop/kill sig. */
struct pgrp *p_pgrp; /* (c + e) Pointer to process group. */
struct knlist *p_klist; /* (c) Knotes attached to this proc. */
int p_numthreads; /* (c) Number of threads. */
diff --git a/sys/sys/sockio.h b/sys/sys/sockio.h
index 5a3b482af17a..193560f64df7 100644
--- a/sys/sys/sockio.h
+++ b/sys/sys/sockio.h
@@ -97,6 +97,7 @@
#define SIOCGIFSTATUS _IOWR('i', 59, struct ifstat) /* get IF status */
#define SIOCSIFLLADDR _IOW('i', 60, struct ifreq) /* set linklevel addr */
#define SIOCGI2C _IOWR('i', 61, struct ifreq) /* get I2C data */
+#define SIOCGHWADDR _IOWR('i', 62, struct ifreq) /* get hardware lladdr */
#define SIOCSIFPHYADDR _IOW('i', 70, struct ifaliasreq) /* set gif address */
#define SIOCGIFPSRCADDR _IOWR('i', 71, struct ifreq) /* get gif psrc addr */
diff --git a/sys/tests/callout_test/callout_test.c b/sys/tests/callout_test/callout_test.c
index 20273e0b09a3..c42e9decb4bb 100644
--- a/sys/tests/callout_test/callout_test.c
+++ b/sys/tests/callout_test/callout_test.c
@@ -27,23 +27,23 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
+#include <sys/cpuctl.h>
#include <sys/fcntl.h>
#include <sys/ioccom.h>
+#include <sys/kernel.h>
+#include <sys/libkern.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mutex.h>
+#include <sys/pcpu.h>
+#include <sys/pmckern.h>
#include <sys/priv.h>
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/sched.h>
-#include <sys/kernel.h>
+#include <sys/smp.h>
#include <sys/sysctl.h>
-#include <sys/libkern.h>
#include <sys/uio.h>
-#include <sys/pcpu.h>
-#include <sys/smp.h>
-#include <sys/pmckern.h>
-#include <sys/cpuctl.h>
#include <tests/kern_testfrwk.h>
#include <tests/callout_test.h>
#include <machine/cpu.h>
diff --git a/sys/tests/framework/kern_testfrwk.c b/sys/tests/framework/kern_testfrwk.c
index f348ee941cf7..2ef1c6f02a50 100644
--- a/sys/tests/framework/kern_testfrwk.c
+++ b/sys/tests/framework/kern_testfrwk.c
@@ -27,22 +27,20 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/types.h>
-#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/callout.h>
-#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/lock.h>
#include <sys/malloc.h>
+#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/sdt.h>
+#include <sys/smp.h>
#include <sys/sysctl.h>
#include <sys/taskqueue.h>
-#include <sys/smp.h>
#include <sys/queue.h>
#include <tests/kern_testfrwk.h>
#ifdef SMP
diff --git a/sys/x86/acpica/acpi_wakeup.c b/sys/x86/acpica/acpi_wakeup.c
index 4a10ac7b3047..74f4fedc28f1 100644
--- a/sys/x86/acpica/acpi_wakeup.c
+++ b/sys/x86/acpica/acpi_wakeup.c
@@ -223,7 +223,9 @@ acpi_sleep_machdep(struct acpi_softc *sc, int state)
WAKECODE_FIXUP(resume_beep, uint8_t, (acpi_resume_beep != 0));
WAKECODE_FIXUP(reset_video, uint8_t, (acpi_reset_video != 0));
-#ifndef __amd64__
+#ifdef __amd64__
+ WAKECODE_FIXUP(wakeup_efer, uint64_t, rdmsr(MSR_EFER));
+#else
WAKECODE_FIXUP(wakeup_cr4, register_t, pcb->pcb_cr4);
#endif
WAKECODE_FIXUP(wakeup_pcb, struct pcb *, pcb);
diff --git a/sys/x86/x86/busdma_bounce.c b/sys/x86/x86/busdma_bounce.c
index 78d04b94f0de..bed0cdb36ee3 100644
--- a/sys/x86/x86/busdma_bounce.c
+++ b/sys/x86/x86/busdma_bounce.c
@@ -396,23 +396,36 @@ bounce_bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
else
attr = VM_MEMATTR_DEFAULT;
- /*
- * XXX:
- * (dmat->alignment <= dmat->maxsize) is just a quick hack; the exact
- * alignment guarantees of malloc need to be nailed down, and the
- * code below should be rewritten to take that into account.
+ /*
+ * Allocate the buffer from the malloc(9) allocator if...
+ * - It's small enough to fit into a single power of two sized bucket.
+ * - The alignment is less than or equal to the maximum size
+ * - The low address requirement is fulfilled.
+ * else allocate non-contiguous pages if...
+ * - The page count that could get allocated doesn't exceed
+ * nsegments also when the maximum segment size is less
+ * than PAGE_SIZE.
+ * - The alignment constraint isn't larger than a page boundary.
+ * - There are no boundary-crossing constraints.
+ * else allocate a block of contiguous pages because one or more of the
+ * constraints is something that only the contig allocator can fulfill.
+ *
+ * NOTE: The (dmat->common.alignment <= dmat->maxsize) check
+ * below is just a quick hack. The exact alignment guarantees
+ * of malloc(9) need to be nailed down, and the code below
+ * should be rewritten to take that into account.
*
- * In the meantime, we'll warn the user if malloc gets it wrong.
+ * In the meantime warn the user if malloc gets it wrong.
*/
if ((dmat->common.maxsize <= PAGE_SIZE) &&
(dmat->common.alignment <= dmat->common.maxsize) &&
dmat->common.lowaddr >= ptoa((vm_paddr_t)Maxmem) &&
attr == VM_MEMATTR_DEFAULT) {
*vaddr = malloc(dmat->common.maxsize, M_DEVBUF, mflags);
- } else if (dmat->common.nsegments >= btoc(dmat->common.maxsize) &&
+ } else if (dmat->common.nsegments >=
+ howmany(dmat->common.maxsize, MIN(dmat->common.maxsegsz, PAGE_SIZE)) &&
dmat->common.alignment <= PAGE_SIZE &&
- (dmat->common.boundary == 0 ||
- dmat->common.boundary >= dmat->common.lowaddr)) {
+ (dmat->common.boundary % PAGE_SIZE) == 0) {
/* Page-based multi-segment allocations allowed */
*vaddr = (void *)kmem_alloc_attr(kernel_arena,
dmat->common.maxsize, mflags, 0ul, dmat->common.lowaddr,
diff --git a/targets/pseudo/clang/Makefile.depend b/targets/pseudo/clang/Makefile.depend
index f84f92d9c35a..97dcb727d68e 100644
--- a/targets/pseudo/clang/Makefile.depend
+++ b/targets/pseudo/clang/Makefile.depend
@@ -9,6 +9,7 @@ DIRDEPS = \
share/doc/llvm/clang \
usr.bin/clang/clang \
usr.bin/clang/clang-tblgen \
+ usr.bin/clang/llvm-objdump \
usr.bin/clang/llvm-tblgen \
.if ${MK_LLDB} == "yes"
@@ -27,19 +28,22 @@ DIRDEPS+= \
usr.bin/clang/llvm-bcanalyzer \
usr.bin/clang/llvm-cov \
usr.bin/clang/llvm-cxxdump \
+ usr.bin/clang/llvm-cxxfilt \
usr.bin/clang/llvm-diff \
usr.bin/clang/llvm-dis \
usr.bin/clang/llvm-dwarfdump \
usr.bin/clang/llvm-extract \
usr.bin/clang/llvm-link \
usr.bin/clang/llvm-lto \
+ usr.bin/clang/llvm-lto2 \
usr.bin/clang/llvm-mc \
+ usr.bin/clang/llvm-modextract \
usr.bin/clang/llvm-nm \
- usr.bin/clang/llvm-objdump \
usr.bin/clang/llvm-pdbdump \
usr.bin/clang/llvm-profdata \
usr.bin/clang/llvm-rtdyld \
usr.bin/clang/llvm-symbolizer \
+ usr.bin/clang/llvm-xray \
usr.bin/clang/opt \
.endif
diff --git a/targets/pseudo/userland/Makefile.depend b/targets/pseudo/userland/Makefile.depend
index 43fe71d61984..3ca21821902d 100644
--- a/targets/pseudo/userland/Makefile.depend
+++ b/targets/pseudo/userland/Makefile.depend
@@ -2,14 +2,9 @@
# This file is not autogenerated - take care!
-.if !defined(MK_MANDOCDB)
.include <src.opts.mk>
-.endif
DIRDEPS=
-.if ${MK_MANDOCDB} == "no"
-DIRDEPS+= usr.bin/makewhatis
-.endif
DIRDEPS+= \
bin/cat \
bin/chflags \
@@ -59,6 +54,7 @@ DIRDEPS+= \
sbin/clri \
sbin/comcontrol \
sbin/conscontrol \
+ sbin/decryptcore \
sbin/ddb \
sbin/devd \
sbin/devfs \
@@ -234,6 +230,7 @@ DIRDEPS+= \
usr.bin/ftp \
usr.bin/gcore \
usr.bin/gencat \
+ usr.bin/getaddrinfo \
usr.bin/getconf \
usr.bin/getent \
usr.bin/getopt \
@@ -437,6 +434,7 @@ DIRDEPS+= \
usr.bin/ypcat \
usr.bin/ypmatch \
usr.bin/ypwhich \
+ usr.bin/zstd \
usr.sbin/IPXrouted \
usr.sbin/ac \
usr.sbin/accton \
@@ -712,6 +710,7 @@ DIRDEPS+= \
usr.sbin/praliases \
usr.sbin/praudit \
usr.sbin/procctl \
+ usr.sbin/prometheus_sysctl_exporter \
usr.sbin/pstat \
usr.sbin/pw \
usr.sbin/pwd_mkdb \
@@ -806,6 +805,11 @@ DIRDEPS+= \
${DEP_RELDIR}/secure \
${DEP_RELDIR}/share \
+
+.if ${MK_EFI} != "no"
+DIRDEPS+= usr.sbin/efidp
+.endif
+
.if ${MK_NAND} != "no"
DIRDEPS+= \
sbin/nandfs \
@@ -833,6 +837,8 @@ DIRDEPS.amd64= \
usr.sbin/camdd \
usr.sbin/cpucontrol \
usr.sbin/hyperv/tools \
+ usr.sbin/hyperv/tools/kvp \
+ usr.sbin/hyperv/tools/vss \
usr.sbin/kgmon \
usr.sbin/lptcontrol \
usr.sbin/mptable \
@@ -858,6 +864,8 @@ DIRDEPS.i386= \
usr.sbin/btxld \
usr.sbin/cpucontrol \
usr.sbin/hyperv/tools \
+ usr.sbin/hyperv/tools/kvp \
+ usr.sbin/hyperv/tools/vss \
usr.sbin/kgmon \
usr.sbin/kgzip \
usr.sbin/lptcontrol \
diff --git a/targets/pseudo/userland/share/Makefile.depend b/targets/pseudo/userland/share/Makefile.depend
index 3589a107ade3..3f5ea1da5889 100644
--- a/targets/pseudo/userland/share/Makefile.depend
+++ b/targets/pseudo/userland/share/Makefile.depend
@@ -13,6 +13,7 @@ DIRDEPS = \
share/doc/legal/intel_iwi \
share/doc/legal/intel_iwn \
share/doc/legal/intel_wpi \
+ share/doc/legal/realtek \
share/doc/llvm/clang \
share/doc/papers/beyond4.3 \
share/doc/papers/bufbio \
@@ -29,6 +30,7 @@ DIRDEPS = \
share/doc/papers/relengr \
share/doc/papers/sysperf \
share/doc/papers/timecounter \
+ share/doc/pjdfstest \
share/doc/psd/01.cacm \
share/doc/psd/02.implement \
share/doc/psd/03.iosys \
diff --git a/tests/sys/aio/aio_test.c b/tests/sys/aio/aio_test.c
index ca8b41eec242..fa494bcad5aa 100644
--- a/tests/sys/aio/aio_test.c
+++ b/tests/sys/aio/aio_test.c
@@ -63,8 +63,6 @@
#include "freebsd_test_suite/macros.h"
#include "local.h"
-#define PATH_TEMPLATE "aio.XXXXXXXXXX"
-
/*
* GLOBAL_MAX sets the largest usable buffer size to be read and written, as
* it sizes ac_buffer in the aio_context structure. It is also the default
@@ -187,7 +185,8 @@ aio_context_init(struct aio_context *ac, int read_fd,
}
static ssize_t
-poll(struct aiocb *aio) {
+poll(struct aiocb *aio)
+{
int error;
while ((error = aio_error(aio)) == EINPROGRESS && !aio_timedout)
@@ -204,7 +203,8 @@ poll(struct aiocb *aio) {
}
static ssize_t
-suspend(struct aiocb *aio) {
+suspend(struct aiocb *aio)
+{
const struct aiocb *const iocbs[] = {aio};
int error;
@@ -216,7 +216,8 @@ suspend(struct aiocb *aio) {
}
static ssize_t
-waitcomplete(struct aiocb *aio) {
+waitcomplete(struct aiocb *aio)
+{
struct aiocb *aiop;
ssize_t ret;
@@ -734,6 +735,7 @@ aio_md_test(completion comp)
struct md_ioctl mdio;
ATF_REQUIRE_KERNEL_MODULE("aio");
+ ATF_REQUIRE_UNSAFE_AIO();
mdctl_fd = open("/dev/" MDCTL_NAME, O_RDWR, 0);
ATF_REQUIRE_MSG(mdctl_fd != -1,
diff --git a/tests/sys/aio/local.h b/tests/sys/aio/local.h
index 308b70010cf4..6620fe37b093 100644
--- a/tests/sys/aio/local.h
+++ b/tests/sys/aio/local.h
@@ -39,36 +39,51 @@
#include <atf-c.h>
-#define ATF_REQUIRE_UNSAFE_AIO() do { \
- size_t _len; \
- int _unsafe; \
- \
- _len = sizeof(_unsafe); \
- if (sysctlbyname("vfs.aio.enable_unsafe", &_unsafe, &_len, NULL,\
- 0) < 0) { \
- if (errno != ENOENT) \
- atf_libc_error(errno, \
- "Failed to read vfs.aio.enable_unsafe"); \
- } else if (_unsafe == 0) \
- atf_tc_skip("Unsafe AIO is disabled"); \
+static const char *sysctl_oid_name = "vfs.aio.enable_unsafe";
+
+static int
+is_unsafe_aio_enabled(void)
+{
+ size_t len;
+ int unsafe;
+
+ len = sizeof(unsafe);
+ if (sysctlbyname(sysctl_oid_name, &unsafe, &len, NULL, 0) < 0) {
+ if (errno == ENOENT)
+ return (-1);
+ return (0);
+ }
+ return (unsafe == 0 ? 0 : 1);
+}
+
+#define ATF_REQUIRE_UNSAFE_AIO() do { \
+ switch (is_unsafe_aio_enabled()) { \
+ case -1: \
+ atf_libc_error(errno, "Failed to read %s", sysctl_oid_name); \
+ break; \
+ case 0: \
+ atf_tc_skip("Unsafe AIO is disabled"); \
+ break; \
+ default: \
+ printf("Unsafe AIO is enabled\n"); \
+ break; \
+ } \
} while (0)
-
-#define PLAIN_REQUIRE_UNSAFE_AIO(_exit_code) do { \
- size_t _len; \
- int _unsafe; \
- \
- _len = sizeof(_unsafe); \
- if (sysctlbyname("vfs.aio.enable_unsafe", &_unsafe, &_len, NULL,\
- 0) < 0) { \
- if (errno != ENOENT) { \
- printf("Failed to read vfs.aio.enable_unsafe: %s\n",\
- strerror(errno)); \
- _exit(1); \
- } \
- } else if (_unsafe == 0) { \
- printf("Unsafe AIO is disabled"); \
- _exit(_exit_code); \
- } \
+
+#define PLAIN_REQUIRE_UNSAFE_AIO(_exit_code) do { \
+ switch (is_unsafe_aio_enabled()) { \
+ case -1: \
+ printf("Failed to read %s", sysctl_oid_name); \
+ _exit(_exit_code); \
+ break; \
+ case 0: \
+ printf("Unsafe AIO is disabled\n"); \
+ _exit(_exit_code); \
+ break; \
+ default: \
+ printf("Unsafe AIO is enabled\n"); \
+ break; \
+ } \
} while (0)
#endif /* !_AIO_TEST_LOCAL_H_ */
diff --git a/tests/sys/kern/ptrace_test.c b/tests/sys/kern/ptrace_test.c
index 06ca3a7af108..408b9b1263ba 100644
--- a/tests/sys/kern/ptrace_test.c
+++ b/tests/sys/kern/ptrace_test.c
@@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/cpuset.h>
#include <sys/event.h>
+#include <sys/file.h>
#include <sys/time.h>
#include <sys/procctl.h>
#include <sys/ptrace.h>
@@ -3025,6 +3026,99 @@ ATF_TC_BODY(ptrace__event_mask_sigkill_discard, tc)
ATF_REQUIRE(errno == ECHILD);
}
+static void *
+flock_thread(void *arg)
+{
+ int fd;
+
+ fd = *(int *)arg;
+ (void)flock(fd, LOCK_EX);
+ (void)flock(fd, LOCK_UN);
+ return (NULL);
+}
+
+/*
+ * Verify that PT_ATTACH will suspend threads sleeping in an SBDRY section.
+ * We rely on the fact that the lockf implementation sets SBDRY before blocking
+ * on a lock. This is a regression test for r318191.
+ */
+ATF_TC_WITHOUT_HEAD(ptrace__PT_ATTACH_with_SBDRY_thread);
+ATF_TC_BODY(ptrace__PT_ATTACH_with_SBDRY_thread, tc)
+{
+ pthread_barrier_t barrier;
+ pthread_barrierattr_t battr;
+ char tmpfile[64];
+ pid_t child, wpid;
+ int error, fd, i, status;
+
+ ATF_REQUIRE(pthread_barrierattr_init(&battr) == 0);
+ ATF_REQUIRE(pthread_barrierattr_setpshared(&battr,
+ PTHREAD_PROCESS_SHARED) == 0);
+ ATF_REQUIRE(pthread_barrier_init(&barrier, &battr, 2) == 0);
+
+ (void)snprintf(tmpfile, sizeof(tmpfile), "./ptrace.XXXXXX");
+ fd = mkstemp(tmpfile);
+ ATF_REQUIRE(fd >= 0);
+
+ ATF_REQUIRE((child = fork()) != -1);
+ if (child == 0) {
+ pthread_t t[2];
+ int error, cfd;
+
+ error = pthread_barrier_wait(&barrier);
+ if (error != 0 && error != PTHREAD_BARRIER_SERIAL_THREAD)
+ _exit(1);
+
+ cfd = open(tmpfile, O_RDONLY);
+ if (cfd < 0)
+ _exit(1);
+
+ /*
+ * We want at least two threads blocked on the file lock since
+ * the SIGSTOP from PT_ATTACH may kick one of them out of
+ * sleep.
+ */
+ if (pthread_create(&t[0], NULL, flock_thread, &cfd) != 0)
+ _exit(1);
+ if (pthread_create(&t[1], NULL, flock_thread, &cfd) != 0)
+ _exit(1);
+ if (pthread_join(t[0], NULL) != 0)
+ _exit(1);
+ if (pthread_join(t[1], NULL) != 0)
+ _exit(1);
+ _exit(0);
+ }
+
+ ATF_REQUIRE(flock(fd, LOCK_EX) == 0);
+
+ error = pthread_barrier_wait(&barrier);
+ ATF_REQUIRE(error == 0 || error == PTHREAD_BARRIER_SERIAL_THREAD);
+
+ /*
+ * Give the child some time to block. Is there a better way to do this?
+ */
+ sleep(1);
+
+ /*
+ * Attach and give the child 3 seconds to stop.
+ */
+ ATF_REQUIRE(ptrace(PT_ATTACH, child, NULL, 0) == 0);
+ for (i = 0; i < 3; i++) {
+ wpid = waitpid(child, &status, WNOHANG);
+ if (wpid == child && WIFSTOPPED(status) &&
+ WSTOPSIG(status) == SIGSTOP)
+ break;
+ sleep(1);
+ }
+ ATF_REQUIRE_MSG(i < 3, "failed to stop child process after PT_ATTACH");
+
+ ATF_REQUIRE(ptrace(PT_DETACH, child, NULL, 0) == 0);
+
+ ATF_REQUIRE(flock(fd, LOCK_UN) == 0);
+ ATF_REQUIRE(unlink(tmpfile) == 0);
+ ATF_REQUIRE(close(fd) == 0);
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -3072,6 +3166,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, ptrace__parent_terminate_with_pending_sigstop1);
ATF_TP_ADD_TC(tp, ptrace__parent_terminate_with_pending_sigstop2);
ATF_TP_ADD_TC(tp, ptrace__event_mask_sigkill_discard);
+ ATF_TP_ADD_TC(tp, ptrace__PT_ATTACH_with_SBDRY_thread);
return (atf_no_error());
}
diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc
index 5de266765865..355b62893e4a 100644
--- a/tools/build/mk/OptionalObsoleteFiles.inc
+++ b/tools/build/mk/OptionalObsoleteFiles.inc
@@ -56,6 +56,7 @@ OLD_FILES+=usr/share/man/man8/iasl.8.gz
.if ${MK_AMD} == no
OLD_FILES+=etc/amd.map
+OLD_FILES+=etc/newsyslog.conf.d/amd.conf
OLD_FILES+=etc/rc.d/amd
OLD_FILES+=usr/bin/pawd
OLD_FILES+=usr/sbin/amd
@@ -1590,9 +1591,11 @@ OLD_FILES+=usr/share/man/man8/fmtree.8.gz
.if ${MK_FTP} == no
OLD_FILES+=etc/ftpusers
+OLD_FILES+=etc/newsyslog.conf.d/ftp.conf
OLD_FILES+=etc/pam.d/ftp
OLD_FILES+=etc/pam.d/ftpd
OLD_FILES+=etc/rc.d/ftpd
+OLD_FILES+=etc/syslog.d/ftp.conf
OLD_FILES+=usr/bin/ftp
OLD_FILES+=usr/bin/gate-ftp
OLD_FILES+=usr/bin/pftp
@@ -6185,7 +6188,9 @@ OLD_FILES+=usr/share/man/man8/updatedb.8.gz
.if ${MK_LPR} == no
OLD_FILES+=etc/hosts.lpd
OLD_FILES+=etc/printcap
+OLD_FILES+=etc/newsyslog.conf.d/lpr.conf
OLD_FILES+=etc/rc.d/lpd
+OLD_FILES+=etc/syslog.d/lpr.conf
OLD_FILES+=usr/bin/lp
OLD_FILES+=usr/bin/lpq
OLD_FILES+=usr/bin/lpr
@@ -7160,6 +7165,7 @@ OLD_DIRS+=usr/share/examples/pc-sysinstall
.endif
.if ${MK_PF} == no
+OLD_FILES+=etc/newsyslog.conf.d/pf.conf
OLD_FILES+=etc/periodic/security/520.pfdenied
OLD_FILES+=etc/pf.os
OLD_FILES+=etc/rc.d/ftp-proxy
@@ -7299,7 +7305,9 @@ OLD_FILES+=usr/share/man/man8/portsnap.8.gz
.endif
.if ${MK_PPP} == no
+OLD_FILES+=etc/newsyslog.conf.d/ppp.conf
OLD_FILES+=etc/ppp/ppp.conf
+OLD_FILES+=etc/syslog.d/ppp.conf
OLD_DIRS+=etc/ppp
OLD_FILES+=usr/sbin/ppp
OLD_FILES+=usr/sbin/pppctl
@@ -7475,6 +7483,7 @@ OLD_FILES+=usr/share/man/man8/rtquery.8.gz
.endif
.if ${MK_SENDMAIL} == no
+OLD_FILES+=etc/newsyslog.conf.d/sendmail.conf
OLD_FILES+=etc/periodic/daily/150.clean-hoststat
OLD_FILES+=etc/periodic/daily/440.status-mailq
OLD_FILES+=etc/periodic/daily/460.status-mail-rejects
@@ -9344,8 +9353,6 @@ OLD_FILES+=usr/share/man/man4/ucom.4.gz
OLD_FILES+=usr/share/man/man4/ucycom.4.gz
OLD_FILES+=usr/share/man/man4/udav.4.gz
OLD_FILES+=usr/share/man/man4/udbp.4.gz
-OLD_FILES+=usr/share/man/man4/udp.4.gz
-OLD_FILES+=usr/share/man/man4/udplite.4.gz
OLD_FILES+=usr/share/man/man4/uep.4.gz
OLD_FILES+=usr/share/man/man4/ufm.4.gz
OLD_FILES+=usr/share/man/man4/ufoma.4.gz
diff --git a/tools/build/options/makeman b/tools/build/options/makeman
index 1e89a4cbbe06..9f200b24516b 100755
--- a/tools/build/options/makeman
+++ b/tools/build/options/makeman
@@ -3,15 +3,15 @@
# This file is in the public domain.
# $FreeBSD$
#
-# This script is used to create the src.conf.5 man page, using template text
-# contained herein and the contents of the WITH_* and WITHOUT_* files in the
-# same directory. Each WITH_* and WITHOUT_* file documents the effect of the
+# This script creates the src.conf.5 man page using template text contained
+# herein and the contents of the WITH_* and WITHOUT_* files in the same
+# directory. Each WITH_* and WITHOUT_* file documents the effect of the
# /etc/src.conf knob with the same name.
#
-# This script invokes "make showconfig" for each supported architecture in
-# order to determine, for each option, whether the default setting is always
-# WITH, always WITHOUT, or is architecture-dependent. It also determines
-# and describes dependencies between options.
+# For each supported architecture, "make showconfig" is invoked to determine
+# the default setting of every option: always WITH_, always WITHOUT_, or
+# architecture-dependent WITH_/WITHOUT_. It also determines and describes
+# dependencies between options.
#
# Usage:
#
diff --git a/usr.bin/bmake/Makefile b/usr.bin/bmake/Makefile
index d33b7025cf55..3ed2955603f5 100644
--- a/usr.bin/bmake/Makefile
+++ b/usr.bin/bmake/Makefile
@@ -14,10 +14,10 @@ CFLAGS+= -I${.CURDIR}
CLEANDIRS+= FreeBSD
CLEANFILES+= bootstrap
-# $Id: Makefile,v 1.88 2017/04/20 14:51:14 sjg Exp $
+# $Id: Makefile,v 1.92 2017/05/10 22:29:04 sjg Exp $
# Base version on src date
-_MAKE_VERSION= 20170420
+_MAKE_VERSION= 20170510
PROG?= ${.CURDIR:T}
diff --git a/usr.bin/fold/Makefile.depend b/usr.bin/fold/Makefile.depend
index 4def626103ce..3646e2e2b1af 100644
--- a/usr.bin/fold/Makefile.depend
+++ b/usr.bin/fold/Makefile.depend
@@ -8,7 +8,6 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
- lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/getaddrinfo/Makefile.depend b/usr.bin/getaddrinfo/Makefile.depend
new file mode 100644
index 000000000000..77151bbd1faf
--- /dev/null
+++ b/usr.bin/getaddrinfo/Makefile.depend
@@ -0,0 +1,20 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libnetbsd \
+ lib/libutil \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.bin/getconf/fake-gperf.awk b/usr.bin/getconf/fake-gperf.awk
index 96fcd3c9977c..d56ec0141453 100644
--- a/usr.bin/getconf/fake-gperf.awk
+++ b/usr.bin/getconf/fake-gperf.awk
@@ -36,7 +36,8 @@ state == 1 { print; next; }
state = 3;
print "\t{ NULL, 0, 0 }";
print "};";
- print "#define\tNWORDS\t(sizeof(wordlist)/sizeof(wordlist[0]) - 1)";
+ print "#include <sys/param.h>";
+ print "#define\tNWORDS\t(nitems(wordlist) - 1)";
print "static const struct map *";
print "in_word_set(const char *word)";
print "{";
diff --git a/usr.bin/grep/Makefile.depend b/usr.bin/grep/Makefile.depend
index ca0df563f1e5..f3f02a165db1 100644
--- a/usr.bin/grep/Makefile.depend
+++ b/usr.bin/grep/Makefile.depend
@@ -4,7 +4,6 @@
DIRDEPS = \
gnu/lib/csu \
gnu/lib/libgcc \
- gnu/lib/libregex \
include \
include/xlocale \
lib/${CSU_DIR} \
diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c
index 3af9090d32c6..56f9c58768fe 100644
--- a/usr.bin/grep/grep.c
+++ b/usr.bin/grep/grep.c
@@ -108,8 +108,8 @@ struct epat *dpattern, *fpattern;
char re_error[RE_ERROR_BUF + 1];
/* Command-line flags */
-unsigned long long Aflag; /* -A x: print x lines trailing each match */
-unsigned long long Bflag; /* -B x: print x lines leading each match */
+long long Aflag; /* -A x: print x lines trailing each match */
+long long Bflag; /* -B x: print x lines leading each match */
bool Hflag; /* -H: always print file name */
bool Lflag; /* -L: only show names of files with no matches */
bool bflag; /* -b: show block numbers for each match */
@@ -351,7 +351,7 @@ main(int argc, char *argv[])
char **aargv, **eargv, *eopts;
char *ep;
const char *pn;
- unsigned long long l;
+ long long l;
unsigned int aargc, eargc, i;
int c, lastc, needpattern, newarg, prevoptind;
@@ -438,10 +438,11 @@ main(int argc, char *argv[])
case '5': case '6': case '7': case '8': case '9':
if (newarg || !isdigit(lastc))
Aflag = 0;
- else if (Aflag > LLONG_MAX / 10) {
+ else if (Aflag > LLONG_MAX / 10 - 1) {
errno = ERANGE;
err(2, NULL);
}
+
Aflag = Bflag = (Aflag * 10) + (c - '0');
break;
case 'C':
@@ -454,14 +455,17 @@ main(int argc, char *argv[])
/* FALLTHROUGH */
case 'B':
errno = 0;
- l = strtoull(optarg, &ep, 10);
- if (((errno == ERANGE) && (l == ULLONG_MAX)) ||
- ((errno == EINVAL) && (l == 0)))
+ l = strtoll(optarg, &ep, 10);
+ if (errno == ERANGE || errno == EINVAL)
err(2, NULL);
else if (ep[0] != '\0') {
errno = EINVAL;
err(2, NULL);
+ } else if (l < 0) {
+ errno = EINVAL;
+ err(2, "context argument must be non-negative");
}
+
if (c == 'A')
Aflag = l;
else if (c == 'B')
diff --git a/usr.bin/grep/grep.h b/usr.bin/grep/grep.h
index 56ce456abb64..906318c67000 100644
--- a/usr.bin/grep/grep.h
+++ b/usr.bin/grep/grep.h
@@ -115,7 +115,7 @@ extern bool Eflag, Fflag, Gflag, Hflag, Lflag,
bflag, cflag, hflag, iflag, lflag, mflag, nflag, oflag,
qflag, sflag, vflag, wflag, xflag;
extern bool dexclude, dinclude, fexclude, finclude, lbflag, nullflag;
-extern unsigned long long Aflag, Bflag;
+extern long long Aflag, Bflag;
extern long long mcount;
extern long long mlimit;
extern char fileeol;
diff --git a/usr.bin/grep/queue.c b/usr.bin/grep/queue.c
index 453183367b8c..272dedfc91dc 100644
--- a/usr.bin/grep/queue.c
+++ b/usr.bin/grep/queue.c
@@ -49,7 +49,7 @@ struct qentry {
};
static STAILQ_HEAD(, qentry) queue = STAILQ_HEAD_INITIALIZER(queue);
-static unsigned long long count;
+static long long count;
static struct qentry *dequeue(void);
diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c
index cfcc72d8cbd6..e4d99c727779 100644
--- a/usr.bin/grep/util.c
+++ b/usr.bin/grep/util.c
@@ -196,11 +196,12 @@ int
procfile(const char *fn)
{
struct parsec pc;
+ long long tail;
struct file *f;
struct stat sb;
struct str *ln;
mode_t s;
- int c, last_outed, t, tail;
+ int c, last_outed, t;
bool doctx, printmatch, same_file;
if (strcmp(fn, "-") == 0) {
diff --git a/usr.bin/hexdump/Makefile.depend b/usr.bin/hexdump/Makefile.depend
index 3646e2e2b1af..4def626103ce 100644
--- a/usr.bin/hexdump/Makefile.depend
+++ b/usr.bin/hexdump/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/iconv/Makefile.depend b/usr.bin/iconv/Makefile.depend
index 3646e2e2b1af..4def626103ce 100644
--- a/usr.bin/iconv/Makefile.depend
+++ b/usr.bin/iconv/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/ident/Makefile.depend b/usr.bin/ident/Makefile.depend
index 6002005509a1..f5d5993a161d 100644
--- a/usr.bin/ident/Makefile.depend
+++ b/usr.bin/ident/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
lib/libsbuf \
diff --git a/usr.bin/ktrdump/Makefile.depend b/usr.bin/ktrdump/Makefile.depend
index 34582cd083a2..8b8697b239e0 100644
--- a/usr.bin/ktrdump/Makefile.depend
+++ b/usr.bin/ktrdump/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
lib/libelf \
lib/libkvm \
diff --git a/usr.bin/lam/Makefile.depend b/usr.bin/lam/Makefile.depend
index 3646e2e2b1af..4def626103ce 100644
--- a/usr.bin/lam/Makefile.depend
+++ b/usr.bin/lam/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/last/Makefile.depend b/usr.bin/last/Makefile.depend
index 3646e2e2b1af..4def626103ce 100644
--- a/usr.bin/last/Makefile.depend
+++ b/usr.bin/last/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
diff --git a/usr.bin/localedef/localedef.c b/usr.bin/localedef/localedef.c
index 5562df041c6f..20ed5b4aa038 100644
--- a/usr.bin/localedef/localedef.c
+++ b/usr.bin/localedef/localedef.c
@@ -119,7 +119,7 @@ open_category(void)
*/
file = fopen(category_file(), "w");
if (file == NULL) {
- errf(strerror(errno));
+ errf("%s", strerror(errno));
return (NULL);
}
return (file);
@@ -131,11 +131,11 @@ close_category(FILE *f)
if (fchmod(fileno(f), 0644) < 0) {
(void) fclose(f);
(void) unlink(category_file());
- errf(strerror(errno));
+ errf("%s", strerror(errno));
}
if (fclose(f) < 0) {
(void) unlink(category_file());
- errf(strerror(errno));
+ errf("%s", strerror(errno));
}
if (verbose) {
(void) fprintf(stdout, "done.\n");
@@ -195,13 +195,13 @@ putl_category(const char *s, FILE *f)
if (s && fputs(s, f) == EOF) {
(void) fclose(f);
(void) unlink(category_file());
- errf(strerror(errno));
+ errf("%s", strerror(errno));
return (EOF);
}
if (fputc('\n', f) == EOF) {
(void) fclose(f);
(void) unlink(category_file());
- errf(strerror(errno));
+ errf("%s", strerror(errno));
return (EOF);
}
return (0);
@@ -216,7 +216,7 @@ wr_category(void *buf, size_t sz, FILE *f)
if (fwrite(buf, sz, 1, f) < 1) {
(void) fclose(f);
(void) unlink(category_file());
- errf(strerror(errno));
+ errf("%s", strerror(errno));
return (EOF);
}
return (0);
@@ -331,7 +331,7 @@ main(int argc, char **argv)
while ((dir = opendir(locname)) == NULL) {
if ((errno != ENOENT) ||
(mkdir(locname, 0755) < 0)) {
- errf(strerror(errno));
+ errf("%s", strerror(errno));
}
}
(void) closedir(dir);
diff --git a/usr.bin/localedef/localedef.h b/usr.bin/localedef/localedef.h
index 287886d93da8..4367a19e2e88 100644
--- a/usr.bin/localedef/localedef.h
+++ b/usr.bin/localedef/localedef.h
@@ -35,10 +35,11 @@
*/
/* Common header files. */
+#include <sys/cdefs.h>
+#include <sys/types.h>
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-#include <stdarg.h>
-#include <sys/types.h>
extern int com_char;
extern int esc_char;
@@ -54,8 +55,8 @@ extern int warnings;
int yylex(void);
void yyerror(const char *);
-void errf(const char *, ...);
-void warn(const char *, ...);
+_Noreturn void errf(const char *, ...) __printflike(1, 2);
+void warn(const char *, ...) __printflike(1, 2);
int putl_category(const char *, FILE *);
int wr_category(void *, size_t, FILE *);
diff --git a/usr.bin/localedef/wide.c b/usr.bin/localedef/wide.c
index 5d5f5a6db276..808239620dbb 100644
--- a/usr.bin/localedef/wide.c
+++ b/usr.bin/localedef/wide.c
@@ -598,7 +598,7 @@ to_mb(char *mb, wchar_t wc)
int rv;
if ((rv = _tomb(mb, wc)) < 0) {
- errf(widemsg);
+ warn("%s", widemsg);
free(widemsg);
widemsg = NULL;
}
@@ -614,7 +614,7 @@ to_mb_string(const wchar_t *wcs)
mbs = malloc((wcslen(wcs) * mb_cur_max) + 1);
if (mbs == NULL) {
- errf("out of memory");
+ warn("out of memory");
return (NULL);
}
ptr = mbs;
diff --git a/usr.bin/ministat/Makefile.depend b/usr.bin/ministat/Makefile.depend
index c9f9d52f6e26..d56ccd254179 100644
--- a/usr.bin/ministat/Makefile.depend
+++ b/usr.bin/ministat/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
lib/msun \
diff --git a/usr.bin/mkimg/mkimg.1 b/usr.bin/mkimg/mkimg.1
index e97b9fc3c1fc..4643aaf0f60b 100644
--- a/usr.bin/mkimg/mkimg.1
+++ b/usr.bin/mkimg/mkimg.1
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 7, 2015
+.Dd April 26, 2017
.Dt MKIMG 1
.Os
.Sh NAME
@@ -37,7 +37,9 @@
.Op Fl S Ar secsz
.Op Fl T Ar tracksz
.Op Fl b Ar bootcode
-.Op Fl c Ar capacity
+.Op Fl c Ar min_capacity
+.Op Fl C Ar max_capacity
+.Op Fl -capacity Ar capacity
.Op Fl f Ar format
.Op Fl o Ar outfile
.Op Fl a Ar active
@@ -125,6 +127,18 @@ given capacity, then the disk image will be larger than the capacity
given.
.Pp
The
+.Fl C
+option specifies a maximum capacity for the disk image.
+If the combined sizes of the given partitions exceed the size given with
+.Fl C ,
+image creation fails.
+.Pp
+The
+.Fl -capacity
+option is a shorthand to specify the minimum and maximum capacity at the
+same time.
+.Pp
+The
.Fl v
option increases the level of output that the
.Nm
diff --git a/usr.bin/mkimg/mkimg.c b/usr.bin/mkimg/mkimg.c
index 92c5a574c5de..51b22c7bceb0 100644
--- a/usr.bin/mkimg/mkimg.c
+++ b/usr.bin/mkimg/mkimg.c
@@ -27,6 +27,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/param.h>
#include <sys/stat.h>
#include <errno.h>
#include <err.h>
@@ -46,18 +47,21 @@ __FBSDID("$FreeBSD$");
#include "mkimg.h"
#include "scheme.h"
-#define LONGOPT_FORMATS 0x01000001
-#define LONGOPT_SCHEMES 0x01000002
-#define LONGOPT_VERSION 0x01000003
+#define LONGOPT_FORMATS 0x01000001
+#define LONGOPT_SCHEMES 0x01000002
+#define LONGOPT_VERSION 0x01000003
+#define LONGOPT_CAPACITY 0x01000004
static struct option longopts[] = {
{ "formats", no_argument, NULL, LONGOPT_FORMATS },
{ "schemes", no_argument, NULL, LONGOPT_SCHEMES },
{ "version", no_argument, NULL, LONGOPT_VERSION },
+ { "capacity", required_argument, NULL, LONGOPT_CAPACITY },
{ NULL, 0, NULL, 0 }
};
-static uint64_t capacity;
+static uint64_t min_capacity = 0;
+static uint64_t max_capacity = 0;
struct partlisthead partlist = TAILQ_HEAD_INITIALIZER(partlist);
u_int nparts = 0;
@@ -148,7 +152,8 @@ usage(const char *why)
fputc('\n', stderr);
fprintf(stderr, "\t-a <num>\t- mark num'th partion as active\n");
fprintf(stderr, "\t-b <file>\t- file containing boot code\n");
- fprintf(stderr, "\t-c <num>\t- capacity (in bytes) of the disk\n");
+ fprintf(stderr, "\t-c <num>\t- minimum capacity (in bytes) of the disk\n");
+ fprintf(stderr, "\t-C <num>\t- maximum capacity (in bytes) of the disk\n");
fprintf(stderr, "\t-f <format>\n");
fprintf(stderr, "\t-o <file>\t- file to write image into\n");
fprintf(stderr, "\t-p <partition>\n");
@@ -378,12 +383,17 @@ mkimg_chs(lba_t lba, u_int maxcyl, u_int *cylp, u_int *hdp, u_int *secp)
static int
capacity_resize(lba_t end)
{
- lba_t capsz;
+ lba_t min_capsz, max_capsz;
- capsz = (capacity + secsz - 1) / secsz;
- if (end >= capsz)
+ min_capsz = (min_capacity + secsz - 1) / secsz;
+ max_capsz = (max_capacity + secsz - 1) / secsz;
+
+ if (max_capsz != 0 && end > max_capsz)
+ return (ENOSPC);
+ if (end >= min_capsz)
return (0);
- return (image_set_size(capsz));
+
+ return (image_set_size(min_capsz));
}
static void
@@ -470,7 +480,7 @@ main(int argc, char *argv[])
bcfd = -1;
outfd = 1; /* Write to stdout by default */
- while ((c = getopt_long(argc, argv, "a:b:c:f:o:p:s:vyH:P:S:T:",
+ while ((c = getopt_long(argc, argv, "a:b:c:C:f:o:p:s:vyH:P:S:T:",
longopts, NULL)) != -1) {
switch (c) {
case 'a': /* ACTIVE PARTITION, if supported */
@@ -485,10 +495,15 @@ main(int argc, char *argv[])
if (bcfd == -1)
err(EX_UNAVAILABLE, "%s", optarg);
break;
- case 'c': /* CAPACITY */
- error = parse_uint64(&capacity, 1, INT64_MAX, optarg);
+ case 'c': /* MINIMUM CAPACITY */
+ error = parse_uint64(&min_capacity, 1, INT64_MAX, optarg);
if (error)
- errc(EX_DATAERR, error, "capacity in bytes");
+ errc(EX_DATAERR, error, "minimum capacity in bytes");
+ break;
+ case 'C': /* MAXIMUM CAPACITY */
+ error = parse_uint64(&max_capacity, 1, INT64_MAX, optarg);
+ if (error)
+ errc(EX_DATAERR, error, "maximum capacity in bytes");
break;
case 'f': /* OUTPUT FORMAT */
if (format_selected() != NULL)
@@ -559,6 +574,12 @@ main(int argc, char *argv[])
print_version();
exit(EX_OK);
/*NOTREACHED*/
+ case LONGOPT_CAPACITY:
+ error = parse_uint64(&min_capacity, 1, INT64_MAX, optarg);
+ if (error)
+ errc(EX_DATAERR, error, "capacity in bytes");
+ max_capacity = min_capacity;
+ break;
default:
usage("unknown option");
}
@@ -568,8 +589,10 @@ main(int argc, char *argv[])
usage("trailing arguments");
if (scheme_selected() == NULL && nparts > 0)
usage("no scheme");
- if (nparts == 0 && capacity == 0)
+ if (nparts == 0 && min_capacity == 0)
usage("no partitions");
+ if (max_capacity != 0 && min_capacity > max_capacity)
+ usage("minimum capacity cannot be larger than the maximum one");
if (secsz > blksz) {
if (blksz != 0)
diff --git a/usr.bin/mkuzip/mkuzip.c b/usr.bin/mkuzip/mkuzip.c
index 6288f4e2d1d0..1a78ae2c9563 100644
--- a/usr.bin/mkuzip/mkuzip.c
+++ b/usr.bin/mkuzip/mkuzip.c
@@ -108,7 +108,7 @@ int main(int argc, char **argv)
struct mkuz_conveyor *cvp;
void *c_ctx;
struct mkuz_blk_info *chit;
- size_t ncpusz, ncpu;
+ size_t ncpusz, ncpu, magiclen;
double st, et;
st = getdtime();
@@ -192,7 +192,8 @@ int main(int argc, char **argv)
/* Not reached */
}
- strcpy(hdr.magic, cfs.handler->magic);
+ magiclen = strlcpy(hdr.magic, cfs.handler->magic, sizeof(hdr.magic));
+ assert(magiclen < sizeof(hdr.magic));
if (cfs.en_dedup != 0) {
hdr.magic[CLOOP_OFS_VERSN] = CLOOP_MAJVER_3;
diff --git a/usr.bin/mt/mt.1 b/usr.bin/mt/mt.1
index 7d1b8785d4f9..51e2e0274825 100644
--- a/usr.bin/mt/mt.1
+++ b/usr.bin/mt/mt.1
@@ -29,7 +29,7 @@
.\" @(#)mt.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd May 5, 2017
+.Dd May 11, 2017
.Dt MT 1
.Os
.Sh NAME
@@ -521,6 +521,7 @@ Value Width Tracks Density Code Type Reference Note
0x58 12.7 (0.5) 1280 15,142 (384,607) C LTO-5
0x5A 12.7 (0.5) 2176 15,142 (384,607) C LTO-6
0x5C 12.7 (0.5) 3584 19,107 (485,318) C LTO-7
+0x5E 12.7 (0.5) 6656 20,669 (524,993) C LTO-8
0x71 12.7 (0.5) 512 11,800 (299,720) C 3592A1 (encrypted)
0x72 12.7 (0.5) 896 11,800 (299,720) C 3592A2 (encrypted)
0x73 12.7 (0.5) 1152 13,452 (341,681) C 3592A3 (encrypted)
diff --git a/usr.bin/pom/Makefile.depend b/usr.bin/pom/Makefile.depend
index c9f9d52f6e26..d56ccd254179 100644
--- a/usr.bin/pom/Makefile.depend
+++ b/usr.bin/pom/Makefile.depend
@@ -8,6 +8,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
lib/msun \
diff --git a/usr.bin/procstat/Makefile b/usr.bin/procstat/Makefile
index 7c951966e414..10b9040372ea 100644
--- a/usr.bin/procstat/Makefile
+++ b/usr.bin/procstat/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+.include <src.opts.mk>
+
PROG= procstat
MAN= procstat.1
SRCS= procstat.c \
@@ -20,4 +22,8 @@ SRCS= procstat.c \
LIBADD+= procstat xo util sbuf
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
.include <bsd.prog.mk>
diff --git a/usr.bin/procstat/procstat.1 b/usr.bin/procstat/procstat.1
index 5d9c6087e386..54f697e5c995 100644
--- a/usr.bin/procstat/procstat.1
+++ b/usr.bin/procstat/procstat.1
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd September 5, 2015
+.Dd May 11, 2017
.Dt PROCSTAT 1
.Os
.Sh NAME
@@ -80,7 +80,7 @@ printed.
.It Fl l
Display resource limits for the process.
.It Fl L
-Display LWP info for the process pertaining to it's signal driven exit.
+Display LWP info for the process pertaining to its signal driven exit.
.It Fl r
Display resource usage information for the process.
.It Fl s
@@ -271,6 +271,60 @@ omitted, and a new capabilities field will be included listing capabilities,
as described in
.Xr cap_rights_limit 2 ,
present for each capability descriptor.
+.Pp
+The following network protocols may be displayed (grouped by address family):
+.Pp
+.Dv AF_INET ,
+.Dv AF_INET6
+.Pp
+.Bl -tag -width indent -compact
+.It ICM
+.Dv IPPROTO_ICMP ;
+see
+.Xr icmp 4 .
+.It IPD
+.Dv IPPROTO_DIVERT ;
+see
+.Xr divert 4 .
+.It IP\?
+unknown protocol.
+.It RAW
+.Dv IPPROTO_RAW ;
+see
+.Xr ip 4 .
+.It SCT
+.Dv IPPROTO_SCTP ;
+see
+.Xr sctp 4 .
+.It TCP
+.Dv IPPROTO_TCP ;
+see
+.Xr tcp 4 .
+.It UDP
+.Dv IPPROTO_UDP ;
+see
+.Xr udp 4 .
+.El
+.Pp
+.Dv AF_LOCAL
+.Pp
+.Bl -tag -width indent -compact
+.It UDD
+.Dv IPPROTO_UDP ;
+see
+.Xr udp 4 .
+.It UDS
+.Dv IPPROTO_TCP ;
+see
+.Xr tcp 4 .
+.It UD\?
+unknown protocol.
+.El
+.Pp
+.Bl -tag -width indent -compact
+.It \?
+unknown address family.
+.El
.Ss Signal Disposition Information
Display signal pending and disposition for a process:
.Pp
@@ -285,11 +339,13 @@ signal name
process signal disposition details, three symbols
.Bl -tag -width X -compact
.It P
-if signal is pending in the global process queue, - otherwise
+if signal is pending in the global process queue; - otherwise.
.It I
-if signal delivery disposition is SIGIGN, - otherwise
+if signal delivery disposition is
+.Dv SIG_IGN;
+- otherwise.
.It C
-if signal delivery is to catch it, - otherwise
+if the signal will be caught; - otherwise.
.El
.El
.Pp
@@ -542,8 +598,15 @@ auxiliary vector value
.Xr cap_rights_limit 2 ,
.Xr libprocstat 3 ,
.Xr libxo 3 ,
+.Xr signal 3 ,
.Xr xo_parse_args 3 ,
.Xr ddb 4 ,
+.Xr divert 4 ,
+.Xr icmp 4 ,
+.Xr ip 4 ,
+.Xr sctp 4 ,
+.Xr tcp 4 ,
+.Xr udp 4 ,
.Xr stack 9
.Sh AUTHORS
.An Robert N M Watson Aq Mt rwatson@FreeBSD.org .
diff --git a/usr.bin/procstat/tests/Makefile b/usr.bin/procstat/tests/Makefile
new file mode 100644
index 000000000000..b8857426ee8d
--- /dev/null
+++ b/usr.bin/procstat/tests/Makefile
@@ -0,0 +1,9 @@
+# $FreeBSD$
+
+ATF_TESTS_SH+= procstat_test
+
+PROGS+= while1
+
+BINDIR= ${TESTSDIR}
+
+.include <bsd.test.mk>
diff --git a/usr.bin/procstat/tests/procstat_test.sh b/usr.bin/procstat/tests/procstat_test.sh
new file mode 100755
index 000000000000..a939f4f26cd7
--- /dev/null
+++ b/usr.bin/procstat/tests/procstat_test.sh
@@ -0,0 +1,140 @@
+#
+# Copyright (c) 2017 Ngie Cooper <ngie@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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+MAX_TRIES=20
+PROG_PID=
+PROG_PATH=$(atf_get_srcdir)/while1
+
+SP='[[:space:]]'
+
+start_program()
+{
+ echo "Starting program in background"
+ PROG_COMM=while1
+ PROG_PATH=$(atf_get_srcdir)/$PROG_COMM
+
+ $PROG_PATH $* &
+ PROG_PID=$!
+ try=0
+ while [ $try -lt $MAX_TRIES ] && ! kill -0 $PROG_PID; do
+ sleep 0.5
+ : $(( try += 1 ))
+ done
+ if [ $try -ge $MAX_TRIES ]; then
+ atf_fail "Polled for program start $MAX_TRIES tries and failed"
+ fi
+}
+
+atf_test_case binary_info
+binary_info_head()
+{
+ atf_set "descr" "Checks -b support"
+}
+binary_info_body()
+{
+ start_program bogus-arg
+
+ line_format="$SP*%s$SP+%s$SP+%s$SP+%s$SP*"
+ header_re=$(printf "$line_format" "PID" "COMM" "OSREL" "PATH")
+ line_re=$(printf "$line_format" $PROG_PID $PROG_COMM "[[:digit:]]+" "$PROG_PATH")
+
+ atf_check -o save:procstat.out procstat -b $PROG_PID
+
+ atf_check -o match:"$header_re" head -n 1 procstat.out
+ atf_check -o match:"$line_re" tail -n 1 procstat.out
+}
+
+atf_test_case command_line_arguments
+command_line_arguments_head()
+{
+ atf_set "descr" "Checks -c support"
+}
+command_line_arguments_body()
+{
+ arguments="my arguments"
+
+ start_program $arguments
+
+ line_format="$SP*%s$SP+%s$SP+%s$SP*"
+ header_re=$(printf "$line_format" "PID" "COMM" "ARGS")
+ line_re=$(printf "$line_format" $PROG_PID "$PROG_COMM" "$PROG_PATH $arguments")
+
+ atf_check -o save:procstat.out procstat -c $PROG_PID
+ atf_check -o match:"$header_re" head -n 1 procstat.out
+ atf_check -o match:"$line_re" tail -n 1 procstat.out
+}
+
+atf_test_case environment
+environment_head()
+{
+ atf_set "descr" "Checks -e support"
+}
+environment_body()
+{
+ var="MY_VARIABLE=foo"
+ eval "export $var"
+
+ start_program my arguments
+
+ line_format="$SP*%s$SP+%s$SP+%s$SP*"
+ header_re=$(printf "$line_format" "PID" "COMM" "ENVIRONMENT")
+ line_re=$(printf "$line_format" $PROG_PID $PROG_COMM ".*$var.*")
+
+ atf_check -o save:procstat.out procstat -e $PROG_PID
+
+ atf_check -o match:"$header_re" head -n 1 procstat.out
+ atf_check -o match:"$line_re" tail -n 1 procstat.out
+}
+
+atf_test_case file_descriptor
+file_descriptor_head()
+{
+ atf_set "descr" "Checks -f support"
+}
+file_descriptor_body()
+{
+ start_program my arguments
+
+ line_format="$SP*%s$SP+%s$SP+%s$SP+%s$SP+%s$SP+%s$SP+%s$SP+%s$SP+%s$SP%s$SP*"
+ header_re=$(printf "$line_format" "PID" "COMM" "FD" "T" "V" "FLAGS" "REF" "OFFSET" "PRO" "NAME")
+ # XXX: write a more sensible feature test
+ line_re=$(printf "$line_format" $PROG_PID $PROG_COMM ".+" ".+" ".+" ".+" ".+" ".+" ".+" ".+")
+
+ atf_check -o save:procstat.out procstat -f $PROG_PID
+
+ atf_check -o match:"$header_re" head -n 1 procstat.out
+ atf_check -o match:"$line_re" awk 'NR > 1' procstat.out
+}
+
+atf_init_test_cases()
+{
+ atf_add_test_case binary_info
+ atf_add_test_case command_line_arguments
+ atf_add_test_case environment
+ atf_add_test_case file_descriptor
+}
diff --git a/usr.bin/procstat/tests/while1.c b/usr.bin/procstat/tests/while1.c
new file mode 100644
index 000000000000..6f706026ee9b
--- /dev/null
+++ b/usr.bin/procstat/tests/while1.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2017 Ngie Cooper <ngie@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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$FreeBSD$");
+
+#include <stdlib.h>
+#include <unistd.h>
+
+int
+main(void)
+{
+
+ for (;;)
+ usleep(100);
+ exit(1);
+}
diff --git a/usr.bin/resizewin/resizewin.1 b/usr.bin/resizewin/resizewin.1
index ce15ce70283e..d6c11abdc515 100644
--- a/usr.bin/resizewin/resizewin.1
+++ b/usr.bin/resizewin/resizewin.1
@@ -27,27 +27,38 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 8, 2017
+.Dd May 9, 2017
.Dt RESIZEWIN 1
.Os
.Sh NAME
.Nm resizewin
-.Nd update the kernel window size for the current TTY
+.Nd update terminal size
.Sh SYNOPSIS
.Nm
.Op Fl z
.Sh DESCRIPTION
-Query the terminal emulator window size with the
+The
+.Nm
+utility
+queries the terminal emulator for the current window size and updates
+the size known to the kernel using the
.Dv TIOCSWINSZ
-ioctl and set the window size known by the kernel to the new values.
-The terminal is assumed to be VT100/ANSI compatible.
+ioctl.
.Pp
The following options are available:
.Bl -tag -width ".Fl z"
.It Fl z
Do nothing unless the current kernel terminal size is zero.
+This is useful when run from user's profile (shell startup) scripts:
+querying the window size is required for serial lines, but not when
+logging in over the network, as protocols like TELNET or SSH already
+handle the terminal size by themselves.
.El
.Pp
+After a terminal window has been resized, running
+.Nm
+updates the kernel's window size to match the new size.
+.Pp
.Nm
is functionally similar to
.Xr resize 1 ,
@@ -56,21 +67,18 @@ which is part of the
distribution.
However,
.Nm
-only works with VT100/ANSI-compatible terminals and does
-not emit commands to set environment variables.
+only works with VT100/ANSI-compatible terminals and does not emit
+commands to set environment variables.
.Pp
-After a terminal window has been resized, running
-.Nm
-updates the kernel's window size to match the new size.
-.Pp
-Note that virtually all modern terninals support VT100/ANSI escape
-sequences, including xterm, konsole, gnome-terminal iTerm,
+The terminal is assumed to be VT100/ANSI compatible.
+The VT100/ANSI escape sequences are supported by virtually all modern
+terminals; this include xterm, konsole, gnome-terminal, iTerm,
Terminal.app, and PuTTY.
.Sh SEE ALSO
-.Xr resize 1 ,
-.Xr stty 1
+.Xr stty 1 ,
+.Xr tty 4
.Sh HISTORY
The
.Nm
command first appeared in
-.Fx 11 .
+.Fx 11.0 .
diff --git a/usr.bin/uniq/uniq.1 b/usr.bin/uniq/uniq.1
index 909ac7f3c15a..969384097fb2 100644
--- a/usr.bin/uniq/uniq.1
+++ b/usr.bin/uniq/uniq.1
@@ -31,7 +31,7 @@
.\" From: @(#)uniq.1 8.1 (Berkeley) 6/6/93
.\" $FreeBSD$
.\"
-.Dd December 17, 2009
+.Dd May 15, 2017
.Dt UNIQ 1
.Os
.Sh NAME
@@ -39,7 +39,8 @@
.Nd report or filter out repeated lines in a file
.Sh SYNOPSIS
.Nm
-.Op Fl c | Fl d | Fl u
+.Op Fl c
+.Op Fl d | Fl u
.Op Fl i
.Op Fl f Ar num
.Op Fl s Ar chars
diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c
index 07b3a9bdf671..1161bc1dcb5f 100644
--- a/usr.bin/uniq/uniq.c
+++ b/usr.bin/uniq/uniq.c
@@ -129,13 +129,6 @@ main (int argc, char *argv[])
argc -= optind;
argv += optind;
- /* If no flags are set, default is -d -u. */
- if (cflag) {
- if (dflag || uflag)
- usage();
- } else if (!dflag && !uflag)
- dflag = uflag = 1;
-
if (argc > 2)
usage();
@@ -182,9 +175,6 @@ main (int argc, char *argv[])
}
tprev = convert(prevline);
- if (!cflag && uflag && dflag)
- show(ofp, prevline);
-
tthis = NULL;
while (getline(&thisline, &thisbuflen, ifp) >= 0) {
if (tthis != NULL)
@@ -200,8 +190,7 @@ main (int argc, char *argv[])
if (comp) {
/* If different, print; set previous to new value. */
- if (cflag || !dflag || !uflag)
- show(ofp, prevline);
+ show(ofp, prevline);
p = prevline;
b1 = prevbuflen;
prevline = thisline;
@@ -209,8 +198,6 @@ main (int argc, char *argv[])
if (tprev != NULL)
free(tprev);
tprev = tthis;
- if (!cflag && uflag && dflag)
- show(ofp, prevline);
thisline = p;
thisbuflen = b1;
tthis = NULL;
@@ -220,8 +207,7 @@ main (int argc, char *argv[])
}
if (ferror(ifp))
err(1, "%s", ifn);
- if (cflag || !dflag || !uflag)
- show(ofp, prevline);
+ show(ofp, prevline);
exit(0);
}
@@ -286,9 +272,11 @@ static void
show(FILE *ofp, const char *str)
{
+ if ((dflag && repeats == 0) || (uflag && repeats > 0))
+ return;
if (cflag)
(void)fprintf(ofp, "%4d %s", repeats + 1, str);
- if ((dflag && repeats) || (uflag && !repeats))
+ else
(void)fprintf(ofp, "%s", str);
}
@@ -351,6 +339,6 @@ static void
usage(void)
{
(void)fprintf(stderr,
-"usage: uniq [-c | -d | -u] [-i] [-f fields] [-s chars] [input [output]]\n");
+"usage: uniq [-c] [-d | -u] [-i] [-f fields] [-s chars] [input [output]]\n");
exit(1);
}
diff --git a/usr.bin/xo/Makefile b/usr.bin/xo/Makefile
index 6159169a8c8f..476ccae8c4d0 100644
--- a/usr.bin/xo/Makefile
+++ b/usr.bin/xo/Makefile
@@ -4,6 +4,7 @@
LIBXOSRC= ${SRCTOP}/contrib/libxo
+.PATH:
.PATH: ${LIBXOSRC}/xo
PROG= xo
diff --git a/usr.bin/zstd/Makefile.depend b/usr.bin/zstd/Makefile.depend
new file mode 100644
index 000000000000..6d2c75dd4bbe
--- /dev/null
+++ b/usr.bin/zstd/Makefile.depend
@@ -0,0 +1,20 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libthr \
+ lib/libzstd \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/amd/amq/Makefile.depend b/usr.sbin/amd/amq/Makefile.depend
index 30890ab9030e..0e0bb6e1e1f1 100644
--- a/usr.sbin/amd/amq/Makefile.depend
+++ b/usr.sbin/amd/amq/Makefile.depend
@@ -12,7 +12,6 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libwrap \
usr.sbin/amd/include \
usr.sbin/amd/libamu \
diff --git a/usr.sbin/amd/fixmount/Makefile.depend b/usr.sbin/amd/fixmount/Makefile.depend
index 4ed49203b42a..a47404470813 100644
--- a/usr.sbin/amd/fixmount/Makefile.depend
+++ b/usr.sbin/amd/fixmount/Makefile.depend
@@ -13,7 +13,6 @@ DIRDEPS = \
lib/libc \
lib/libcompiler_rt \
lib/librpcsvc \
- lib/libwrap \
usr.sbin/amd/include \
usr.sbin/amd/libamu \
diff --git a/usr.sbin/amd/fsinfo/Makefile.depend b/usr.sbin/amd/fsinfo/Makefile.depend
index 5f63255c3f8b..cfaeac1fe13e 100644
--- a/usr.sbin/amd/fsinfo/Makefile.depend
+++ b/usr.sbin/amd/fsinfo/Makefile.depend
@@ -12,7 +12,6 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libwrap \
usr.bin/yacc.host \
usr.sbin/amd/include \
usr.sbin/amd/libamu \
diff --git a/usr.sbin/amd/hlfsd/Makefile.depend b/usr.sbin/amd/hlfsd/Makefile.depend
index 30890ab9030e..0e0bb6e1e1f1 100644
--- a/usr.sbin/amd/hlfsd/Makefile.depend
+++ b/usr.sbin/amd/hlfsd/Makefile.depend
@@ -12,7 +12,6 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libwrap \
usr.sbin/amd/include \
usr.sbin/amd/libamu \
diff --git a/usr.sbin/amd/libamu/Makefile.depend b/usr.sbin/amd/libamu/Makefile.depend
index c6f8f4b5fa66..3f45467826c9 100644
--- a/usr.sbin/amd/libamu/Makefile.depend
+++ b/usr.sbin/amd/libamu/Makefile.depend
@@ -7,7 +7,6 @@ DIRDEPS = \
include/rpc \
include/rpcsvc \
include/xlocale \
- lib/libwrap \
usr.sbin/amd/include \
diff --git a/usr.sbin/amd/mk-amd-map/Makefile.depend b/usr.sbin/amd/mk-amd-map/Makefile.depend
index 30890ab9030e..0e0bb6e1e1f1 100644
--- a/usr.sbin/amd/mk-amd-map/Makefile.depend
+++ b/usr.sbin/amd/mk-amd-map/Makefile.depend
@@ -12,7 +12,6 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libwrap \
usr.sbin/amd/include \
usr.sbin/amd/libamu \
diff --git a/usr.sbin/amd/pawd/Makefile.depend b/usr.sbin/amd/pawd/Makefile.depend
index 30890ab9030e..0e0bb6e1e1f1 100644
--- a/usr.sbin/amd/pawd/Makefile.depend
+++ b/usr.sbin/amd/pawd/Makefile.depend
@@ -12,7 +12,6 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libwrap \
usr.sbin/amd/include \
usr.sbin/amd/libamu \
diff --git a/usr.sbin/amd/wire-test/Makefile.depend b/usr.sbin/amd/wire-test/Makefile.depend
index 30890ab9030e..0e0bb6e1e1f1 100644
--- a/usr.sbin/amd/wire-test/Makefile.depend
+++ b/usr.sbin/amd/wire-test/Makefile.depend
@@ -12,7 +12,6 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
- lib/libwrap \
usr.sbin/amd/include \
usr.sbin/amd/libamu \
diff --git a/usr.sbin/arp/Makefile.depend b/usr.sbin/arp/Makefile.depend
index 54c1f6f1442e..7fad2713c8db 100644
--- a/usr.sbin/arp/Makefile.depend
+++ b/usr.sbin/arp/Makefile.depend
@@ -10,6 +10,8 @@ DIRDEPS = \
lib/${CSU_DIR} \
lib/libc \
lib/libcompiler_rt \
+ lib/libutil \
+ lib/libxo \
.include <dirdeps.mk>
diff --git a/usr.sbin/bhyve/Makefile.depend b/usr.sbin/bhyve/Makefile.depend
index 3cc9293cf771..681b1277639b 100644
--- a/usr.sbin/bhyve/Makefile.depend
+++ b/usr.sbin/bhyve/Makefile.depend
@@ -9,6 +9,7 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
lib/libcompiler_rt \
lib/libmd \
lib/libthr \
diff --git a/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile.depend b/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile.depend
index fc795736c34a..b69d36eac75e 100644
--- a/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile.depend
+++ b/usr.sbin/bsnmpd/tools/libbsnmptools/Makefile.depend
@@ -2,15 +2,10 @@
# Autogenerated - do NOT edit!
DIRDEPS = \
- gnu/lib/csu \
- gnu/lib/libgcc \
include \
include/arpa \
include/xlocale \
- lib/${CSU_DIR} \
lib/libbsnmp/libbsnmp \
- lib/libc \
- lib/libcompiler_rt \
.include <dirdeps.mk>
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index 206ef578c502..66c47255a518 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -230,9 +230,9 @@ static char **exnames;
static char **hosts = NULL;
static struct xucred def_anon = {
XUCRED_VERSION,
- (uid_t)-2,
+ (uid_t)65534,
1,
- { (gid_t)-2 },
+ { (gid_t)65533 },
NULL
};
static int force_v2 = 0;
@@ -2893,8 +2893,8 @@ parsecred(char *namelist, struct xucred *cr)
/*
* Set up the unprivileged user.
*/
- cr->cr_uid = -2;
- cr->cr_groups[0] = -2;
+ cr->cr_uid = 65534;
+ cr->cr_groups[0] = 65533;
cr->cr_ngroups = 1;
/*
* Get the user's password table entry.
diff --git a/usr.sbin/prometheus_sysctl_exporter/Makefile.depend b/usr.sbin/prometheus_sysctl_exporter/Makefile.depend
new file mode 100644
index 000000000000..411ae145c7fc
--- /dev/null
+++ b/usr.sbin/prometheus_sysctl_exporter/Makefile.depend
@@ -0,0 +1,20 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ gnu/lib/csu \
+ gnu/lib/libgcc \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libcompiler_rt \
+ lib/libz \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 5466becfb585..76849ba95546 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -33,6 +33,7 @@ static const char rcsid[] =
#include <sys/param.h>
#include <sys/types.h>
+#include <assert.h>
#include <ctype.h>
#include <dirent.h>
#include <err.h>
@@ -490,6 +491,7 @@ pw_pwcrypt(char *password)
char salt[SALTSIZE + 1];
char *cryptpw;
static char buf[256];
+ size_t pwlen;
/*
* Calculate a salt value
@@ -501,7 +503,9 @@ pw_pwcrypt(char *password)
cryptpw = crypt(password, salt);
if (cryptpw == NULL)
errx(EX_CONFIG, "crypt(3) failure");
- return strcpy(buf, cryptpw);
+ pwlen = strlcpy(buf, cryptpw, sizeof(buf));
+ assert(pwlen < sizeof(buf));
+ return (buf);
}
static char *
diff --git a/usr.sbin/rpc.statd/Makefile.depend b/usr.sbin/rpc.statd/Makefile.depend
index bdd7bc273d10..6401ed61118e 100644
--- a/usr.sbin/rpc.statd/Makefile.depend
+++ b/usr.sbin/rpc.statd/Makefile.depend
@@ -7,7 +7,6 @@ DIRDEPS = \
include \
include/arpa \
include/rpc \
- include/rpcsvc \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
diff --git a/usr.sbin/traceroute/Makefile.depend b/usr.sbin/traceroute/Makefile.depend
index 27cbf261b843..fd3e4ac98a4b 100644
--- a/usr.sbin/traceroute/Makefile.depend
+++ b/usr.sbin/traceroute/Makefile.depend
@@ -9,8 +9,12 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
+ lib/libcapsicum \
+ lib/libcasper/libcasper \
+ lib/libcasper/services/cap_dns \
lib/libcompiler_rt \
lib/libipsec \
+ lib/libnv \
.include <dirdeps.mk>