summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgjb <gjb@FreeBSD.org>2016-04-16 02:32:12 +0000
committergjb <gjb@FreeBSD.org>2016-04-16 02:32:12 +0000
commit6549ef7d128d37c0dfff87f6c1c189b42ed3e1ef (patch)
treea8871301d693c6d33d43cd3171b1ee4783fec0e4
parentae096a53a90aee9859587d48d5a0279567abb413 (diff)
parent35691f7a6f04cec368d8636543bca596e870faf3 (diff)
downloadFreeBSD-src-6549ef7d128d37c0dfff87f6c1c189b42ed3e1ef.zip
FreeBSD-src-6549ef7d128d37c0dfff87f6c1c189b42ed3e1ef.tar.gz
MFH
Sponsored by: The FreeBSD Foundation
-rw-r--r--Makefile6
-rw-r--r--Makefile.inc135
-rw-r--r--Makefile.libcompat5
-rw-r--r--ObsoleteFiles.inc1
-rw-r--r--UPDATING27
-rw-r--r--bin/csh/Makefile2
-rw-r--r--bin/sh/Makefile6
-rw-r--r--bin/sh/parser.c4
-rw-r--r--cddl/lib/libdtrace/tcp.d8
-rw-r--r--contrib/elftoolchain/elfcopy/sections.c17
-rw-r--r--contrib/ipfilter/bpf_filter.c6
-rw-r--r--contrib/ipfilter/mli_ipl.c6
-rw-r--r--contrib/libpcap/pcap-snf.c3
-rw-r--r--contrib/libxo/Makefile.am1
-rw-r--r--contrib/libxo/configure.ac31
-rw-r--r--contrib/libxo/doc/libxo-manual.html1046
-rw-r--r--contrib/libxo/doc/libxo.txt318
-rw-r--r--contrib/libxo/encoder/cbor/enc_cbor.c2
-rw-r--r--contrib/libxo/libxo-config.in16
-rw-r--r--contrib/libxo/libxo/libxo.c581
-rw-r--r--contrib/libxo/libxo/xo.h70
-rw-r--r--contrib/libxo/libxo/xo_config.h.in246
-rw-r--r--contrib/libxo/libxo/xo_emit_f.3111
-rw-r--r--contrib/libxo/libxo/xo_format.5318
-rw-r--r--contrib/libxo/libxo/xo_parse_args.34
-rw-r--r--contrib/libxo/packaging/libxo.pc.in6
-rw-r--r--contrib/libxo/packaging/libxo.rb.base.in8
-rw-r--r--contrib/libxo/tests/core/Makefile.am4
-rw-r--r--contrib/libxo/tests/core/saved/test_01.E.out18
-rw-r--r--contrib/libxo/tests/core/saved/test_01.H.out3
-rw-r--r--contrib/libxo/tests/core/saved/test_01.HIPx.out41
-rw-r--r--contrib/libxo/tests/core/saved/test_01.HP.out41
-rw-r--r--contrib/libxo/tests/core/saved/test_01.J.out2
-rw-r--r--contrib/libxo/tests/core/saved/test_01.JP.out20
-rw-r--r--contrib/libxo/tests/core/saved/test_01.T.out6
-rw-r--r--contrib/libxo/tests/core/saved/test_01.X.out2
-rw-r--r--contrib/libxo/tests/core/saved/test_01.XP.out18
-rw-r--r--contrib/libxo/tests/core/saved/test_12.E.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_12.E.out89
-rw-r--r--contrib/libxo/tests/core/saved/test_12.H.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_12.H.out1
-rw-r--r--contrib/libxo/tests/core/saved/test_12.HIPx.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_12.HIPx.out160
-rw-r--r--contrib/libxo/tests/core/saved/test_12.HP.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_12.HP.out160
-rw-r--r--contrib/libxo/tests/core/saved/test_12.J.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_12.J.out2
-rw-r--r--contrib/libxo/tests/core/saved/test_12.JP.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_12.JP.out88
-rw-r--r--contrib/libxo/tests/core/saved/test_12.T.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_12.T.out20
-rw-r--r--contrib/libxo/tests/core/saved/test_12.X.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_12.X.out1
-rw-r--r--contrib/libxo/tests/core/saved/test_12.XP.err0
-rw-r--r--contrib/libxo/tests/core/saved/test_12.XP.out84
-rw-r--r--contrib/libxo/tests/core/test_01.c22
-rw-r--r--contrib/libxo/tests/core/test_02.c1
-rw-r--r--contrib/libxo/tests/core/test_12.c76
-rw-r--r--contrib/libxo/tests/gettext/gt_01.c2
-rw-r--r--include/Makefile16
-rw-r--r--lib/libc/aarch64/sys/brk.S1
-rw-r--r--lib/libc/aarch64/sys/cerror.S1
-rw-r--r--lib/libc/aarch64/sys/sbrk.S1
-rw-r--r--lib/libcam/camlib.c24
-rw-r--r--lib/libcam/camlib.h12
-rw-r--r--lib/libcasper/services/cap_dns/cap_dns.c1
-rw-r--r--lib/libgssapi/gss_add_cred.c4
-rw-r--r--lib/libgssapi/gss_encapsulate_token.c2
-rw-r--r--lib/libgssapi/gss_get_mic.c3
-rw-r--r--lib/libgssapi/gss_inquire_context.c2
-rw-r--r--lib/libgssapi/gss_mech_switch.c2
-rw-r--r--lib/libgssapi/gss_pseudo_random.c3
-rw-r--r--lib/libgssapi/gss_verify_mic.c3
-rw-r--r--lib/libgssapi/gss_wrap.c3
-rw-r--r--lib/libgssapi/gss_wrap_size_limit.c3
-rw-r--r--lib/libmagic/Makefile2
-rw-r--r--lib/libpam/Makefile9
-rw-r--r--lib/libpam/libpam/Makefile14
-rw-r--r--lib/libpam/modules/Makefile1
-rw-r--r--lib/libpam/modules/Makefile.inc7
-rw-r--r--lib/libpam/static_libpam/Makefile (renamed from lib/libpam/static_modules/Makefile)20
-rw-r--r--lib/libpam/static_libpam/Makefile.depend (renamed from lib/libpam/static_modules/Makefile.depend)0
-rw-r--r--lib/libthr/arch/riscv/include/pthread_md.h2
-rw-r--r--lib/libxo/add.man4
-rw-r--r--lib/libxo/xo_config.h18
-rw-r--r--lib/libypclnt/ypclnt_passwd.c4
-rw-r--r--lib/msun/tests/Makefile5
-rw-r--r--lib/ncurses/ncurses/Makefile4
-rw-r--r--release/Makefile2
-rw-r--r--sbin/devd/devd.conf.522
-rw-r--r--sbin/dump/optr.c2
-rw-r--r--sbin/fsck_ffs/globs.c2
-rw-r--r--sbin/ifconfig/sfp.c2
-rw-r--r--sbin/ipfw/ipfw2.c155
-rw-r--r--sbin/ipfw/ipfw2.h11
-rw-r--r--sbin/ipfw/ipv6.c6
-rw-r--r--sbin/ipfw/tables.c39
-rw-r--r--sbin/mount_nfs/mount_nfs.c2
-rw-r--r--sbin/pfctl/parse.y15
-rw-r--r--sbin/reboot/nextboot.83
-rw-r--r--sbin/reboot/nextboot.sh2
-rw-r--r--sbin/savecore/savecore.c33
-rw-r--r--share/examples/Makefile4
-rw-r--r--share/man/man4/dtrace_tcp.410
-rw-r--r--share/man/man5/src.conf.573
-rw-r--r--share/man/man7/build.710
-rw-r--r--share/mk/bsd.README36
-rw-r--r--share/mk/bsd.dep.mk2
-rw-r--r--share/mk/bsd.lib.mk9
-rw-r--r--share/mk/bsd.progs.mk4
-rw-r--r--share/mk/bsd.sys.mk7
-rw-r--r--share/mk/local.sys.mk11
-rw-r--r--share/sendmail/Makefile4
-rw-r--r--share/syscons/scrnmaps/Makefile2
-rw-r--r--share/zoneinfo/Makefile4
-rw-r--r--sys/amd64/amd64/apic_vector.S16
-rw-r--r--sys/amd64/amd64/exception.S1
-rw-r--r--sys/amd64/amd64/minidump_machdep.c16
-rw-r--r--sys/amd64/conf/GENERIC2
-rw-r--r--sys/amd64/conf/NOTES1
-rw-r--r--sys/arm/allwinner/a10_common.c4
-rw-r--r--sys/arm/altera/socfpga/socfpga_common.c2
-rw-r--r--sys/arm/amlogic/aml8726/aml8726_machdep.c4
-rw-r--r--sys/arm/annapurna/alpine/common.c2
-rw-r--r--sys/arm/arm/gic.c347
-rw-r--r--sys/arm/arm/machdep_intr.c4
-rw-r--r--sys/arm/arm/mp_machdep.c18
-rw-r--r--sys/arm/arm/nexus.c18
-rw-r--r--sys/arm/arm/pmap-v4.c4
-rw-r--r--sys/arm/arm/pmap-v6.c6
-rw-r--r--sys/arm/at91/at91_common.c2
-rw-r--r--sys/arm/at91/at91_mci.c6
-rw-r--r--sys/arm/at91/at91_pio.c6
-rw-r--r--sys/arm/at91/at91_pmc.c2
-rw-r--r--sys/arm/at91/at91_rtc.c6
-rw-r--r--sys/arm/at91/at91_ssc.c6
-rw-r--r--sys/arm/at91/at91_twi.c6
-rw-r--r--sys/arm/at91/if_ate.c2
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_common.c4
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_gpio.c20
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2835_intr.c20
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2836.c4
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2836.h2
-rw-r--r--sys/arm/broadcom/bcm2835/bcm2836_mp.c2
-rw-r--r--sys/arm/cavium/cns11xx/if_ece.c6
-rw-r--r--sys/arm/conf/A202
-rw-r--r--sys/arm/conf/ALPINE2
-rw-r--r--sys/arm/conf/ARMADA38X2
-rw-r--r--sys/arm/conf/BEAGLEBONE2
-rw-r--r--sys/arm/conf/EXYNOS5.common2
-rw-r--r--sys/arm/conf/IMX62
-rw-r--r--sys/arm/conf/ODROIDC12
-rw-r--r--sys/arm/conf/PANDABOARD2
-rw-r--r--sys/arm/conf/RK31882
-rw-r--r--sys/arm/conf/RPI-B2
-rw-r--r--sys/arm/conf/RPI22
-rw-r--r--sys/arm/conf/SOCKIT.common2
-rw-r--r--sys/arm/conf/VIRT2
-rw-r--r--sys/arm/conf/VSATV1022
-rw-r--r--sys/arm/conf/VYBRID2
-rw-r--r--sys/arm/conf/ZEDBOARD2
-rw-r--r--sys/arm/freescale/imx/imx6_machdep.c2
-rw-r--r--sys/arm/freescale/imx/imx_common.c4
-rw-r--r--sys/arm/freescale/imx/imx_gpio.c14
-rw-r--r--sys/arm/freescale/vybrid/vf_common.c2
-rw-r--r--sys/arm/include/intr.h6
-rw-r--r--sys/arm/include/smp.h4
-rw-r--r--sys/arm/lpc/lpc_intc.c2
-rw-r--r--sys/arm/mv/mpic.c20
-rw-r--r--sys/arm/mv/mv_common.c2
-rw-r--r--sys/arm/nvidia/tegra124/std.tegra1242
-rw-r--r--sys/arm/qemu/virt_common.c2
-rw-r--r--sys/arm/rockchip/rk30xx_common.c2
-rw-r--r--sys/arm/samsung/exynos/exynos5_common.c2
-rw-r--r--sys/arm/ti/aintc.c14
-rw-r--r--sys/arm/ti/omap4/omap4_prcm_clks.c4
-rw-r--r--sys/arm/ti/ti_common.c4
-rw-r--r--sys/arm/ti/ti_gpio.c16
-rw-r--r--sys/arm/ti/ti_gpio.h6
-rw-r--r--sys/arm/versatile/versatile_common.c2
-rw-r--r--sys/arm/xilinx/zy7_machdep.c2
-rw-r--r--sys/arm/xscale/ixp425/ixp425_qmgr.c2
-rw-r--r--sys/arm64/arm64/gic_fdt.c2
-rw-r--r--sys/arm64/arm64/gic_v3_its.c2
-rw-r--r--sys/arm64/arm64/nexus.c2
-rw-r--r--sys/arm64/arm64/pmap.c21
-rw-r--r--sys/arm64/include/vmparam.h8
-rw-r--r--sys/boot/efi/loader/arch/amd64/elf64_freebsd.c17
-rw-r--r--sys/boot/fdt/dts/mips/fbsd-mt7620a.dtsi52
-rw-r--r--sys/boot/fdt/dts/mips/fbsd-mt7620n.dtsi38
-rw-r--r--sys/boot/fdt/dts/mips/fbsd-mt7621.dtsi102
-rw-r--r--sys/boot/fdt/dts/mips/fbsd-mt7628an.dtsi88
-rw-r--r--sys/boot/fdt/dts/mips/fbsd-rt2880.dtsi33
-rw-r--r--sys/boot/fdt/dts/mips/fbsd-rt3050.dtsi41
-rw-r--r--sys/boot/fdt/dts/mips/fbsd-rt3352.dtsi38
-rw-r--r--sys/boot/fdt/dts/mips/fbsd-rt3883.dtsi50
-rw-r--r--sys/boot/fdt/dts/mips/fbsd-rt5350.dtsi38
-rw-r--r--sys/boot/i386/libi386/biosacpi.c17
-rw-r--r--sys/cam/ata/ata_all.c66
-rw-r--r--sys/cam/ata/ata_all.h4
-rw-r--r--sys/cam/ata/ata_da.c472
-rw-r--r--sys/cam/cam.c3
-rw-r--r--sys/cam/cam_ccb.h1
-rw-r--r--sys/cam/cam_iosched.c1603
-rw-r--r--sys/cam/cam_iosched.h64
-rw-r--r--sys/cam/cam_periph.c102
-rw-r--r--sys/cam/cam_xpt.c5
-rw-r--r--sys/cam/scsi/scsi_da.c305
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/vdev_geom.c37
-rw-r--r--sys/compat/linux/linux_ioctl.c2
-rw-r--r--sys/conf/NOTES2
-rw-r--r--sys/conf/files4
-rw-r--r--sys/conf/files.amd641
-rw-r--r--sys/conf/files.arm6
-rw-r--r--sys/conf/files.i3861
-rw-r--r--sys/conf/kern.post.mk2
-rw-r--r--sys/conf/options1
-rw-r--r--sys/conf/options.amd642
-rw-r--r--sys/conf/options.arm2
-rw-r--r--sys/conf/options.i3862
-rw-r--r--sys/conf/options.mips3
-rw-r--r--sys/contrib/ipfilter/netinet/ip_fil_freebsd.c4
-rw-r--r--sys/contrib/rdma/krping/krping.c124
-rw-r--r--sys/contrib/rdma/krping/krping.h1
-rw-r--r--sys/contrib/rdma/krping/krping_dev.c10
-rw-r--r--sys/ddb/db_command.c4
-rw-r--r--sys/ddb/db_ps.c3
-rw-r--r--sys/ddb/db_sym.c6
-rw-r--r--sys/dev/acpica/acpi_pci.c77
-rw-r--r--sys/dev/ahci/ahci.c5
-rw-r--r--sys/dev/cardbus/cardbus.c15
-rw-r--r--sys/dev/fdt/fdt_common.h2
-rw-r--r--sys/dev/fdt/fdt_powerpc.c65
-rw-r--r--sys/dev/flash/mx25l.c8
-rw-r--r--sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c13
-rw-r--r--sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c11
-rw-r--r--sys/dev/hyperv/vmbus/amd64/hv_vector.S46
-rw-r--r--sys/dev/hyperv/vmbus/hv_channel_mgmt.c10
-rw-r--r--sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c6
-rw-r--r--sys/dev/hyperv/vmbus/i386/hv_vector.S49
-rw-r--r--sys/dev/isp/isp.c16
-rw-r--r--sys/dev/isp/isp_library.c5
-rw-r--r--sys/dev/isp/ispvar.h17
-rw-r--r--sys/dev/pci/pci.c62
-rw-r--r--sys/dev/pci/pci_if.m4
-rw-r--r--sys/dev/pci/pci_iov.c2
-rw-r--r--sys/dev/pci/pci_private.h12
-rw-r--r--sys/dev/pci/pcivar.h1
-rw-r--r--sys/dev/rt/if_rt.c15
-rw-r--r--sys/dev/wbwd/wbwd.c17
-rw-r--r--sys/fs/cd9660/cd9660_vfsops.c4
-rw-r--r--sys/fs/msdosfs/msdosfs_conv.c4
-rw-r--r--sys/fs/msdosfs/msdosfs_fat.c4
-rw-r--r--sys/fs/msdosfs/msdosfs_lookup.c2
-rw-r--r--sys/geom/gate/g_gate.c2
-rw-r--r--sys/geom/geom_io.c4
-rw-r--r--sys/geom/geom_subr.c4
-rw-r--r--sys/geom/mirror/g_mirror.c2
-rw-r--r--sys/geom/raid3/g_raid3.c2
-rw-r--r--sys/i386/conf/GENERIC2
-rw-r--r--sys/i386/i386/apic_vector.s19
-rw-r--r--sys/i386/i386/db_disasm.c14
-rw-r--r--sys/i386/i386/exception.s1
-rw-r--r--sys/i386/i386/pmap.c6
-rw-r--r--sys/i386/ibcs2/imgact_coff.c6
-rw-r--r--sys/isa/pnp.c10
-rw-r--r--sys/kern/kern_dump.c36
-rw-r--r--sys/kern/kern_environment.c46
-rw-r--r--sys/kern/kern_kthread.c2
-rw-r--r--sys/kern/kern_proc.c2
-rw-r--r--sys/kern/kern_racct.c15
-rw-r--r--sys/kern/kern_rctl.c66
-rw-r--r--sys/kern/kern_shutdown.c32
-rw-r--r--sys/kern/kern_sysctl.c4
-rw-r--r--sys/kern/link_elf.c4
-rw-r--r--sys/kern/link_elf_obj.c4
-rw-r--r--sys/kern/sysv_sem.c4
-rw-r--r--sys/kern/uipc_mbuf.c2
-rw-r--r--sys/kern/uipc_mqueue.c127
-rw-r--r--sys/kern/uipc_sem.c37
-rw-r--r--sys/kern/uipc_shm.c38
-rw-r--r--sys/kern/uipc_sockbuf.c6
-rw-r--r--sys/kern/uipc_syscalls.c2
-rw-r--r--sys/kern/vfs_cluster.c2
-rw-r--r--sys/kern/vfs_export.c2
-rw-r--r--sys/kern/vfs_lookup.c4
-rw-r--r--sys/libkern/strtol.c2
-rw-r--r--sys/libkern/strtoq.c2
-rw-r--r--sys/libkern/strtoul.c2
-rw-r--r--sys/libkern/strtouq.c2
-rw-r--r--sys/mips/adm5120/obio.c2
-rw-r--r--sys/mips/alchemy/obio.c2
-rw-r--r--sys/mips/atheros/apb.c2
-rw-r--r--sys/mips/conf/MEDIATEK81
-rw-r--r--sys/mips/conf/MEDIATEK_BASE89
-rw-r--r--sys/mips/conf/MT7620A_FDT30
-rw-r--r--sys/mips/conf/MT7620N_FDT30
-rw-r--r--sys/mips/conf/MT7621_FDT30
-rw-r--r--sys/mips/conf/MT7628_FDT30
-rw-r--r--sys/mips/conf/RT3050_FDT31
-rw-r--r--sys/mips/conf/RT3352_FDT30
-rw-r--r--sys/mips/conf/RT3883_FDT30
-rw-r--r--sys/mips/conf/RT5350_FDT30
-rw-r--r--sys/mips/idt/obio.c2
-rw-r--r--sys/mips/include/intr.h12
-rw-r--r--sys/mips/include/smp.h2
-rw-r--r--sys/mips/mediatek/mtk_ehci.c2
-rw-r--r--sys/mips/mediatek/mtk_gpio_v1.c4
-rw-r--r--sys/mips/mediatek/mtk_gpio_v2.c6
-rw-r--r--sys/mips/mediatek/mtk_intr_gic.c4
-rw-r--r--sys/mips/mediatek/mtk_ohci.c2
-rw-r--r--sys/mips/mediatek/mtk_pcie.c41
-rw-r--r--sys/mips/mediatek/mtk_soc.c1
-rw-r--r--sys/mips/mediatek/mtk_usb_phy.c5
-rw-r--r--sys/mips/mediatek/mtk_xhci.c3
-rw-r--r--sys/mips/mips/exception.S8
-rw-r--r--sys/mips/mips/machdep.c2
-rw-r--r--sys/mips/mips/nexus.c16
-rw-r--r--sys/mips/mips/tick.c6
-rw-r--r--sys/mips/nlm/xlp_pci.c4
-rw-r--r--sys/mips/nlm/xlp_simplebus.c2
-rw-r--r--sys/mips/rmi/xlr_pci.c2
-rw-r--r--sys/mips/rt305x/obio.c2
-rw-r--r--sys/mips/rt305x/rt305x_gpio.c2
-rw-r--r--sys/modules/cam/Makefile2
-rw-r--r--sys/modules/hyperv/vmbus/Makefile15
-rw-r--r--sys/modules/ipfw/Makefile2
-rw-r--r--sys/net/bpf_filter.c8
-rw-r--r--sys/net/if.c6
-rw-r--r--sys/net/if_arcsubr.c16
-rw-r--r--sys/net/if_atmsubr.c4
-rw-r--r--sys/net/if_bridge.c4
-rw-r--r--sys/net/if_disc.c2
-rw-r--r--sys/net/if_ethersubr.c4
-rw-r--r--sys/net/if_fddisubr.c8
-rw-r--r--sys/net/if_fwsubr.c12
-rw-r--r--sys/net/if_iso88025subr.c8
-rw-r--r--sys/net/if_loop.c2
-rw-r--r--sys/net/if_spppsubr.c6
-rw-r--r--sys/net/radix.c18
-rw-r--r--sys/net/raw_usrreq.c2
-rw-r--r--sys/netgraph/atm/ccatm/ng_ccatm.c2
-rw-r--r--sys/netgraph/ng_socket.c4
-rw-r--r--sys/netgraph/ng_source.c2
-rw-r--r--sys/netinet/if_ether.c2
-rw-r--r--sys/netinet/igmp.c2
-rw-r--r--sys/netinet/in_mcast.c4
-rw-r--r--sys/netinet/ip_divert.c6
-rw-r--r--sys/netinet/ip_fw.h8
-rw-r--r--sys/netinet/ip_icmp.c21
-rw-r--r--sys/netinet/ip_icmp.h7
-rw-r--r--sys/netinet/ip_input.c3
-rw-r--r--sys/netinet/ip_mroute.c2
-rw-r--r--sys/netinet/ip_options.c2
-rw-r--r--sys/netinet/ip_output.c2
-rw-r--r--sys/netinet/libalias/alias_db.c6
-rw-r--r--sys/netinet/raw_ip.c2
-rw-r--r--sys/netinet/sctp_syscalls.c2
-rw-r--r--sys/netinet/sctp_usrreq.c74
-rw-r--r--sys/netinet/udp_usrreq.c4
-rw-r--r--sys/netinet6/in6.c2
-rw-r--r--sys/netinet6/ip6_output.c10
-rw-r--r--sys/netinet6/nd6_rtr.c2
-rw-r--r--sys/netinet6/raw_ip6.c2
-rw-r--r--sys/netinet6/udp6_usrreq.c4
-rw-r--r--sys/netipsec/ipsec_mbuf.c2
-rw-r--r--sys/netipsec/key.c12
-rw-r--r--sys/netipsec/keysock.c8
-rw-r--r--sys/netipsec/xform_ipcomp.c2
-rw-r--r--sys/netpfil/ipfw/ip_fw2.c7
-rw-r--r--sys/netpfil/ipfw/ip_fw_eaction.c369
-rw-r--r--sys/netpfil/ipfw/ip_fw_iface.c2
-rw-r--r--sys/netpfil/ipfw/ip_fw_private.h38
-rw-r--r--sys/netpfil/ipfw/ip_fw_sockopt.c431
-rw-r--r--sys/netpfil/ipfw/ip_fw_table.c134
-rw-r--r--sys/netpfil/ipfw/ip_fw_table_value.c9
-rw-r--r--sys/ofed/drivers/infiniband/hw/mlx4/main.c2
-rw-r--r--sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c2
-rw-r--r--sys/ofed/drivers/net/mlx4/en_netdev.c4
-rw-r--r--sys/ofed/drivers/net/mlx4/en_rx.c18
-rw-r--r--sys/ofed/drivers/net/mlx4/en_tx.c19
-rw-r--r--sys/ofed/drivers/net/mlx4/mlx4_en.h7
-rw-r--r--sys/powerpc/ofw/ofw_pcibus.c17
-rw-r--r--sys/powerpc/powerpc/db_disasm.c4
-rw-r--r--sys/powerpc/powerpc/elf32_machdep.c2
-rw-r--r--sys/powerpc/powerpc/elf64_machdep.c2
-rw-r--r--sys/powerpc/psim/iobus.c2
-rw-r--r--sys/riscv/riscv/nexus.c2
-rw-r--r--sys/rpc/svc_vc.c2
-rw-r--r--sys/sparc64/ebus/ebus.c2
-rw-r--r--sys/sparc64/pci/ofw_pcibus.c19
-rw-r--r--sys/sys/bio.h8
-rw-r--r--sys/sys/buf.h4
-rw-r--r--sys/sys/conf.h11
-rw-r--r--sys/sys/kernel.h38
-rw-r--r--sys/sys/module.h2
-rw-r--r--sys/sys/systm.h2
-rw-r--r--sys/x86/acpica/OsdEnvironment.c11
-rw-r--r--sys/x86/x86/busdma_bounce.c56
-rw-r--r--sys/x86/x86/local_apic.c49
-rw-r--r--sys/x86/x86/nexus.c4
-rw-r--r--sys/xdr/xdr_mem.c2
-rw-r--r--targets/pseudo/userland/lib/Makefile.depend1
-rw-r--r--tests/sys/aio/aio_test.c60
-rw-r--r--tests/sys/file/flock_helper.c2
-rw-r--r--tools/build/options/WITHOUT_INSTALLLIB3
-rw-r--r--tools/build/options/WITHOUT_TOOLCHAIN3
-rw-r--r--tools/build/options/WITH_DIRDEPS_BUILD20
-rw-r--r--tools/build/options/WITH_META_MODE37
-rw-r--r--tools/regression/capsicum/libcasper/dns.c130
-rw-r--r--usr.bin/awk/Makefile2
-rw-r--r--usr.bin/bsdiff/bsdiff/bsdiff.c50
-rw-r--r--usr.bin/bsdiff/bspatch/bspatch.c4
-rw-r--r--usr.bin/calendar/dates.c2
-rw-r--r--usr.bin/calendar/io.c2
-rw-r--r--usr.bin/mkcsmapper_static/Makefile2
-rw-r--r--usr.bin/mkesdb_static/Makefile2
-rw-r--r--usr.bin/rpcgen/rpc_cout.c2
-rw-r--r--usr.bin/rpcgen/rpc_main.c2
-rw-r--r--usr.bin/rpcgen/rpc_parse.c2
-rw-r--r--usr.bin/rpcgen/rpc_svcout.c2
-rw-r--r--usr.bin/rpcgen/rpc_util.c4
-rw-r--r--usr.bin/showmount/showmount.c6
-rw-r--r--usr.bin/sort/bwstring.c2
-rw-r--r--usr.bin/sort/coll.c2
-rw-r--r--usr.bin/sort/file.c2
-rw-r--r--usr.bin/truss/syscalls.c2
-rw-r--r--usr.bin/vi/catalog/Makefile2
-rw-r--r--usr.bin/xlint/lint1/func.c2
-rw-r--r--usr.bin/xstr/xstr.c2
-rw-r--r--usr.sbin/bhyve/pci_emul.h2
-rw-r--r--usr.sbin/bhyve/pci_passthru.c117
-rw-r--r--usr.sbin/ctm/ctm/ctm.17
-rw-r--r--usr.sbin/fdformat/fdformat.c6
-rw-r--r--usr.sbin/fdread/fdread.c2
-rw-r--r--usr.sbin/fdread/fdutil.c4
-rw-r--r--usr.sbin/fmtree/excludes.c6
-rw-r--r--usr.sbin/fstyp/fstyp.c2
-rw-r--r--usr.sbin/keyserv/keyserv.c2
-rw-r--r--usr.sbin/kgmon/kgmon.c2
-rw-r--r--usr.sbin/lmcconfig/lmcconfig.c4
-rw-r--r--usr.sbin/mountd/mountd.c6
-rw-r--r--usr.sbin/nfscbd/nfscbd.c2
-rw-r--r--usr.sbin/nfsd/nfsd.c2
-rw-r--r--usr.sbin/pmcstudy/pmcstudy.c2
-rw-r--r--usr.sbin/portsnap/phttpget/phttpget.c2
-rw-r--r--usr.sbin/ppp/command.c2
-rw-r--r--usr.sbin/ppp/filter.c2
-rw-r--r--usr.sbin/ppp/radius.c2
-rw-r--r--usr.sbin/rmt/rmt.c8
-rw-r--r--usr.sbin/tzsetup/tzsetup.c16
451 files changed, 9397 insertions, 2748 deletions
diff --git a/Makefile b/Makefile
index cde0f2c..a45706f 100644
--- a/Makefile
+++ b/Makefile
@@ -125,7 +125,7 @@ TGTS= all all-man buildenv buildenvvars buildkernel buildworld \
obj objlink rerelease showconfig tags toolchain update \
_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
_build-tools _cross-tools _includes _libraries \
- build32 distribute32 install32 build32 distribute32 install32 \
+ build32 distribute32 install32 buildsoft distributesoft installsoft \
builddtb xdev xdev-build xdev-install \
xdev-links native-xtools stageworld stagekernel stage-packages \
create-world-packages create-kernel-packages create-packages \
@@ -408,7 +408,7 @@ MAKEFAIL=cat
universe_prologue: upgrade_checks
universe: universe_prologue
-universe_prologue:
+universe_prologue: .PHONY
@echo "--------------------------------------------------------------"
@echo ">>> make universe started on ${STARTTIME}"
@echo "--------------------------------------------------------------"
@@ -494,7 +494,7 @@ universe_kernconf_${TARGET}_${kernel}: .MAKE
"check _.${TARGET}.${kernel} for details"| ${MAKEFAIL}))
.endfor
universe: universe_epilogue
-universe_epilogue:
+universe_epilogue: .PHONY
@echo "--------------------------------------------------------------"
@echo ">>> make universe completed on `LC_ALL=C date`"
@echo " (started ${STARTTIME})"
diff --git a/Makefile.inc1 b/Makefile.inc1
index 1ce1362..aadcc36 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -144,6 +144,15 @@ CLEANDIR= clean cleandepend
CLEANDIR= cleandir
.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
+# it change.
+.if empty(.MAKE.MODE:Mnofilemon)
+NO_CLEAN= t
+.endif
+.endif
+
LOCAL_TOOL_DIRS?=
PACKAGEDIR?= ${DESTDIR}/${DISTDIR}
@@ -316,6 +325,10 @@ CROSSENV+= MAKEOBJDIRPREFIX=${OBJTREE} \
MACHINE_ARCH=${TARGET_ARCH} \
MACHINE=${TARGET} \
CPUTYPE=${TARGET_CPUTYPE}
+.if ${MK_META_MODE} != "no"
+# Don't rebuild build-tools targets during normal build.
+CROSSENV+= BUILD_TOOLS_META=.NOMETA_CMP
+.endif
.if ${MK_GROFF} != "no"
CROSSENV+= GROFF_BIN_PATH=${WORLDTMP}/legacy/usr/bin \
GROFF_FONT_PATH=${WORLDTMP}/legacy/usr/share/groff_font \
@@ -327,6 +340,7 @@ CROSSENV+= ${TARGET_CFLAGS}
# bootstrap-tools stage
BMAKEENV= INSTALL="sh ${.CURDIR}/tools/install.sh" \
+ TOOLS_PREFIX=${WORLDTMP} \
PATH=${BPATH}:${PATH} \
WORLDTMP=${WORLDTMP} \
MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}"
@@ -672,12 +686,12 @@ WMAKE_TGTS+= build${libcompat}
buildworld: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
.ORDER: buildworld_prologue ${WMAKE_TGTS} buildworld_epilogue
-buildworld_prologue:
+buildworld_prologue: .PHONY
@echo "--------------------------------------------------------------"
@echo ">>> World build started on `LC_ALL=C date`"
@echo "--------------------------------------------------------------"
-buildworld_epilogue:
+buildworld_epilogue: .PHONY
@echo
@echo "--------------------------------------------------------------"
@echo ">>> World build completed on `LC_ALL=C date`"
@@ -1897,7 +1911,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \
lib/libkiconv lib/libkvm lib/liblzma lib/libmd lib/libnv \
${_lib_casper} \
lib/ncurses/ncurses lib/ncurses/ncursesw \
- lib/libopie lib/libpam ${_lib_libthr} \
+ lib/libopie lib/libpam/libpam ${_lib_libthr} \
${_lib_libradius} lib/libsbuf lib/libtacplus \
lib/libgeom \
${_cddl_lib_libumem} ${_cddl_lib_libnvpair} \
@@ -1909,6 +1923,7 @@ _prebuild_libs= ${_kerberos5_lib_libasn1} \
${_secure_lib_libcrypto} ${_lib_libldns} \
${_secure_lib_libssh} ${_secure_lib_libssl} \
gnu/lib/libdialog
+
.if ${MK_GNUCXX} != "no"
_prebuild_libs+= gnu/lib/libstdc++ gnu/lib/libsupc++
gnu/lib/libstdc++__L: lib/msun__L
@@ -2076,7 +2091,7 @@ ${_lib}__PL: .PHONY .MAKE
.endif
.endfor
-.for _lib in ${_startup_libs} ${_prebuild_libs:Nlib/libpam} ${_generic_libs}
+.for _lib in ${_startup_libs} ${_prebuild_libs} ${_generic_libs}
${_lib}__L: .PHONY .MAKE
.if exists(${.CURDIR}/${_lib})
${_+_}@${ECHODIR} "===> ${_lib} (obj,all,install)"; \
@@ -2087,18 +2102,6 @@ ${_lib}__L: .PHONY .MAKE
.endif
.endfor
-# libpam is special: we need to build static PAM modules before
-# static PAM library, and dynamic PAM library before dynamic PAM
-# modules.
-lib/libpam__L: .PHONY .MAKE
- ${_+_}@${ECHODIR} "===> lib/libpam (obj,all,install)"; \
- cd ${.CURDIR}/lib/libpam; \
- ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ obj; \
- ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
- -D_NO_LIBPAM_SO_YET all; \
- ${MAKE} MK_TESTS=no DIRPRFX=lib/libpam/ \
- -D_NO_LIBPAM_SO_YET install
-
_prereq_libs: ${_prereq_libs:S/$/__PL/}
_startup_libs: ${_startup_libs:S/$/__L/}
_prebuild_libs: ${_prebuild_libs:S/$/__L/}
diff --git a/Makefile.libcompat b/Makefile.libcompat
index 2c15a9b..2cbaf2e 100644
--- a/Makefile.libcompat
+++ b/Makefile.libcompat
@@ -88,8 +88,13 @@ LIBCOMPATWMAKEENV+= MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} \
LIBDIR=/usr/lib${libcompat} \
SHLIBDIR=/usr/lib${libcompat} \
DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}"
+.if ${MK_META_MODE} != "no"
+# Don't rebuild build-tools targets during normal build.
+LIBCOMPATWMAKEENV+= BUILD_TOOLS_META=.NOMETA_CMP
+.endif
LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \
CXX="${XCXX} ${LIBCOMPATCFLAGS} ${LIBCOMPATCXXFLAGS}" \
+ CPP="${XCPP} ${LIBCOMPATCFLAGS}" \
DESTDIR=${LIBCOMPATTMP} \
-DNO_CPU_CFLAGS \
MK_CTF=no \
diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index 5f29f4b..d1cfd7f 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -1732,7 +1732,6 @@ OLD_FILES+=usr/share/man/man4/lindev.4.gz
# 20140425
OLD_FILES+=usr/lib/libssp_p.a
OLD_FILES+=usr/lib/libstand_p.a
-OLD_FILES+=usr/lib32/libc_pic.a
OLD_FILES+=usr/lib32/libssp_p.a
OLD_FILES+=usr/lib32/libstand_p.a
# 20140314: AppleTalk
diff --git a/UPDATING b/UPDATING
index 2e4c37b..dcff315 100644
--- a/UPDATING
+++ b/UPDATING
@@ -31,6 +31,33 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 11.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
+20160414:
+ The CAM I/O scheduler has been committed to the kernel. There should be
+ no user visible impact. This does enable NCQ Trim on ada SSDs. While the
+ list of known rogues that claim support for this but actually corrupt
+ data is believed to be complete, be on the lookout for data
+ corruption. The known rogue list is believed to be complete:
+
+ o Crucial MX100, M550 drives with MU01 firmware.
+ o Micron M510 and M550 drives with MU01 firmware.
+ o Micron M500 prior to MU07 firmware
+ o Samsung 830, 840, and 850 all firmwares
+ o FCCT M500 all firmwares
+
+ Crucial has firmware http://www.crucial.com/usa/en/support-ssd-firmware
+ with working NCQ TRIM. For Micron branded drives, see your sales rep for
+ updated firmware. Black listed drives will work correctly because these
+ drives work correctly so long as no NCQ TRIMs are sent to them. Given
+ this list is the same as found in Linux, it's believed there are no
+ other rogues in the market place. All other models from the above
+ vendors work.
+
+ To be safe, if you are at all concerned, you can quirk each of your
+ drives to prevent NCQ from being sent by setting:
+ kern.cam.ada.X.quirks="0x2"
+ in loader.conf. If the drive requires the 4k sector quirk, set the
+ quirks entry to 0x3.
+
20160330:
The FAST_DEPEND build option has been removed and its functionality is
now the one true way. The old mkdep(1) style of 'make depend' has
diff --git a/bin/csh/Makefile b/bin/csh/Makefile
index aa3b83b..6e3c32d 100644
--- a/bin/csh/Makefile
+++ b/bin/csh/Makefile
@@ -110,7 +110,7 @@ csh.1: tcsh.man
build-tools: gethost
-gethost: gethost.c sh.err.h tc.const.h sh.h
+gethost: gethost.c sh.err.h tc.const.h sh.h ${BUILD_TOOLS_META}
@rm -f ${.TARGET}
${CC} -o gethost ${LDFLAGS} ${CFLAGS:C/-DHAVE_ICONV//} \
${TCSHDIR}/gethost.c
diff --git a/bin/sh/Makefile b/bin/sh/Makefile
index 419ff79..d3422b4 100644
--- a/bin/sh/Makefile
+++ b/bin/sh/Makefile
@@ -45,10 +45,10 @@ builtins.c builtins.h: mkbuiltins builtins.def
# XXX this is just to stop the default .c rule being used, so that the
# intermediate object has a fixed name.
# XXX we have a default .c rule, but no default .o rule.
-.o:
+mknodes.o mksyntax.o: ${BUILD_TOOLS_META}
${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
-mknodes: mknodes.o
-mksyntax: mksyntax.o
+mknodes: mknodes.o ${BUILD_TOOLS_META}
+mksyntax: mksyntax.o ${BUILD_TOOLS_META}
.ORDER: nodes.c nodes.h
nodes.c nodes.h: mknodes nodetypes nodes.c.pat
diff --git a/bin/sh/parser.c b/bin/sh/parser.c
index 3f9732c..e72a6f1 100644
--- a/bin/sh/parser.c
+++ b/bin/sh/parser.c
@@ -1616,7 +1616,6 @@ parsesub: {
int flags;
char *p;
static const char types[] = "}-+?=";
- int bracketed_name = 0; /* used to handle ${[0-9]*} variables */
int linno;
int length;
int c1;
@@ -1640,7 +1639,6 @@ parsesub: {
subtype = VSNORMAL;
flags = 0;
if (c == '{') {
- bracketed_name = 1;
c = pgetc_linecont();
subtype = 0;
}
@@ -1665,7 +1663,7 @@ varname:
flags |= VSLINENO;
}
} else if (is_digit(c)) {
- if (bracketed_name) {
+ if (subtype != VSNORMAL) {
do {
STPUTC(c, out);
c = pgetc_linecont();
diff --git a/cddl/lib/libdtrace/tcp.d b/cddl/lib/libdtrace/tcp.d
index ec73503..9b27076 100644
--- a/cddl/lib/libdtrace/tcp.d
+++ b/cddl/lib/libdtrace/tcp.d
@@ -108,16 +108,16 @@ typedef struct tcpsinfo {
uint32_t tcps_snxt; /* next sequence # to send */
uint32_t tcps_rack; /* sequence # we have acked */
uint32_t tcps_rnxt; /* next sequence # expected */
- uint32_t tcps_swnd; /* send window size */
+ u_long tcps_swnd; /* send window size */
int32_t tcps_snd_ws; /* send window scaling */
uint32_t tcps_swl1; /* window update seg seq number */
uint32_t tcps_swl2; /* window update seg ack number */
uint32_t tcps_rup; /* receive urgent pointer */
uint32_t tcps_radv; /* advertised window */
- uint32_t tcps_rwnd; /* receive window size */
+ u_long tcps_rwnd; /* receive window size */
int32_t tcps_rcv_ws; /* receive window scaling */
- uint32_t tcps_cwnd; /* congestion window */
- uint32_t tcps_cwnd_ssthresh; /* threshold for congestion avoidance */
+ u_long tcps_cwnd; /* congestion window */
+ u_long tcps_cwnd_ssthresh; /* threshold for congestion avoidance */
uint32_t tcps_srecover; /* for use in NewReno Fast Recovery */
uint32_t tcps_sack_fack; /* SACK sequence # we have acked */
uint32_t tcps_sack_snxt; /* next SACK seq # for retransmission */
diff --git a/contrib/elftoolchain/elfcopy/sections.c b/contrib/elftoolchain/elfcopy/sections.c
index 5848eab..1434138 100644
--- a/contrib/elftoolchain/elfcopy/sections.c
+++ b/contrib/elftoolchain/elfcopy/sections.c
@@ -343,7 +343,7 @@ create_scn(struct elfcopy *ecp)
GElf_Shdr ish;
size_t indx;
uint64_t oldndx, newndx;
- int elferr, sec_flags;
+ int elferr, sec_flags, reorder;
/*
* Insert a pseudo section that contains the ELF header
@@ -367,6 +367,7 @@ create_scn(struct elfcopy *ecp)
errx(EXIT_FAILURE, "elf_getshstrndx failed: %s",
elf_errmsg(-1));
+ reorder = 0;
is = NULL;
while ((is = elf_nextscn(ecp->ein, is)) != NULL) {
if (gelf_getshdr(is, &ish) == NULL)
@@ -482,8 +483,20 @@ create_scn(struct elfcopy *ecp)
/* create section header based on input object. */
if (strcmp(name, ".symtab") != 0 &&
strcmp(name, ".strtab") != 0 &&
- strcmp(name, ".shstrtab") != 0)
+ strcmp(name, ".shstrtab") != 0) {
copy_shdr(ecp, s, NULL, 0, sec_flags);
+ /*
+ * elfcopy puts .symtab, .strtab and .shstrtab
+ * sections in the end of the output object.
+ * If the input objects have more sections
+ * after any of these 3 sections, the section
+ * table will be reordered. section symbols
+ * should be regenerated for relocations.
+ */
+ if (reorder)
+ ecp->flags &= ~SYMTAB_INTACT;
+ } else
+ reorder = 1;
if (strcmp(name, ".symtab") == 0) {
ecp->flags |= SYMTAB_EXIST;
diff --git a/contrib/ipfilter/bpf_filter.c b/contrib/ipfilter/bpf_filter.c
index d75570e..bd46576 100644
--- a/contrib/ipfilter/bpf_filter.c
+++ b/contrib/ipfilter/bpf_filter.c
@@ -132,7 +132,7 @@ m_xword(m, k, err)
return EXTRACT_LONG(cp);
}
m0 = m->m_next;
- if (m0 == 0 || M_LEN(m0) + len - k < 4)
+ if (m0 == NULL || M_LEN(m0) + len - k < 4)
goto bad;
*err = 0;
np = MTOD(m0, u_char *);
@@ -168,7 +168,7 @@ m_xhalf(m, k, err)
return EXTRACT_SHORT(cp);
}
m0 = m->m_next;
- if (m0 == 0)
+ if (m0 == NULL)
goto bad;
*err = 0;
return (cp[0] << 8) | MTOD(m0, u_char *)[0];
@@ -205,7 +205,7 @@ bpf_filter(pc, p, wirelen, buflen)
} else
m = NULL;
- if (pc == 0)
+ if (pc == NULL)
/*
* No filter means accept all.
*/
diff --git a/contrib/ipfilter/mli_ipl.c b/contrib/ipfilter/mli_ipl.c
index 2a0024c..ccedf76 100644
--- a/contrib/ipfilter/mli_ipl.c
+++ b/contrib/ipfilter/mli_ipl.c
@@ -64,9 +64,9 @@ ipfrwlock_t ipf_global, ipf_mutex, ipf_ipidfrag, ipf_frcache, ipf_tokens;
int (*ipf_checkp) __P((struct ip *, int, void *, int, mb_t **));
#ifdef IPFILTER_LKM
-static int *ipff_addr = 0;
+static int *ipff_addr;
static int ipff_value;
-static __psunsigned_t *ipfk_addr = 0;
+static __psunsigned_t *ipfk_addr;
static __psunsigned_t ipfk_code[4];
#endif
static void nifattach();
@@ -85,7 +85,7 @@ typedef struct nif {
int nf_unit;
} nif_t;
-static nif_t *nif_head = 0;
+static nif_t *nif_head;
static int nif_interfaces = 0;
extern int in_interfaces;
#if IRIX >= 60500
diff --git a/contrib/libpcap/pcap-snf.c b/contrib/libpcap/pcap-snf.c
index ee6ffa4..b8025ba 100644
--- a/contrib/libpcap/pcap-snf.c
+++ b/contrib/libpcap/pcap-snf.c
@@ -57,10 +57,11 @@ snf_pcap_stats(pcap_t *p, struct pcap_stat *ps)
static void
snf_platform_cleanup(pcap_t *p)
{
- struct pcap_snf *ps = p->priv;
+ struct pcap_snf *ps;
if (p == NULL)
return;
+ ps = p->priv;
snf_ring_close(ps->snf_ring);
snf_close(ps->snf_handle);
diff --git a/contrib/libxo/Makefile.am b/contrib/libxo/Makefile.am
index e050bc4..cb71d52 100644
--- a/contrib/libxo/Makefile.am
+++ b/contrib/libxo/Makefile.am
@@ -77,6 +77,7 @@ GH_PAGES_PACKAGE_DIR = ${GH_PAGES_DIR}/${GH_PACKAGING_DIR}
packages:
@-[ -d ${GH_PAGES_DIR} ] && set -x \
&& echo "Updating packages on gh-pages ..." \
+ && mkdir -p ${GH_PAGES_DIR}/${GH_PACKAGING_DIR} \
&& SHA1="`openssl sha1 ${PACKAGE_FILE} | awk '{print $$2}'`" \
&& SHA256="`openssl sha256 ${PACKAGE_FILE} | awk '{print $$2}'`" \
&& SIZE="`ls -l ${PACKAGE_FILE} | awk '{print $$5}'`" \
diff --git a/contrib/libxo/configure.ac b/contrib/libxo/configure.ac
index e7bc61d..d1db438 100644
--- a/contrib/libxo/configure.ac
+++ b/contrib/libxo/configure.ac
@@ -12,7 +12,7 @@
#
AC_PREREQ(2.2)
-AC_INIT([libxo], [0.4.6], [phil@juniper.net])
+AC_INIT([libxo], [0.6.1], [phil@juniper.net])
AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability])
# Support silent build rules. Requires at least automake-1.11.
@@ -74,6 +74,7 @@ AC_CHECK_HEADERS([ctype.h errno.h stdio.h stdlib.h])
AC_CHECK_HEADERS([string.h sys/param.h unistd.h ])
AC_CHECK_HEADERS([sys/sysctl.h])
AC_CHECK_HEADERS([threads.h])
+AC_CHECK_HEADERS([monitor.h])
dnl humanize_number(3) is a great function, but it's not standard.
dnl Note Macosx has the function in libutil.a but doesn't ship the
@@ -148,10 +149,18 @@ fi
AC_SUBST(GETTEXT_CFLAGS)
AC_SUBST(GETTEXT_LIBS)
-GETTEXT_BINDIR=${GETTEXT_PREFIX}/bin
-AC_SUBST(GETTEXT_BINDIR)
GETTEXT_LIBDIR=${GETTEXT_PREFIX}/lib
AC_SUBST(GETTEXT_LIBDIR)
+if test -x ${GETTEXT_PREFIX}/bin/msgfmt ; then
+ GETTEXT_BINDIR=${GETTEXT_PREFIX}/bin
+elif test -x ${GETTEXT_PREFIX}/local/bin/msgfmt ; then
+ GETTEXT_BINDIR=${GETTEXT_PREFIX}/local/bin
+else
+ AC_MSG_NOTICE("could not find msgfmt tool")
+ # Use a (bad) fall back value
+ GETTEXT_BINDIR=${GETTEXT_PREFIX}/bin
+fi
+AC_SUBST(GETTEXT_BINDIR)
AM_CONDITIONAL([HAVE_GETTEXT], [test "$HAVE_GETTEXT" = "yes"])
@@ -287,6 +296,18 @@ if test "${LIBXO_WCWIDTH}" != "no"; then
AC_DEFINE([LIBXO_WCWIDTH], [1], [Enable local wcwidth implementation])
fi
+AC_MSG_CHECKING([retain hash bucket size])
+AC_ARG_WITH(retain-size,
+ [ --with-retain-size=[DIR] Specify retain hash bucket size (in bits)],
+ [XO_RETAIN_SIZE=$withval],
+ [XO_RETAIN_SIZE=default]
+)
+
+AC_MSG_RESULT([$XO_RETAIN_SIZE])
+if test "${XO_RETAIN_SIZE}" != "default"; then
+ AC_DEFINE_UNQUOTED([XO_RETAIN_SIZE], ${XO_RETAIN_SIZE}, [Retain hash bucket size])
+fi
+
AC_CHECK_LIB([m], [lrint])
AM_CONDITIONAL([HAVE_LIBM], [test "$HAVE_LIBM" != "no"])
@@ -347,12 +368,15 @@ XO_SRCDIR=${srcdir}
XO_LIBDIR=${libdir}
XO_BINDIR=${bindir}
XO_INCLUDEDIR=${includedir}
+XO_CFLAGS="${CFLAGS}"
+AC_SUBST(XO_LIBS)
AC_SUBST(XO_SRCDIR)
AC_SUBST(XO_LIBDIR)
AC_SUBST(XO_BINDIR)
AC_SUBST(XO_INCLUDEDIR)
AC_SUBST(XO_LIBEXT)
+AC_SUBST(XO_CFLAGS)
AC_ARG_WITH(encoder-dir,
[ --with-encoder-dir=[DIR] Specify location of encoder libraries],
@@ -449,4 +473,5 @@ AC_MSG_NOTICE([summary of build options:
isthreaded: ${HAVE_ISTHREADED:-no}
thread-local: ${THREAD_LOCAL:-no}
local wcwidth: ${LIBXO_WCWIDTH:-no}
+ retain size: ${XO_RETAIN_SIZE:-no}
])
diff --git a/contrib/libxo/doc/libxo-manual.html b/contrib/libxo/doc/libxo-manual.html
index bc4463d..4db374b 100644
--- a/contrib/libxo/doc/libxo-manual.html
+++ b/contrib/libxo/doc/libxo-manual.html
@@ -515,7 +515,7 @@ li.indline1 {
}
@top-right {
- content: "August 2015";
+ content: "April 2016";
}
@top-center {
@@ -22009,7 +22009,7 @@ jQuery(function ($) {
</tr>
<tr>
<td class="header left"></td>
-<td class="header right">August 24, 2015</td>
+<td class="header right">April 15, 2016</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>
@@ -22130,46 +22130,54 @@ jQuery(function ($) {
<a href="#field-modifiers">Field Modifiers</a><ul class="toc">
<li class="tocline1">
<div class="section-number" id="toc_doc_section_2_2_2_1">2.2.2.1   </div>
-<a href="#the-colon-modifier-c">The Colon Modifier ({c:})</a>
+<a href="#the-argument-modifier-a">The Argument Modifier ({a:})</a>
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_2_2_2_2">2.2.2.2   </div>
-<a href="#the-display-modifier-d">The Display Modifier ({d:})</a>
+<a href="#the-colon-modifier-c">The Colon Modifier ({c:})</a>
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_2_2_2_3">2.2.2.3   </div>
-<a href="#e-modifier">The Encoding Modifier ({e:})</a>
+<a href="#the-display-modifier-d">The Display Modifier ({d:})</a>
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_2_2_2_4">2.2.2.4   </div>
-<a href="#gettext-modifier">The Gettext Modifier ({g:})</a>
+<a href="#e-modifier">The Encoding Modifier ({e:})</a>
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_2_2_2_5">2.2.2.5   </div>
-<a href="#the-humanize-modifier-h">The Humanize Modifier ({h:})</a>
+<a href="#gettext-modifier">The Gettext Modifier ({g:})</a>
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_2_2_2_6">2.2.2.6   </div>
-<a href="#the-key-modifier-k">The Key Modifier ({k:})</a>
+<a href="#the-humanize-modifier-h">The Humanize Modifier ({h:})</a>
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_2_2_2_7">2.2.2.7   </div>
-<a href="#the-leaf-list-modifier-l">The Leaf-List Modifier ({l:})</a>
+<a href="#the-key-modifier-k">The Key Modifier ({k:})</a>
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_2_2_2_8">2.2.2.8   </div>
-<a href="#the-no-quotes-modifier-n">The No-Quotes Modifier ({n:})</a>
+<a href="#the-leaf-list-modifier-l">The Leaf-List Modifier ({l:})</a>
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_2_2_2_9">2.2.2.9   </div>
-<a href="#plural-modifier">The Plural Modifier ({p:})</a>
+<a href="#the-no-quotes-modifier-n">The No-Quotes Modifier ({n:})</a>
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_2_2_2_10">2.2.2.10   </div>
-<a href="#the-quotes-modifier-q">The Quotes Modifier ({q:})</a>
+<a href="#plural-modifier">The Plural Modifier ({p:})</a>
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_2_2_2_11">2.2.2.11   </div>
+<a href="#the-quotes-modifier-q">The Quotes Modifier ({q:})</a>
+</li>
+<li class="tocline1">
+<div class="section-number" id="toc_doc_section_2_2_2_12">2.2.2.12   </div>
+<a href="#the-trim-modifier-t">The Trim Modifier ({t:})</a>
+</li>
+<li class="tocline1">
+<div class="section-number" id="toc_doc_section_2_2_2_13">2.2.2.13   </div>
<a href="#the-white-space-modifier-w">The White Space Modifier ({w:})</a>
</li>
</ul>
@@ -22208,42 +22216,38 @@ jQuery(function ($) {
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_2_2_11">2.2.11   </div>
+<a href="#retain">Retaining Parsed Format Information</a>
+</li>
+<li class="tocline1">
+<div class="section-number" id="toc_doc_section_2_2_12">2.2.12   </div>
<a href="#example">Example</a>
</li>
</ul>
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_2_3">2.3   </div>
-<a href="#command-line-arguments">Command-line Arguments</a>
-</li>
-<li class="tocline1">
-<div class="section-number" id="toc_doc_section_2_4">2.4   </div>
<a href="#representing-hierarchy">Representing Hierarchy</a><ul class="toc">
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_2_4_1">2.4.1   </div>
+<div class="section-number" id="toc_doc_section_2_3_1">2.3.1   </div>
<a href="#containers">Containers</a>
</li>
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_2_4_2">2.4.2   </div>
+<div class="section-number" id="toc_doc_section_2_3_2">2.3.2   </div>
<a href="#lists-and-instances">Lists and Instances</a>
</li>
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_2_4_3">2.4.3   </div>
+<div class="section-number" id="toc_doc_section_2_3_3">2.3.3   </div>
<a href="#dtrt-mode">DTRT Mode</a>
</li>
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_2_4_4">2.4.4   </div>
+<div class="section-number" id="toc_doc_section_2_3_4">2.3.4   </div>
<a href="#markers">Markers</a>
</li>
</ul>
</li>
<li class="tocline1">
-<div class="section-number" id="toc_doc_section_2_5">2.5   </div>
-<a href="#handles">Handles</a>
-</li>
-<li class="tocline1">
-<div class="section-number" id="toc_doc_section_2_6">2.6   </div>
-<a href="#utf-8">UTF-8</a>
+<div class="section-number" id="toc_doc_section_2_4">2.4   </div>
+<a href="#command-line-arguments">Command-line Arguments</a>
</li>
</ul>
</li>
@@ -22252,7 +22256,7 @@ jQuery(function ($) {
<a href="#the-libxo-api">The libxo API</a><ul class="toc top-toc">
<li class="tocline1">
<div class="section-number" id="toc_doc_section_3_1">3.1   </div>
-<a href="#handles-2">Handles</a><ul class="toc">
+<a href="#handles">Handles</a><ul class="toc">
<li class="tocline1">
<div class="section-number" id="toc_doc_section_3_1_1">3.1.1   </div>
<a href="#xo_create">xo_create</a>
@@ -22306,14 +22310,18 @@ jQuery(function ($) {
<a href="#emitting-content-xo_emit">Emitting Content (xo_emit)</a><ul class="toc">
<li class="tocline1">
<div class="section-number" id="toc_doc_section_3_2_1">3.2.1   </div>
-<a href="#xo_attr">Attributes (xo_attr)</a>
+<a href="#xo_emit_field">Single Field Emitting Functions (xo_emit_field)</a>
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_3_2_2">3.2.2   </div>
-<a href="#flushing-output-xo_flush">Flushing Output (xo_flush)</a>
+<a href="#xo_attr">Attributes (xo_attr)</a>
</li>
<li class="tocline1">
<div class="section-number" id="toc_doc_section_3_2_3">3.2.3   </div>
+<a href="#flushing-output-xo_flush">Flushing Output (xo_flush)</a>
+</li>
+<li class="tocline1">
+<div class="section-number" id="toc_doc_section_3_2_4">3.2.4   </div>
<a href="#finishing-output-xo_finish">Finishing Output (xo_finish)</a>
</li>
</ul>
@@ -22851,10 +22859,8 @@ jQuery(function ($) {
<ul>
<li><a href="#encoding-styles" title="Encoding Styles">Section 2.1</a></li>
<li><a href="#format-strings" title="Format Strings">Section 2.2</a></li>
-<li><a href="#command-line-arguments" title="Command-line Arguments">Section 2.3</a></li>
-<li><a href="#representing-hierarchy" title="Representing Hierarchy">Section 2.4</a></li>
-<li><a href="#handles" title="Handles">Section 2.5</a></li>
-<li><a href="#utf-8" title="UTF-8">Section 2.6</a></li>
+<li><a href="#representing-hierarchy" title="Representing Hierarchy">Section 2.3</a></li>
+<li><a href="#command-line-arguments" title="Command-line Arguments">Section 2.4</a></li>
</ul>
<div class="content">
<h2 id="doc_section_2_1">
@@ -22992,7 +22998,8 @@ jQuery(function ($) {
<li><a href="#the-encoding-format-eformat" title="The Encoding Format (eformat)">Section 2.2.8</a></li>
<li><a href="#content-strings" title="Content Strings">Section 2.2.9</a></li>
<li><a href="#printf-like" title="Argument Validation">Section 2.2.10</a></li>
-<li><a href="#example" title="Example">Section 2.2.11</a></li>
+<li><a href="#retain" title="Retaining Parsed Format Information">Section 2.2.11</a></li>
+<li><a href="#example" title="Example">Section 2.2.12</a></li>
</ul>
<div class="content">
<h3 id="doc_section_2_2_1">
@@ -23356,6 +23363,11 @@ jQuery(function ($) {
</tr></thead>
<tbody>
<tr>
+<td>a</td>
+<td>argument</td>
+<td>The content appears as a 'const char *' argument</td>
+</tr>
+<tr>
<td>c</td>
<td>colon</td>
<td>A colon (":") is appended after the label</td>
@@ -23435,87 +23447,107 @@ jQuery(function ($) {
<p id="doc_section_2_2_2_p_2">Roles and modifiers can also use more verbose names, when preceeded by a comma. For example, the modifier string "Lwc" (or "L,white,colon") means the field has a label role (text that describes the next field) and should be followed by a colon ('c') and a space ('w'). The modifier string "Vkq" (or ":key,quote") means the field has a value role (the default role), that it is a key for the current instance, and that the value should be quoted when encoded for JSON.</p>
<p id="doc_section_2_2_2_p_3">Section Contents: </p>
<ul>
-<li><a href="#the-colon-modifier-c" title="The Colon Modifier ({c:})">Section 2.2.2.1</a></li>
-<li><a href="#the-display-modifier-d" title="The Display Modifier ({d:})">Section 2.2.2.2</a></li>
-<li><a href="#e-modifier" title="The Encoding Modifier ({e:})">Section 2.2.2.3</a></li>
-<li><a href="#gettext-modifier" title="The Gettext Modifier ({g:})">Section 2.2.2.4</a></li>
-<li><a href="#the-humanize-modifier-h" title="The Humanize Modifier ({h:})">Section 2.2.2.5</a></li>
-<li><a href="#the-key-modifier-k" title="The Key Modifier ({k:})">Section 2.2.2.6</a></li>
-<li><a href="#the-leaf-list-modifier-l" title="The Leaf-List Modifier ({l:})">Section 2.2.2.7</a></li>
-<li><a href="#the-no-quotes-modifier-n" title="The No-Quotes Modifier ({n:})">Section 2.2.2.8</a></li>
-<li><a href="#plural-modifier" title="The Plural Modifier ({p:})">Section 2.2.2.9</a></li>
-<li><a href="#the-quotes-modifier-q" title="The Quotes Modifier ({q:})">Section 2.2.2.10</a></li>
-<li><a href="#the-white-space-modifier-w" title="The White Space Modifier ({w:})">Section 2.2.2.11</a></li>
+<li><a href="#the-argument-modifier-a" title="The Argument Modifier ({a:})">Section 2.2.2.1</a></li>
+<li><a href="#the-colon-modifier-c" title="The Colon Modifier ({c:})">Section 2.2.2.2</a></li>
+<li><a href="#the-display-modifier-d" title="The Display Modifier ({d:})">Section 2.2.2.3</a></li>
+<li><a href="#e-modifier" title="The Encoding Modifier ({e:})">Section 2.2.2.4</a></li>
+<li><a href="#gettext-modifier" title="The Gettext Modifier ({g:})">Section 2.2.2.5</a></li>
+<li><a href="#the-humanize-modifier-h" title="The Humanize Modifier ({h:})">Section 2.2.2.6</a></li>
+<li><a href="#the-key-modifier-k" title="The Key Modifier ({k:})">Section 2.2.2.7</a></li>
+<li><a href="#the-leaf-list-modifier-l" title="The Leaf-List Modifier ({l:})">Section 2.2.2.8</a></li>
+<li><a href="#the-no-quotes-modifier-n" title="The No-Quotes Modifier ({n:})">Section 2.2.2.9</a></li>
+<li><a href="#plural-modifier" title="The Plural Modifier ({p:})">Section 2.2.2.10</a></li>
+<li><a href="#the-quotes-modifier-q" title="The Quotes Modifier ({q:})">Section 2.2.2.11</a></li>
+<li><a href="#the-trim-modifier-t" title="The Trim Modifier ({t:})">Section 2.2.2.12</a></li>
+<li><a href="#the-white-space-modifier-w" title="The White Space Modifier ({w:})">Section 2.2.2.13</a></li>
</ul>
<div class="content">
<h4 id="doc_section_2_2_2_1">
<div class="self-section-number">
<a href="#doc_section_2_2_2_1">2.2.2.1</a> </div>
-<a id="the-colon-modifier-c" href="#the-colon-modifier-c">The Colon Modifier ({c:})</a>
+<a id="the-argument-modifier-a" href="#the-argument-modifier-a">The Argument Modifier ({a:})</a>
</h4>
-<p id="doc_section_2_2_2_1_p_1">The colon modifier appends a single colon to the data value:</p>
+<p id="doc_section_2_2_2_1_p_1">The argument modifier indicates that the content of the field descriptor will be placed as a UTF-8 string (const char *) argument within the xo_emit parameters.</p>
<div id="doc_figure_u.48"></div> <pre>
EXAMPLE:
- xo_emit("{Lc:Name}{:name}\n", "phil");
+ xo_emit("{La:} {a:}\n", "Label text", "label", "value");
TEXT:
- Name:phil
- </pre> <p id="doc_section_2_2_2_1_p_3">The colon modifier is only used for the TEXT and HTML output styles. It is commonly combined with the space modifier ('{w:}'). It is purely a convenience feature.</p>
+ Label text value
+ JSON:
+ "label": "value"
+ XML:
+ &lt;label&gt;value&lt;/label&gt;
+ </pre> <p id="doc_section_2_2_2_1_p_3">The argument modifier allows field names for value fields to be passed on the stack, avoiding the need to build a field descriptor using snprintf. For many field roles, the argument modifier is not needed, since those roles have specific mechanisms for arguments, such as "{C:fg&#8209;%s}".</p>
</div>
<div class="content">
<h4 id="doc_section_2_2_2_2">
<div class="self-section-number">
<a href="#doc_section_2_2_2_2">2.2.2.2</a> </div>
-<a id="the-display-modifier-d" href="#the-display-modifier-d">The Display Modifier ({d:})</a>
+<a id="the-colon-modifier-c" href="#the-colon-modifier-c">The Colon Modifier ({c:})</a>
</h4>
-<p id="doc_section_2_2_2_2_p_1">The display modifier indicated the field should only be generated for the display output styles, TEXT and HTML.</p>
+<p id="doc_section_2_2_2_2_p_1">The colon modifier appends a single colon to the data value:</p>
<div id="doc_figure_u.49"></div> <pre>
EXAMPLE:
+ xo_emit("{Lc:Name}{:name}\n", "phil");
+ TEXT:
+ Name:phil
+ </pre> <p id="doc_section_2_2_2_2_p_3">The colon modifier is only used for the TEXT and HTML output styles. It is commonly combined with the space modifier ('{w:}'). It is purely a convenience feature.</p>
+</div>
+<div class="content">
+<h4 id="doc_section_2_2_2_3">
+<div class="self-section-number">
+<a href="#doc_section_2_2_2_3">2.2.2.3</a> </div>
+<a id="the-display-modifier-d" href="#the-display-modifier-d">The Display Modifier ({d:})</a>
+</h4>
+<p id="doc_section_2_2_2_3_p_1">The display modifier indicated the field should only be generated for the display output styles, TEXT and HTML.</p>
+<div id="doc_figure_u.50"></div> <pre>
+ EXAMPLE:
xo_emit("{Lcw:Name}{d:name} {:id/%d}\n", "phil", 1);
TEXT:
Name: phil 1
XML:
&lt;id&gt;1&lt;/id&gt;
- </pre> <p id="doc_section_2_2_2_2_p_3">The display modifier is the opposite of the encoding modifier, and they are often used to give to distinct views of the underlying data.</p>
+ </pre> <p id="doc_section_2_2_2_3_p_3">The display modifier is the opposite of the encoding modifier, and they are often used to give to distinct views of the underlying data.</p>
</div>
<div class="content">
-<h4 id="doc_section_2_2_2_3">
+<h4 id="doc_section_2_2_2_4">
<div class="self-section-number">
-<a href="#doc_section_2_2_2_3">2.2.2.3</a> </div>
+<a href="#doc_section_2_2_2_4">2.2.2.4</a> </div>
<a id="e-modifier" href="#e-modifier">The Encoding Modifier ({e:})</a>
</h4>
-<p id="doc_section_2_2_2_3_p_1">The display modifier indicated the field should only be generated for the display output styles, TEXT and HTML.</p>
-<div id="doc_figure_u.50"></div> <pre>
+<p id="doc_section_2_2_2_4_p_1">The display modifier indicated the field should only be generated for the display output styles, TEXT and HTML.</p>
+<div id="doc_figure_u.51"></div> <pre>
EXAMPLE:
xo_emit("{Lcw:Name}{:name} {e:id/%d}\n", "phil", 1);
TEXT:
Name: phil
XML:
&lt;name&gt;phil&lt;/name&gt;&lt;id&gt;1&lt;/id&gt;
- </pre> <p id="doc_section_2_2_2_3_p_3">The encoding modifier is the opposite of the display modifier, and they are often used to give to distinct views of the underlying data.</p>
+ </pre> <p id="doc_section_2_2_2_4_p_3">The encoding modifier is the opposite of the display modifier, and they are often used to give to distinct views of the underlying data.</p>
</div>
<div class="content">
-<h4 id="doc_section_2_2_2_4">
+<h4 id="doc_section_2_2_2_5">
<div class="self-section-number">
-<a href="#doc_section_2_2_2_4">2.2.2.4</a> </div>
+<a href="#doc_section_2_2_2_5">2.2.2.5</a> </div>
<a id="gettext-modifier" href="#gettext-modifier">The Gettext Modifier ({g:})</a>
</h4>
-<p id="doc_section_2_2_2_4_p_1">The gettext modifier is used to translate individual fields using the gettext domain (typically set using the "{G:}" role) and current language settings. Once libxo renders the field value, it is passed to gettext(3), where it is used as a key to find the native language translation.</p>
-<p id="doc_section_2_2_2_4_p_2">In the following example, the strings "State" and "full" are passed to gettext() to find locale-based translated strings.</p>
-<div id="doc_figure_u.51"></div> <pre>
+<p id="doc_section_2_2_2_5_p_1">The gettext modifier is used to translate individual fields using the gettext domain (typically set using the "{G:}" role) and current language settings. Once libxo renders the field value, it is passed to gettext(3), where it is used as a key to find the native language translation.</p>
+<p id="doc_section_2_2_2_5_p_2">In the following example, the strings "State" and "full" are passed to gettext() to find locale-based translated strings.</p>
+<div id="doc_figure_u.52"></div> <pre>
xo_emit("{Lgwc:State}{g:state}\n", "full");
- </pre> <p id="doc_section_2_2_2_4_p_4">See <a href="#gettext-role" title="The Gettext Role ({G:})">Section 2.2.1.3</a>, <a href="#plural-modifier" title="The Plural Modifier ({p:})">Section 2.2.2.9</a>, and <a href="#howto-i18n" title="Howto: Internationalization (i18n)">Section 9.5</a> for additional details.</p>
+ </pre> <p id="doc_section_2_2_2_5_p_4">See <a href="#gettext-role" title="The Gettext Role ({G:})">Section 2.2.1.3</a>, <a href="#plural-modifier" title="The Plural Modifier ({p:})">Section 2.2.2.10</a>, and <a href="#howto-i18n" title="Howto: Internationalization (i18n)">Section 9.5</a> for additional details.</p>
</div>
<div class="content">
-<h4 id="doc_section_2_2_2_5">
+<h4 id="doc_section_2_2_2_6">
<div class="self-section-number">
-<a href="#doc_section_2_2_2_5">2.2.2.5</a> </div>
+<a href="#doc_section_2_2_2_6">2.2.2.6</a> </div>
<a id="the-humanize-modifier-h" href="#the-humanize-modifier-h">The Humanize Modifier ({h:})</a>
</h4>
-<p id="doc_section_2_2_2_5_p_1">The humanize modifier is used to render large numbers as in a human-readable format. While numbers like "44470272" are completely readable to computers and savants, humans will generally find "44M" more meaningful.</p>
-<p id="doc_section_2_2_2_5_p_2">"hn" can be used as an alias for "humanize".</p>
-<p id="doc_section_2_2_2_5_p_3">The humanize modifier only affects display styles (TEXT and HMTL). The "no&#8209;humanize" option (See <a href="#LIBXO_OPTIONS" title="LIBXO_OPTIONS">Section 3.4.6</a>) will block the function of the humanize modifier.</p>
-<p id="doc_section_2_2_2_5_p_4">There are a number of modifiers that affect details of humanization. These are only available in as full names, not single characters. The "hn&#8209;space" modifier places a space between the number and any multiplier symbol, such as "M" or "K" (ex: "44 K"). The "hn&#8209;decimal" modifier will add a decimal point and a single tenths digit when the number is less than 10 (ex: "4.4K"). The "hn&#8209;1000" modifier will use 1000 as divisor instead of 1024, following the JEDEC-standard instead of the more natural binary powers-of-two tradition.</p>
-<div id="doc_figure_u.52"></div> <pre>
+<p id="doc_section_2_2_2_6_p_1">The humanize modifier is used to render large numbers as in a human-readable format. While numbers like "44470272" are completely readable to computers and savants, humans will generally find "44M" more meaningful.</p>
+<p id="doc_section_2_2_2_6_p_2">"hn" can be used as an alias for "humanize".</p>
+<p id="doc_section_2_2_2_6_p_3">The humanize modifier only affects display styles (TEXT and HMTL). The "no&#8209;humanize" option (See <a href="#LIBXO_OPTIONS" title="LIBXO_OPTIONS">Section 3.4.6</a>) will block the function of the humanize modifier.</p>
+<p id="doc_section_2_2_2_6_p_4">There are a number of modifiers that affect details of humanization. These are only available in as full names, not single characters. The "hn&#8209;space" modifier places a space between the number and any multiplier symbol, such as "M" or "K" (ex: "44 K"). The "hn&#8209;decimal" modifier will add a decimal point and a single tenths digit when the number is less than 10 (ex: "4.4K"). The "hn&#8209;1000" modifier will use 1000 as divisor instead of 1024, following the JEDEC-standard instead of the more natural binary powers-of-two tradition.</p>
+<div id="doc_figure_u.53"></div> <pre>
EXAMPLE:
xo_emit("{h:input/%u}, {h,hn-space:output/%u}, "
"{h,hn-decimal:errors/%u}, {h,hn-1000:capacity/%u}, "
@@ -23523,19 +23555,19 @@ jQuery(function ($) {
input, output, errors, capacity, remaining);
TEXT:
21, 57 K, 96M, 44M, 1.2G
- </pre> <p id="doc_section_2_2_2_5_p_6">In the HTML style, the original numeric value is rendered in the "data&#8209;number" attribute on the &lt;div&gt; element:</p>
-<div id="doc_figure_u.53"></div> <pre>
+ </pre> <p id="doc_section_2_2_2_6_p_6">In the HTML style, the original numeric value is rendered in the "data&#8209;number" attribute on the &lt;div&gt; element:</p>
+<div id="doc_figure_u.54"></div> <pre>
&lt;div class="data" data-tag="errors"
data-number="100663296"&gt;96M&lt;/div&gt;
</pre> </div>
<div class="content">
-<h4 id="doc_section_2_2_2_6">
+<h4 id="doc_section_2_2_2_7">
<div class="self-section-number">
-<a href="#doc_section_2_2_2_6">2.2.2.6</a> </div>
+<a href="#doc_section_2_2_2_7">2.2.2.7</a> </div>
<a id="the-key-modifier-k" href="#the-key-modifier-k">The Key Modifier ({k:})</a>
</h4>
-<p id="doc_section_2_2_2_6_p_1">The key modifier is used to indicate that a particular field helps uniquely identify an instance of list data.</p>
-<div id="doc_figure_u.54"></div> <pre>
+<p id="doc_section_2_2_2_7_p_1">The key modifier is used to indicate that a particular field helps uniquely identify an instance of list data.</p>
+<div id="doc_figure_u.55"></div> <pre>
EXAMPLE:
xo_open_list("user");
for (i = 0; i &lt; num_users; i++) {
@@ -23545,16 +23577,16 @@ jQuery(function ($) {
xo_close_instance("user");
}
xo_close_list("user");
- </pre> <p id="doc_section_2_2_2_6_p_3">Currently the key modifier is only used when generating XPath value for the HTML output style when XOF_XPATH is set, but other uses are likely in the near future.</p>
+ </pre> <p id="doc_section_2_2_2_7_p_3">Currently the key modifier is only used when generating XPath value for the HTML output style when XOF_XPATH is set, but other uses are likely in the near future.</p>
</div>
<div class="content">
-<h4 id="doc_section_2_2_2_7">
+<h4 id="doc_section_2_2_2_8">
<div class="self-section-number">
-<a href="#doc_section_2_2_2_7">2.2.2.7</a> </div>
+<a href="#doc_section_2_2_2_8">2.2.2.8</a> </div>
<a id="the-leaf-list-modifier-l" href="#the-leaf-list-modifier-l">The Leaf-List Modifier ({l:})</a>
</h4>
-<p id="doc_section_2_2_2_7_p_1">The leaf-list modifier is used to distinguish lists where each instance consists of only a single value. In XML, these are rendered as single elements, where JSON renders them as arrays.</p>
-<div id="doc_figure_u.55"></div> <pre>
+<p id="doc_section_2_2_2_8_p_1">The leaf-list modifier is used to distinguish lists where each instance consists of only a single value. In XML, these are rendered as single elements, where JSON renders them as arrays.</p>
+<div id="doc_figure_u.56"></div> <pre>
EXAMPLE:
for (i = 0; i &lt; num_users; i++) {
xo_emit("Member {l:user}\n", user[i].u_name);
@@ -23564,16 +23596,16 @@ jQuery(function ($) {
&lt;user&gt;pallavi&lt;/user&gt;
JSON:
"user": [ "phil", "pallavi" ]
- </pre> <p id="doc_section_2_2_2_7_p_3">The name of the field must match the name of the leaf list.</p>
+ </pre> <p id="doc_section_2_2_2_8_p_3">The name of the field must match the name of the leaf list.</p>
</div>
<div class="content">
-<h4 id="doc_section_2_2_2_8">
+<h4 id="doc_section_2_2_2_9">
<div class="self-section-number">
-<a href="#doc_section_2_2_2_8">2.2.2.8</a> </div>
+<a href="#doc_section_2_2_2_9">2.2.2.9</a> </div>
<a id="the-no-quotes-modifier-n" href="#the-no-quotes-modifier-n">The No-Quotes Modifier ({n:})</a>
</h4>
-<p id="doc_section_2_2_2_8_p_1">The no-quotes modifier (and its twin, the 'quotes' modifier) affect the quoting of values in the JSON output style. JSON uses quotes for string value, but no quotes for numeric, boolean, and null data. xo_emit applies a simple heuristic to determine whether quotes are needed, but often this needs to be controlled by the caller.</p>
-<div id="doc_figure_u.56"></div> <pre>
+<p id="doc_section_2_2_2_9_p_1">The no-quotes modifier (and its twin, the 'quotes' modifier) affect the quoting of values in the JSON output style. JSON uses quotes for string value, but no quotes for numeric, boolean, and null data. xo_emit applies a simple heuristic to determine whether quotes are needed, but often this needs to be controlled by the caller.</p>
+<div id="doc_figure_u.57"></div> <pre>
EXAMPLE:
const char *bool = is_true ? "true" : "false";
xo_emit("{n:fancy/%s}", bool);
@@ -23581,45 +23613,61 @@ jQuery(function ($) {
"fancy": true
</pre> </div>
<div class="content">
-<h4 id="doc_section_2_2_2_9">
+<h4 id="doc_section_2_2_2_10">
<div class="self-section-number">
-<a href="#doc_section_2_2_2_9">2.2.2.9</a> </div>
+<a href="#doc_section_2_2_2_10">2.2.2.10</a> </div>
<a id="plural-modifier" href="#plural-modifier">The Plural Modifier ({p:})</a>
</h4>
-<p id="doc_section_2_2_2_9_p_1">The plural modifier selects the appropriate plural form of an expression based on the most recent number emitted and the current language settings. The contents of the field should be the singular and plural English values, separated by a comma:</p>
-<div id="doc_figure_u.57"></div> <pre>
+<p id="doc_section_2_2_2_10_p_1">The plural modifier selects the appropriate plural form of an expression based on the most recent number emitted and the current language settings. The contents of the field should be the singular and plural English values, separated by a comma:</p>
+<div id="doc_figure_u.58"></div> <pre>
xo_emit("{:bytes} {Ngp:byte,bytes}\n", bytes);
- </pre> <p id="doc_section_2_2_2_9_p_3">The plural modifier is meant to work with the gettext modifier ({g:}) but can work independently. See <a href="#gettext-modifier" title="The Gettext Modifier ({g:})">Section 2.2.2.4</a>.</p>
-<p id="doc_section_2_2_2_9_p_4">When used without the gettext modifier or when the message does not appear in the message catalog, the first token is chosen when the last numeric value is equal to 1; otherwise the second value is used, mimicking the simple pluralization rules of English.</p>
-<p id="doc_section_2_2_2_9_p_5">When used with the gettext modifier, the ngettext(3) function is called to handle the heavy lifting, using the message catalog to convert the singular and plural forms into the native language.</p>
+ </pre> <p id="doc_section_2_2_2_10_p_3">The plural modifier is meant to work with the gettext modifier ({g:}) but can work independently. See <a href="#gettext-modifier" title="The Gettext Modifier ({g:})">Section 2.2.2.5</a>.</p>
+<p id="doc_section_2_2_2_10_p_4">When used without the gettext modifier or when the message does not appear in the message catalog, the first token is chosen when the last numeric value is equal to 1; otherwise the second value is used, mimicking the simple pluralization rules of English.</p>
+<p id="doc_section_2_2_2_10_p_5">When used with the gettext modifier, the ngettext(3) function is called to handle the heavy lifting, using the message catalog to convert the singular and plural forms into the native language.</p>
</div>
<div class="content">
-<h4 id="doc_section_2_2_2_10">
+<h4 id="doc_section_2_2_2_11">
<div class="self-section-number">
-<a href="#doc_section_2_2_2_10">2.2.2.10</a> </div>
+<a href="#doc_section_2_2_2_11">2.2.2.11</a> </div>
<a id="the-quotes-modifier-q" href="#the-quotes-modifier-q">The Quotes Modifier ({q:})</a>
</h4>
-<p id="doc_section_2_2_2_10_p_1">The quotes modifier (and its twin, the 'no&#8209;quotes' modifier) affect the quoting of values in the JSON output style. JSON uses quotes for string value, but no quotes for numeric, boolean, and null data. xo_emit applies a simple heuristic to determine whether quotes are needed, but often this needs to be controlled by the caller.</p>
-<div id="doc_figure_u.58"></div> <pre>
+<p id="doc_section_2_2_2_11_p_1">The quotes modifier (and its twin, the 'no&#8209;quotes' modifier) affect the quoting of values in the JSON output style. JSON uses quotes for string value, but no quotes for numeric, boolean, and null data. xo_emit applies a simple heuristic to determine whether quotes are needed, but often this needs to be controlled by the caller.</p>
+<div id="doc_figure_u.59"></div> <pre>
EXAMPLE:
xo_emit("{q:time/%d}", 2014);
JSON:
"year": "2014"
+ </pre> <p id="doc_section_2_2_2_11_p_3">The heuristic is based on the format; if the format uses any of the following conversion specifiers, then no quotes are used:</p>
+<div id="doc_figure_u.60"></div> <pre>
+ d i o u x X D O U e E f F g G a A c C p
</pre> </div>
<div class="content">
-<h4 id="doc_section_2_2_2_11">
+<h4 id="doc_section_2_2_2_12">
<div class="self-section-number">
-<a href="#doc_section_2_2_2_11">2.2.2.11</a> </div>
+<a href="#doc_section_2_2_2_12">2.2.2.12</a> </div>
+<a id="the-trim-modifier-t" href="#the-trim-modifier-t">The Trim Modifier ({t:})</a>
+</h4>
+<p id="doc_section_2_2_2_12_p_1">The trim modifier removes any leading or trailing whitespace from the value.</p>
+<div id="doc_figure_u.61"></div> <pre>
+ EXAMPLE:
+ xo_emit("{t:description}", " some input ");
+ JSON:
+ "description": "some input"
+ </pre> </div>
+<div class="content">
+<h4 id="doc_section_2_2_2_13">
+<div class="self-section-number">
+<a href="#doc_section_2_2_2_13">2.2.2.13</a> </div>
<a id="the-white-space-modifier-w" href="#the-white-space-modifier-w">The White Space Modifier ({w:})</a>
</h4>
-<p id="doc_section_2_2_2_11_p_1">The white space modifier appends a single space to the data value:</p>
-<div id="doc_figure_u.59"></div> <pre>
+<p id="doc_section_2_2_2_13_p_1">The white space modifier appends a single space to the data value:</p>
+<div id="doc_figure_u.62"></div> <pre>
EXAMPLE:
xo_emit("{Lw:Name}{:name}\n", "phil");
TEXT:
Name phil
- </pre> <p id="doc_section_2_2_2_11_p_3">The white space modifier is only used for the TEXT and HTML output styles. It is commonly combined with the colon modifier ('{c:}'). It is purely a convenience feature.</p>
-<p id="doc_section_2_2_2_11_p_4">Note that the sense of the 'w' modifier is reversed for the units role ({Uw:}); a blank is added before the contents, rather than after it.</p>
+ </pre> <p id="doc_section_2_2_2_13_p_3">The white space modifier is only used for the TEXT and HTML output styles. It is commonly combined with the colon modifier ('{c:}'). It is purely a convenience feature.</p>
+<p id="doc_section_2_2_2_13_p_4">Note that the sense of the 'w' modifier is reversed for the units role ({Uw:}); a blank is added before the contents, rather than after it.</p>
</div>
</div>
<div class="content">
@@ -23632,7 +23680,7 @@ jQuery(function ($) {
<p id="doc_section_2_2_3_p_2">If the format string is not provided for a value field, it defaults to "%s".</p>
<p id="doc_section_2_2_3_p_3">Note a field definition can contain zero or more printf-style 'directives', which are sequences that start with a '%' and end with one of following characters: "diouxXDOUeEfFgGaAcCsSp". Each directive is matched by one of more arguments to the xo_emit function.</p>
<p id="doc_section_2_2_3_p_4">The format string has the form:</p>
-<div id="doc_figure_u.60"></div> <pre>
+<div id="doc_figure_u.63"></div> <pre>
'%' format-modifier * format-character
</pre> <p id="doc_section_2_2_3_p_6">The format- modifier can be:</p>
<p id="doc_section_2_2_3_p_7"> </p>
@@ -23829,8 +23877,42 @@ jQuery(function ($) {
<a id="utf-8-and-locale-strings" href="#utf-8-and-locale-strings">UTF-8 and Locale Strings</a>
</h3>
<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">For example, a function is passed a locale-base name, a hat size, and a time value. The hat size is formatted in a UTF-8 (ASCII) string, and the time value is formatted into a wchar_t string.</p>
-<div id="doc_figure_u.61"></div> <pre>
+<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}",
+ 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">
+<thead><tr>
+<th class="left">Format</th>
+<th class="left">Argument Type</th>
+<th class="left">Argument Contents</th>
+</tr></thead>
+<tbody>
+<tr>
+<td>%s</td>
+<td>const char *</td>
+<td>UTF-8 string</td>
+</tr>
+<tr>
+<td>%S</td>
+<td>const char *</td>
+<td>UTF-8 string (alias for '%s')</td>
+</tr>
+<tr>
+<td>%ls</td>
+<td>const wchar_t *</td>
+<td>Wide character UNICODE string</td>
+</tr>
+<tr>
+<td>%hs</td>
+<td>const char *</td>
+<td>locale-based string</td>
+</tr>
+</tbody>
+</table></div>
+<p id="doc_section_2_2_4_p_5">For example, a function is passed a locale-base name, a hat size, and a time value. The hat size is formatted in a UTF-8 (ASCII) string, and the time value is formatted into a wchar_t string.</p>
+<div id="doc_figure_u.65"></div> <pre>
void print_order (const char *name, int size,
struct tm *timep) {
char buf[32];
@@ -23849,10 +23931,10 @@ jQuery(function ($) {
xo_emit("It was ordered on {:order-time/%ls}.\n",
when);
}
- </pre> <p id="doc_section_2_2_4_p_4">It is important to note that xo_emit will perform the conversion required to make appropriate output. Text style output uses the current locale (as described above), while XML, JSON, and HTML use UTF-8.</p>
-<p id="doc_section_2_2_4_p_5">UTF-8 and locale-encoded strings can use multiple bytes to encode one column of data. The traditional "precision'" (aka "max&#8209;width") value for "%s" printf formatting becomes overloaded since it specifies both the number of bytes that can be safely referenced and the maximum number of columns to emit. xo_emit uses the precision as the former, and adds a third value for specifying the maximum number of columns.</p>
-<p id="doc_section_2_2_4_p_6">In this example, the name field is printed with a minimum of 3 columns and a maximum of 6. Up to ten bytes of data at the location given by 'name' are in used in filling those columns.</p>
-<div id="doc_figure_u.62"></div> <pre>
+ </pre> <p id="doc_section_2_2_4_p_7">It is important to note that xo_emit will perform the conversion required to make appropriate output. Text style output uses the current locale (as described above), while XML, JSON, and HTML use UTF-8.</p>
+<p id="doc_section_2_2_4_p_8">UTF-8 and locale-encoded strings can use multiple bytes to encode one column of data. The traditional "precision'" (aka "max&#8209;width") value for "%s" printf formatting becomes overloaded since it specifies both the number of bytes that can be safely referenced and the maximum number of columns to emit. xo_emit uses the precision as the former, and adds a third value for specifying the maximum number of columns.</p>
+<p id="doc_section_2_2_4_p_9">In this example, the name field is printed with a minimum of 3 columns and a maximum of 6. Up to ten bytes of data at the location given by 'name' are in used in filling those columns.</p>
+<div id="doc_figure_u.66"></div> <pre>
xo_emit("{:name/%3.10.6s}", name);
</pre> </div>
<div class="content">
@@ -23862,7 +23944,7 @@ jQuery(function ($) {
<a id="characters-outside-of-field-definitions" href="#characters-outside-of-field-definitions">Characters Outside of Field Definitions</a>
</h3>
<p id="doc_section_2_2_5_p_1">Characters in the format string that are not part of a field definition are copied to the output for the TEXT style, and are ignored for the JSON and XML styles. For HTML, these characters are placed in a &lt;div&gt; with class "text".</p>
-<div id="doc_figure_u.63"></div> <pre>
+<div id="doc_figure_u.67"></div> <pre>
EXAMPLE:
xo_emit("The hat is {:size/%s}.\n", size_val);
TEXT:
@@ -23883,7 +23965,7 @@ jQuery(function ($) {
<a id="m-is-supported" href="#m-is-supported">"%m" Is Supported</a>
</h3>
<p id="doc_section_2_2_6_p_1">libxo supports the '%m' directive, which formats the error message associated with the current value of "errno". It is the equivalent of "%s" with the argument strerror(errno).</p>
-<div id="doc_figure_u.64"></div> <pre>
+<div id="doc_figure_u.68"></div> <pre>
xo_emit("{:filename} cannot be opened: {:error/%m}", filename);
xo_emit("{:filename} cannot be opened: {:error/%s}",
filename, strerror(errno));
@@ -23930,7 +24012,7 @@ jQuery(function ($) {
<li>distinct encoding formats, where "{:tag/#%s/%s}" means the display styles (text and HTML) will use "#%s" where other styles use "%s";</li>
</ul>
<p id="doc_section_2_2_10_p_5">If none of these features are in use by your code, then using the "_p" variants might be wise.</p>
-<div id="doc_table_u.7"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
+<div id="doc_table_u.8"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Function</th>
<th class="left">printf-like Equivalent</th>
@@ -23987,14 +24069,71 @@ jQuery(function ($) {
<h3 id="doc_section_2_2_11">
<div class="self-section-number">
<a href="#doc_section_2_2_11">2.2.11</a> </div>
+<a id="retain" href="#retain">Retaining Parsed Format Information</a>
+</h3>
+<p id="doc_section_2_2_11_p_1">libxo can retain the parsed internal information related to the given format string, allowing subsequent xo_emit calls, the retained information is used, avoiding repetitive parsing of the format string.</p>
+<div id="doc_figure_u.69"></div> <pre>
+ SYNTAX:
+ int xo_emit_f(xo_emit_flags_t flags, const char fmt, ...);
+ EXAMPLE:
+ xo_emit_f(XOEF_RETAIN, "{:some/%02d}{:thing/%-6s}{:fancy}\n",
+ some, thing, fancy);
+ </pre> <p id="doc_section_2_2_11_p_3">To retain parsed format information, use the XOEF_RETAIN flag to the xo_emit_f() function. A complete set of xo_emit_f functions exist to match all the xo_emit function signatures (with handles, varadic argument, and printf-like flags):</p>
+<div id="doc_table_u.9"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
+<thead><tr>
+<th class="left">Function</th>
+<th class="left">Flags Equivalent</th>
+</tr></thead>
+<tbody>
+<tr>
+<td>xo_emit_hv</td>
+<td>xo_emit_hvf</td>
+</tr>
+<tr>
+<td>xo_emit_h</td>
+<td>xo_emit_hf</td>
+</tr>
+<tr>
+<td>xo_emit</td>
+<td>xo_emit_f</td>
+</tr>
+<tr>
+<td>xo_emit_hvp</td>
+<td>xo_emit_hvfp</td>
+</tr>
+<tr>
+<td>xo_emit_hp</td>
+<td>xo_emit_hfp</td>
+</tr>
+<tr>
+<td>xo_emit_p</td>
+<td>xo_emit_fp</td>
+</tr>
+</tbody>
+</table></div>
+<p id="doc_section_2_2_11_p_4">The format string must be immutable across multiple calls to xo_emit_f(), since the library retains the string. Typically this is done by using static constant strings, such as string literals. If the string is not immutable, the XOEF_RETAIN flag must not be used.</p>
+<p id="doc_section_2_2_11_p_5">The functions xo_retain_clear() and xo_retain_clear_all() release internal information on either a single format string or all format strings, respectively. Neither is required, but the library will retain this information until it is cleared or the process exits.</p>
+<div id="doc_figure_u.70"></div> <pre>
+ const char *fmt = "{:name} {:count/%d}\n";
+ for (i = 0; i &lt; 1000; i++) {
+ xo_open_instance("item");
+ xo_emit_f(XOEF_RETAIN, fmt, name[i], count[i]);
+ }
+ xo_retain_clear(fmt);
+ </pre> <p id="doc_section_2_2_11_p_7">The retained information is kept as thread-specific data.</p>
+</div>
+<div class="content">
+<h3 id="doc_section_2_2_12">
+<div class="self-section-number">
+<a href="#doc_section_2_2_12">2.2.12</a> </div>
<a id="example" href="#example">Example</a>
</h3>
-<p id="doc_section_2_2_11_p_1">In this example, the value for the number of items in stock is emitted:</p>
-<div id="doc_figure_u.65"></div> <pre>
+<p id="doc_section_2_2_12_p_1">In this example, the value for the number of items in stock is emitted:</p>
+<div id="doc_figure_u.71"></div> <pre>
xo_emit("{P: }{Lwc:In stock}{:in-stock/%u}\n",
instock);
- </pre> <p id="doc_section_2_2_11_p_3">This call will generate the following output:</p>
-<div id="doc_figure_u.66"></div> <pre>
+ </pre> <p id="doc_section_2_2_12_p_3">This call will generate the following output:</p>
+<div id="doc_figure_u.72"></div> <pre>
TEXT:
In stock: 144
XML:
@@ -24009,8 +24148,8 @@ jQuery(function ($) {
&lt;div class="padding"&gt; &lt;/div&gt;
&lt;div class="data" data-tag="in-stock"&gt;144&lt;/div&gt;
&lt;/div&gt;
- </pre> <p id="doc_section_2_2_11_p_5">Clearly HTML wins the verbosity award, and this output does not include XOF_XPATH or XOF_INFO data, which would expand the penultimate line to:</p>
-<div id="doc_figure_u.67"></div> <pre>
+ </pre> <p id="doc_section_2_2_12_p_5">Clearly HTML wins the verbosity award, and this output does not include XOF_XPATH or XOF_INFO data, which would expand the penultimate line to:</p>
+<div id="doc_figure_u.73"></div> <pre>
&lt;div class="data" data-tag="in-stock"
data-xpath="/top/data/item/in-stock"
data-type="number"
@@ -24021,17 +24160,148 @@ jQuery(function ($) {
<h2 id="doc_section_2_3">
<div class="self-section-number">
<a href="#doc_section_2_3">2.3</a> </div>
+<a id="representing-hierarchy" href="#representing-hierarchy">Representing Hierarchy</a>
+</h2>
+<p id="doc_section_2_3_p_1">For XML and JSON, individual fields appear inside hierarchies which provide context and meaning to the fields. Unfortunately, these encoding have a basic disconnect between how lists is similar objects are represented.</p>
+<p id="doc_section_2_3_p_2">XML encodes lists as set of sequential elements:</p>
+<div id="doc_figure_u.74"></div> <pre>
+ &lt;user&gt;phil&lt;/user&gt;
+ &lt;user&gt;pallavi&lt;/user&gt;
+ &lt;user&gt;sjg&lt;/user&gt;
+ </pre> <p id="doc_section_2_3_p_4">JSON encodes lists using a single name and square brackets:</p>
+<div id="doc_figure_u.75"></div> <pre>
+ "user": [ "phil", "pallavi", "sjg" ]
+ </pre> <p id="doc_section_2_3_p_6">This means libxo needs three distinct indications of hierarchy: one for containers of hierarchy appear only once for any specific parent, one for lists, and one for each item in a list.</p>
+<p id="doc_section_2_3_p_7">Section Contents: </p>
+<ul>
+<li><a href="#containers" title="Containers">Section 2.3.1</a></li>
+<li><a href="#lists-and-instances" title="Lists and Instances">Section 2.3.2</a></li>
+<li><a href="#dtrt-mode" title="DTRT Mode">Section 2.3.3</a></li>
+<li><a href="#markers" title="Markers">Section 2.3.4</a></li>
+</ul>
+<div class="content">
+<h3 id="doc_section_2_3_1">
+<div class="self-section-number">
+<a href="#doc_section_2_3_1">2.3.1</a> </div>
+<a id="containers" href="#containers">Containers</a>
+</h3>
+<p id="doc_section_2_3_1_p_1">A "container" is an element of a hierarchy that appears only once under any specific parent. The container has no value, but serves to contain other nodes.</p>
+<p id="doc_section_2_3_1_p_2">To open a container, call xo_open_container() or xo_open_container_h(). The former uses the default handle and the latter accepts a specific handle.</p>
+<div id="doc_figure_u.76"></div> <pre>
+ int xo_open_container_h (xo_handle_t *xop, const char *name);
+ int xo_open_container (const char *name);
+ </pre> <p id="doc_section_2_3_1_p_4">To close a level, use the xo_close_container() or xo_close_container_h() functions:</p>
+<div id="doc_figure_u.77"></div> <pre>
+ int xo_close_container_h (xo_handle_t *xop, const char *name);
+ int xo_close_container (const char *name);
+ </pre> <p id="doc_section_2_3_1_p_6">Each open call must have a matching close call. If the XOF_WARN flag is set and the name given does not match the name of the currently open container, a warning will be generated.</p>
+<div id="doc_figure_u.78"></div> <pre>
+ Example:
+
+ xo_open_container("top");
+ xo_open_container("system");
+ xo_emit("{:host-name/%s%s%s", hostname,
+ domainname ? "." : "", domainname ?: "");
+ xo_close_container("system");
+ xo_close_container("top");
+
+ Sample Output:
+ Text:
+ my-host.example.org
+ XML:
+ &lt;top&gt;
+ &lt;system&gt;
+ &lt;host-name&gt;my-host.example.org&lt;/host-name&gt;
+ &lt;/system&gt;
+ &lt;/top&gt;
+ JSON:
+ "top" : {
+ "system" : {
+ "host-name": "my-host.example.org"
+ }
+ }
+ HTML:
+ &lt;div class="data"
+ data-tag="host-name"&gt;my-host.example.org&lt;/div&gt;
+ </pre> </div>
+<div class="content">
+<h3 id="doc_section_2_3_2">
+<div class="self-section-number">
+<a href="#doc_section_2_3_2">2.3.2</a> </div>
+<a id="lists-and-instances" href="#lists-and-instances">Lists and Instances</a>
+</h3>
+<p id="doc_section_2_3_2_p_1">A list is set of one or more instances that appear under the same parent. The instances contain details about a specific object. One can think of instances as objects or records. A call is needed to open and close the list, while a distinct call is needed to open and close each instance of the list:</p>
+<div id="doc_figure_u.79"></div> <pre>
+ xo_open_list("item");
+
+ for (ip = list; ip-&gt;i_title; ip++) {
+ xo_open_instance("item");
+ xo_emit("{L:Item} '{:name/%s}':\n", ip-&gt;i_title);
+ xo_close_instance("item");
+ }
+
+ xo_close_list("item");
+ </pre> <p id="doc_section_2_3_2_p_3">Getting the list and instance calls correct is critical to the proper generation of XML and JSON data.</p>
+</div>
+<div class="content">
+<h3 id="doc_section_2_3_3">
+<div class="self-section-number">
+<a href="#doc_section_2_3_3">2.3.3</a> </div>
+<a id="dtrt-mode" href="#dtrt-mode">DTRT Mode</a>
+</h3>
+<p id="doc_section_2_3_3_p_1">Some users may find tracking the names of open containers, lists, and instances inconvenient. libxo offers a "Do The Right Thing" mode, where libxo will track the names of open containers, lists, and instances so the close function can be called without a name. To enable DTRT mode, turn on the XOF_DTRT flag prior to making any other libxo output.</p>
+<div id="doc_figure_u.80"></div> <pre>
+ xo_set_flags(NULL, XOF_DTRT);
+ </pre> <p id="doc_section_2_3_3_p_3">Each open and close function has a version with the suffix "_d", which will close the open container, list, or instance:</p>
+<div id="doc_figure_u.81"></div> <pre>
+ xo_open_container("top");
+ ...
+ xo_close_container_d();
+ </pre> <p id="doc_section_2_3_3_p_5">This also works for lists and instances:</p>
+<div id="doc_figure_u.82"></div> <pre>
+ xo_open_list("item");
+ for (...) {
+ xo_open_instance("item");
+ xo_emit(...);
+ xo_close_instance_d();
+ }
+ xo_close_list_d();
+ </pre> <p id="doc_section_2_3_3_p_7">Note that the XOF_WARN flag will also cause libxo to track open containers, lists, and instances. A warning is generated when the name given to the close function and the name recorded do not match.</p>
+</div>
+<div class="content">
+<h3 id="doc_section_2_3_4">
+<div class="self-section-number">
+<a href="#doc_section_2_3_4">2.3.4</a> </div>
+<a id="markers" href="#markers">Markers</a>
+</h3>
+<p id="doc_section_2_3_4_p_1">Markers are used to protect and restore the state of open constructs. While a marker is open, no other open constructs can be closed. When a marker is closed, all constructs open since the marker was opened will be closed.</p>
+<p id="doc_section_2_3_4_p_2">Markers use names which are not user-visible, allowing the caller to choose appropriate internal names.</p>
+<p id="doc_section_2_3_4_p_3">In this example, the code whiffles through a list of fish, calling a function to emit details about each fish. The marker "fish&#8209;guts" is used to ensure that any constructs opened by the function are closed properly.</p>
+<div id="doc_figure_u.83"></div> <pre>
+ for (i = 0; fish[i]; i++) {
+ xo_open_instance("fish");
+ xo_open_marker("fish-guts");
+ dump_fish_details(i);
+ xo_close_marker("fish-guts");
+ }
+ </pre> </div>
+</div>
+<div class="content">
+<h2 id="doc_section_2_4">
+<div class="self-section-number">
+<a href="#doc_section_2_4">2.4</a> </div>
<a id="command-line-arguments" href="#command-line-arguments">Command-line Arguments</a>
</h2>
-<p id="doc_section_2_3_p_1">libxo uses command line options to trigger rendering behavior. The following options are recognised:</p>
-<p id="doc_section_2_3_p_2"> </p>
+<p id="doc_section_2_4_p_1">libxo uses command line options to trigger rendering behavior. The following options are recognised:</p>
+<p id="doc_section_2_4_p_2"> </p>
<ul>
<li>--libxo &lt;options&gt;</li>
<li>--libxo=&lt;options&gt;</li>
<li>--libxo:&lt;brief&#8209;options&gt;</li>
</ul>
-<p id="doc_section_2_3_p_3">Options is a comma-separated list of tokens that correspond to output styles, flags, or features:</p>
-<div id="doc_table_u.8"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
+<p id="doc_section_2_4_p_3">Programs using libxo are expecting to call the xo_parse_args function to parse these arguments. See <a href="#xo_parse_args" title="Parsing Command-line Arguments (xo_parse_args)">Section 3.4.1</a> for details.</p>
+<p id="doc_section_2_4_p_4">Options is a comma-separated list of tokens that correspond to output styles, flags, or features:</p>
+<div id="doc_table_u.10"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Token</th>
<th class="left">Action</th>
@@ -24082,6 +24352,10 @@ jQuery(function ($) {
<td>Do not initialize the locale setting</td>
</tr>
<tr>
+<td>no-retain</td>
+<td>Prevent retaining formatting information</td>
+</tr>
+<tr>
<td>no-top</td>
<td>Do not emit a top set of braces (JSON)</td>
</tr>
@@ -24094,6 +24368,10 @@ jQuery(function ($) {
<td>Emit pretty-printed output</td>
</tr>
<tr>
+<td>retain</td>
+<td>Force retaining formatting information</td>
+</tr>
+<tr>
<td>text</td>
<td>Emit TEXT output</td>
</tr>
@@ -24123,165 +24401,7 @@ jQuery(function ($) {
</tr>
</tbody>
</table></div>
-<p id="doc_section_2_3_p_4">The brief options are detailed in <a href="#LIBXO_OPTIONS" title="LIBXO_OPTIONS">Section 3.4.6</a>.</p>
-</div>
-<div class="content">
-<h2 id="doc_section_2_4">
-<div class="self-section-number">
-<a href="#doc_section_2_4">2.4</a> </div>
-<a id="representing-hierarchy" href="#representing-hierarchy">Representing Hierarchy</a>
-</h2>
-<p id="doc_section_2_4_p_1">For XML and JSON, individual fields appear inside hierarchies which provide context and meaning to the fields. Unfortunately, these encoding have a basic disconnect between how lists is similar objects are represented.</p>
-<p id="doc_section_2_4_p_2">XML encodes lists as set of sequential elements:</p>
-<div id="doc_figure_u.68"></div> <pre>
- &lt;user&gt;phil&lt;/user&gt;
- &lt;user&gt;pallavi&lt;/user&gt;
- &lt;user&gt;sjg&lt;/user&gt;
- </pre> <p id="doc_section_2_4_p_4">JSON encodes lists using a single name and square brackets:</p>
-<div id="doc_figure_u.69"></div> <pre>
- "user": [ "phil", "pallavi", "sjg" ]
- </pre> <p id="doc_section_2_4_p_6">This means libxo needs three distinct indications of hierarchy: one for containers of hierarchy appear only once for any specific parent, one for lists, and one for each item in a list.</p>
-<p id="doc_section_2_4_p_7">Section Contents: </p>
-<ul>
-<li><a href="#containers" title="Containers">Section 2.4.1</a></li>
-<li><a href="#lists-and-instances" title="Lists and Instances">Section 2.4.2</a></li>
-<li><a href="#dtrt-mode" title="DTRT Mode">Section 2.4.3</a></li>
-<li><a href="#markers" title="Markers">Section 2.4.4</a></li>
-</ul>
-<div class="content">
-<h3 id="doc_section_2_4_1">
-<div class="self-section-number">
-<a href="#doc_section_2_4_1">2.4.1</a> </div>
-<a id="containers" href="#containers">Containers</a>
-</h3>
-<p id="doc_section_2_4_1_p_1">A "container" is an element of a hierarchy that appears only once under any specific parent. The container has no value, but serves to contain other nodes.</p>
-<p id="doc_section_2_4_1_p_2">To open a container, call xo_open_container() or xo_open_container_h(). The former uses the default handle and the latter accepts a specific handle.</p>
-<div id="doc_figure_u.70"></div> <pre>
- int xo_open_container_h (xo_handle_t *xop, const char *name);
- int xo_open_container (const char *name);
- </pre> <p id="doc_section_2_4_1_p_4">To close a level, use the xo_close_container() or xo_close_container_h() functions:</p>
-<div id="doc_figure_u.71"></div> <pre>
- int xo_close_container_h (xo_handle_t *xop, const char *name);
- int xo_close_container (const char *name);
- </pre> <p id="doc_section_2_4_1_p_6">Each open call must have a matching close call. If the XOF_WARN flag is set and the name given does not match the name of the currently open container, a warning will be generated.</p>
-<div id="doc_figure_u.72"></div> <pre>
- Example:
-
- xo_open_container("top");
- xo_open_container("system");
- xo_emit("{:host-name/%s%s%s", hostname,
- domainname ? "." : "", domainname ?: "");
- xo_close_container("system");
- xo_close_container("top");
-
- Sample Output:
- Text:
- my-host.example.org
- XML:
- &lt;top&gt;
- &lt;system&gt;
- &lt;host-name&gt;my-host.example.org&lt;/host-name&gt;
- &lt;/system&gt;
- &lt;/top&gt;
- JSON:
- "top" : {
- "system" : {
- "host-name": "my-host.example.org"
- }
- }
- HTML:
- &lt;div class="data"
- data-tag="host-name"&gt;my-host.example.org&lt;/div&gt;
- </pre> </div>
-<div class="content">
-<h3 id="doc_section_2_4_2">
-<div class="self-section-number">
-<a href="#doc_section_2_4_2">2.4.2</a> </div>
-<a id="lists-and-instances" href="#lists-and-instances">Lists and Instances</a>
-</h3>
-<p id="doc_section_2_4_2_p_1">A list is set of one or more instances that appear under the same parent. The instances contain details about a specific object. One can think of instances as objects or records. A call is needed to open and close the list, while a distinct call is needed to open and close each instance of the list:</p>
-<div id="doc_figure_u.73"></div> <pre>
- xo_open_list("item");
-
- for (ip = list; ip-&gt;i_title; ip++) {
- xo_open_instance("item");
- xo_emit("{L:Item} '{:name/%s}':\n", ip-&gt;i_title);
- xo_close_instance("item");
- }
-
- xo_close_list("item");
- </pre> <p id="doc_section_2_4_2_p_3">Getting the list and instance calls correct is critical to the proper generation of XML and JSON data.</p>
-</div>
-<div class="content">
-<h3 id="doc_section_2_4_3">
-<div class="self-section-number">
-<a href="#doc_section_2_4_3">2.4.3</a> </div>
-<a id="dtrt-mode" href="#dtrt-mode">DTRT Mode</a>
-</h3>
-<p id="doc_section_2_4_3_p_1">Some users may find tracking the names of open containers, lists, and instances inconvenient. libxo offers a "Do The Right Thing" mode, where libxo will track the names of open containers, lists, and instances so the close function can be called without a name. To enable DTRT mode, turn on the XOF_DTRT flag prior to making any other libxo output.</p>
-<div id="doc_figure_u.74"></div> <pre>
- xo_set_flags(NULL, XOF_DTRT);
- </pre> <p id="doc_section_2_4_3_p_3">Each open and close function has a version with the suffix "_d", which will close the open container, list, or instance:</p>
-<div id="doc_figure_u.75"></div> <pre>
- xo_open_container("top");
- ...
- xo_close_container_d();
- </pre> <p id="doc_section_2_4_3_p_5">This also works for lists and instances:</p>
-<div id="doc_figure_u.76"></div> <pre>
- xo_open_list("item");
- for (...) {
- xo_open_instance("item");
- xo_emit(...);
- xo_close_instance_d();
- }
- xo_close_list_d();
- </pre> <p id="doc_section_2_4_3_p_7">Note that the XOF_WARN flag will also cause libxo to track open containers, lists, and instances. A warning is generated when the name given to the close function and the name recorded do not match.</p>
-</div>
-<div class="content">
-<h3 id="doc_section_2_4_4">
-<div class="self-section-number">
-<a href="#doc_section_2_4_4">2.4.4</a> </div>
-<a id="markers" href="#markers">Markers</a>
-</h3>
-<p id="doc_section_2_4_4_p_1">Markers are used to protect and restore the state of open constructs. While a marker is open, no other open constructs can be closed. When a marker is closed, all constructs open since the marker was opened will be closed.</p>
-<p id="doc_section_2_4_4_p_2">Markers use names which are not user-visible, allowing the caller to choose appropriate internal names.</p>
-<p id="doc_section_2_4_4_p_3">In this example, the code whiffles through a list of fish, calling a function to emit details about each fish. The marker "fish&#8209;guts" is used to ensure that any constructs opened by the function are closed properly.</p>
-<div id="doc_figure_u.77"></div> <pre>
- for (i = 0; fish[i]; i++) {
- xo_open_instance("fish");
- xo_open_marker("fish-guts");
- dump_fish_details(i);
- xo_close_marker("fish-guts");
- }
- </pre> </div>
-</div>
-<div class="content">
-<h2 id="doc_section_2_5">
-<div class="self-section-number">
-<a href="#doc_section_2_5">2.5</a> </div>
-<a id="handles" href="#handles">Handles</a>
-</h2>
-<p id="doc_section_2_5_p_1">libxo uses "handles" to control its rendering functionality. The handle contains state and buffered data, as well as callback functions to process data.</p>
-<p id="doc_section_2_5_p_2">A default handle is used when a NULL is passed to functions accepting a handle. This handle is initialized to write its data to stdout using the default style of text (XO_STYLE_TEXT).</p>
-<p id="doc_section_2_5_p_3">For the convenience of callers, the libxo library includes handle-less functions that implicitly use the default handle. Any function that takes a handle will use the default handle is a value of NULL is passed in place of a valid handle.</p>
-<p id="doc_section_2_5_p_4">For example, the following are equivalent:</p>
-<div id="doc_figure_u.78"></div> <pre>
- xo_emit("test");
- xo_emit_h(NULL, "test");
- </pre> <p id="doc_section_2_5_p_6">Handles are created using xo_create() and destroy using xo_destroy().</p>
-</div>
-<div class="content">
-<h2 id="doc_section_2_6">
-<div class="self-section-number">
-<a href="#doc_section_2_6">2.6</a> </div>
-<a id="utf-8" href="#utf-8">UTF-8</a>
-</h2>
-<p id="doc_section_2_6_p_1">All strings for libxo must be UTF-8. libxo will handle turning them into locale-based strings for display to the user.</p>
-<p id="doc_section_2_6_p_2">The only exception is argument formatted using the "%ls" format, which require a wide character string (wchar_t *) as input. 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.79"></div> <pre>
- xo_emit("Alll strings are utf-8 content {:tag/%ls}",
- L"except for wide strings");
- </pre> <p id="doc_section_2_6_p_4">"%S" is equivalent to "%ls".</p>
+<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>
</div>
</div>
<hr class="noprint">
@@ -24294,7 +24414,7 @@ jQuery(function ($) {
<p id="doc_section_3_p_1">This section gives details about the functions in libxo, how to call them, and the actions they perform.</p>
<p id="doc_section_3_p_2">Section Contents: </p>
<ul>
-<li><a href="#handles-2" title="Handles">Section 3.1</a></li>
+<li><a href="#handles" title="Handles">Section 3.1</a></li>
<li><a href="#emitting-content-xo_emit" title="Emitting Content (xo_emit)">Section 3.2</a></li>
<li><a href="#emitting-hierarchy" title="Emitting Hierarchy">Section 3.3</a></li>
<li><a href="#support-functions" title="Support Functions">Section 3.4</a></li>
@@ -24305,13 +24425,19 @@ jQuery(function ($) {
<h2 id="doc_section_3_1">
<div class="self-section-number">
<a href="#doc_section_3_1">3.1</a> </div>
-<a id="handles-2" href="#handles-2">Handles</a>
+<a id="handles" href="#handles">Handles</a>
</h2>
-<p id="doc_section_3_1_p_1">Handles give an abstraction for libxo that encapsulates the state of a stream of output. Handles have the data type "xo_handle_t" and are opaque to the caller.</p>
-<p id="doc_section_3_1_p_2">The library has a default handle that is automatically initialized. By default, this handle will send text style output to standard output. The xo_set_style and xo_set_flags functions can be used to change this behavior.</p>
-<p id="doc_section_3_1_p_3">Many libxo functions take a handle as their first parameter; most that do not use the default handle. Any function taking a handle can be passed NULL to access the default handle.</p>
+<p id="doc_section_3_1_p_1">libxo uses "handles" to control its rendering functionality. The handle contains state and buffered data, as well as callback functions to process data.</p>
+<p id="doc_section_3_1_p_2">Handles give an abstraction for libxo that encapsulates the state of a stream of output. Handles have the data type "xo_handle_t" and are opaque to the caller.</p>
+<p id="doc_section_3_1_p_3">The library has a default handle that is automatically initialized. By default, this handle will send text style output (XO_STYLE_TEXT) to standard output. The xo_set_style and xo_set_flags functions can be used to change this behavior.</p>
<p id="doc_section_3_1_p_4">For the typical command that is generating output on standard output, there is no need to create an explicit handle, but they are available when needed, e.g., for daemons that generate multiple streams of output.</p>
-<p id="doc_section_3_1_p_5">Section Contents: </p>
+<p id="doc_section_3_1_p_5">Many libxo functions take a handle as their first parameter; most that do not use the default handle. Any function taking a handle can be passed NULL to access the default handle. For the convenience of callers, the libxo library includes handle-less functions that implicitly use the default handle.</p>
+<p id="doc_section_3_1_p_6">For example, the following are equivalent:</p>
+<div id="doc_figure_u.84"></div> <pre>
+ xo_emit("test");
+ xo_emit_h(NULL, "test");
+ </pre> <p id="doc_section_3_1_p_8">Handles are created using xo_create() and destroy using xo_destroy().</p>
+<p id="doc_section_3_1_p_9">Section Contents: </p>
<ul>
<li><a href="#xo_create" title="xo_create">Section 3.1.1</a></li>
<li><a href="#xo_create_to_file" title="xo_create_to_file">Section 3.1.2</a></li>
@@ -24327,7 +24453,7 @@ jQuery(function ($) {
<a id="xo_create" href="#xo_create">xo_create</a>
</h3>
<p id="doc_section_3_1_1_p_1">A handle can be allocated using the xo_create() function:</p>
-<div id="doc_figure_u.80"></div> <pre>
+<div id="doc_figure_u.85"></div> <pre>
xo_handle_t *xo_create (unsigned style, unsigned flags);
Example:
@@ -24343,7 +24469,7 @@ jQuery(function ($) {
<a id="xo_create_to_file" href="#xo_create_to_file">xo_create_to_file</a>
</h3>
<p id="doc_section_3_1_2_p_1">By default, libxo writes output to standard output. A convenience function is provided for situations when output should be written to a different file:</p>
-<div id="doc_figure_u.81"></div> <pre>
+<div id="doc_figure_u.86"></div> <pre>
xo_handle_t *xo_create_to_file (FILE *fp, unsigned style,
unsigned flags);
</pre> <p id="doc_section_3_1_2_p_3">Use the XOF_CLOSE_FP flag to trigger a call to fclose() for the FILE pointer when the handle is destroyed.</p>
@@ -24355,7 +24481,7 @@ jQuery(function ($) {
<a id="xo_set_writer" href="#xo_set_writer">xo_set_writer</a>
</h3>
<p id="doc_section_3_1_3_p_1">The xo_set_writer function allows custom 'write' functions which can tailor how libxo writes data. An opaque argument is recorded and passed back to the write function, allowing the function to acquire context information. The 'close' function can release this opaque data and any other resources as needed. The flush function can flush buffered data associated with the opaque object.</p>
-<div id="doc_figure_u.82"></div> <pre>
+<div id="doc_figure_u.87"></div> <pre>
void xo_set_writer (xo_handle_t *xop, void *opaque,
xo_write_func_t write_func,
xo_close_func_t close_func);
@@ -24368,10 +24494,10 @@ jQuery(function ($) {
<a id="xo_set_style" href="#xo_set_style">xo_set_style</a>
</h3>
<p id="doc_section_3_1_4_p_1">To set the style, use the xo_set_style() function:</p>
-<div id="doc_figure_u.83"></div> <pre>
+<div id="doc_figure_u.88"></div> <pre>
void xo_set_style(xo_handle_t *xop, unsigned style);
</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.84"></div> <pre>
+<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>
<ul>
@@ -24385,7 +24511,7 @@ jQuery(function ($) {
<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>
-<div id="doc_table_u.9"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
+<div id="doc_table_u.11"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Flag</th>
<th class="left">Description</th>
@@ -24417,10 +24543,10 @@ jQuery(function ($) {
<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.85"></div> <pre>
+<div id="doc_figure_u.90"></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.86"></div> <pre>
+<div id="doc_figure_u.91"></div> <pre>
EXAMPLE:
xo_set_style_name(NULL, "html");
</pre> </div>
@@ -24432,10 +24558,10 @@ jQuery(function ($) {
<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.87"></div> <pre>
+<div id="doc_figure_u.92"></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.88"></div> <pre>
+<div id="doc_figure_u.93"></div> <pre>
xo_set_style(NULL, XO_STYLE_XML);
</pre> <p id="doc_section_3_1_5_p_5">Section Contents: </p>
<ul>
@@ -24450,7 +24576,7 @@ jQuery(function ($) {
<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>
-<div id="doc_table_u.10"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
+<div id="doc_table_u.12"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Flag</th>
<th class="left">Description</th>
@@ -24528,7 +24654,7 @@ jQuery(function ($) {
<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>
-<div id="doc_table_u.11"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
+<div id="doc_table_u.13"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Flag</th>
<th class="left">Description</th>
@@ -24547,7 +24673,7 @@ jQuery(function ($) {
<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>
-<div id="doc_table_u.12"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
+<div id="doc_table_u.14"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Flag</th>
<th class="left">Description</th>
@@ -24558,7 +24684,7 @@ jQuery(function ($) {
</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.89"></div> <pre>
+<div id="doc_figure_u.94"></div> <pre>
xo_emit("{k:name}", item);
XML:
@@ -24571,7 +24697,7 @@ jQuery(function ($) {
<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.90"></div> <pre>
+<div id="doc_figure_u.95"></div> <pre>
void xo_clear_flags (xo_handle_t *xop, xo_xof_flags_t flags);
</pre> </div>
<div class="content">
@@ -24581,9 +24707,9 @@ jQuery(function ($) {
<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.91"></div> <pre>
+<div id="doc_figure_u.96"></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.3</a>.</p>
+ </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>
</div>
</div>
<div class="content">
@@ -24593,7 +24719,7 @@ jQuery(function ($) {
<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.92"></div> <pre>
+<div id="doc_figure_u.97"></div> <pre>
void xo_destroy(xo_handle_t *xop);
</pre> </div>
</div>
@@ -24604,33 +24730,57 @@ 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.93"></div> <pre>
+<div id="doc_figure_u.98"></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);
- </pre> <p id="doc_section_3_2_p_3">The "fmt" argument is a string containing field descriptors as specified in <a href="#format-strings" title="Format Strings">Section 2.2</a>. The use of a handle is optional and NULL can be passed to access the internal 'default' handle. See <a href="#handles" title="Handles">Section 2.5</a>.</p>
+ </pre> <p id="doc_section_3_2_p_3">The "fmt" argument is a string containing field descriptors as specified in <a href="#format-strings" title="Format Strings">Section 2.2</a>. The use of a handle is optional and NULL can be passed to access the internal 'default' handle. See <a href="#handles" title="Handles">Section 3.1</a>.</p>
<p id="doc_section_3_2_p_4">The remaining arguments to xo_emit() and xo_emit_h() are a set of arguments corresponding to the fields in the format string. Care must be taken to ensure the argument types match the fields in the format string, since an inappropriate cast can ruin your day. The vap argument to xo_emit_hv() points to a variable argument list that can be used to retrieve arguments via va_arg().</p>
<p id="doc_section_3_2_p_5">Section Contents: </p>
<ul>
-<li><a href="#xo_attr" title="Attributes (xo_attr)">Section 3.2.1</a></li>
-<li><a href="#flushing-output-xo_flush" title="Flushing Output (xo_flush)">Section 3.2.2</a></li>
-<li><a href="#finishing-output-xo_finish" title="Finishing Output (xo_finish)">Section 3.2.3</a></li>
+<li><a href="#xo_emit_field" title="Single Field Emitting Functions (xo_emit_field)">Section 3.2.1</a></li>
+<li><a href="#xo_attr" title="Attributes (xo_attr)">Section 3.2.2</a></li>
+<li><a href="#flushing-output-xo_flush" title="Flushing Output (xo_flush)">Section 3.2.3</a></li>
+<li><a href="#finishing-output-xo_finish" title="Finishing Output (xo_finish)">Section 3.2.4</a></li>
</ul>
<div class="content">
<h3 id="doc_section_3_2_1">
<div class="self-section-number">
<a href="#doc_section_3_2_1">3.2.1</a> </div>
+<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>
+ int 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_emit_field_h (xo_handle_t *xop, const char *rolmod,
+ const char *contents, const char *fmt,
+ const char *efmt, ...);
+
+ 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>
+ xo_emit("T", "Host name is ", NULL, NULL);
+ xo_emit("V", "host-name", NULL, NULL, host-name);
+ </pre> </div>
+<div class="content">
+<h3 id="doc_section_3_2_2">
+<div class="self-section-number">
+<a href="#doc_section_3_2_2">3.2.2</a> </div>
<a id="xo_attr" href="#xo_attr">Attributes (xo_attr)</a>
</h3>
-<p id="doc_section_3_2_1_p_1">The xo_attr() function emits attributes for the XML output style.</p>
-<div id="doc_figure_u.94"></div> <pre>
+<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>
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_1_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.95"></div> <pre>
+ </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>
EXAMPLE:
xo_attr("seconds", "%ld", (unsigned long) login_time);
struct tm *tmp = localtime(login_time);
@@ -24638,34 +24788,34 @@ jQuery(function ($) {
xo_emit("Logged in at {:login-time}\n", buf);
XML:
&lt;login-time seconds="1408336270"&gt;00:14&lt;/login-time&gt;
- </pre> <p id="doc_section_3_2_1_p_5">xo_attr is placed on the next container, instance, leaf, or leaf list that is emitted.</p>
-<p id="doc_section_3_2_1_p_6">Since attributes are only emitted in XML, their use should be limited to meta-data and additional or redundant representations of data already emitted in other form.</p>
+ </pre> <p id="doc_section_3_2_2_p_5">xo_attr is placed on the next container, instance, leaf, or leaf list that is emitted.</p>
+<p id="doc_section_3_2_2_p_6">Since attributes are only emitted in XML, their use should be limited to meta-data and additional or redundant representations of data already emitted in other form.</p>
</div>
<div class="content">
-<h3 id="doc_section_3_2_2">
+<h3 id="doc_section_3_2_3">
<div class="self-section-number">
-<a href="#doc_section_3_2_2">3.2.2</a> </div>
+<a href="#doc_section_3_2_3">3.2.3</a> </div>
<a id="flushing-output-xo_flush" href="#flushing-output-xo_flush">Flushing Output (xo_flush)</a>
</h3>
-<p id="doc_section_3_2_2_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.96"></div> <pre>
+<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>
void xo_flush (void);
void xo_flush_h (xo_handle_t *xop);
- </pre> <p id="doc_section_3_2_2_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>
+ </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>
</div>
<div class="content">
-<h3 id="doc_section_3_2_3">
+<h3 id="doc_section_3_2_4">
<div class="self-section-number">
-<a href="#doc_section_3_2_3">3.2.3</a> </div>
+<a href="#doc_section_3_2_4">3.2.4</a> </div>
<a id="finishing-output-xo_finish" href="#finishing-output-xo_finish">Finishing Output (xo_finish)</a>
</h3>
-<p id="doc_section_3_2_3_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.97"></div> <pre>
+<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>
int xo_finish (void);
int xo_finish_h (xo_handle_t *xop);
void xo_finish_atexit (void);
- </pre> <p id="doc_section_3_2_3_p_3">Calling this function is vital to the proper operation of libxo, especially for the non-TEXT output styles.</p>
-<p id="doc_section_3_2_3_p_4">xo_finish_atexit is suitable for use with atexit(3).</p>
+ </pre> <p id="doc_section_3_2_4_p_3">Calling this function is vital to the proper operation of libxo, especially for the non-TEXT output styles.</p>
+<p id="doc_section_3_2_4_p_4">xo_finish_atexit is suitable for use with atexit(3).</p>
</div>
</div>
<div class="content">
@@ -24676,7 +24826,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.98"></div> <pre>
+<div id="doc_figure_u.105"></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);
@@ -24690,7 +24840,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.99"></div> <pre>
+<div id="doc_figure_u.106"></div> <pre>
EXAMPLE:
xo_open_container("system");
xo_emit("The host name is {:host-name}\n", hn);
@@ -24707,7 +24857,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.100"></div> <pre>
+<div id="doc_figure_u.107"></div> <pre>
EXAMPLE:
xo_open_list("user");
for (i = 0; i &lt; num_users; i++) {
@@ -24776,11 +24926,11 @@ 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.101"></div> <pre>
+<div id="doc_figure_u.108"></div> <pre>
argc = xo_parse_args(argc, argv);
if (argc &lt; 0)
exit(EXIT_FAILURE);
- </pre> <p id="doc_section_3_4_1_p_3">Following the call to xo_parse_args, the application can process the remaining arguments in a normal manner. See <a href="#command-line-arguments" title="Command-line Arguments">Section 2.3</a> for a description of valid arguments.</p>
+ </pre> <p id="doc_section_3_4_1_p_3">Following the call to xo_parse_args, the application can process the remaining arguments in a normal manner. See <a href="#command-line-arguments" title="Command-line Arguments">Section 2.4</a> for a description of valid arguments.</p>
</div>
<div class="content">
<h3 id="doc_section_3_4_2">
@@ -24789,7 +24939,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.102"></div> <pre>
+<div id="doc_figure_u.109"></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>
@@ -24800,7 +24950,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.103"></div> <pre>
+<div id="doc_figure_u.110"></div> <pre>
void xo_set_version (const char *version);
void xo_set_version_h (xo_handle_t *xop, const char *version);
</pre> </div>
@@ -24813,7 +24963,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.104"></div> <pre>
+<div id="doc_figure_u.111"></div> <pre>
typedef struct xo_info_s {
const char *xi_name; /* Name of the element */
const char *xi_type; /* Type of field */
@@ -24823,7 +24973,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.105"></div> <pre>
+<div id="doc_figure_u.112"></div> <pre>
xo_info_t info[] = {
{ "in-stock", "number", "Number of items in stock" },
{ "name", "string", "Name of the item" },
@@ -24836,7 +24986,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.106"></div> <pre>
+<div id="doc_figure_u.113"></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>
@@ -24847,7 +24997,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.107"></div> <pre>
+<div id="doc_figure_u.114"></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>
@@ -24860,7 +25010,7 @@ jQuery(function ($) {
<a id="LIBXO_OPTIONS" href="#LIBXO_OPTIONS">LIBXO_OPTIONS</a>
</h3>
<p id="doc_section_3_4_6_p_1">The environment variable "LIBXO_OPTIONS" can be set to a string of options:</p>
-<div id="doc_table_u.13"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
+<div id="doc_table_u.15"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Option</th>
<th class="left">Action</th>
@@ -24929,10 +25079,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.108"></div> <pre>
+<div id="doc_figure_u.115"></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.109"></div> <pre>
+<div id="doc_figure_u.116"></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>
@@ -24943,7 +25093,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.110"></div> <pre>
+<div id="doc_figure_u.117"></div> <pre>
void xo_warn (const char *fmt, ...);
void xo_warnx (const char *fmt, ...);
void xo_warn_c (int code, const char *fmt, ...);
@@ -24959,7 +25109,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.111"></div> <pre>
+<div id="doc_figure_u.118"></div> <pre>
EXAMPLE:
if (open(filename, O_RDONLY) &lt; 0)
xo_err(1, "cannot open file '%s'", filename);
@@ -24971,7 +25121,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.112"></div> <pre>
+<div id="doc_figure_u.119"></div> <pre>
EXAMPLE::
xo_error("Does not %s", "compute");
XML::
@@ -24986,7 +25136,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.113"></div> <pre>
+<div id="doc_figure_u.120"></div> <pre>
void xo_no_setlocale (void);
</pre> </div>
</div>
@@ -25002,7 +25152,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.114"></div> <pre>
+<div id="doc_figure_u.121"></div> <pre>
/* Both of these calls are optional */
xo_set_syslog_enterprise_id(32473);
xo_open_log("my-program", 0, LOG_DAEMON);
@@ -25030,13 +25180,13 @@ 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.115"></div> <pre>
+<div id="doc_figure_u.122"></div> <pre>
xo_syslog(LOG_ERR | LOG_AUTH, "login-failed",
"Login failed; user '{:user}' from host '{:address}'",
user, addr);
</pre> <p id="doc_section_3_5_1_p_3">These values are defined in &lt;syslog.h&gt;.</p>
<p id="doc_section_3_5_1_p_4">The priority value indicates the importance and potential impact of each message.</p>
-<div id="doc_table_u.14"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
+<div id="doc_table_u.16"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Priority</th>
<th class="left">Description</th>
@@ -25077,7 +25227,7 @@ jQuery(function ($) {
</tbody>
</table></div>
<p id="doc_section_3_5_1_p_5">The facility value indicates the source of message, in fairly generic terms.</p>
-<div id="doc_table_u.15"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
+<div id="doc_table_u.17"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Facility</th>
<th class="left">Description</th>
@@ -25142,7 +25292,7 @@ jQuery(function ($) {
</tbody>
</table></div>
<p id="doc_section_3_5_1_p_6">In addition to the values listed above, xo_open_log accepts a set of addition flags requesting specific behaviors.</p>
-<div id="doc_table_u.16"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
+<div id="doc_table_u.18"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Flag</th>
<th class="left">Description</th>
@@ -25175,7 +25325,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.116"></div> <pre>
+<div id="doc_figure_u.123"></div> <pre>
xo_syslog(LOG_ERR, "poofd-missing-file",
"'{:filename}' not found: {:error/%m}", filename);
@@ -25204,7 +25354,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.117"></div> <pre>
+<div id="doc_figure_u.124"></div> <pre>
void my_log (const char *name, const char *fmt, ...)
{
va_list vap;
@@ -25220,7 +25370,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.118"></div> <pre>
+<div id="doc_figure_u.125"></div> <pre>
void
xo_open_log (const char *ident, int logopt, int facility);
</pre> </div>
@@ -25231,7 +25381,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.119"></div> <pre>
+<div id="doc_figure_u.126"></div> <pre>
void
xo_close_log (void);
</pre> </div>
@@ -25242,7 +25392,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.120"></div> <pre>
+<div id="doc_figure_u.127"></div> <pre>
int
xo_set_logmask (int maskpri);
@@ -25257,7 +25407,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.121"></div> <pre>
+<div id="doc_figure_u.128"></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>
@@ -25299,7 +25449,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.122"></div> <pre>
+<div id="doc_figure_u.129"></div> <pre>
% ls -1 lib/libxo/extensions/*.enc
lib/libxo/extensions/cbor.enc
lib/libxo/extensions/test.enc
@@ -25311,7 +25461,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.123"></div> <pre>
+<div id="doc_figure_u.130"></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>
@@ -25329,7 +25479,7 @@ jQuery(function ($) {
<a id="operations" href="#operations">Operations</a>
</h3>
<p id="doc_section_3_6_3_p_1">The encoder API defines a set of operations representing the processing model of libxo. Content is formatted within libxo, and callbacks are made to the encoder's handler function when data is ready to be processed.</p>
-<div id="doc_table_u.17"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
+<div id="doc_table_u.19"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Operation</th>
<th class="left">Meaning (Base function)</th>
@@ -25416,7 +25566,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.124"></div> <pre>
+<div id="doc_figure_u.131"></div> <pre>
xo "The {k:name} weighs {:weight/%d} pounds.\n" fish 6
TEXT:
@@ -25436,7 +25586,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.125"></div> <pre>
+<div id="doc_figure_u.132"></div> <pre>
xo --wrap top/a/b/c '{:tag}' value
XML:
@@ -25460,7 +25610,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.126"></div> <pre>
+<div id="doc_figure_u.133"></div> <pre>
#!/bin/sh
xo --open top/data
xo --depth 2 '{tag}' value
@@ -25489,7 +25639,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.127"></div> <pre>
+<div id="doc_figure_u.134"></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
@@ -25513,7 +25663,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.128"></div> <pre>
+<div id="doc_figure_u.135"></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"
@@ -25530,7 +25680,7 @@ jQuery(function ($) {
</h1>
<p id="doc_section_5_p_1">xolint is a tool for reporting common mistakes in format strings in source code that invokes xo_emit(). It allows these errors to be diagnosed at build time, rather than waiting until runtime.</p>
<p id="doc_section_5_p_2">xolint takes the one or more C files as arguments, and reports and errors, warning, or informational messages as needed.</p>
-<div id="doc_table_u.18"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
+<div id="doc_table_u.20"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Option</th>
<th class="left">Meaning</th>
@@ -25571,7 +25721,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.129"></div> <pre>
+<div id="doc_figure_u.136"></div> <pre>
% xolint.pl -t xolint.c
xolint.c: 16: error: anchor format should be "%d"
16 xo_emit("{[:/%s}");
@@ -25587,7 +25737,7 @@ jQuery(function ($) {
</h1>
<p id="doc_section_6_p_1">xohtml is a tool for turning the output of libxo-enabled commands into html files suitable for display in modern HTML web browsers. It can be used to test and debug HTML output, as well as to make the user ache to escape the world of 70s terminal devices.</p>
<p id="doc_section_6_p_2">xohtml is given a command, either on the command line or via the "&#8209;c" option. If not command is given, standard input is used. The command's output is wrapped in HTML tags, with references to supporting CSS and Javascript files, and written to standard output or the file given in the "&#8209;f" option. The "&#8209;b" option can be used to provide an alternative base path for the support files.</p>
-<div id="doc_table_u.19"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
+<div id="doc_table_u.21"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Option</th>
<th class="left">Meaning</th>
@@ -25619,7 +25769,7 @@ jQuery(function ($) {
<p id="doc_section_7_p_1">The "xopo" utility filters ".pot" files generated by the "xgettext" utility to remove formatting information suitable for use with the "{G:}" modifier. This means that when the developer changes the formatting portion of the field definitions, or the fields modifiers, the string passed to gettext(3) is unchanged, avoiding the expense of updating any existing translation files (".po" files).</p>
<p id="doc_section_7_p_2">The syntax for the xopo command is one of two forms; it can be used as a filter for processing a .po or .pot file, rewriting the "msgid" strings with a simplified message string. In this mode, the input is either standard input or a file given by the "&#8209;f" option, and the output is either standard output or a file given by the "&#8209;o" option.</p>
<p id="doc_section_7_p_3">In the second mode, a simple message given using the "&#8209;s" option on the command, and the simplified version of that message is printed on stdout.</p>
-<div id="doc_table_u.20"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
+<div id="doc_table_u.22"><table summary="" class="tt full" cellpadding="3" cellspacing="0">
<thead><tr>
<th class="left">Option</th>
<th class="left">Meaning</th>
@@ -25639,7 +25789,7 @@ jQuery(function ($) {
</tr>
</tbody>
</table></div>
-<div id="doc_figure_u.130"></div> <pre>
+<div id="doc_figure_u.137"></div> <pre>
EXAMPLE:
% xopo -s "There are {:count/%u} {:event/%.6s} events\n"
There are {:count} {:event} events\n
@@ -25687,9 +25837,9 @@ jQuery(function ($) {
<a href="#doc_section_8_1_1">8.1.1</a> </div>
<a id="can-you-share-the-history-of-libxo" href="#can-you-share-the-history-of-libxo">Can you share the history of libxo?</a>
</h3>
-<p id="doc_section_8_1_1_p_1">In 2001, we added an XML API to the JUNOS operating system, which is built on top of FreeBSD. Eventually this API became standardized as the NETCONF API (RFC 6241). As part of this effort, we modified many FreeBSD utilities to emit XML, typically via a "&#8209;X" switch. The results were mixed. The cost of maintaining this code, updating it and carrying it were non-trivial, and contributed to our expense (and the associated delay) with upgrading the version of FreeBSD on which each release of JUNOS is based.</p>
-<p id="doc_section_8_1_1_p_2">A recent (2014) effort within JUNOS aims at removing our modifications to the underlying FreeBSD code as a means of reducing the expense and delay. JUNOS is structured to have system components generate XML that is rendered by the CLI (think: login shell) into human-readable text. This allows the API to use the same plumbing as the CLI, and ensures that all components emit XML, and that it is emitted with knowledge of the consumer of that XML, yielding an API that have no incremental cost or feature delay.</p>
-<p id="doc_section_8_1_1_p_3">libxo is an effort to mix the best aspects of the JUNOS strategy into FreeBSD in a seemless way, allowing commands to make printf-like output calls without needing to care how the output is rendered.</p>
+<p id="doc_section_8_1_1_p_1">In 2001, we added an XML API to the JUNOS operating system, which is built on top of FreeBSD. Eventually this API became standardized as the NETCONF API (RFC 6241). As part of this effort, we modified many FreeBSD utilities to emit XML, typically via a "&#8209;X" switch. The results were mixed. The cost of maintaining this code, updating it, and carrying it were non-trivial, and contributed to our expense (and the associated delay) with upgrading the version of FreeBSD on which each release of JUNOS is based.</p>
+<p id="doc_section_8_1_1_p_2">A recent (2014) effort within JUNOS aims at removing our modifications to the underlying FreeBSD code as a means of reducing the expense and delay in tracking HEAD. JUNOS is structured to have system components generate XML that is rendered by the CLI (think: login shell) into human-readable text. This allows the API to use the same plumbing as the CLI, and ensures that all components emit XML, and that it is emitted with knowledge of the consumer of that XML, yielding an API that have no incremental cost or feature delay.</p>
+<p id="doc_section_8_1_1_p_3">libxo is an effort to mix the best aspects of the JUNOS strategy into FreeBSD in a seemless way, allowing commands to make printf-like output calls with a single code path.</p>
</div>
<div class="content">
<h3 id="doc_section_8_1_2">
@@ -25698,7 +25848,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.131"></div> <pre>
+<div id="doc_figure_u.138"></div> <pre>
tag docsis-state {
help "State of the DOCSIS interface";
type string;
@@ -25777,7 +25927,7 @@ jQuery(function ($) {
<dt>Reuse existing field names</dt>
<dd>Nothing's worse than writing expressions like:</dd>
</dl>
-<div id="doc_figure_u.132"></div> <pre>
+<div id="doc_figure_u.139"></div> <pre>
if ($src1/process[pid == $pid]/name ==
$src2/proc-table/proc-list
/proc-entry[process-id == $pid]/proc-name) {
@@ -25789,7 +25939,7 @@ jQuery(function ($) {
<dt>Use containment as scoping</dt>
<dd>In the previous example, all the names are prefixed with "proc&#8209;", which is redundant given that they are nested under the process table.</dd>
<dt>Think about your users</dt>
-<dd>Have empathy for your users, choosing clear and useful fields that contain clear and useful data. You may need to augment the display content with xo_attr() calls (<a href="#xo_attr" title="Attributes (xo_attr)">Section 3.2.1</a>) or "{e:}" fields (<a href="#e-modifier" title="The Encoding Modifier ({e:})">Section 2.2.2.3</a>) to make the data useful.</dd>
+<dd>Have empathy for your users, choosing clear and useful fields that contain clear and useful data. You may need to augment the display content with xo_attr() calls (<a href="#xo_attr" title="Attributes (xo_attr)">Section 3.2.2</a>) or "{e:}" fields (<a href="#e-modifier" title="The Encoding Modifier ({e:})">Section 2.2.2.4</a>) to make the data useful.</dd>
<dt>Don't use an arbitrary number postfix</dt>
<dd>What does "errors2" mean? No one will know. "errors&#8209;after&#8209;restart" would be a better choice. Think of your users, and think of the future. If you make "errors2", the next guy will happily make "errors3" and before you know it, someone will be asking what's the difference between errors37 and errors63.</dd>
<dt>Be consistent, uniform, unsurprising, and predictable</dt>
@@ -25838,10 +25988,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.133"></div> <pre>
+<div id="doc_figure_u.140"></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.134"></div> <pre>
+<div id="doc_figure_u.141"></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>
@@ -25852,10 +26002,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.135"></div> <pre>
+<div id="doc_figure_u.142"></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.136"></div> <pre>
+<div id="doc_figure_u.143"></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>
@@ -25867,10 +26017,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.137"></div> <pre>
+<div id="doc_figure_u.144"></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.138"></div> <pre>
+<div id="doc_figure_u.145"></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>
@@ -25881,10 +26031,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.139"></div> <pre>
+<div id="doc_figure_u.146"></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.140"></div> <pre>
+<div id="doc_figure_u.147"></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>
@@ -25895,10 +26045,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.141"></div> <pre>
+<div id="doc_figure_u.148"></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.142"></div> <pre>
+<div id="doc_figure_u.149"></div> <pre>
xo_emit("{T:Max}");
</pre> </div>
<div class="content">
@@ -25908,10 +26058,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.143"></div> <pre>
+<div id="doc_figure_u.150"></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.144"></div> <pre>
+<div id="doc_figure_u.151"></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>
@@ -25922,7 +26072,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.145"></div> <pre>
+<div id="doc_figure_u.152"></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>
@@ -25933,7 +26083,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.146"></div> <pre>
+<div id="doc_figure_u.153"></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>
@@ -25944,10 +26094,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.147"></div> <pre>
+<div id="doc_figure_u.154"></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.148"></div> <pre>
+<div id="doc_figure_u.155"></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>
@@ -25958,10 +26108,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.149"></div> <pre>
+<div id="doc_figure_u.156"></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.150"></div> <pre>
+<div id="doc_figure_u.157"></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>
@@ -25972,10 +26122,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.151"></div> <pre>
+<div id="doc_figure_u.158"></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.152"></div> <pre>
+<div id="doc_figure_u.159"></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>
@@ -25986,10 +26136,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.153"></div> <pre>
+<div id="doc_figure_u.160"></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.154"></div> <pre>
+<div id="doc_figure_u.161"></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>
@@ -26000,10 +26150,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.155"></div> <pre>
+<div id="doc_figure_u.162"></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.156"></div> <pre>
+<div id="doc_figure_u.163"></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>
@@ -26014,10 +26164,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.157"></div> <pre>
+<div id="doc_figure_u.164"></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.158"></div> <pre>
+<div id="doc_figure_u.165"></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>
@@ -26028,10 +26178,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.159"></div> <pre>
+<div id="doc_figure_u.166"></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.160"></div> <pre>
+<div id="doc_figure_u.167"></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>
@@ -26042,10 +26192,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.161"></div> <pre>
+<div id="doc_figure_u.168"></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.162"></div> <pre>
+<div id="doc_figure_u.169"></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>
@@ -26056,10 +26206,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.163"></div> <pre>
+<div id="doc_figure_u.170"></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.164"></div> <pre>
+<div id="doc_figure_u.171"></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>
@@ -26070,10 +26220,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.165"></div> <pre>
+<div id="doc_figure_u.172"></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.166"></div> <pre>
+<div id="doc_figure_u.173"></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>
@@ -26084,10 +26234,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.167"></div> <pre>
+<div id="doc_figure_u.174"></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.168"></div> <pre>
+<div id="doc_figure_u.175"></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>
@@ -26098,10 +26248,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.169"></div> <pre>
+<div id="doc_figure_u.176"></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.170"></div> <pre>
+<div id="doc_figure_u.177"></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>
@@ -26112,10 +26262,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.171"></div> <pre>
+<div id="doc_figure_u.178"></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.172"></div> <pre>
+<div id="doc_figure_u.179"></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>
@@ -26126,10 +26276,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.173"></div> <pre>
+<div id="doc_figure_u.180"></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.174"></div> <pre>
+<div id="doc_figure_u.181"></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>
@@ -26140,10 +26290,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.175"></div> <pre>
+<div id="doc_figure_u.182"></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.176"></div> <pre>
+<div id="doc_figure_u.183"></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>
@@ -26183,7 +26333,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.177"></div> <pre>
+<div id="doc_figure_u.184"></div> <pre>
sh bin/setup.sh
cd build
../configure
@@ -26192,7 +26342,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.178"></div> <pre>
+<div id="doc_figure_u.185"></div> <pre>
--enable-warnings Turn on compiler warnings
--enable-debug Turn on debugging
--enable-text-only Turn on text-only rendering
@@ -26212,7 +26362,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.179"></div> <pre>
+<div id="doc_figure_u.186"></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>
@@ -26236,10 +26386,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.180"></div> <pre>
+<div id="doc_figure_u.187"></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.181"></div> <pre>
+<div id="doc_figure_u.188"></div> <pre>
int main (int argc, char **argv)
{
argc = xo_parse_args(argc, argv);
@@ -26247,8 +26397,8 @@ jQuery(function ($) {
return argc;
....
}
- </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 2.5</a>). libxo provides the xo_finish_atexit function that is suitable for use with the atexit(3) function.</p>
-<div id="doc_figure_u.182"></div> <pre>
+ </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>
atexit(xo_finish_atexit);
</pre> </div>
<div class="content">
@@ -26258,20 +26408,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.183"></div> <pre>
+<div id="doc_figure_u.190"></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.184"></div> <pre>
+<div id="doc_figure_u.191"></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.185"></div> <pre>
+<div id="doc_figure_u.192"></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.186"></div> <pre>
+<div id="doc_figure_u.193"></div> <pre>
snprintf(buf, sizeof(buf), "(%u/%u/%u)", min, ave, max);
printf("%30s", buf);
@@ -26285,7 +26435,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.187"></div> <pre>
+<div id="doc_figure_u.194"></div> <pre>
printf("table %d\n", tnum);
for (i = 0; i &lt; tmax; i++) {
printf(" %s %d\n", table[i].name, table[i].size);
@@ -26303,7 +26453,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.188"></div> <pre>
+<div id="doc_figure_u.195"></div> <pre>
printf("Paging information:\n");
printf(" Free: %lu\n", free);
printf(" Active: %lu\n", active);
@@ -26322,7 +26472,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.189"></div> <pre>
+<div id="doc_figure_u.196"></div> <pre>
err(1, "cannot open output file: %s", file);
xo_err(1, "cannot open output file: %s", file);
@@ -26340,12 +26490,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.190"></div> <pre>
+<div id="doc_figure_u.197"></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.191"></div> <pre>
+<div id="doc_figure_u.198"></div> <pre>
EXAMPLE:
% xopo -s "There are {:count/%u} {:event/%.6s} events\n"
There are {:count} {:event} events\n
@@ -26378,7 +26528,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.192"></div> <pre>
+<div id="doc_figure_u.199"></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>
@@ -26396,7 +26546,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.193"></div> <pre>
+<div id="doc_figure_u.200"></div> <pre>
printf(gettext("Received %zu %s from {g:server} server\n"),
counter, ngettext("byte", "bytes", counter),
gettext("web"));
@@ -26404,17 +26554,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.194"></div> <pre>
+<div id="doc_figure_u.201"></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.195"></div> <pre>
+<div id="doc_figure_u.202"></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.196"></div> <pre>
+<div id="doc_figure_u.203"></div> <pre>
printf(dgettext("dns", "Host %s not found: %d(%s)\n"),
name, errno, dgettext("strerror", strerror(errno)));
@@ -26439,7 +26589,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.197"></div> <pre>
+<div id="doc_figure_u.204"></div> <pre>
int
main (int argc, char **argv)
{
@@ -26532,7 +26682,7 @@ jQuery(function ($) {
return 0;
}
</pre> <p id="doc_section_10_1_p_3">Text output:</p>
-<div id="doc_figure_u.198"></div> <pre>
+<div id="doc_figure_u.205"></div> <pre>
% ./testxo --libxo text
Item 'gum':
Total sold: 1412.0
@@ -26565,7 +26715,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.199"></div> <pre>
+<div id="doc_figure_u.206"></div> <pre>
% ./testxo --libxo json,pretty
"top": {
"data": {
@@ -26620,7 +26770,7 @@ jQuery(function ($) {
}
}
</pre> <p id="doc_section_10_1_p_7">XML output:</p>
-<div id="doc_figure_u.200"></div> <pre>
+<div id="doc_figure_u.207"></div> <pre>
% ./testxo --libxo pretty,xml
&lt;top&gt;
&lt;data&gt;
@@ -26671,7 +26821,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.201"></div> <pre>
+<div id="doc_figure_u.208"></div> <pre>
% ./testxo --libxo pretty,html
&lt;div class="line"&gt;
&lt;div class="label"&gt;Item&lt;/div&gt;
@@ -26866,7 +27016,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.202"></div> <pre>
+<div id="doc_figure_u.209"></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 1e7acc7..ba63702 100644
--- a/contrib/libxo/doc/libxo.txt
+++ b/contrib/libxo/doc/libxo.txt
@@ -699,25 +699,26 @@ XOF_WARN is set, a warning will be generated.
Field modifiers are flags which modify the way content emitted for
particular output styles:
-|---+---------------+-------------------------------------------------|
-| M | Name | Description |
-|---+---------------+-------------------------------------------------|
-| c | colon | A colon (":") is appended after the label |
-| d | display | Only emit field for display styles (text/HTML) |
-| e | encoding | Only emit for encoding styles (XML/JSON) |
-| g | gettext | Call gettext on field's render content |
-| h | humanize (hn) | Format large numbers in human-readable style |
-| | hn-space | Humanize: Place space between numeric and unit |
-| | hn-decimal | Humanize: Add a decimal digit, if number < 10 |
-| | hn-1000 | Humanize: Use 1000 as divisor instead of 1024 |
-| k | key | Field is a key, suitable for XPath predicates |
-| l | leaf-list | Field is a leaf-list |
-| n | no-quotes | Do not quote the field when using JSON style |
-| p | plural | Gettext: Use comma-separated plural form |
-| q | quotes | Quote the field when using JSON style |
-| t | trim | Trim leading and trailing whitespace |
-| w | white | A blank (" ") is appended after the label |
-|---+---------------+-------------------------------------------------|
+|---+---------------+--------------------------------------------------|
+| M | Name | Description |
+|---+---------------+--------------------------------------------------|
+| a | argument | The content appears as a 'const char *' argument |
+| c | colon | A colon (":") is appended after the label |
+| d | display | Only emit field for display styles (text/HTML) |
+| e | encoding | Only emit for encoding styles (XML/JSON) |
+| g | gettext | Call gettext on field's render content |
+| h | humanize (hn) | Format large numbers in human-readable style |
+| | hn-space | Humanize: Place space between numeric and unit |
+| | hn-decimal | Humanize: Add a decimal digit, if number < 10 |
+| | hn-1000 | Humanize: Use 1000 as divisor instead of 1024 |
+| k | key | Field is a key, suitable for XPath predicates |
+| l | leaf-list | Field is a leaf-list |
+| n | no-quotes | Do not quote the field when using JSON style |
+| p | plural | Gettext: Use comma-separated plural form |
+| q | quotes | Quote the field when using JSON style |
+| t | trim | Trim leading and trailing whitespace |
+| w | white | A blank (" ") is appended after the label |
+|---+---------------+--------------------------------------------------|
Roles and modifiers can also use more verbose names, when preceeded by
a comma. For example, the modifier string "Lwc" (or "L,white,colon")
@@ -727,6 +728,27 @@ modifier string "Vkq" (or ":key,quote") means the field has a value
role (the default role), that it is a key for the current instance,
and that the value should be quoted when encoded for JSON.
+**** The Argument Modifier ({a:})
+
+The argument modifier indicates that the content of the field
+descriptor will be placed as a UTF-8 string (const char *) argument
+within the xo_emit parameters.
+
+ EXAMPLE:
+ xo_emit("{La:} {a:}\n", "Label text", "label", "value");
+ TEXT:
+ Label text value
+ JSON:
+ "label": "value"
+ XML:
+ <label>value</label>
+
+The argument modifier allows field names for value fields to be passed
+on the stack, avoiding the need to build a field descriptor using
+snprintf. For many field roles, the argument modifier is not needed,
+since those roles have specific mechanisms for arguments, such as
+"{C:fg-%s}".
+
**** The Colon Modifier ({c:})
The colon modifier appends a single colon to the data value:
@@ -907,6 +929,21 @@ needed, but often this needs to be controlled by the caller.
JSON:
"year": "2014"
+The heuristic is based on the format; if the format uses any of the
+following conversion specifiers, then no quotes are used:
+
+ d i o u x X D O U e E f F g G a A c C p
+
+**** The Trim Modifier ({t:})
+
+The trim modifier removes any leading or trailing whitespace from
+the value.
+
+ EXAMPLE:
+ xo_emit("{t:description}", " some input ");
+ JSON:
+ "description": "some input"
+
**** The White Space Modifier ({w:})
The white space modifier appends a single space to the data value:
@@ -1029,6 +1066,24 @@ 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-8".
+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}",
+ L"except for wide strings");
+
+"%S" is equivalent to "%ls".
+
+|--------+-----------------+-------------------------------|
+| Format | Argument Type | Argument Contents |
+|--------+-----------------+-------------------------------|
+| %s | const char * | UTF-8 string |
+| %S | const char * | UTF-8 string (alias for '%s') |
+| %ls | const wchar_t * | Wide character UNICODE string |
+| %hs | const char * | locale-based string |
+|--------+-----------------+-------------------------------|
+
For example, a function is passed a locale-base name, a hat size,
and a time value. The hat size is formatted in a UTF-8 (ASCII)
string, and the time value is formatted into a wchar_t string.
@@ -1163,6 +1218,53 @@ variants might be wise.
| xo_emit_errc | xo_emit_errc_p |
|------------------+------------------------|
+*** Retaining Parsed Format Information @retain@
+
+libxo can retain the parsed internal information related to the given
+format string, allowing subsequent xo_emit calls, the retained
+information is used, avoiding repetitive parsing of the format string.
+
+ SYNTAX:
+ int xo_emit_f(xo_emit_flags_t flags, const char fmt, ...);
+ EXAMPLE:
+ xo_emit_f(XOEF_RETAIN, "{:some/%02d}{:thing/%-6s}{:fancy}\n",
+ some, thing, fancy);
+
+To retain parsed format information, use the XOEF_RETAIN flag to the
+xo_emit_f() function. A complete set of xo_emit_f functions exist to
+match all the xo_emit function signatures (with handles, varadic
+argument, and printf-like flags):
+
+|------------------+------------------------|
+| Function | Flags Equivalent |
+|------------------+------------------------|
+| xo_emit_hv | xo_emit_hvf |
+| xo_emit_h | xo_emit_hf |
+| xo_emit | xo_emit_f |
+| xo_emit_hvp | xo_emit_hvfp |
+| xo_emit_hp | xo_emit_hfp |
+| xo_emit_p | xo_emit_fp |
+|------------------+------------------------|
+
+The format string must be immutable across multiple calls to xo_emit_f(),
+since the library retains the string. Typically this is done by using
+static constant strings, such as string literals. If the string is not
+immutable, the XOEF_RETAIN flag must not be used.
+
+The functions xo_retain_clear() and xo_retain_clear_all() release
+internal information on either a single format string or all format
+strings, respectively. Neither is required, but the library will
+retain this information until it is cleared or the process exits.
+
+ const char *fmt = "{:name} {:count/%d}\n";
+ for (i = 0; i < 1000; i++) {
+ xo_open_instance("item");
+ xo_emit_f(XOEF_RETAIN, fmt, name[i], count[i]);
+ }
+ xo_retain_clear(fmt);
+
+The retained information is kept as thread-specific data.
+
*** Example
In this example, the value for the number of items in stock is emitted:
@@ -1196,46 +1298,6 @@ penultimate line to:
data-type="number"
data-help="Number of items in stock">144</div>
-** Command-line Arguments
-
-libxo uses command line options to trigger rendering behavior. The
-following options are recognised:
-
-- --libxo <options>
-- --libxo=<options>
-- --libxo:<brief-options>
-
-Options is a comma-separated list of tokens that correspond to output
-styles, flags, or features:
-
-|-------------+-------------------------------------------------------|
-| Token | Action |
-|-------------+-------------------------------------------------------|
-| color | Enable colors/effects for display styles (TEXT, HTML) |
-| dtrt | Enable "Do The Right Thing" mode |
-| html | Emit HTML output |
-| indent=xx | Set the indentation level |
-| info | Add info attributes (HTML) |
-| json | Emit JSON output |
-| keys | Emit the key attribute for keys (XML) |
-| log-gettext | Log (via stderr) each gettext(3) string lookup |
-| log-syslog | Log (via stderr) each syslog message (via xo_syslog) |
-| no-humanize | Ignore the {h:} modifier (TEXT, HTML) |
-| no-locale | Do not initialize the locale setting |
-| no-top | Do not emit a top set of braces (JSON) |
-| not-first | Pretend the 1st output item was not 1st (JSON) |
-| pretty | Emit pretty-printed output |
-| text | Emit TEXT output |
-| underscores | Replace XML-friendly "-"s with JSON friendly "_"s e |
-| units | Add the 'units' (XML) or 'data-units (HTML) attribute |
-| warn | Emit warnings when libxo detects bad calls |
-| warn-xml | Emit warnings in XML |
-| xml | Emit XML output |
-| xpath | Add XPath expressions (HTML) |
-|-------------+-------------------------------------------------------|
-
-The brief options are detailed in ^LIBXO_OPTIONS^.
-
** Representing Hierarchy
For XML and JSON, individual fields appear inside hierarchies which
@@ -1382,68 +1444,89 @@ properly.
xo_close_marker("fish-guts");
}
-** Handles @handles@
-
-libxo uses "handles" to control its rendering functionality. The
-handle contains state and buffered data, as well as callback functions
-to process data.
-
-A default handle is used when a NULL is passed to functions accepting
-a handle. This handle is initialized to write its data to stdout
-using the default style of text (XO_STYLE_TEXT).
-
-For the convenience of callers, the libxo library includes handle-less
-functions that implicitly use the default handle. Any function that
-takes a handle will use the default handle is a value of NULL is
-passed in place of a valid handle.
-
-For example, the following are equivalent:
-
- xo_emit("test");
- xo_emit_h(NULL, "test");
+** Command-line Arguments
-Handles are created using xo_create() and destroy using xo_destroy().
+libxo uses command line options to trigger rendering behavior. The
+following options are recognised:
-** UTF-8
+- --libxo <options>
+- --libxo=<options>
+- --libxo:<brief-options>
-All strings for libxo must be UTF-8. libxo will handle turning them
-into locale-based strings for display to the user.
+Programs using libxo are expecting to call the xo_parse_args function
+to parse these arguments. See ^xo_parse_args^ for details.
-The only exception is argument formatted using the "%ls" format, which
-require a wide character string (wchar_t *) as input. 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.
+Options is a comma-separated list of tokens that correspond to output
+styles, flags, or features:
- xo_emit("Alll strings are utf-8 content {:tag/%ls}",
- L"except for wide strings");
+|-------------+-------------------------------------------------------|
+| Token | Action |
+|-------------+-------------------------------------------------------|
+| color | Enable colors/effects for display styles (TEXT, HTML) |
+| dtrt | Enable "Do The Right Thing" mode |
+| html | Emit HTML output |
+| indent=xx | Set the indentation level |
+| info | Add info attributes (HTML) |
+| json | Emit JSON output |
+| keys | Emit the key attribute for keys (XML) |
+| log-gettext | Log (via stderr) each gettext(3) string lookup |
+| log-syslog | Log (via stderr) each syslog message (via xo_syslog) |
+| no-humanize | Ignore the {h:} modifier (TEXT, HTML) |
+| no-locale | Do not initialize the locale setting |
+| no-retain | Prevent retaining formatting information |
+| no-top | Do not emit a top set of braces (JSON) |
+| not-first | Pretend the 1st output item was not 1st (JSON) |
+| pretty | Emit pretty-printed output |
+| retain | Force retaining formatting information |
+| text | Emit TEXT output |
+| underscores | Replace XML-friendly "-"s with JSON friendly "_"s e |
+| units | Add the 'units' (XML) or 'data-units (HTML) attribute |
+| warn | Emit warnings when libxo detects bad calls |
+| warn-xml | Emit warnings in XML |
+| xml | Emit XML output |
+| xpath | Add XPath expressions (HTML) |
+|-------------+-------------------------------------------------------|
-"%S" is equivalent to "%ls".
+The brief options are detailed in ^LIBXO_OPTIONS^.
* The libxo API
This section gives details about the functions in libxo, how to call
them, and the actions they perform.
-** Handles
+** Handles @handles@
+
+libxo uses "handles" to control its rendering functionality. The
+handle contains state and buffered data, as well as callback functions
+to process data.
Handles give an abstraction for libxo that encapsulates the state of a
stream of output. Handles have the data type "xo_handle_t" and are
opaque to the caller.
The library has a default handle that is automatically initialized.
-By default, this handle will send text style output to standard output.
-The xo_set_style and xo_set_flags functions can be used to change this
-behavior.
-
-Many libxo functions take a handle as their first parameter; most that
-do not use the default handle. Any function taking a handle can
-be passed NULL to access the default handle.
+By default, this handle will send text style output (XO_STYLE_TEXT) to
+standard output. The xo_set_style and xo_set_flags functions can be
+used to change this behavior.
For the typical command that is generating output on standard output,
there is no need to create an explicit handle, but they are available
when needed, e.g., for daemons that generate multiple streams of
output.
+Many libxo functions take a handle as their first parameter; most that
+do not use the default handle. Any function taking a handle can be
+passed NULL to access the default handle. For the convenience of
+callers, the libxo library includes handle-less functions that
+implicitly use the default handle.
+
+For example, the following are equivalent:
+
+ xo_emit("test");
+ xo_emit_h(NULL, "test");
+
+Handles are created using xo_create() and destroy using xo_destroy().
+
*** xo_create
A handle can be allocated using the xo_create() function:
@@ -1653,11 +1736,34 @@ string, since an inappropriate cast can ruin your day. The vap
argument to xo_emit_hv() points to a variable argument list that can
be used to retrieve arguments via va_arg().
+*** Single Field Emitting Functions (xo_emit_field) @xo_emit_field@
+
+The following functions can also make output, but only make a single
+field at a time:
+
+ int 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_emit_field_h (xo_handle_t *xop, const char *rolmod,
+ const char *contents, const char *fmt,
+ const char *efmt, ...);
+
+ int xo_emit_field (const char *rolmod, const char *contents,
+ const char *fmt, const char *efmt, ...);
+
+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.
+
+ xo_emit("T", "Host name is ", NULL, NULL);
+ xo_emit("V", "host-name", NULL, NULL, host-name);
+
*** Attributes (xo_attr) @xo_attr@
The xo_attr() function emits attributes for the XML output style.
-
int xo_attr (const char *name, const char *fmt, ...);
int xo_attr_h (xo_handle_t *xop, const char *name,
const char *fmt, ...);
@@ -2555,23 +2661,23 @@ In 2001, we added an XML API to the JUNOS operating system, which is
built on top of FreeBSD. Eventually this API became standardized as
the NETCONF API (RFC 6241). As part of this effort, we modified many
FreeBSD utilities to emit XML, typically via a "-X" switch. The
-results were mixed. The cost of maintaining this code, updating it
+results were mixed. The cost of maintaining this code, updating it,
and carrying it were non-trivial, and contributed to our expense (and
the associated delay) with upgrading the version of FreeBSD on which
each release of JUNOS is based.
A recent (2014) effort within JUNOS aims at removing our modifications
to the underlying FreeBSD code as a means of reducing the expense and
-delay. JUNOS is structured to have system components generate XML
-that is rendered by the CLI (think: login shell) into human-readable
-text. This allows the API to use the same plumbing as the CLI, and
-ensures that all components emit XML, and that it is emitted with
-knowledge of the consumer of that XML, yielding an API that have no
-incremental cost or feature delay.
+delay in tracking HEAD. JUNOS is structured to have system components
+generate XML that is rendered by the CLI (think: login shell) into
+human-readable text. This allows the API to use the same plumbing as
+the CLI, and ensures that all components emit XML, and that it is
+emitted with knowledge of the consumer of that XML, yielding an API
+that have no incremental cost or feature delay.
libxo is an effort to mix the best aspects of the JUNOS strategy into
FreeBSD in a seemless way, allowing commands to make printf-like
-output calls without needing to care how the output is rendered.
+output calls with a single code path.
*** Did the complex semantics of format strings evolve over time?
diff --git a/contrib/libxo/encoder/cbor/enc_cbor.c b/contrib/libxo/encoder/cbor/enc_cbor.c
index 513063f..7c0a1d3 100644
--- a/contrib/libxo/encoder/cbor/enc_cbor.c
+++ b/contrib/libxo/encoder/cbor/enc_cbor.c
@@ -135,7 +135,7 @@ cbor_encode_uint (xo_buffer_t *xbp, uint64_t minor, unsigned limit)
char *bp = xbp->xb_curp;
int i, m;
- if (minor > (1UL<<32)) {
+ if (minor > (1ULL << 32)) {
*bp++ |= CBOR_LEN64;
m = 64;
diff --git a/contrib/libxo/libxo-config.in b/contrib/libxo/libxo-config.in
index 3dbb7d4..f08f234 100644
--- a/contrib/libxo/libxo-config.in
+++ b/contrib/libxo/libxo-config.in
@@ -77,34 +77,34 @@ while test $# -gt 0; do
;;
--cflags)
- echo -I@LIBXO_INCLUDEDIR@ @LIBXO_CFLAGS@
+ echo -I@XO_INCLUDEDIR@ @XO_CFLAGS@
;;
--share)
- echo @LIBXO_SHAREDIR@
+ echo @XO_SHAREDIR@
;;
--bindir)
- echo @LIBXO_BINDIR@
+ echo @XO_BINDIR@
;;
--libdir)
- echo @LIBXO_LIBDIR@
+ echo @XO_LIBDIR@
;;
--libs)
if [ "`uname`" = "Linux" ]
then
- if [ "@LIBXO_LIBDIR@" = "-L/usr/lib" -o "@LIBXO_LIBDIR@" = "-L/usr/lib64" ]
+ if [ "@XO_LIBDIR@" = "-L/usr/lib" -o "@XO_LIBDIR@" = "-L/usr/lib64" ]
then
- echo @LIBXO_LIBS@
+ echo @XO_LIBS@
else
- echo -L@LIBXO_LIBDIR@ @LIBXO_LIBS@
+ echo -L@XO_LIBDIR@ @XO_LIBS@
fi
else
- echo -L@LIBXO_LIBDIR@ @LIBXO_LIBS@ @WIN32_EXTRA_LIBADD@
+ echo -L@XO_LIBDIR@ @XO_LIBS@
fi
;;
diff --git a/contrib/libxo/libxo/libxo.c b/contrib/libxo/libxo/libxo.c
index cceebfa..194a096 100644
--- a/contrib/libxo/libxo/libxo.c
+++ b/contrib/libxo/libxo/libxo.c
@@ -19,7 +19,8 @@
* http://juniper.github.io/libxo/libxo-manual.html
*
* For first time readers, the core bits of code to start looking at are:
- * - xo_do_emit() -- the central function of the library
+ * - xo_do_emit() -- parse and emit a set of fields
+ * - xo_do_emit_fields -- the central function of the library
* - xo_do_format_field() -- handles formatting a single field
* - xo_transiton() -- the state machine that keeps things sane
* and of course the "xo_handle_t" data structure, which carries all
@@ -120,6 +121,7 @@
const char xo_version[] = LIBXO_VERSION;
const char xo_version_extra[] = LIBXO_VERSION_EXTRA;
+static const char xo_default_format[] = "%s";
#ifndef UNUSED
#define UNUSED __attribute__ ((__unused__))
@@ -338,6 +340,7 @@ typedef unsigned long xo_xff_flags_t;
#define XFF_GT_FIELD (1<<19) /* Call gettext() on a field */
#define XFF_GT_PLURAL (1<<20) /* Call dngettext to find plural form */
+#define XFF_ARGUMENT (1<<21) /* Content provided via argument */
/* Flags to turn off when we don't want i18n processing */
#define XFF_GT_FLAGS (XFF_GT_FIELD | XFF_GT_PLURAL)
@@ -1046,7 +1049,7 @@ xo_is_utf8 (char ch)
return (ch & 0x80);
}
-static int
+static inline int
xo_utf8_to_wc_len (const char *buf)
{
unsigned b = (unsigned char) *buf;
@@ -1105,9 +1108,13 @@ xo_buf_utf8_len (xo_handle_t *xop, const char *buf, int bufsiz)
* bits we pull off the first character is dependent on the length,
* but we put 6 bits off all other bytes.
*/
-static wchar_t
+static inline wchar_t
xo_utf8_char (const char *buf, int len)
{
+ /* Most common case: singleton byte */
+ if (len == 1)
+ return (unsigned char) buf[0];
+
int i;
wchar_t wc;
const unsigned char *cp = (const unsigned char *) buf;
@@ -1281,6 +1288,195 @@ xo_data_escape (xo_handle_t *xop, const char *str, int len)
xo_buf_escape(xop, &xop->xo_data, str, len, 0);
}
+#ifdef LIBXO_NO_RETAIN
+/*
+ * Empty implementations of the retain logic
+ */
+
+void
+xo_retain_clear_all (void)
+{
+ return;
+}
+
+void
+xo_retain_clear (const char *fmt UNUSED)
+{
+ return;
+}
+static void
+xo_retain_add (const char *fmt UNUSED, xo_field_info_t *fields UNUSED,
+ unsigned num_fields UNUSED)
+{
+ return;
+}
+
+static int
+xo_retain_find (const char *fmt UNUSED, xo_field_info_t **valp UNUSED,
+ unsigned *nump UNUSED)
+{
+ return -1;
+}
+
+#else /* !LIBXO_NO_RETAIN */
+/*
+ * Retain: We retain parsed field definitions to enhance performance,
+ * especially inside loops. We depend on the caller treating the format
+ * strings as immutable, so that we can retain pointers into them. We
+ * hold the pointers in a hash table, so allow quick access. Retained
+ * information is retained until xo_retain_clear is called.
+ */
+
+/*
+ * xo_retain_entry_t holds information about one retained set of
+ * parsed fields.
+ */
+typedef struct xo_retain_entry_s {
+ struct xo_retain_entry_s *xre_next; /* Pointer to next (older) entry */
+ unsigned long xre_hits; /* Number of times we've hit */
+ const char *xre_format; /* Pointer to format string */
+ unsigned xre_num_fields; /* Number of fields saved */
+ xo_field_info_t *xre_fields; /* Pointer to fields */
+} xo_retain_entry_t;
+
+/*
+ * xo_retain_t holds a complete set of parsed fields as a hash table.
+ */
+#ifndef XO_RETAIN_SIZE
+#define XO_RETAIN_SIZE 6
+#endif /* XO_RETAIN_SIZE */
+#define RETAIN_HASH_SIZE (1<<XO_RETAIN_SIZE)
+
+typedef struct xo_retain_s {
+ xo_retain_entry_t *xr_bucket[RETAIN_HASH_SIZE];
+} xo_retain_t;
+
+static THREAD_LOCAL(xo_retain_t) xo_retain;
+static THREAD_LOCAL(unsigned) xo_retain_count;
+
+/*
+ * Simple hash function based on Thomas Wang's paper. The original is
+ * gone, but an archive is available on the Way Back Machine:
+ *
+ * http://web.archive.org/web/20071223173210/\
+ * http://www.concentric.net/~Ttwang/tech/inthash.htm
+ *
+ * For our purposes, we can assume the low four bits are uninteresting
+ * since any string less that 16 bytes wouldn't be worthy of
+ * retaining. We toss the high bits also, since these bits are likely
+ * to be common among constant format strings. We then run Wang's
+ * algorithm, and cap the result at RETAIN_HASH_SIZE.
+ */
+static unsigned
+xo_retain_hash (const char *fmt)
+{
+ volatile uintptr_t iptr = (uintptr_t) (const void *) fmt;
+
+ /* Discard low four bits and high bits; they aren't interesting */
+ uint32_t val = (uint32_t) ((iptr >> 4) & (((1 << 24) - 1)));
+
+ val = (val ^ 61) ^ (val >> 16);
+ val = val + (val << 3);
+ val = val ^ (val >> 4);
+ val = val * 0x3a8f05c5; /* My large prime number */
+ val = val ^ (val >> 15);
+ val &= RETAIN_HASH_SIZE - 1;
+
+ return val;
+}
+
+/*
+ * Walk all buckets, clearing all retained entries
+ */
+void
+xo_retain_clear_all (void)
+{
+ int i;
+ xo_retain_entry_t *xrep, *next;
+
+ for (i = 0; i < RETAIN_HASH_SIZE; i++) {
+ for (xrep = xo_retain.xr_bucket[i]; xrep; xrep = next) {
+ next = xrep->xre_next;
+ xo_free(xrep);
+ }
+ xo_retain.xr_bucket[i] = NULL;
+ }
+ xo_retain_count = 0;
+}
+
+/*
+ * Walk all buckets, clearing all retained entries
+ */
+void
+xo_retain_clear (const char *fmt)
+{
+ xo_retain_entry_t **xrepp;
+ unsigned hash = xo_retain_hash(fmt);
+
+ for (xrepp = &xo_retain.xr_bucket[hash]; *xrepp;
+ xrepp = &(*xrepp)->xre_next) {
+ if ((*xrepp)->xre_format == fmt) {
+ *xrepp = (*xrepp)->xre_next;
+ xo_retain_count -= 1;
+ return;
+ }
+ }
+}
+
+/*
+ * Search the hash for an entry matching 'fmt'; return it's fields.
+ */
+static int
+xo_retain_find (const char *fmt, xo_field_info_t **valp, unsigned *nump)
+{
+ if (xo_retain_count == 0)
+ return -1;
+
+ unsigned hash = xo_retain_hash(fmt);
+ xo_retain_entry_t *xrep;
+
+ for (xrep = xo_retain.xr_bucket[hash]; xrep != NULL;
+ xrep = xrep->xre_next) {
+ if (xrep->xre_format == fmt) {
+ *valp = xrep->xre_fields;
+ *nump = xrep->xre_num_fields;
+ xrep->xre_hits += 1;
+ return 0;
+ }
+ }
+
+ return -1;
+}
+
+static void
+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);
+ xo_field_info_t *xfip;
+
+ xrep = xo_realloc(NULL, sz);
+ if (xrep == NULL)
+ return;
+
+ xfip = (xo_field_info_t *) &xrep[1];
+ memcpy(xfip, fields, num_fields * sizeof(*fields));
+
+ bzero(xrep, sizeof(*xrep));
+
+ xrep->xre_format = fmt;
+ xrep->xre_fields = xfip;
+ xrep->xre_num_fields = num_fields;
+
+ /* Record the field info in the retain bucket */
+ xrep->xre_next = xo_retain.xr_bucket[hash];
+ xo_retain.xr_bucket[hash] = xrep;
+ xo_retain_count += 1;
+}
+
+#endif /* !LIBXO_NO_RETAIN */
+
/*
* Generate a warning. Normally, this is a text message written to
* standard error. If the XOF_WARN_XML flag is set, then we generate
@@ -1574,6 +1770,19 @@ xo_message_hcv (xo_handle_t *xop, int code, const char *fmt, va_list vap)
break;
}
+ switch (xo_style(xop)) {
+ case XO_STYLE_HTML:
+ if (XOIF_ISSET(xop, XOIF_DIV_OPEN)) {
+ static char div_close[] = "</div>";
+ XOIF_CLEAR(xop, XOIF_DIV_OPEN);
+ xo_data_append(xop, div_close, sizeof(div_close) - 1);
+
+ if (XOF_ISSET(xop, XOF_PRETTY))
+ xo_data_append(xop, "\n", 1);
+ }
+ break;
+ }
+
(void) xo_flush_h(xop);
}
@@ -1680,6 +1889,39 @@ xo_create_to_file (FILE *fp, xo_style_t style, xo_xof_flags_t flags)
}
/**
+ * Set the default handler to output to a file.
+ * @xop libxo handle
+ * @fp FILE pointer to use
+ */
+int
+xo_set_file_h (xo_handle_t *xop, FILE *fp)
+{
+ xop = xo_default(xop);
+
+ if (fp == NULL) {
+ xo_failure(xop, "xo_set_file: NULL fp");
+ return -1;
+ }
+
+ xop->xo_opaque = fp;
+ xop->xo_write = xo_write_to_file;
+ xop->xo_close = xo_close_file;
+ xop->xo_flush = xo_flush_file;
+
+ return 0;
+}
+
+/**
+ * Set the default handler to output to a file.
+ * @fp FILE pointer to use
+ */
+int
+xo_set_file (FILE *fp)
+{
+ return xo_set_file_h(NULL, fp);
+}
+
+/**
* Release any resources held by the handle.
* @xop XO handle to alter (or NULL for default handle)
*/
@@ -1824,9 +2066,11 @@ static xo_mapping_t xo_xof_names[] = {
{ XOF_LOG_SYSLOG, "log-syslog" },
{ XOF_NO_HUMANIZE, "no-humanize" },
{ XOF_NO_LOCALE, "no-locale" },
+ { XOF_RETAIN_NONE, "no-retain" },
{ XOF_NO_TOP, "no-top" },
{ XOF_NOT_FIRST, "not-first" },
{ XOF_PRETTY, "pretty" },
+ { XOF_RETAIN_ALL, "retain" },
{ XOF_UNDERSCORES, "underscores" },
{ XOF_UNITS, "units" },
{ XOF_WARN, "warn" },
@@ -3374,6 +3618,15 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
static char div_end[] = "\">";
static char div_close[] = "</div>";
+ /* The encoding format defaults to the normal format */
+ if (encoding == NULL) {
+ char *enc = alloca(vlen + 1);
+ memcpy(enc, value, vlen);
+ enc[vlen] = '\0';
+ encoding = xo_fix_encoding(xop, enc);
+ elen = strlen(encoding);
+ }
+
/*
* To build our XPath predicate, we need to save the va_list before
* we format our data, and then restore it before we format the
@@ -3406,15 +3659,6 @@ xo_buf_append_div (xo_handle_t *xop, const char *class, xo_xff_flags_t flags,
else
xo_buf_append(pbp, "='", 2);
- /* The encoding format defaults to the normal format */
- if (encoding == NULL) {
- char *enc = alloca(vlen + 1);
- memcpy(enc, value, vlen);
- enc[vlen] = '\0';
- encoding = xo_fix_encoding(xop, enc);
- elen = strlen(encoding);
- }
-
xo_xff_flags_t pflags = flags | XFF_XML | XFF_ATTR;
pflags &= ~(XFF_NO_OUTPUT | XFF_ENCODE_ONLY);
xo_do_format_field(xop, pbp, encoding, elen, pflags);
@@ -3613,10 +3857,9 @@ 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)
+xo_format_title (xo_handle_t *xop, xo_field_info_t *xfip,
+ const char *str, unsigned len)
{
- const char *str = xfip->xfi_content;
- unsigned len = xfip->xfi_clen;
const char *fmt = xfip->xfi_format;
unsigned flen = xfip->xfi_flen;
xo_xff_flags_t flags = xfip->xfi_flags;
@@ -4083,10 +4326,9 @@ 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)
+xo_set_gettext_domain (xo_handle_t *xop, xo_field_info_t *xfip,
+ const char *str, unsigned len)
{
- const char *str = xfip->xfi_content;
- unsigned len = xfip->xfi_clen;
const char *fmt = xfip->xfi_format;
unsigned flen = xfip->xfi_flen;
@@ -4335,13 +4577,13 @@ xo_colors_enabled (xo_handle_t *xop UNUSED)
}
static void
-xo_colors_handle_text (xo_handle_t *xop UNUSED, xo_colors_t *newp)
+xo_colors_handle_text (xo_handle_t *xop, xo_colors_t *newp)
{
char buf[BUFSIZ];
char *cp = buf, *ep = buf + sizeof(buf);
unsigned i, bit;
xo_colors_t *oldp = &xop->xo_colors;
- const char *code;
+ const char *code = NULL;
/*
* Start the buffer with an escape. We don't want to add the '['
@@ -4460,10 +4702,9 @@ 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)
+xo_format_colors (xo_handle_t *xop, xo_field_info_t *xfip,
+ const char *str, unsigned len)
{
- const char *str = xfip->xfi_content;
- unsigned len = xfip->xfi_clen;
const char *fmt = xfip->xfi_format;
unsigned flen = xfip->xfi_flen;
@@ -4534,10 +4775,9 @@ 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)
+xo_format_units (xo_handle_t *xop, xo_field_info_t *xfip,
+ const char *str, unsigned len)
{
- const char *str = xfip->xfi_content;
- unsigned len = xfip->xfi_clen;
const char *fmt = xfip->xfi_format;
unsigned flen = xfip->xfi_flen;
xo_xff_flags_t flags = xfip->xfi_flags;
@@ -4589,10 +4829,9 @@ xo_format_units (xo_handle_t *xop, xo_field_info_t *xfip)
}
static int
-xo_find_width (xo_handle_t *xop, xo_field_info_t *xfip)
+xo_find_width (xo_handle_t *xop, xo_field_info_t *xfip,
+ const char *str, unsigned len)
{
- const char *str = xfip->xfi_content;
- unsigned len = xfip->xfi_clen;
const char *fmt = xfip->xfi_format;
unsigned flen = xfip->xfi_flen;
@@ -4639,7 +4878,8 @@ xo_anchor_clear (xo_handle_t *xop)
* format it when the end anchor tag is seen.
*/
static void
-xo_anchor_start (xo_handle_t *xop, xo_field_info_t *xfip)
+xo_anchor_start (xo_handle_t *xop, xo_field_info_t *xfip,
+ const char *str, unsigned len)
{
if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML)
return;
@@ -4656,11 +4896,12 @@ xo_anchor_start (xo_handle_t *xop, xo_field_info_t *xfip)
* Now we find the width, if possible. If it's not there,
* we'll get it on the end anchor.
*/
- xop->xo_anchor_min_width = xo_find_width(xop, xfip);
+ xop->xo_anchor_min_width = xo_find_width(xop, xfip, str, len);
}
static void
-xo_anchor_stop (xo_handle_t *xop, xo_field_info_t *xfip)
+xo_anchor_stop (xo_handle_t *xop, xo_field_info_t *xfip,
+ const char *str, unsigned len)
{
if (xo_style(xop) != XO_STYLE_TEXT && xo_style(xop) != XO_STYLE_HTML)
return;
@@ -4672,7 +4913,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);
+ int width = xo_find_width(xop, xfip, str, len);
if (width == 0)
width = xop->xo_anchor_min_width;
@@ -4787,6 +5028,7 @@ static xo_mapping_t xo_role_names[] = {
#define XO_ROLE_NEWLINE '\n'
static xo_mapping_t xo_modifier_names[] = {
+ { XFF_ARGUMENT, "argument" },
{ XFF_COLON, "colon" },
{ XFF_COMMA, "comma" },
{ XFF_DISPLAY_ONLY, "display" },
@@ -4858,6 +5100,7 @@ xo_count_fields (xo_handle_t *xop UNUSED, const char *fmt)
* '[': start a section of anchored text
* ']': end a section of anchored text
* The following modifiers are also supported:
+ * 'a': content is provided via argument (const char *), not descriptor
* 'c': flag: emit a colon after the label
* 'd': field is only emitted for display styles (text and html)
* 'e': field is only emitted for encoding styles (xml and json)
@@ -4884,7 +5127,7 @@ xo_parse_roles (xo_handle_t *xop, const char *fmt,
xo_xff_flags_t flags = 0;
uint8_t fnum = 0;
- for (sp = basep; sp; sp++) {
+ for (sp = basep; sp && *sp; sp++) {
if (*sp == ':' || *sp == '/' || *sp == '}')
break;
@@ -4961,6 +5204,10 @@ xo_parse_roles (xo_handle_t *xop, const char *fmt,
fnum = (fnum * 10) + (*sp - '0');
break;
+ case 'a':
+ flags |= XFF_ARGUMENT;
+ break;
+
case 'c':
flags |= XFF_COLON;
break;
@@ -5133,7 +5380,6 @@ static int
xo_parse_fields (xo_handle_t *xop, xo_field_info_t *fields,
unsigned num_fields, const char *fmt)
{
- static const char default_format[] = "%s";
const char *cp, *sp, *ep, *basep;
unsigned field = 0;
xo_field_info_t *xfip = fields;
@@ -5267,12 +5513,12 @@ xo_parse_fields (xo_handle_t *xop, xo_field_info_t *fields,
xfip->xfi_next = ++sp;
/* If we have content, then we have a default format */
- if (xfip->xfi_clen || format) {
+ if (xfip->xfi_clen || format || (xfip->xfi_flags & XFF_ARGUMENT)) {
if (format) {
xfip->xfi_format = format;
xfip->xfi_flen = flen;
} else if (xo_role_wants_default_format(xfip->xfi_ftype)) {
- xfip->xfi_format = default_format;
+ xfip->xfi_format = xo_default_format;
xfip->xfi_flen = 2;
}
}
@@ -5568,9 +5814,8 @@ xo_gettext_combine_formats (xo_handle_t *xop, const char *fmt UNUSED,
* Summary: i18n aighn't cheap.
*/
static const char *
-xo_gettext_build_format (xo_handle_t *xop UNUSED,
- xo_field_info_t *fields UNUSED,
- int this_field UNUSED,
+xo_gettext_build_format (xo_handle_t *xop,
+ xo_field_info_t *fields, int this_field,
const char *fmt, char **new_fmtp)
{
if (xo_style_is_encoding(xop))
@@ -5686,17 +5931,22 @@ xo_gettext_rebuild_content (xo_handle_t *xop UNUSED,
#endif /* HAVE_GETTEXT */
/*
- * The central function for emitting libxo output.
+ * Emit a set of fields. This is really the core of libxo.
*/
static int
-xo_do_emit (xo_handle_t *xop, const char *fmt)
+xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields,
+ unsigned max_fields, const char *fmt)
{
int gettext_inuse = 0;
int gettext_changed = 0;
int gettext_reordered = 0;
+ unsigned ftype;
+ xo_xff_flags_t flags;
xo_field_info_t *new_fields = NULL;
-
+ xo_field_info_t *xfip;
+ unsigned field;
int rc = 0;
+
int flush = XOF_ISSET(xop, XOF_FLUSH);
int flush_line = XOF_ISSET(xop, XOF_FLUSH_LINE);
char *new_fmt = NULL;
@@ -5704,20 +5954,6 @@ xo_do_emit (xo_handle_t *xop, const char *fmt)
if (XOIF_ISSET(xop, XOIF_REORDER) || xo_style(xop) == XO_STYLE_ENCODER)
flush_line = 0;
- xop->xo_columns = 0; /* Always reset it */
- xop->xo_errno = errno; /* Save for "%m" */
-
- unsigned max_fields = xo_count_fields(xop, fmt), field;
- xo_field_info_t fields[max_fields], *xfip;
-
- bzero(fields, max_fields * sizeof(fields[0]));
-
- if (xo_parse_fields(xop, fields, max_fields, fmt))
- return -1; /* Warning already displayed */
-
- unsigned ftype;
- xo_xff_flags_t flags;
-
/*
* Some overhead for gettext; if the fields in the msgstr returned
* by gettext are reordered, then we need to record start and end
@@ -5745,6 +5981,18 @@ xo_do_emit (xo_handle_t *xop, const char *fmt)
min_fstart = field;
}
+ const char *content = xfip->xfi_content;
+ int clen = xfip->xfi_clen;
+
+ if (flags & XFF_ARGUMENT) {
+ /*
+ * Argument flag means the content isn't given in the descriptor,
+ * but as a UTF-8 string ('const char *') argument in xo_vap.
+ */
+ content = va_arg(xop->xo_vap, char *);
+ clen = content ? strlen(content) : 0;
+ }
+
if (ftype == XO_ROLE_NEWLINE) {
xo_line_close(xop);
if (flush_line && xo_flush_h(xop) < 0)
@@ -5773,15 +6021,15 @@ xo_do_emit (xo_handle_t *xop, const char *fmt)
}
if (ftype == 'V')
- xo_format_value(xop, xfip->xfi_content, xfip->xfi_clen,
+ xo_format_value(xop, content, clen,
xfip->xfi_format, xfip->xfi_flen,
xfip->xfi_encoding, xfip->xfi_elen, flags);
else if (ftype == '[')
- xo_anchor_start(xop, xfip);
+ xo_anchor_start(xop, xfip, content, clen);
else if (ftype == ']')
- xo_anchor_stop(xop, xfip);
+ xo_anchor_stop(xop, xfip, content, clen);
else if (ftype == 'C')
- xo_format_colors(xop, xfip);
+ xo_format_colors(xop, xfip, content, clen);
else if (ftype == 'G') {
/*
@@ -5792,7 +6040,7 @@ xo_do_emit (xo_handle_t *xop, const char *fmt)
* Since gettext returns strings in a static buffer, we make
* a copy in new_fmt.
*/
- xo_set_gettext_domain(xop, xfip);
+ xo_set_gettext_domain(xop, xfip, content, clen);
if (!gettext_inuse) { /* Only translate once */
gettext_inuse = 1;
@@ -5843,17 +6091,17 @@ xo_do_emit (xo_handle_t *xop, const char *fmt)
}
continue;
- } else if (xfip->xfi_clen || xfip->xfi_format) {
+ } else if (clen || xfip->xfi_format) {
const char *class_name = xo_class_name(ftype);
if (class_name)
xo_format_content(xop, class_name, xo_tag_name(ftype),
- xfip->xfi_content, xfip->xfi_clen,
+ content, clen,
xfip->xfi_format, xfip->xfi_flen, flags);
else if (ftype == 'T')
- xo_format_title(xop, xfip);
+ xo_format_title(xop, xfip, content, clen);
else if (ftype == 'U')
- xo_format_units(xop, xfip);
+ xo_format_units(xop, xfip, content, clen);
else
xo_failure(xop, "unknown field type: '%c'", ftype);
}
@@ -5884,7 +6132,7 @@ xo_do_emit (xo_handle_t *xop, const char *fmt)
if (flush && !XOIF_ISSET(xop, XOIF_ANCHOR)) {
if (xo_write(xop) < 0)
rc = -1; /* Report failure */
- else if (xop->xo_flush && xop->xo_flush(xop->xo_opaque) < 0)
+ else if (xo_flush_h(xop) < 0)
rc = -1;
}
@@ -5905,6 +6153,53 @@ xo_do_emit (xo_handle_t *xop, const char *fmt)
}
/*
+ * Parse and emit a set of fields
+ */
+static int
+xo_do_emit (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt)
+{
+ xop->xo_columns = 0; /* Always reset it */
+ xop->xo_errno = errno; /* Save for "%m" */
+
+ if (fmt == NULL)
+ return 0;
+
+ unsigned max_fields;
+ xo_field_info_t *fields = NULL;
+
+ /* Adjust XOEF_RETAIN based on global flags */
+ if (XOF_ISSET(xop, XOF_RETAIN_ALL))
+ flags |= XOEF_RETAIN;
+ if (XOF_ISSET(xop, XOF_RETAIN_NONE))
+ flags &= ~XOEF_RETAIN;
+
+ /*
+ * Check for 'retain' flag, telling us to retain the field
+ * information. If we've already saved it, then we can avoid
+ * re-parsing the format string.
+ */
+ if (!(flags & XOEF_RETAIN)
+ || xo_retain_find(fmt, &fields, &max_fields) != 0
+ || fields == NULL) {
+
+ /* Nothing retained; parse the format string */
+ max_fields = xo_count_fields(xop, fmt);
+ fields = alloca(max_fields * sizeof(fields[0]));
+ bzero(fields, max_fields * sizeof(fields[0]));
+
+ if (xo_parse_fields(xop, fields, max_fields, fmt))
+ return -1; /* Warning already displayed */
+
+ if (flags & XOEF_RETAIN) {
+ /* Retain the info */
+ xo_retain_add(fmt, fields, max_fields);
+ }
+ }
+
+ return xo_do_emit_fields(xop, fields, max_fields, fmt);
+}
+
+/*
* Rebuild a format string in a gettext-friendly format. This function
* is exposed to tools can perform this function. See xo(1).
*/
@@ -5944,7 +6239,7 @@ xo_emit_hv (xo_handle_t *xop, const char *fmt, va_list vap)
xop = xo_default(xop);
va_copy(xop->xo_vap, vap);
- rc = xo_do_emit(xop, fmt);
+ rc = xo_do_emit(xop, 0, fmt);
va_end(xop->xo_vap);
bzero(&xop->xo_vap, sizeof(xop->xo_vap));
@@ -5958,7 +6253,7 @@ xo_emit_h (xo_handle_t *xop, const char *fmt, ...)
xop = xo_default(xop);
va_start(xop->xo_vap, fmt);
- rc = xo_do_emit(xop, fmt);
+ rc = xo_do_emit(xop, 0, fmt);
va_end(xop->xo_vap);
bzero(&xop->xo_vap, sizeof(xop->xo_vap));
@@ -5972,13 +6267,137 @@ xo_emit (const char *fmt, ...)
int rc;
va_start(xop->xo_vap, fmt);
- rc = xo_do_emit(xop, fmt);
+ rc = xo_do_emit(xop, 0, fmt);
+ va_end(xop->xo_vap);
+ bzero(&xop->xo_vap, sizeof(xop->xo_vap));
+
+ return rc;
+}
+
+int
+xo_emit_hvf (xo_handle_t *xop, xo_emit_flags_t flags,
+ const char *fmt, va_list vap)
+{
+ int rc;
+
+ xop = xo_default(xop);
+ va_copy(xop->xo_vap, vap);
+ rc = xo_do_emit(xop, flags, fmt);
+ va_end(xop->xo_vap);
+ bzero(&xop->xo_vap, sizeof(xop->xo_vap));
+
+ return rc;
+}
+
+int
+xo_emit_hf (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt, ...)
+{
+ int rc;
+
+ xop = xo_default(xop);
+ va_start(xop->xo_vap, fmt);
+ rc = xo_do_emit(xop, flags, fmt);
+ va_end(xop->xo_vap);
+ bzero(&xop->xo_vap, sizeof(xop->xo_vap));
+
+ return rc;
+}
+
+int
+xo_emit_f (xo_emit_flags_t flags, const char *fmt, ...)
+{
+ xo_handle_t *xop = xo_default(NULL);
+ int rc;
+
+ va_start(xop->xo_vap, fmt);
+ rc = xo_do_emit(xop, flags, fmt);
va_end(xop->xo_vap);
bzero(&xop->xo_vap, sizeof(xop->xo_vap));
return rc;
}
+/*
+ * Emit a single field by providing the info information typically provided
+ * inside the field description (role, modifiers, and formats). This is
+ * a convenience function to avoid callers using snprintf to build field
+ * descriptions.
+ */
+int
+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;
+
+ xop = xo_default(xop);
+
+ if (rolmod == NULL)
+ rolmod = "V";
+
+ xo_field_info_t xfi;
+
+ bzero(&xfi, sizeof(xfi));
+
+ const char *cp;
+ cp = xo_parse_roles(xop, rolmod, rolmod, &xfi);
+ if (cp == NULL)
+ return -1;
+
+ xfi.xfi_start = fmt;
+ xfi.xfi_content = contents;
+ xfi.xfi_format = fmt;
+ xfi.xfi_encoding = efmt;
+ xfi.xfi_clen = contents ? strlen(contents) : 0;
+ xfi.xfi_flen = fmt ? strlen(fmt) : 0;
+ xfi.xfi_elen = efmt ? strlen(efmt) : 0;
+
+ /* If we have content, then we have a default format */
+ if (contents && fmt == NULL
+ && xo_role_wants_default_format(xfi.xfi_ftype)) {
+ xfi.xfi_format = xo_default_format;
+ xfi.xfi_flen = 2;
+ }
+
+
+
+ va_copy(xop->xo_vap, vap);
+
+ rc = xo_do_emit_fields(xop, &xfi, 1, fmt ?: contents ?: "field");
+
+ va_end(xop->xo_vap);
+
+ return rc;
+}
+
+int
+xo_emit_field_h (xo_handle_t *xop, const char *rolmod, const char *contents,
+ const char *fmt, const char *efmt, ...)
+{
+ int rc;
+ va_list vap;
+
+ va_start(vap, efmt);
+ rc = xo_emit_field_hv(xop, rolmod, contents, fmt, efmt, vap);
+ va_end(vap);
+
+ return rc;
+}
+
+int
+xo_emit_field (const char *rolmod, const char *contents,
+ const char *fmt, const char *efmt, ...)
+{
+ int rc;
+ va_list vap;
+
+ va_start(vap, efmt);
+ rc = xo_emit_field_hv(NULL, rolmod, contents, fmt, efmt, vap);
+ va_end(vap);
+
+ return rc;
+}
+
int
xo_attr_hv (xo_handle_t *xop, const char *name, const char *fmt, va_list vap)
{
@@ -6392,7 +6811,7 @@ xo_open_list_hf (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name)
}
int
-xo_open_list_h (xo_handle_t *xop, const char *name UNUSED)
+xo_open_list_h (xo_handle_t *xop, const char *name)
{
return xo_open_list_hf(xop, 0, name);
}
@@ -6404,7 +6823,7 @@ xo_open_list (const char *name)
}
int
-xo_open_list_hd (xo_handle_t *xop, const char *name UNUSED)
+xo_open_list_hd (xo_handle_t *xop, const char *name)
{
return xo_open_list_hf(xop, XOF_DTRT, name);
}
@@ -7113,6 +7532,11 @@ xo_transition (xo_handle_t *xop, xo_xsf_flags_t flags, const char *name,
xsp->xs_state, new_state);
}
+ /* Handle the flush flag */
+ if (rc >= 0 && XOF_ISSET(xop, XOF_FLUSH))
+ if (xo_flush_h(xop))
+ rc = -1;
+
return rc;
marker_prevents_close:
@@ -7179,22 +7603,11 @@ xo_set_allocator (xo_realloc_func_t realloc_func, xo_free_func_t free_func)
int
xo_flush_h (xo_handle_t *xop)
{
- static char div_close[] = "</div>";
int rc;
xop = xo_default(xop);
switch (xo_style(xop)) {
- case XO_STYLE_HTML:
- if (XOIF_ISSET(xop, XOIF_DIV_OPEN)) {
- XOIF_CLEAR(xop, XOIF_DIV_OPEN);
- xo_data_append(xop, div_close, sizeof(div_close) - 1);
-
- if (XOF_ISSET(xop, XOF_PRETTY))
- xo_data_append(xop, "\n", 1);
- }
- break;
-
case XO_STYLE_ENCODER:
xo_encoder_handle(xop, XO_OP_FLUSH, NULL, NULL);
}
@@ -7435,7 +7848,7 @@ xo_set_program (const char *name)
}
void
-xo_set_version_h (xo_handle_t *xop, const char *version UNUSED)
+xo_set_version_h (xo_handle_t *xop, const char *version)
{
xop = xo_default(xop);
diff --git a/contrib/libxo/libxo/xo.h b/contrib/libxo/libxo/xo.h
index 88bcce2..310b21c 100644
--- a/contrib/libxo/libxo/xo.h
+++ b/contrib/libxo/libxo/xo.h
@@ -94,6 +94,11 @@ typedef unsigned long long xo_xof_flags_t;
#define XOF_LOG_GETTEXT XOF_BIT(28) /** Log (stderr) gettext lookup strings */
#define XOF_UTF8 XOF_BIT(29) /** Force text output to be UTF8 */
+#define XOF_RETAIN_ALL XOF_BIT(30) /** Force use of XOEF_RETAIN */
+#define XOF_RETAIN_NONE XOF_BIT(31) /** Prevent use of XOEF_RETAIN */
+
+typedef unsigned xo_emit_flags_t; /* Flags to xo_emit() and friends */
+#define XOEF_RETAIN (1<<0) /* Retain parsed formatting information */
/*
* The xo_info_t structure provides a mapping between names and
@@ -162,6 +167,12 @@ xo_set_flags (xo_handle_t *xop, xo_xof_flags_t flags);
void
xo_clear_flags (xo_handle_t *xop, xo_xof_flags_t flags);
+int
+xo_set_file_h (xo_handle_t *xop, FILE *fp);
+
+int
+xo_set_file (FILE *fp);
+
void
xo_set_info (xo_handle_t *xop, xo_info_t *infop, int count);
@@ -180,6 +191,16 @@ xo_emit_h (xo_handle_t *xop, const char *fmt, ...);
int
xo_emit (const char *fmt, ...);
+int
+xo_emit_hvf (xo_handle_t *xop, xo_emit_flags_t flags,
+ const char *fmt, va_list vap);
+
+int
+xo_emit_hf (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt, ...);
+
+int
+xo_emit_f (xo_emit_flags_t flags, const char *fmt, ...);
+
PRINTFLIKE(2, 0)
static inline int
xo_emit_hvp (xo_handle_t *xop, const char *fmt, va_list vap)
@@ -209,6 +230,36 @@ xo_emit_p (const char *fmt, ...)
return rc;
}
+PRINTFLIKE(3, 0)
+static inline int
+xo_emit_hvfp (xo_handle_t *xop, xo_emit_flags_t flags,
+ const char *fmt, va_list vap)
+{
+ return xo_emit_hvf(xop, flags, fmt, vap);
+}
+
+PRINTFLIKE(3, 4)
+static inline int
+xo_emit_hfp (xo_handle_t *xop, xo_emit_flags_t flags, const char *fmt, ...)
+{
+ va_list vap;
+ va_start(vap, fmt);
+ int rc = xo_emit_hvf(xop, flags, fmt, vap);
+ va_end(vap);
+ return rc;
+}
+
+PRINTFLIKE(2, 3)
+static inline int
+xo_emit_fp (xo_emit_flags_t flags, const char *fmt, ...)
+{
+ va_list vap;
+ va_start(vap, fmt);
+ int rc = xo_emit_hvf(NULL, flags, fmt, vap);
+ va_end(vap);
+ return rc;
+}
+
int
xo_open_container_h (xo_handle_t *xop, const char *name);
@@ -593,4 +644,23 @@ char *
xo_simplify_format (xo_handle_t *xop, const char *fmt, int with_numbers,
xo_simplify_field_func_t field_cb);
+int
+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_emit_field_h (xo_handle_t *xop, const char *rolmod, const char *contents,
+ const char *fmt, const char *efmt, ...);
+
+int
+xo_emit_field (const char *rolmod, const char *contents,
+ const char *fmt, const char *efmt, ...);
+
+void
+xo_retain_clear_all (void);
+
+void
+xo_retain_clear (const char *fmt);
+
#endif /* INCLUDE_XO_H */
diff --git a/contrib/libxo/libxo/xo_config.h.in b/contrib/libxo/libxo/xo_config.h.in
deleted file mode 100644
index 614e7fe..0000000
--- a/contrib/libxo/libxo/xo_config.h.in
+++ /dev/null
@@ -1,246 +0,0 @@
-/* libxo/xo_config.h.in. Generated from configure.ac by autoheader. */
-
-/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
- systems. This function is required for `alloca.c' support on those systems.
- */
-#undef CRAY_STACKSEG_END
-
-/* Define to 1 if using `alloca.c'. */
-#undef C_ALLOCA
-
-/* Define to 1 if you have `alloca', as a function or macro. */
-#undef HAVE_ALLOCA
-
-/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
- */
-#undef HAVE_ALLOCA_H
-
-/* Define to 1 if you have the `asprintf' function. */
-#undef HAVE_ASPRINTF
-
-/* Define to 1 if you have the `bzero' function. */
-#undef HAVE_BZERO
-
-/* Define to 1 if you have the `ctime' function. */
-#undef HAVE_CTIME
-
-/* Define to 1 if you have the <ctype.h> header file. */
-#undef HAVE_CTYPE_H
-
-/* Define to 1 if you have the declaration of `__isthreaded', and to 0 if you
- don't. */
-#undef HAVE_DECL___ISTHREADED
-
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#undef HAVE_DLFCN_H
-
-/* Define to 1 if you have the `dlfunc' function. */
-#undef HAVE_DLFUNC
-
-/* Define to 1 if you have the <errno.h> header file. */
-#undef HAVE_ERRNO_H
-
-/* Define to 1 if you have the `fdopen' function. */
-#undef HAVE_FDOPEN
-
-/* Define to 1 if you have the `flock' function. */
-#undef HAVE_FLOCK
-
-/* Define to 1 if you have the `getpass' function. */
-#undef HAVE_GETPASS
-
-/* Define to 1 if you have the `getprogname' function. */
-#undef HAVE_GETPROGNAME
-
-/* Define to 1 if you have the `getrusage' function. */
-#undef HAVE_GETRUSAGE
-
-/* gettext(3) */
-#undef HAVE_GETTEXT
-
-/* Define to 1 if you have the `gettimeofday' function. */
-#undef HAVE_GETTIMEOFDAY
-
-/* humanize_number(3) */
-#undef HAVE_HUMANIZE_NUMBER
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#undef HAVE_INTTYPES_H
-
-/* Define to 1 if you have the `crypto' library (-lcrypto). */
-#undef HAVE_LIBCRYPTO
-
-/* Define to 1 if you have the `m' library (-lm). */
-#undef HAVE_LIBM
-
-/* Define to 1 if you have the <libutil.h> header file. */
-#undef HAVE_LIBUTIL_H
-
-/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
- to 0 otherwise. */
-#undef HAVE_MALLOC
-
-/* Define to 1 if you have the `memmove' function. */
-#undef HAVE_MEMMOVE
-
-/* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
-
-/* Support printflike */
-#undef HAVE_PRINTFLIKE
-
-/* Define to 1 if your system has a GNU libc compatible `realloc' function,
- and to 0 otherwise. */
-#undef HAVE_REALLOC
-
-/* Define to 1 if you have the `srand' function. */
-#undef HAVE_SRAND
-
-/* Define to 1 if you have the `sranddev' function. */
-#undef HAVE_SRANDDEV
-
-/* Define to 1 if you have the <stdint.h> header file. */
-#undef HAVE_STDINT_H
-
-/* Define to 1 if you have the <stdio_ext.h> header file. */
-#undef HAVE_STDIO_EXT_H
-
-/* Define to 1 if you have the <stdio.h> header file. */
-#undef HAVE_STDIO_H
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#undef HAVE_STDLIB_H
-
-/* Define to 1 if you have the <stdtime/tzfile.h> header file. */
-#undef HAVE_STDTIME_TZFILE_H
-
-/* Define to 1 if you have the `strchr' function. */
-#undef HAVE_STRCHR
-
-/* Define to 1 if you have the `strcspn' function. */
-#undef HAVE_STRCSPN
-
-/* Define to 1 if you have the `strerror' function. */
-#undef HAVE_STRERROR
-
-/* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
-
-/* Define to 1 if you have the <string.h> header file. */
-#undef HAVE_STRING_H
-
-/* Define to 1 if you have the `strlcpy' function. */
-#undef HAVE_STRLCPY
-
-/* Define to 1 if you have the `strspn' function. */
-#undef HAVE_STRSPN
-
-/* Have struct sockaddr_un.sun_len */
-#undef HAVE_SUN_LEN
-
-/* Define to 1 if you have the `sysctlbyname' function. */
-#undef HAVE_SYSCTLBYNAME
-
-/* Define to 1 if you have the <sys/param.h> header file. */
-#undef HAVE_SYS_PARAM_H
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#undef HAVE_SYS_STAT_H
-
-/* Define to 1 if you have the <sys/sysctl.h> header file. */
-#undef HAVE_SYS_SYSCTL_H
-
-/* Define to 1 if you have the <sys/time.h> header file. */
-#undef HAVE_SYS_TIME_H
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#undef HAVE_SYS_TYPES_H
-
-/* Define to 1 if you have the <threads.h> header file. */
-#undef HAVE_THREADS_H
-
-/* thread-local setting */
-#undef HAVE_THREAD_LOCAL
-
-/* Define to 1 if you have the <tzfile.h> header file. */
-#undef HAVE_TZFILE_H
-
-/* Define to 1 if you have the <unistd.h> header file. */
-#undef HAVE_UNISTD_H
-
-/* Define to 1 if you have the `__flbf' function. */
-#undef HAVE___FLBF
-
-/* Enable debugging */
-#undef LIBXO_DEBUG
-
-/* Enable text-only rendering */
-#undef LIBXO_TEXT_ONLY
-
-/* Version number as dotted value */
-#undef LIBXO_VERSION
-
-/* Version number extra information */
-#undef LIBXO_VERSION_EXTRA
-
-/* Version number as a number */
-#undef LIBXO_VERSION_NUMBER
-
-/* Version number as string */
-#undef LIBXO_VERSION_STRING
-
-/* Enable local wcwidth implementation */
-#undef LIBXO_WCWIDTH
-
-/* Define to the sub-directory where libtool stores uninstalled libraries. */
-#undef LT_OBJDIR
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* If using the C implementation of alloca, define if you know the
- direction of stack growth for your system; otherwise it will be
- automatically deduced at runtime.
- STACK_DIRECTION > 0 => grows toward higher addresses
- STACK_DIRECTION < 0 => grows toward lower addresses
- STACK_DIRECTION = 0 => direction of growth unknown */
-#undef STACK_DIRECTION
-
-/* Define to 1 if you have the ANSI C header files. */
-#undef STDC_HEADERS
-
-/* Version number of package */
-#undef VERSION
-
-/* Define to `__inline__' or `__inline' if that's what the C compiler
- calls it, or to nothing if 'inline' is not supported under any name. */
-#ifndef __cplusplus
-#undef inline
-#endif
-
-/* Define to rpl_malloc if the replacement function should be used. */
-#undef malloc
-
-/* Define to rpl_realloc if the replacement function should be used. */
-#undef realloc
-
-/* Define to `unsigned int' if <sys/types.h> does not define. */
-#undef size_t
diff --git a/contrib/libxo/libxo/xo_emit_f.3 b/contrib/libxo/libxo/xo_emit_f.3
new file mode 100644
index 0000000..0879546
--- /dev/null
+++ b/contrib/libxo/libxo/xo_emit_f.3
@@ -0,0 +1,111 @@
+.\" #
+.\" # Copyright (c) 2016, 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, April 2016
+.\"
+.Dd April 15, 2016
+.Dt LIBXO 3
+.Os
+.Sh NAME
+.Nm xo_emit_f , xo_emit_hf , xo_emit_hvf
+.Nd emit formatted output based on format string and arguments
+.Sh LIBRARY
+.Lb libxo
+.Sh SYNOPSIS
+.In libxo/xo.h
+.Ft int
+.Fn xo_emit_f "xo_emit_flags_t flags" "const char *fmt" "..."
+.Ft int
+.Fn xo_emit_hf "xo_handle_t *xop" "xo_emit_flags_t flags" "const char *fmt" "..."
+.Ft int
+.Fn xo_emit_hvf "xo_handle_t *xop" "xo_emit_flags_t flags" "const char *fmt" "va_list vap"
+.Ft void
+.Fn xo_retain_clear_all "void"
+.Ft void
+.Fn xo_retain_clear "const char *fmt"
+.Sh DESCRIPTION
+These functions allow callers to pass a set of flags to
+.Nm
+emitting functions. These processing of arguments, except for
+.Fa flags ,
+is identical to the base functions.
+See
+.Xr xo_emit 3
+for additional information.
+.Pp
+The only currently defined flag is
+.Dv XOEF_RETAIN .
+.Nm
+can retain the parsed internal information related to the given
+format string, allowing subsequent
+.Xr xo_emit 3
+calls, the retained
+information is used, avoiding repetitive parsing of the format string.
+To retain parsed format information, use the
+.Dv XOEF_RETAIN
+flag to the
+.Fn xo_emit_f
+function.
+.Pp
+The format string must be immutable across multiple calls to
+.Xn xo_emit_f ,
+since the library retains the string.
+Typically this is done by using
+static constant strings, such as string literals. If the string is not
+immutable, the
+.Dv XOEF_RETAIN
+flag must not be used.
+.Pp
+The functions
+.Fn xo_retain_clear
+and
+.Fn xo_retain_clear_all
+release internal information on either a single format string or all
+format strings, respectively.
+Neither is required, but the library will
+retain this information until it is cleared or the process exits.
+.Pp
+The retained information is kept as thread-specific data.
+.Pp
+Use
+.Fn xo_retain_clear
+and
+.Fn xo_retain_clear_all
+to clear the retained information, clearing the retained information
+for either a specific format string or all format strings, respectively.
+These functions are only needed when the calling application wants to
+clear this information; they are not generally needed.
+.Sh EXAMPLES
+.Pp
+.Bd -literal -offset indent
+ for (i = 0; i < 1000; i++) {
+ xo_open_instance("item");
+ xo_emit_f(XOEF_RETAIN, "{:name} {:count/%d}\n",
+ name[i], count[i]);
+ }
+.Ed
+.Pp
+In this example, the caller desires to clear the retained information.
+.Bd -literal -offset indent
+ const char *fmt = "{:name} {:count/%d}\n";
+ for (i = 0; i < 1000; i++) {
+ xo_open_instance("item");
+ xo_emit_f(XOEF_RETAIN, fmt, name[i], count[i]);
+ }
+ xo_retain_clear(fmt);
+.Ed
+.Sh RETURN CODE
+The return values for these functions is identical to those of their
+traditional counterparts. See
+.Xr xo_emit 3
+for details.
+.Sh SEE ALSO
+.Xr xo_emit 3 ,
+.Xr xo_open_container 3 ,
+.Xr xo_open_list 3 ,
+.Xr xo_format 5 ,
+.Xr libxo 3
diff --git a/contrib/libxo/libxo/xo_format.5 b/contrib/libxo/libxo/xo_format.5
index 89c0103..79af3fa 100644
--- a/contrib/libxo/libxo/xo_format.5
+++ b/contrib/libxo/libxo/xo_format.5
@@ -51,14 +51,14 @@ field descriptions within the format string.
.Pp
The field description is given as follows:
.Bd -literal -offset indent
- '{' [ role | modifier ]* [',' long-names ]* ':' [ content ]
- [ '/' field-format [ '/' encoding-format ]] '}'
+ \(aq{\(aq [ role | modifier ]* [\(aq,\(aq long\-names ]* \(aq:\(aq [ content ]
+ [ \(aq/\(aq field\-format [ \(aq/\(aq encoding\-format ]] \(aq}\(aq
.Ed
.Pp
The role describes the function of the field, while the modifiers
enable optional behaviors.
-The contents, field-format, and
-encoding-format are used in varying ways, based on the role.
+The contents, field\-format, and
+encoding\-format are used in varying ways, based on the role.
These are described in the following sections.
.Pp
Braces can be escaped by using double braces, similar to "%%" in
@@ -68,26 +68,26 @@ The format string "{{braces}}" would emit "{braces}".
In the following example, three field descriptors appear.
The first
is a padding field containing three spaces of padding, the second is a
-label ("In stock"), and the third is a value field ("in-stock").
-The in-stock field has a "%u" format that will parse the next argument
+label ("In stock"), and the third is a value field ("in\-stock").
+The in\-stock field has a "%u" format that will parse the next argument
passed to the
.Xr xo_emit 3 ,
function as an unsigned integer.
.Bd -literal -offset indent
- xo_emit("{P: }{Lwc:In stock}{:in-stock/%u}\\n", 65);
+ xo_emit("{P: }{Lwc:In stock}{:in\-stock/%u}\\n", 65);
.Ed
.Pp
This single line of code can generate text ("In stock: 65\\n"), XML
-("<in-stock>65</in-stock>"), JSON ('"in-stock": 65'), or HTML (too
+("<in\-stock>65</in\-stock>"), JSON (\(aq"in\-stock": 65\(aq), or HTML (too
lengthy to be listed here).
.Pp
While roles and modifiers typically use single character for brevity,
there are alternative names for each which allow more verbose
formatting strings.
These names must be preceded by a comma, and may follow any
-single-character values:
+single\-character values:
.Bd -literal -offset indent
- xo_emit("{L,white,colon:In stock}{,key:in-stock/%u}\n", 65);
+ xo_emit("{L,white,colon:In stock}{,key:in\-stock/%u}\\n", 65);
.Ed
.Ss "Field Roles"
Field roles are optional, and indicate the role and formatting of the
@@ -96,7 +96,7 @@ The roles are listed below; only one role is permitted:
.Bl -column "M" "Name12341234"
.It Sy "M" "Name " "Description"
.It C "color " "Field is a color or effect"
-.It D "decoration " "Field is non-text (e.g. colon, comma)"
+.It D "decoration " "Field is non\-text (e.g. colon, comma)"
.It E "error " "Field is an error message"
.It L "label " "Field is text that prefixes a value"
.It N "note " "Field is text that follows a value"
@@ -105,12 +105,12 @@ The roles are listed below; only one role is permitted:
.It U "units " "Field is the units for the previous value field"
.It V "value " "Field is the name of field (the default)"
.It W "warning " "Field is a warning message"
-.It \&[ "start-anchor" "Begin a section of anchored variable-width text"
-.It \&] "stop-anchor " "End a section of anchored variable-width text"
+.It \&[ "start\-anchor" "Begin a section of anchored variable\-width text"
+.It \&] "stop\-anchor " "End a section of anchored variable\-width text"
.El
.Bd -literal -offset indent
EXAMPLE:
- xo_emit("{L:Free}{D::}{P: }{:free/%u} {U:Blocks}\n",
+ xo_emit("{L:Free}{D::}{P: }{:free/%u} {U:Blocks}\\n",
free_blocks);
.Ed
.Pp
@@ -121,50 +121,50 @@ a comma:
.Bd -literal -offset indent
EXAMPLE:
xo_emit("{,label:Free}{,decoration::}{,padding: }"
- "{,value:free/%u} {,units:Blocks}\n",
+ "{,value:free/%u} {,units:Blocks}\\n",
free_blocks);
.Ed
.Ss "The Color Role ({C:})"
Colors and effects control how text values are displayed; they are
used for display styles (TEXT and HTML).
.Bd -literal -offset indent
- xo_emit("{C:bold}{:value}{C:no-bold}\n", value);
+ xo_emit("{C:bold}{:value}{C:no\-bold}\\n", value);
.Ed
.Pp
-Colors and effects remain in effect until modified by other "C"-role
+Colors and effects remain in effect until modified by other "C"\-role
fields.
.Bd -literal -offset indent
- xo_emit("{C:bold}{C:inverse}both{C:no-bold}only inverse\n");
+ xo_emit("{C:bold}{C:inverse}both{C:no\-bold}only inverse\\n");
.Ed
.Pp
If the content is empty, the "reset" action is performed.
.Bd -literal -offset indent
- xo_emit("{C:both,underline}{:value}{C:}\n", value);
+ xo_emit("{C:both,underline}{:value}{C:}\\n", value);
.Ed
.Pp
-The content should be a comma-separated list of zero or more colors or
+The content should be a comma\-separated list of zero or more colors or
display effects.
.Bd -literal -offset indent
- xo_emit("{C:bold,underline,inverse}All three{C:no-bold,no-inverse}\n");
+ xo_emit("{C:bold,underline,inverse}All three{C:no\-bold,no\-inverse}\\n");
.Ed
.Pp
The color content can be either static, when placed directly within
-the field descriptor, or a printf-style format descriptor can be used,
+the field descriptor, or a printf\-style format descriptor can be used,
if preceded by a slash ("/"):
.Bd -literal -offset indent
xo_emit("{C:/%s%s}{:value}{C:}", need_bold ? "bold" : "",
need_underline ? "underline" : "", value);
.Ed
.Pp
-Color names are prefixed with either "fg-" or "bg-" to change the
+Color names are prefixed with either "fg\-" or "bg\-" to change the
foreground and background colors, respectively.
.Bd -literal -offset indent
- xo_emit("{C:/fg-%s,bg-%s}{Lwc:Cost}{:cost/%u}{C:reset}\n",
+ xo_emit("{C:/fg\-%s,bg\-%s}{Lwc:Cost}{:cost/%u}{C:reset}\\n",
fg_color, bg_color, cost);
.Ed
.Pp
The following table lists the supported effects:
-.Bl -column "no-underline"
+.Bl -column "no\-underline"
.It Sy "Name " "Description"
.It "bg\-xxxxx " "Change background color"
.It "bold " "Start bold text effect"
@@ -179,7 +179,7 @@ The following table lists the supported effects:
.El
.Pp
The following color names are supported:
-.Bl -column "no-underline"
+.Bl -column "no\-underline"
.It Sy "Name"
.It black
.It blue
@@ -193,7 +193,7 @@ The following color names are supported:
.El
.Ss "The Decoration Role ({D:})"
Decorations are typically punctuation marks such as colons,
-semi-colons, and commas used to decorate the text and make it simpler
+semi\-colons, and commas used to decorate the text and make it simpler
for human readers.
By marking these distinctly, HTML usage scenarios
can use CSS to direct their display parameters.
@@ -219,22 +219,23 @@ change such as changing "/%06d" to "/%08d" should not force hand
inspection of all .po files.
.Pp
The simplified version can be generated for a single message using the
-"xopo -s <text>" command, or an entire .pot can be translated using
-the "xopo -f <input> -o <output>" command.
+"xopo \-s <text>" command, or an entire .pot can be translated using
+the "xopo \-f <input> \-o <output>" command.
.Bd -literal -offset indent
- xo_emit("{G:}Invalid token\n");
+ xo_emit("{G:}Invalid token\\n");
.Ed
+.Pp
The {G:} role allows a domain name to be set.
.Fn gettext
calls will
continue to use that domain name until the current format string
processing is complete, enabling a library function to emit strings
-using it's own catalog.
+using it\(aqs own catalog.
The domain name can be either static as the
content of the field, or a format can be used to get the domain name
from the arguments.
.Bd -literal -offset indent
- xo_emit("{G:libc}Service unavailable in restricted mode\n");
+ xo_emit("{G:libc}Service unavailable in restricted mode\\n");
.Ed
.Ss "The Label Role ({L:})"
Labels are text that appears before a value.
@@ -249,7 +250,7 @@ Notes are text that appears after a value.
.Ss "The Padding Role ({P:})"
Padding represents whitespace used before and between fields.
The padding content can be either static, when placed directly within
-the field descriptor, or a printf-style format descriptor can be used,
+the field descriptor, or a printf\-style format descriptor can be used,
if preceded by a slash ("/"):
.Bd -literal -offset indent
xo_emit("{P: }{Lwc:Cost}{:cost/%u}\\n", cost);
@@ -259,7 +260,7 @@ if preceded by a slash ("/"):
Titles are heading or column headers that are meant to be displayed to
the user.
The title can be either static, when placed directly within
-the field descriptor, or a printf-style format descriptor can be used,
+the field descriptor, or a printf\-style format descriptor can be used,
if preceded by a slash ("/"):
.Bd -literal -offset indent
xo_emit("{T:Interface Statistics}\\n");
@@ -274,7 +275,7 @@ for the previous value field.
xo_emit("{Lwc:Distance}{:distance/%u}{Uw:miles}\\n", miles);
.Ed
.Pp
-Note that the sense of the 'w' modifier is reversed for units;
+Note that the sense of the \(aqw\(aq modifier is reversed for units;
a blank is added before the contents, rather than after it.
.Pp
When the
@@ -286,14 +287,14 @@ attribute:
<distance units="miles">50</distance>
.Ed
.Pp
-Units can also be rendered in HTML as the "data-units" attribute:
+Units can also be rendered in HTML as the "data\-units" attribute:
.Bd -literal -offset indent
- <div class="data" data-tag="distance" data-units="miles"
- data-xpath="/top/data/distance">50</div>
+ <div class="data" data\-tag="distance" data\-units="miles"
+ data\-xpath="/top/data/distance">50</div>
.Ed
.Ss "The Value Role ({V:} and {:})"
The value role is used to represent the a data value that is
-interesting for the non-display output styles (XML and JSON).
+interesting for the non\-display output styles (XML and JSON).
Value
is the default role; if no other role designation is given, the field
is a value.
@@ -356,16 +357,17 @@ Field modifiers are flags which modify the way content emitted for
particular output styles:
.Bl -column M "Name123456789"
.It Sy M "Name " "Description"
+.It a "argument " "The content appears as a ""const char *"" argument"
.It c "colon " "A colon ("":"") is appended after the label"
.It d "display " "Only emit field for display styles (text/HTML)"
.It e "encoding " "Only emit for encoding styles (XML/JSON)"
-.It h "humanize (hn) " "Format large numbers in human-readable style"
-.It " " "hn-space " "Humanize: Place space between numeric and unit"
-.It " " "hn-decimal " "Humanize: Add a decimal digit, if number < 10"
-.It " " "hn-1000 " "Humanize: Use 1000 as divisor instead of 1024"
+.It h "humanize (hn) " "Format large numbers in human\-readable style"
+.It " " "hn\-space " "Humanize: Place space between numeric and unit"
+.It " " "hn\-decimal " "Humanize: Add a decimal digit, if number < 10"
+.It " " "hn\-1000 " "Humanize: Use 1000 as divisor instead of 1024"
.It k "key " "Field is a key, suitable for XPath predicates"
-.It l "leaf-list " "Field is a leaf-list, a list of leaf values"
-.It n "no-quotes " "Do not quote the field when using JSON style"
+.It l "leaf\-list " "Field is a leaf\-list, a list of leaf values"
+.It n "no\-quotes " "Do not quote the field when using JSON style"
.It q "quotes " "Quote the field when using JSON style"
.It t "trim " "Trim leading and trailing whitespace"
.It w "white space " "A blank ("" "") is appended after the label"
@@ -373,7 +375,7 @@ particular output styles:
.Pp
For example, the modifier string "Lwc" means the field has a label
role (text that describes the next field) and should be followed by a
-colon ('c') and a space ('w').
+colon (\(aqc\(aq) and a space (\(aqw\(aq).
The modifier string "Vkq" means the
field has a value role, that it is a key for the current instance, and
that the value should be quoted when encoded for JSON.
@@ -382,10 +384,31 @@ Roles and modifiers can also use more verbose names, when preceeded by
a comma.
For example, the modifier string "Lwc" (or "L,white,colon")
means the field has a label role (text that describes the next field)
-and should be followed by a colon ('c') and a space ('w').
+and should be followed by a colon (\(aqc\(aq) and a space (\(aqw\(aq).
The modifier string "Vkq" (or ":key,quote") means the field has a value
role (the default role), that it is a key for the current instance,
and that the value should be quoted when encoded for JSON.
+.Ss "The Argument Modifier ({a:})"
+The argument modifier indicates that the content of the field
+descriptor will be placed as a UTF\-8 string (const char *) argument
+within the xo_emit parameters.
+.Bd -literal -offset indent
+ EXAMPLE:
+ xo_emit("{La:} {a:}\\n", "Label text", "label", "value");
+ TEXT:
+ Label text value
+ JSON:
+ "label": "value"
+ XML:
+ <label>value</label>
+.Ed
+.Pp
+The argument modifier allows field names for value fields to be passed
+on the stack, avoiding the need to build a field descriptor using
+.Xr snprintf 1 .
+For many field roles, the argument modifier is not needed,
+since those roles have specific mechanisms for arguments,
+such as "{C:fg\-%s}".
.Ss "The Colon Modifier ({c:})"
The colon modifier appends a single colon to the data value:
.Bd -literal -offset indent
@@ -397,7 +420,7 @@ The colon modifier appends a single colon to the data value:
.Pp
The colon modifier is only used for the TEXT and HTML output
styles.
-It is commonly combined with the space modifier ('{w:}').
+It is commonly combined with the space modifier (\(aq{w:}\(aq).
It is purely a convenience feature.
.Ss "The Display Modifier ({d:})"
The display modifier indicated the field should only be generated for
@@ -429,39 +452,39 @@ The encoding modifier is the opposite of the display modifier, and
they are often used to give to distinct views of the underlying data.
.Ss "The Humanize Modifier ({h:})"
The humanize modifier is used to render large numbers as in a
-human-readable format.
+human\-readable format.
While numbers like "44470272" are completely readable to computers and
savants, humans will generally find "44M" more meaningful.
.Pp
"hn" can be used as an alias for "humanize".
.Pp
The humanize modifier only affects display styles (TEXT and HMTL).
-The "no-humanize" option will block the function of the humanize modifier.
+The "no\-humanize" option will block the function of the humanize modifier.
.Pp
There are a number of modifiers that affect details of humanization.
These are only available in as full names, not single characters.
-The "hn-space" modifier places a space between the number and any
+The "hn\-space" modifier places a space between the number and any
multiplier symbol, such as "M" or "K" (ex: "44 K").
-The "hn-decimal" modifier will add a decimal point and a single tenths digit
+The "hn\-decimal" modifier will add a decimal point and a single tenths digit
when the number is less than 10 (ex: "4.4K").
-The "hn-1000" modifier will use 1000 as divisor instead of 1024, following the
-JEDEC-standard instead of the more natural binary powers-of-two
+The "hn\-1000" modifier will use 1000 as divisor instead of 1024, following the
+JEDEC\-standard instead of the more natural binary powers\-of\-two
tradition.
.Bd -literal -offset indent
EXAMPLE:
- xo_emit("{h:input/%u}, {h,hn-space:output/%u}, "
- "{h,hn-decimal:errors/%u}, {h,hn-1000:capacity/%u}, "
- "{h,hn-decimal:remaining/%u}\n",
+ xo_emit("{h:input/%u}, {h,hn\-space:output/%u}, "
+ "{h,hn\-decimal:errors/%u}, {h,hn\-1000:capacity/%u}, "
+ "{h,hn\-decimal:remaining/%u}\\n",
input, output, errors, capacity, remaining);
TEXT:
21, 57 K, 96M, 44M, 1.2G
.Ed
.Pp
In the HTML style, the original numeric value is rendered in the
-"data-number" attribute on the <div> element:
+"data\-number" attribute on the <div> element:
.Bd -literal -offset indent
- <div class="data" data-tag="errors"
- data-number="100663296">96M</div>
+ <div class="data" data\-tag="errors"
+ data\-number="100663296">96M</div>
.Ed
.Ss "The Gettext Modifier ({g:})"
The gettext modifier is used to translate individual fields using the
@@ -476,9 +499,9 @@ translation.
In the following example, the strings "State" and "full" are passed
to
.Fn gettext
-to find locale-based translated strings.
+to find locale\-based translated strings.
.Bd -literal -offset indent
- xo_emit("{Lgwc:State}{g:state}\n", "full");
+ xo_emit("{Lgwc:State}{g:state}\\n", "full");
.Ed
.Ss "The Key Modifier ({k:})"
The key modifier is used to indicate that a particular field helps
@@ -499,15 +522,15 @@ Currently the key modifier is only used when generating XPath values
for the HTML output style when
.Dv XOF_XPATH
is set, but other uses are likely in the near future.
-.Ss "The Leaf-List Modifier ({l:})"
-The leaf-list modifier is used to distinguish lists where each
+.Ss "The Leaf\-List Modifier ({l:})"
+The leaf\-list modifier is used to distinguish lists where each
instance consists of only a single value. In XML, these are
rendered as single elements, where JSON renders them as arrays.
.Bd -literal -offset indent
EXAMPLE:
xo_open_list("user");
for (i = 0; i < num_users; i++) {
- xo_emit("Member {l:name}\n", user[i].u_name);
+ xo_emit("Member {l:name}\\n", user[i].u_name);
}
xo_close_list("user");
XML:
@@ -516,8 +539,8 @@ rendered as single elements, where JSON renders them as arrays.
JSON:
"user": [ "phil", "pallavi" ]
.Ed
-.Ss "The No-Quotes Modifier ({n:})"
-The no-quotes modifier (and its twin, the 'quotes' modifier) affect
+.Ss "The No\-Quotes Modifier ({n:})"
+The no\-quotes modifier (and its twin, the \(aqquotes\(aq modifier) affect
the quoting of values in the JSON output style.
JSON uses quotes for
string values, but no quotes for numeric, boolean, and null data.
@@ -538,8 +561,9 @@ language settings.
The contents of the field should be the singular
and plural English values, separated by a comma:
.Bd -literal -offset indent
- xo_emit("{:bytes} {Ngp:byte,bytes}\n", bytes);
+ xo_emit("{:bytes} {Ngp:byte,bytes}\\n", bytes);
.Ed
+.Pp
The plural modifier is meant to work with the gettext modifier ({g:})
but can work independently.
.Pp
@@ -554,7 +578,7 @@ function is
called to handle the heavy lifting, using the message catalog to
convert the singular and plural forms into the native language.
.Ss "The Quotes Modifier ({q:})"
-The quotes modifier (and its twin, the 'no-quotes' modifier) affect
+The quotes modifier (and its twin, the \(aqno-quotes\(aq modifier) affect
the quoting of values in the JSON output style.
JSON uses quotes for
string values, but no quotes for numeric, boolean, and null data.
@@ -578,23 +602,23 @@ The white space modifier appends a single space to the data value:
.Pp
The white space modifier is only used for the TEXT and HTML output
styles.
-It is commonly combined with the colon modifier ('{c:}').
+It is commonly combined with the colon modifier (\(aq{c:}\(aq).
It is purely a convenience feature.
.Pp
-Note that the sense of the 'w' modifier is reversed for the units role
+Note that the sense of the \(aqw\(aq modifier is reversed for the units role
({Uw:}); a blank is added before the contents, rather than after it.
.Ss "Field Formatting"
The field format is similar to the format string for
.Xr printf 3 .
Its use varies based on the role of the field, but generally is used to
-format the field's contents.
+format the field\(aqs contents.
.Pp
If the format string is not provided for a value field, it defaults
to "%s".
.Pp
-Note a field definition can contain zero or more printf-style
+Note a field definition can contain zero or more printf\-style
.Dq directives ,
-which are sequences that start with a '%' and end with
+which are sequences that start with a \(aq%\(aq and end with
one of following characters: "diouxXDOUeEfFgGaAcCsSp".
Each directive
is matched by one of more arguments to the
@@ -603,54 +627,54 @@ function.
.Pp
The format string has the form:
.Bd -literal -offset indent
- '%' format-modifier * format-character
+ \(aq%\(aq format\-modifier * format\-character
.Ed
.Pp
-The format- modifier can be:
+The format\- modifier can be:
.Bl -bullet
.It
-a '#' character, indicating the output value should be prefixed with
+a \(aq#\(aq character, indicating the output value should be prefixed with
"0x", typically to indicate a base 16 (hex) value.
.It
-a minus sign ('-'), indicating the output value should be padded on
+a minus sign (\(aq\-\(aq), indicating the output value should be padded on
the right instead of the left.
.It
-a leading zero ('0') indicating the output value should be padded on the
-left with zeroes instead of spaces (' ').
+a leading zero (\(aq0\(aq) indicating the output value should be padded on the
+left with zeroes instead of spaces (\(aq \(aq).
.It
-one or more digits ('0' - '9') indicating the minimum width of the
+one or more digits (\(aq0\(aq \- \(aq9\(aq) indicating the minimum width of the
argument.
If the width in columns of the output value is less than
the minimum width, the value will be padded to reach the minimum.
.It
a period followed by one or more digits indicating the maximum
number of bytes which will be examined for a string argument, or the maximum
-width for a non-string argument.
+width for a non\-string argument.
When handling ASCII strings this
-functions as the field width but for multi-byte characters, a single
+functions as the field width but for multi\-byte characters, a single
character may be composed of multiple bytes.
.Xr xo_emit 3
will never dereference memory beyond the given number of bytes.
.It
a second period followed by one or more digits indicating the maximum
width for a string argument.
-This modifier cannot be given for non-string arguments.
+This modifier cannot be given for non\-string arguments.
.It
-one or more 'h' characters, indicating shorter input data.
+one or more \(aqh\(aq characters, indicating shorter input data.
.It
-one or more 'l' characters, indicating longer input data.
+one or more \(aql\(aq characters, indicating longer input data.
.It
-a 'z' character, indicating a 'size_t' argument.
+a \(aqz\(aq character, indicating a \(aqsize_t\(aq argument.
.It
-a 't' character, indicating a 'ptrdiff_t' argument.
+a \(aqt\(aq character, indicating a \(aqptrdiff_t\(aq argument.
.It
-a ' ' character, indicating a space should be emitted before
+a \(aq \(aq character, indicating a space should be emitted before
positive numbers.
.It
-a '+' character, indicating sign should emitted before any number.
+a \(aq+\(aq character, indicating sign should emitted before any number.
.El
.Pp
-Note that 'q', 'D', 'O', and 'U' are considered deprecated and will be
+Note that \(aqq\(aq, \(aqD\(aq, \(aqO\(aq, and \(aqU\(aq are considered deprecated and will be
removed eventually.
.Pp
The format character is described in the following table:
@@ -665,22 +689,22 @@ The format character is described in the following table:
.It D "long " "base 10 (decimal)"
.It O "unsigned long " "base 8 (octal)"
.It U "unsigned long " "base 10 (decimal)"
-.It e "double " "[-]d.ddde+-dd"
-.It E "double " "[-]d.dddE+-dd"
-.It f "double " "[-]ddd.ddd"
-.It F "double " "[-]ddd.ddd"
-.It g "double " "as 'e' or 'f'"
-.It G "double " "as 'E' or 'F'"
-.It a "double " "[-]0xh.hhhp[+-]d"
-.It A "double " "[-]0Xh.hhhp[+-]d"
+.It e "double " "[\-]d.ddde+\-dd"
+.It E "double " "[\-]d.dddE+\-dd"
+.It f "double " "[\-]ddd.ddd"
+.It F "double " "[\-]ddd.ddd"
+.It g "double " "as \(aqe\(aq or \(aqf\(aq"
+.It G "double " "as \(aqE\(aq or \(aqF\(aq"
+.It a "double " "[\-]0xh.hhhp[+\-]d"
+.It A "double " "[\-]0Xh.hhhp[+\-]d"
.It c "unsigned char " "a character"
.It C "wint_t " "a character"
-.It s "char * " "a UTF-8 string"
+.It s "char * " "a UTF\-8 string"
.It S "wchar_t * " "a unicode/WCS string"
-.It p "void * " "'%#lx'"
+.It p "void * " "\(aq%#lx\(aq"
.El
.Pp
-The 'h' and 'l' modifiers affect the size and treatment of the
+The \(aqh\(aq and \(aql\(aq modifiers affect the size and treatment of the
argument:
.Bl -column "Mod" "d, i " "o, u, x, X "
.It Sy "Mod" "d, i " "o, u, x, X"
@@ -693,27 +717,27 @@ argument:
.It "z " "size_t " "size_t"
.It "q " "quad_t " "u_quad_t"
.El
-.Ss "UTF-8 and Locale Strings"
+.Ss "UTF\-8 and Locale Strings"
All strings for
.Nm libxo
-must be UTF-8.
+must be UTF\-8.
.Nm libxo
will handle turning them
-into locale-based strings for display to the user.
+into locale\-based strings for display to the user.
.Pp
-For strings, the 'h' and 'l' modifiers affect the interpretation of
+For strings, the \(aqh\(aq and \(aql\(aq 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
+The default \(aq%s\(aq string is a \(aqchar *\(aq
+pointer to a string encoded as UTF\-8.
+Since UTF\-8 is compatible with
.Em ASCII
-data, a normal 7-bit
+data, a normal 7\-bit
.Em ASCII
string can be used.
"%ls" expects a
-"wchar_t *" pointer to a wide-character string, encoded as 32-bit
+"wchar_t *" pointer to a wide\-character string, encoded as 32\-bit
Unicode values.
-"%hs" expects a "char *" pointer to a multi-byte
+"%hs" expects a "char *" pointer to a multi\-byte
string encoded with the current locale, as given by the
.Ev LC_CTYPE ,
.Ev LANG ,
@@ -722,22 +746,22 @@ or
environment variables.
The first of this list of
variables is used and if none of the variables are set, the locale defaults to
-.Em UTF-8 .
+.Em UTF\-8 .
.Pp
.Nm 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.
+convert these arguments as needed to either UTF\-8 (for XML, JSON, and
+HTML styles) or locale\-based strings for display in text style.
.Bd -literal -offset indent
- xo_emit("All strings are utf-8 content {:tag/%ls}",
+ xo_emit("All strings are utf\-8 content {:tag/%ls}",
L"except for wide strings");
.Ed
.Pp
"%S" is equivalent to "%ls".
.Pp
-For example, a function is passed a locale-base name, a hat size,
+For example, a function is passed a locale\-base name, a hat size,
and a time value.
-The hat size is formatted in a UTF-8 (ASCII)
+The hat size is formatted in a UTF\-8 (ASCII)
string, and the time value is formatted into a wchar_t string.
.Bd -literal -offset indent
void print_order (const char *name, int size,
@@ -755,7 +779,7 @@ string, and the time value is formatted into a wchar_t string.
xo_emit("The hat for {:name/%hs} is {:size/%s}.\\n",
name, size_val);
- xo_emit("It was ordered on {:order-time/%ls}.\\n",
+ xo_emit("It was ordered on {:order\-time/%ls}.\\n",
when);
}
.Ed
@@ -766,11 +790,11 @@ will perform the conversion
required to make appropriate output.
Text style output uses the
current locale (as described above), while XML, JSON, and HTML use
-UTF-8.
+UTF\-8.
.Pp
-UTF-8 and locale-encoded strings can use multiple bytes to encode one
+UTF\-8 and locale\-encoded strings can use multiple bytes to encode one
column of data.
-The traditional "precision'" (aka "max-width") value
+The traditional "precision" (aka "max\-width") value
for "%s" printf formatting becomes overloaded since it specifies both
the number of bytes that can be safely referenced and the maximum
number of columns to emit.
@@ -800,12 +824,12 @@ For HTML, these characters are placed in a <div> with class "text".
"size": "extra small"
HTML:
<div class="text">The hat is </div>
- <div class="data" data-tag="size">extra small</div>
+ <div class="data" data\-tag="size">extra small</div>
<div class="text">.</div>
.Ed
-.Ss "'%n' is Not Supported"
+.Ss "\(aq%n\(aq is Not Supported"
.Nm libxo
-does not support the '%n' directive.
+does not support the \(aq%n\(aq directive.
It is a bad idea and we
just do not do it.
.Ss "The Encoding Format (eformat)"
@@ -817,7 +841,7 @@ If the primary is not given, both default to "%s".
.Sh EXAMPLE
In this example, the value for the number of items in stock is emitted:
.Bd -literal -offset indent
- xo_emit("{P: }{Lwc:In stock}{:in-stock/%u}\\n",
+ xo_emit("{P: }{Lwc:In stock}{:in\-stock/%u}\\n",
instock);
.Ed
.Pp
@@ -826,16 +850,16 @@ This call will generate the following output:
TEXT:
In stock: 144
XML:
- <in-stock>144</in-stock>
+ <in\-stock>144</in\-stock>
JSON:
- "in-stock": 144,
+ "in\-stock": 144,
HTML:
<div class="line">
<div class="padding"> </div>
<div class="label">In stock</div>
<div class="decoration">:</div>
<div class="padding"> </div>
- <div class="data" data-tag="in-stock">144</div>
+ <div class="data" data\-tag="in\-stock">144</div>
</div>
.Ed
.Pp
@@ -846,10 +870,10 @@ or
.Dv XOF_INFO
data, which would expand the penultimate line to:
.Bd -literal -offset indent
- <div class="data" data-tag="in-stock"
- data-xpath="/top/data/item/in-stock"
- data-type="number"
- data-help="Number of items in stock">144</div>
+ <div class="data" data\-tag="in\-stock"
+ data\-xpath="/top/data/item/in\-stock"
+ data\-type="number"
+ data\-help="Number of items in stock">144</div>
.Ed
.Sh WHAT MAKES A GOOD FIELD NAME?
To make useful, consistent field names, follow these guidelines:
@@ -867,23 +891,23 @@ But the raw field name should use hyphens.
.Ss "Use full words"
Do not abbreviate especially when the abbreviation is not obvious or
not widely used.
-Use "data-size", not "dsz" or "dsize".
+Use "data\-size", not "dsz" or "dsize".
Use
-"interface" instead of "ifname", "if-name", "iface", "if", or "intf".
-.Ss "Use <verb>-<units>"
-Using the form <verb>-<units> or <verb>-<classifier>-<units> helps in
+"interface" instead of "ifname", "if\-name", "iface", "if", or "intf".
+.Ss "Use <verb>\-<units>"
+Using the form <verb>\-<units> or <verb>\-<classifier>\-<units> helps in
making consistent, useful names, avoiding the situation where one app
-uses "sent-packet" and another "packets-sent" and another
-"packets-we-have-sent".
+uses "sent\-packet" and another "packets\-sent" and another
+"packets\-we\-have\-sent".
The <units> can be dropped when it is
obvious, as can obvious words in the classification.
-Use "receive-after-window-packets" instead of
-"received-packets-of-data-after-window".
+Use "receive\-after\-window\-packets" instead of
+"received\-packets\-of\-data\-after\-window".
.Ss "Reuse existing field names"
Nothing is worse than writing expressions like:
.Bd -literal -offset indent
if ($src1/process[pid == $pid]/name ==
- $src2/proc-table/proc/p[process-id == $pid]/proc-name) {
+ $src2/proc\-table/proc/p[process\-id == $pid]/proc\-name) {
...
}
.Ed
@@ -903,7 +927,7 @@ calls or "{e:}" fields to make the data useful.
.Ss "Do not use an arbitrary number postfix"
What does "errors2" mean?
No one will know.
-"errors-after-restart" would be a better choice.
+"errors\-after\-restart" would be a better choice.
Think of your users, and think of the future.
If you make "errors2", the next guy will happily make
"errors3" and before you know it, someone will be asking what is the
@@ -913,7 +937,7 @@ Think of your field vocabulary as an API.
You want it useful,
expressive, meaningful, direct, and obvious.
You want the client
-application's programmer to move between without the need to
+application\(aqs programmer to move between without the need to
understand a variety of opinions on how fields are named.
They should
see the system as a single cohesive whole, not a sack of cats.
@@ -925,12 +949,12 @@ By choosing wise names now, you are making their lives better.
After using
.Xr xolint 1
to find errors in your field descriptors, use
-.Dq "xolint -V"
+.Dq "xolint \-V"
to spell check your field names and to detect different
names for the same data.
-.Dq dropped-short
+.Dq dropped\-short
and
-.Dq dropped-too-short
+.Dq dropped\-too\-short
are both reasonable names, but using them both will lead users to ask the
difference between the two fields.
If there is no difference,
diff --git a/contrib/libxo/libxo/xo_parse_args.3 b/contrib/libxo/libxo/xo_parse_args.3
index 80dceca..487b50b 100644
--- a/contrib/libxo/libxo/xo_parse_args.3
+++ b/contrib/libxo/libxo/xo_parse_args.3
@@ -83,12 +83,16 @@ Log (via stderr) each syslog message (via
Ignore the {h:} modifier (TEXT, HTML)
.It Dv no-locale
Do not initialize the locale setting
+.It Dv no-retain
+Prevent retaining formatting information
.It Dv no-top
Do not emit a top set of braces (JSON)
.It Dv not-first
Pretend the 1st output item was not 1st (JSON)
.It Dv pretty
Emit pretty-printed output
+.It Dv retain
+Force retaining formatting information
.It Dv text
Emit TEXT output
.If Dv underscores
diff --git a/contrib/libxo/packaging/libxo.pc.in b/contrib/libxo/packaging/libxo.pc.in
index b291d07..0e18234 100644
--- a/contrib/libxo/packaging/libxo.pc.in
+++ b/contrib/libxo/packaging/libxo.pc.in
@@ -5,7 +5,7 @@ includedir=@includedir@
Name: libxo
-Version: @VERSION@
+Version: @LIBXO_VERSION@
Description: The XML Output Library
-Libs: @LIBXO_LIBDIR@ @LIBXO_LIBS@
-Cflags: @LIBXO_INCLUDEDIR@
+Libs: -L@XO_LIBDIR@ @XO_LIBS@
+Cflags: -I@XO_INCLUDEDIR@
diff --git a/contrib/libxo/packaging/libxo.rb.base.in b/contrib/libxo/packaging/libxo.rb.base.in
index 70b712d..ab87be2 100644
--- a/contrib/libxo/packaging/libxo.rb.base.in
+++ b/contrib/libxo/packaging/libxo.rb.base.in
@@ -6,15 +6,15 @@
require 'formula'
class Libxo < Formula
- homepage 'https://github.com/Juniper/@PACKAGE-NAME@'
- url 'https://github.com/Juniper/@PACKAGE_NAME@/releases/@PACKAGE_VERSION@/@PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz'
+ homepage 'https://github.com/Juniper/@PACKAGE_NAME@'
+ url 'https://github.com/Juniper/@PACKAGE_NAME@/releases/download/@PACKAGE_VERSION@/@PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz'
sha1 '__SHA1__'
depends_on 'libtool' => :build
def install
- system "./configure", "--disable-dependency-tracking",
+ system "./configure", "--disable-dependency-tracking", "--disable-silent-rules",
"--prefix=#{prefix}"
- system "make install"
+ system "make", "install"
end
end
diff --git a/contrib/libxo/tests/core/Makefile.am b/contrib/libxo/tests/core/Makefile.am
index 0131a6f..7e61f55 100644
--- a/contrib/libxo/tests/core/Makefile.am
+++ b/contrib/libxo/tests/core/Makefile.am
@@ -22,7 +22,8 @@ test_07.c \
test_08.c \
test_09.c \
test_10.c \
-test_11.c
+test_11.c \
+test_12.c
test_01_test_SOURCES = test_01.c
test_02_test_SOURCES = test_02.c
@@ -35,6 +36,7 @@ test_08_test_SOURCES = test_08.c
test_09_test_SOURCES = test_09.c
test_10_test_SOURCES = test_10.c
test_11_test_SOURCES = test_11.c
+test_12_test_SOURCES = test_12.c
# TEST_CASES := $(shell cd ${srcdir} ; echo *.c )
diff --git a/contrib/libxo/tests/core/saved/test_01.E.out b/contrib/libxo/tests/core/saved/test_01.E.out
index 296a34e..de23baa 100644
--- a/contrib/libxo/tests/core/saved/test_01.E.out
+++ b/contrib/libxo/tests/core/saved/test_01.E.out
@@ -2,6 +2,14 @@ op create: [] []
op open_container: [top] []
op string: [host] [my-box]
op string: [domain] [example.com]
+op string: [host] [my-box]
+op string: [domain] [example.com]
+op string: [label] [value]
+op string: [max-chaos] [very]
+op content: [min-chaos] [42]
+op string: [some-chaos] [[42]]
+op string: [host] [my-box]
+op string: [domain] [example.com]
op attr: [test] [value]
op open_container: [data] []
op open_list: [item] []
@@ -114,6 +122,16 @@ op close_list: [item] []
op close_container: [data4] []
op content: [cost] [425]
op content: [cost] [455]
+op string: [mode] [mode]
+op string: [mode_octal] [octal]
+op string: [links] [links]
+op string: [user] [user]
+op string: [group] [group]
+op string: [mode] [/some/file]
+op content: [mode_octal] [640]
+op content: [links] [1]
+op string: [user] [user]
+op string: [group] [group]
op close_container: [top] []
op finish: [] []
op flush: [] []
diff --git a/contrib/libxo/tests/core/saved/test_01.H.out b/contrib/libxo/tests/core/saved/test_01.H.out
index ead320e..7c0b3de 100644
--- a/contrib/libxo/tests/core/saved/test_01.H.out
+++ b/contrib/libxo/tests/core/saved/test_01.H.out
@@ -1 +1,2 @@
-<div class="line"><div class="text">Connecting to </div><div class="data" data-tag="host">my-box</div><div class="text">.</div><div class="data" data-tag="domain">example.com</div><div class="text">...</div></div><div class="line"><div class="title">Item </div><div class="title"> Total Sold</div><div class="title"> In Stock</div><div class="title"> On Order</div><div class="title"> SKU</div></div><div class="line"><div class="data" data-tag="name" data-key="key">gum </div><div class="data" data-tag="sold"> 1412</div><div class="data" data-tag="in-stock"> 54</div><div class="data" data-tag="on-order"> 10</div><div class="data" data-tag="sku" data-key="key"> GRO-000-415</div></div><div class="line"><div class="data" data-tag="name" data-key="key">rope </div><div class="data" data-tag="sold"> 85</div><div class="data" data-tag="in-stock"> 4</div><div class="data" data-tag="on-order"> 2</div><div class="data" data-tag="sku" data-key="key"> HRD-000-212</div></div><div class="line"><div class="data" data-tag="name" data-key="key">ladder </div><div class="data" data-tag="sold"> 0</div><div class="data" data-tag="in-stock"> 2</div><div class="data" data-tag="on-order"> 1</div><div class="data" data-tag="sku" data-key="key"> HRD-000-517</div></div><div class="line"><div class="data" data-tag="name" data-key="key">bolt </div><div class="data" data-tag="sold"> 4123</div><div class="data" data-tag="in-stock"> 144</div><div class="data" data-tag="on-order"> 42</div><div class="data" data-tag="sku" data-key="key"> HRD-000-632</div></div><div class="line"><div class="data" data-tag="name" data-key="key">water </div><div class="data" data-tag="sold"> 17</div><div class="data" data-tag="in-stock"> 14</div><div class="data" data-tag="on-order"> 2</div><div class="data" data-tag="sku" data-key="key"> GRO-000-2331</div></div><div class="line"></div><div class="line"></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">gum</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">1412.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">54</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">10</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">GRO-000-415</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">rope</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">85.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">4</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">2</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">HRD-000-212</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">ladder</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">2</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">1</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">HRD-000-517</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">bolt</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">4123.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">144</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">42</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">HRD-000-632</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">water</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">17.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">14</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">2</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">GRO-000-2331</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">fish</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">1321.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">45</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">1</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">GRO-000-533</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">gum</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">rope</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">ladder</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">bolt</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">water</div></div><div class="line"><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div></div><div class="line"><div class="text">X</div><div class="padding"> </div><div class="text">X</div><div class="label">Cost</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="cost">425</div></div><div class="line"><div class="text">X</div><div class="padding"> </div><div class="text">X</div><div class="label">Cost</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="cost">455</div></div> \ No newline at end of file
+<div class="line"><div class="text">testing argument modifier </div><div class="data" data-tag="host">my-box</div><div class="text">.</div><div class="data" data-tag="domain">example.com</div><div class="text">...</div></div><div class="line"><div class="text">testing argument modifier with encoding to </div><div class="text">.</div><div class="data" data-tag="domain">example.com</div><div class="text">...</div></div><div class="line"><div class="label">Label text</div><div class="text"> </div><div class="data" data-tag="label">value</div></div><div class="line"><div class="data" data-tag="max-chaos"> very </div><div class="data" data-tag="min-chaos">42</div><div class="data" data-tag="some-chaos">42
+</div><div class="text">Connecting to </div><div class="data" data-tag="host">my-box</div><div class="text">.</div><div class="data" data-tag="domain">example.com</div><div class="text">...</div></div><div class="line"><div class="title">Item </div><div class="title"> Total Sold</div><div class="title"> In Stock</div><div class="title"> On Order</div><div class="title"> SKU</div></div><div class="line"><div class="data" data-tag="name" data-key="key">gum </div><div class="data" data-tag="sold"> 1412</div><div class="data" data-tag="in-stock"> 54</div><div class="data" data-tag="on-order"> 10</div><div class="data" data-tag="sku" data-key="key"> GRO-000-415</div></div><div class="line"><div class="data" data-tag="name" data-key="key">rope </div><div class="data" data-tag="sold"> 85</div><div class="data" data-tag="in-stock"> 4</div><div class="data" data-tag="on-order"> 2</div><div class="data" data-tag="sku" data-key="key"> HRD-000-212</div></div><div class="line"><div class="data" data-tag="name" data-key="key">ladder </div><div class="data" data-tag="sold"> 0</div><div class="data" data-tag="in-stock"> 2</div><div class="data" data-tag="on-order"> 1</div><div class="data" data-tag="sku" data-key="key"> HRD-000-517</div></div><div class="line"><div class="data" data-tag="name" data-key="key">bolt </div><div class="data" data-tag="sold"> 4123</div><div class="data" data-tag="in-stock"> 144</div><div class="data" data-tag="on-order"> 42</div><div class="data" data-tag="sku" data-key="key"> HRD-000-632</div></div><div class="line"><div class="data" data-tag="name" data-key="key">water </div><div class="data" data-tag="sold"> 17</div><div class="data" data-tag="in-stock"> 14</div><div class="data" data-tag="on-order"> 2</div><div class="data" data-tag="sku" data-key="key"> GRO-000-2331</div></div><div class="line"></div><div class="line"></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">gum</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">1412.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">54</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">10</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">GRO-000-415</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">rope</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">85.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">4</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">2</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">HRD-000-212</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">ladder</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">2</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">1</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">HRD-000-517</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">bolt</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">4123.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">144</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">42</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">HRD-000-632</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">water</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">17.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">14</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">2</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">GRO-000-2331</div></div><div class="line"><div class="label">Item</div><div class="text"> '</div><div class="data" data-tag="name" data-key="key">fish</div><div class="text">':</div></div><div class="line"><div class="padding"> </div><div class="label">Total sold</div><div class="text">: </div><div class="data" data-tag="sold">1321.0</div></div><div class="line"><div class="padding"> </div><div class="label">In stock</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="in-stock">45</div></div><div class="line"><div class="padding"> </div><div class="label">On order</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="on-order">1</div></div><div class="line"><div class="padding"> </div><div class="label">SKU</div><div class="text">: </div><div class="data" data-tag="sku" data-key="key">GRO-000-533</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">gum</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">rope</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">ladder</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">bolt</div></div><div class="line"><div class="label">Item</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="item">water</div></div><div class="line"><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div><div class="text">X</div></div><div class="line"><div class="text">X</div><div class="padding"> </div><div class="text">X</div><div class="label">Cost</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="cost">425</div></div><div class="line"><div class="text">X</div><div class="padding"> </div><div class="text">X</div><div class="label">Cost</div><div class="decoration">:</div><div class="padding"> </div><div class="data" data-tag="cost">455</div></div><div class="line"><div class="text"> </div><div class="data" data-tag="links">links</div><div class="text"> </div><div class="data" data-tag="user">user</div><div class="text"> </div><div class="data" data-tag="group">group</div><div class="text"> </div></div><div class="line"><div class="data" data-tag="mode">/some/file</div><div class="text"> </div><div class="data" data-tag="links"> 1</div><div class="text"> </div><div class="data" data-tag="user">user </div><div class="text"> </div><div class="data" data-tag="group">group </div><div class="text"> </div></div> \ No newline at end of file
diff --git a/contrib/libxo/tests/core/saved/test_01.HIPx.out b/contrib/libxo/tests/core/saved/test_01.HIPx.out
index 2b8e296..f6c7290 100644
--- a/contrib/libxo/tests/core/saved/test_01.HIPx.out
+++ b/contrib/libxo/tests/core/saved/test_01.HIPx.out
@@ -1,4 +1,26 @@
<div class="line">
+ <div class="text">testing argument modifier </div>
+ <div class="data" data-tag="host" data-xpath="/top/host">my-box</div>
+ <div class="text">.</div>
+ <div class="data" data-tag="domain" data-xpath="/top/domain">example.com</div>
+ <div class="text">...</div>
+</div>
+<div class="line">
+ <div class="text">testing argument modifier with encoding to </div>
+ <div class="text">.</div>
+ <div class="data" data-tag="domain" data-xpath="/top/domain">example.com</div>
+ <div class="text">...</div>
+</div>
+<div class="line">
+ <div class="label">Label text</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="label" data-xpath="/top/label">value</div>
+</div>
+<div class="line">
+ <div class="data" data-tag="max-chaos" data-xpath="/top/max-chaos"> very </div>
+ <div class="data" data-tag="min-chaos" data-xpath="/top/min-chaos">42</div>
+ <div class="data" data-tag="some-chaos" data-xpath="/top/some-chaos">42
+</div>
<div class="text">Connecting to </div>
<div class="data" data-tag="host" data-xpath="/top/host">my-box</div>
<div class="text">.</div>
@@ -301,3 +323,22 @@
<div class="padding"> </div>
<div class="data" data-tag="cost" data-xpath="/top/cost">455</div>
</div>
+<div class="line">
+ <div class="text"> </div>
+ <div class="data" data-tag="links" data-xpath="/top/links">links</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="user" data-xpath="/top/user">user</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="group" data-xpath="/top/group">group</div>
+ <div class="text"> </div>
+</div>
+<div class="line">
+ <div class="data" data-tag="mode" data-xpath="/top/mode">/some/file</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="links" data-xpath="/top/links"> 1</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="user" data-xpath="/top/user">user </div>
+ <div class="text"> </div>
+ <div class="data" data-tag="group" data-xpath="/top/group">group </div>
+ <div class="text"> </div>
+</div>
diff --git a/contrib/libxo/tests/core/saved/test_01.HP.out b/contrib/libxo/tests/core/saved/test_01.HP.out
index c8f2dbc..0fdcbd1 100644
--- a/contrib/libxo/tests/core/saved/test_01.HP.out
+++ b/contrib/libxo/tests/core/saved/test_01.HP.out
@@ -1,4 +1,26 @@
<div class="line">
+ <div class="text">testing argument modifier </div>
+ <div class="data" data-tag="host">my-box</div>
+ <div class="text">.</div>
+ <div class="data" data-tag="domain">example.com</div>
+ <div class="text">...</div>
+</div>
+<div class="line">
+ <div class="text">testing argument modifier with encoding to </div>
+ <div class="text">.</div>
+ <div class="data" data-tag="domain">example.com</div>
+ <div class="text">...</div>
+</div>
+<div class="line">
+ <div class="label">Label text</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="label">value</div>
+</div>
+<div class="line">
+ <div class="data" data-tag="max-chaos"> very </div>
+ <div class="data" data-tag="min-chaos">42</div>
+ <div class="data" data-tag="some-chaos">42
+</div>
<div class="text">Connecting to </div>
<div class="data" data-tag="host">my-box</div>
<div class="text">.</div>
@@ -301,3 +323,22 @@
<div class="padding"> </div>
<div class="data" data-tag="cost">455</div>
</div>
+<div class="line">
+ <div class="text"> </div>
+ <div class="data" data-tag="links">links</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="user">user</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="group">group</div>
+ <div class="text"> </div>
+</div>
+<div class="line">
+ <div class="data" data-tag="mode">/some/file</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="links"> 1</div>
+ <div class="text"> </div>
+ <div class="data" data-tag="user">user </div>
+ <div class="text"> </div>
+ <div class="data" data-tag="group">group </div>
+ <div class="text"> </div>
+</div>
diff --git a/contrib/libxo/tests/core/saved/test_01.J.out b/contrib/libxo/tests/core/saved/test_01.J.out
index 69e3faa..3fc12a1 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", "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}
+{"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"}
}
diff --git a/contrib/libxo/tests/core/saved/test_01.JP.out b/contrib/libxo/tests/core/saved/test_01.JP.out
index e65897f..2c7397f 100644
--- a/contrib/libxo/tests/core/saved/test_01.JP.out
+++ b/contrib/libxo/tests/core/saved/test_01.JP.out
@@ -2,6 +2,14 @@
"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": [
{
@@ -101,6 +109,16 @@
]
},
"cost": 425,
- "cost": 455
+ "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.T.out b/contrib/libxo/tests/core/saved/test_01.T.out
index 2ecf537..71cd130 100644
--- a/contrib/libxo/tests/core/saved/test_01.T.out
+++ b/contrib/libxo/tests/core/saved/test_01.T.out
@@ -1,3 +1,7 @@
+testing argument modifier my-box.example.com...
+testing argument modifier with encoding to .example.com...
+Label text value
+ very 4242
Connecting to my-box.example.com...
Item Total Sold In Stock On Order SKU
gum 1412 54 10 GRO-000-415
@@ -45,3 +49,5 @@ Item: water
XXXXXXXX
X XCost: 425
X XCost: 455
+ links user group
+/some/file 1 user group
diff --git a/contrib/libxo/tests/core/saved/test_01.X.out b/contrib/libxo/tests/core/saved/test_01.X.out
index 46f501e2..da80e68 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><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></top> \ No newline at end of file
+<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
diff --git a/contrib/libxo/tests/core/saved/test_01.XP.out b/contrib/libxo/tests/core/saved/test_01.XP.out
index c7f4bfe8..c331dce 100644
--- a/contrib/libxo/tests/core/saved/test_01.XP.out
+++ b/contrib/libxo/tests/core/saved/test_01.XP.out
@@ -1,6 +1,14 @@
<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>
@@ -93,4 +101,14 @@
</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>
diff --git a/contrib/libxo/tests/core/saved/test_12.E.err b/contrib/libxo/tests/core/saved/test_12.E.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.E.err
diff --git a/contrib/libxo/tests/core/saved/test_12.E.out b/contrib/libxo/tests/core/saved/test_12.E.out
new file mode 100644
index 0000000..1c899a1
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.E.out
@@ -0,0 +1,89 @@
+op create: [] []
+op open_container: [top] []
+op open_container: [data] []
+op open_list: [thing] []
+op open_instance: [thing] []
+op string: [name] [thing]
+op string: [color] [green]
+op content: [time] [2:15]
+op string: [hand] [left]
+op string: [color] [blue]
+op content: [time] [3:45]
+op close_instance: [thing] []
+op open_instance: [thing] []
+op string: [name] [thing]
+op string: [color] [green]
+op content: [time] [2:15]
+op string: [hand] [left]
+op string: [color] [blue]
+op content: [time] [3:45]
+op close_instance: [thing] []
+op open_instance: [thing] []
+op string: [name] [thing]
+op string: [color] [green]
+op content: [time] [2:15]
+op string: [hand] [left]
+op string: [color] [blue]
+op content: [time] [3:45]
+op close_instance: [thing] []
+op open_instance: [thing] []
+op string: [name] [thing]
+op string: [color] [green]
+op content: [time] [2:15]
+op string: [hand] [left]
+op string: [color] [blue]
+op content: [time] [3:45]
+op close_instance: [thing] []
+op open_instance: [thing] []
+op string: [name] [thing]
+op string: [color] [green]
+op content: [time] [2:15]
+op string: [hand] [left]
+op string: [color] [blue]
+op content: [time] [3:45]
+op close_instance: [thing] []
+op open_instance: [thing] []
+op string: [name] [thing]
+op string: [color] [green]
+op content: [time] [2:15]
+op string: [hand] [left]
+op string: [color] [blue]
+op content: [time] [3:45]
+op close_instance: [thing] []
+op open_instance: [thing] []
+op string: [name] [thing]
+op string: [color] [green]
+op content: [time] [2:15]
+op string: [hand] [left]
+op string: [color] [blue]
+op content: [time] [3:45]
+op close_instance: [thing] []
+op open_instance: [thing] []
+op string: [name] [thing]
+op string: [color] [green]
+op content: [time] [2:15]
+op string: [hand] [left]
+op string: [color] [blue]
+op content: [time] [3:45]
+op close_instance: [thing] []
+op open_instance: [thing] []
+op string: [name] [thing]
+op string: [color] [green]
+op content: [time] [2:15]
+op string: [hand] [left]
+op string: [color] [blue]
+op content: [time] [3:45]
+op close_instance: [thing] []
+op open_instance: [thing] []
+op string: [name] [thing]
+op string: [color] [green]
+op content: [time] [2:15]
+op string: [hand] [left]
+op string: [color] [blue]
+op content: [time] [3:45]
+op close_instance: [thing] []
+op close_list: [thing] []
+op close_container: [data] []
+op close_container: [top] []
+op finish: [] []
+op flush: [] []
diff --git a/contrib/libxo/tests/core/saved/test_12.H.err b/contrib/libxo/tests/core/saved/test_12.H.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.H.err
diff --git a/contrib/libxo/tests/core/saved/test_12.H.out b/contrib/libxo/tests/core/saved/test_12.H.out
new file mode 100644
index 0000000..5cbac17
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.H.out
@@ -0,0 +1 @@
+<div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div><div class="line"><div class="text">The </div><div class="data" data-tag="name">thing</div><div class="text"> is </div><div class="data" data-tag="color">green</div><div class="text"> til </div><div class="data" data-tag="time">02:15</div></div><div class="line"><div class="text">My </div><div class="data" data-tag="hand">left</div><div class="text"> hand is </div><div class="data" data-tag="color">blue</div><div class="text"> til </div><div class="data" data-tag="time">03:45</div></div> \ No newline at end of file
diff --git a/contrib/libxo/tests/core/saved/test_12.HIPx.err b/contrib/libxo/tests/core/saved/test_12.HIPx.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.HIPx.err
diff --git a/contrib/libxo/tests/core/saved/test_12.HIPx.out b/contrib/libxo/tests/core/saved/test_12.HIPx.out
new file mode 100644
index 0000000..9b5fea1
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.HIPx.out
@@ -0,0 +1,160 @@
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name" data-xpath="/top/data/thing/name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand" data-xpath="/top/data/thing[name = 'thing']/hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color" data-xpath="/top/data/thing[name = 'thing']/color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time" data-xpath="/top/data/thing[name = 'thing']/time">03:45</div>
+</div>
diff --git a/contrib/libxo/tests/core/saved/test_12.HP.err b/contrib/libxo/tests/core/saved/test_12.HP.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.HP.err
diff --git a/contrib/libxo/tests/core/saved/test_12.HP.out b/contrib/libxo/tests/core/saved/test_12.HP.out
new file mode 100644
index 0000000..1e0e923
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.HP.out
@@ -0,0 +1,160 @@
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">03:45</div>
+</div>
+<div class="line">
+ <div class="text">The </div>
+ <div class="data" data-tag="name">thing</div>
+ <div class="text"> is </div>
+ <div class="data" data-tag="color">green</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">02:15</div>
+</div>
+<div class="line">
+ <div class="text">My </div>
+ <div class="data" data-tag="hand">left</div>
+ <div class="text"> hand is </div>
+ <div class="data" data-tag="color">blue</div>
+ <div class="text"> til </div>
+ <div class="data" data-tag="time">03:45</div>
+</div>
diff --git a/contrib/libxo/tests/core/saved/test_12.J.err b/contrib/libxo/tests/core/saved/test_12.J.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.J.err
diff --git a/contrib/libxo/tests/core/saved/test_12.J.out b/contrib/libxo/tests/core/saved/test_12.J.out
new file mode 100644
index 0000000..118bb76
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.J.out
@@ -0,0 +1,2 @@
+{"top": {"data": {"thing": [{"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}, {"name":"thing","color":"green","time":2:15,"hand":"left","color":"blue","time":3:45}]}}
+}
diff --git a/contrib/libxo/tests/core/saved/test_12.JP.err b/contrib/libxo/tests/core/saved/test_12.JP.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.JP.err
diff --git a/contrib/libxo/tests/core/saved/test_12.JP.out b/contrib/libxo/tests/core/saved/test_12.JP.out
new file mode 100644
index 0000000..3e15e0d
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.JP.out
@@ -0,0 +1,88 @@
+{
+ "top": {
+ "data": {
+ "thing": [
+ {
+ "name": "thing",
+ "color": "green",
+ "time": 2:15,
+ "hand": "left",
+ "color": "blue",
+ "time": 3:45
+ },
+ {
+ "name": "thing",
+ "color": "green",
+ "time": 2:15,
+ "hand": "left",
+ "color": "blue",
+ "time": 3:45
+ },
+ {
+ "name": "thing",
+ "color": "green",
+ "time": 2:15,
+ "hand": "left",
+ "color": "blue",
+ "time": 3:45
+ },
+ {
+ "name": "thing",
+ "color": "green",
+ "time": 2:15,
+ "hand": "left",
+ "color": "blue",
+ "time": 3:45
+ },
+ {
+ "name": "thing",
+ "color": "green",
+ "time": 2:15,
+ "hand": "left",
+ "color": "blue",
+ "time": 3:45
+ },
+ {
+ "name": "thing",
+ "color": "green",
+ "time": 2:15,
+ "hand": "left",
+ "color": "blue",
+ "time": 3:45
+ },
+ {
+ "name": "thing",
+ "color": "green",
+ "time": 2:15,
+ "hand": "left",
+ "color": "blue",
+ "time": 3:45
+ },
+ {
+ "name": "thing",
+ "color": "green",
+ "time": 2:15,
+ "hand": "left",
+ "color": "blue",
+ "time": 3:45
+ },
+ {
+ "name": "thing",
+ "color": "green",
+ "time": 2:15,
+ "hand": "left",
+ "color": "blue",
+ "time": 3:45
+ },
+ {
+ "name": "thing",
+ "color": "green",
+ "time": 2:15,
+ "hand": "left",
+ "color": "blue",
+ "time": 3:45
+ }
+ ]
+ }
+ }
+}
diff --git a/contrib/libxo/tests/core/saved/test_12.T.err b/contrib/libxo/tests/core/saved/test_12.T.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.T.err
diff --git a/contrib/libxo/tests/core/saved/test_12.T.out b/contrib/libxo/tests/core/saved/test_12.T.out
new file mode 100644
index 0000000..6f777c7
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.T.out
@@ -0,0 +1,20 @@
+The thing is green til 02:15
+My left hand is blue til 03:45
+The thing is green til 02:15
+My left hand is blue til 03:45
+The thing is green til 02:15
+My left hand is blue til 03:45
+The thing is green til 02:15
+My left hand is blue til 03:45
+The thing is green til 02:15
+My left hand is blue til 03:45
+The thing is green til 02:15
+My left hand is blue til 03:45
+The thing is green til 02:15
+My left hand is blue til 03:45
+The thing is green til 02:15
+My left hand is blue til 03:45
+The thing is green til 02:15
+My left hand is blue til 03:45
+The thing is green til 02:15
+My left hand is blue til 03:45
diff --git a/contrib/libxo/tests/core/saved/test_12.X.err b/contrib/libxo/tests/core/saved/test_12.X.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.X.err
diff --git a/contrib/libxo/tests/core/saved/test_12.X.out b/contrib/libxo/tests/core/saved/test_12.X.out
new file mode 100644
index 0000000..ed2d8e4
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.X.out
@@ -0,0 +1 @@
+<top><data><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing><thing><name>thing</name><color>green</color><time>2:15</time><hand>left</hand><color>blue</color><time>3:45</time></thing></data></top> \ No newline at end of file
diff --git a/contrib/libxo/tests/core/saved/test_12.XP.err b/contrib/libxo/tests/core/saved/test_12.XP.err
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.XP.err
diff --git a/contrib/libxo/tests/core/saved/test_12.XP.out b/contrib/libxo/tests/core/saved/test_12.XP.out
new file mode 100644
index 0000000..73eec4c
--- /dev/null
+++ b/contrib/libxo/tests/core/saved/test_12.XP.out
@@ -0,0 +1,84 @@
+<top>
+ <data>
+ <thing>
+ <name>thing</name>
+ <color>green</color>
+ <time>2:15</time>
+ <hand>left</hand>
+ <color>blue</color>
+ <time>3:45</time>
+ </thing>
+ <thing>
+ <name>thing</name>
+ <color>green</color>
+ <time>2:15</time>
+ <hand>left</hand>
+ <color>blue</color>
+ <time>3:45</time>
+ </thing>
+ <thing>
+ <name>thing</name>
+ <color>green</color>
+ <time>2:15</time>
+ <hand>left</hand>
+ <color>blue</color>
+ <time>3:45</time>
+ </thing>
+ <thing>
+ <name>thing</name>
+ <color>green</color>
+ <time>2:15</time>
+ <hand>left</hand>
+ <color>blue</color>
+ <time>3:45</time>
+ </thing>
+ <thing>
+ <name>thing</name>
+ <color>green</color>
+ <time>2:15</time>
+ <hand>left</hand>
+ <color>blue</color>
+ <time>3:45</time>
+ </thing>
+ <thing>
+ <name>thing</name>
+ <color>green</color>
+ <time>2:15</time>
+ <hand>left</hand>
+ <color>blue</color>
+ <time>3:45</time>
+ </thing>
+ <thing>
+ <name>thing</name>
+ <color>green</color>
+ <time>2:15</time>
+ <hand>left</hand>
+ <color>blue</color>
+ <time>3:45</time>
+ </thing>
+ <thing>
+ <name>thing</name>
+ <color>green</color>
+ <time>2:15</time>
+ <hand>left</hand>
+ <color>blue</color>
+ <time>3:45</time>
+ </thing>
+ <thing>
+ <name>thing</name>
+ <color>green</color>
+ <time>2:15</time>
+ <hand>left</hand>
+ <color>blue</color>
+ <time>3:45</time>
+ </thing>
+ <thing>
+ <name>thing</name>
+ <color>green</color>
+ <time>2:15</time>
+ <hand>left</hand>
+ <color>blue</color>
+ <time>3:45</time>
+ </thing>
+ </data>
+</top>
diff --git a/contrib/libxo/tests/core/test_01.c b/contrib/libxo/tests/core/test_01.c
index f7fe61e..05d778a 100644
--- a/contrib/libxo/tests/core/test_01.c
+++ b/contrib/libxo/tests/core/test_01.c
@@ -79,6 +79,18 @@ main (int argc, char **argv)
xo_open_container_h(NULL, "top");
+ xo_emit("testing argument modifier {a:}.{a:}...\n",
+ "host", "my-box", "domain", "example.com");
+
+ xo_emit("testing argument modifier with encoding to {ea:}.{a:}...\n",
+ "host", "my-box", "domain", "example.com");
+
+ xo_emit("{La:} {a:}\n", "Label text", "label", "value");
+
+ xo_emit_field("Vt", "max-chaos", NULL, NULL, " very ");
+ xo_emit_field("V", "min-chaos", "%d", NULL, 42);
+ xo_emit_field("V", "some-chaos", "%d\n", "[%d]", 42);
+
xo_emit("Connecting to {:host}.{:domain}...\n", "my-box", "example.com");
xo_attr("test", "value");
@@ -169,6 +181,16 @@ main (int argc, char **argv)
xo_emit("X{P: }X{Lwc:Cost}{:cost/%u}\n", 425);
xo_emit("X{P:/%30s}X{Lwc:Cost}{:cost/%u}\n", "", 455);
+ xo_emit("{e:mode/%s}{e:mode_octal/%s} {t:links/%s} "
+ "{t:user/%s} {t:group/%s} \n",
+ "mode", "octal", "links",
+ "user", "group", "extra1", "extra2", "extra3");
+
+ xo_emit("{t:mode/%s}{e:mode_octal/%03o} {t:links/%*u} "
+ "{t:user/%-*s} {t:group/%-*s} \n",
+ "/some/file", (int) 0640, 8, 1,
+ 10, "user", 12, "group");
+
xo_close_container_h(NULL, "top");
xo_finish();
diff --git a/contrib/libxo/tests/core/test_02.c b/contrib/libxo/tests/core/test_02.c
index abddcf2..9a02680 100644
--- a/contrib/libxo/tests/core/test_02.c
+++ b/contrib/libxo/tests/core/test_02.c
@@ -42,6 +42,7 @@ main (int argc, char **argv)
}
xo_set_flags(NULL, XOF_UNITS); /* Always test w/ this */
+ xo_set_file(stdout);
xo_open_container_h(NULL, "top");
diff --git a/contrib/libxo/tests/core/test_12.c b/contrib/libxo/tests/core/test_12.c
new file mode 100644
index 0000000..17d26a6
--- /dev/null
+++ b/contrib/libxo/tests/core/test_12.c
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2014, Juniper Networks, Inc.
+ * All rights reserved.
+ * This SOFTWARE is licensed under the LICENSE provided in the
+ * ../Copyright file. By downloading, installing, copying, or otherwise
+ * using the SOFTWARE, you agree to be bound by the terms of that
+ * LICENSE.
+ * Phil Shafer, July 2014
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "xo_config.h"
+#include "xo.h"
+
+int
+main (int argc, char **argv)
+{
+ int i, count = 10;
+ int mon = 0;
+ xo_emit_flags_t flags = XOEF_RETAIN;
+
+ argc = xo_parse_args(argc, argv);
+ if (argc < 0)
+ return 1;
+
+ for (argc = 1; argv[argc]; argc++) {
+ if (strcmp(argv[argc], "xml") == 0)
+ xo_set_style(NULL, XO_STYLE_XML);
+ else if (strcmp(argv[argc], "json") == 0)
+ xo_set_style(NULL, XO_STYLE_JSON);
+ else if (strcmp(argv[argc], "text") == 0)
+ xo_set_style(NULL, XO_STYLE_TEXT);
+ else if (strcmp(argv[argc], "html") == 0)
+ xo_set_style(NULL, XO_STYLE_HTML);
+ else if (strcmp(argv[argc], "pretty") == 0)
+ xo_set_flags(NULL, XOF_PRETTY);
+ else if (strcmp(argv[argc], "xpath") == 0)
+ xo_set_flags(NULL, XOF_XPATH);
+ else if (strcmp(argv[argc], "info") == 0)
+ xo_set_flags(NULL, XOF_INFO);
+ else if (strcmp(argv[argc], "no-retain") == 0)
+ flags &= ~XOEF_RETAIN;
+ else if (strcmp(argv[argc], "big") == 0) {
+ if (argv[argc + 1])
+ count = atoi(argv[++argc]);
+ }
+ }
+
+ xo_set_flags(NULL, XOF_UNITS); /* Always test w/ this */
+ xo_set_file(stdout);
+
+ xo_open_container("top");
+ xo_open_container("data");
+
+ const char *fmt1 = "The {C:fg-red}{k:name}{C:reset} is "
+ "{C:/fg-%s}{:color}{C:reset} til {:time/%02d:%02d}\n";
+ const char *fmt2 = "My {C:fg-red}{:hand}{C:reset} hand is "
+ "{C:/fg-%s}{:color}{C:reset} til {:time/%02d:%02d}\n";
+
+ for (i = 0; i < count; i++) {
+ xo_open_instance("thing");
+ xo_emit_f(flags, fmt1, "thing", "green", "green", 2, 15);
+ xo_emit_f(flags, fmt2, "left", "blue", "blue", 3, 45);
+ }
+
+ xo_close_container("data");
+ xo_close_container_h(NULL, "top");
+
+ xo_finish();
+
+ return 0;
+}
diff --git a/contrib/libxo/tests/gettext/gt_01.c b/contrib/libxo/tests/gettext/gt_01.c
index a0200c2..d636747 100644
--- a/contrib/libxo/tests/gettext/gt_01.c
+++ b/contrib/libxo/tests/gettext/gt_01.c
@@ -26,7 +26,7 @@ int
main (int argc, char **argv)
{
static char domainname[] = "gt_01";
- char path[MAXPATHLEN];
+ static char path[MAXPATHLEN];
const char *tzone = "EST";
const char *lang = "pig_latin";
diff --git a/include/Makefile b/include/Makefile
index d014681..d8ed1a2 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -133,13 +133,8 @@ _MARCHS+= x86
META_TARGETS+= compat copies symlinks
stage_includes: ${SHARED}
-.include <bsd.prog.mk>
-
-installincludes: ${SHARED}
-${SHARED}: compat
-
# Take care of stale directory-level symlinks.
-compat: ${META_DEPS}
+compat:
.for i in ${LDIRS} ${LSUBDIRS} machine ${_MARCHS} crypto
if [ -L ${DESTDIR}${INCLUDEDIR}/$i ]; then \
rm -f ${DESTDIR}${INCLUDEDIR}/$i; \
@@ -149,7 +144,7 @@ compat: ${META_DEPS}
-f ${.CURDIR}/../etc/mtree/BSD.include.dist \
-p ${DESTDIR}${INCLUDEDIR} > /dev/null
-copies: ${META_DEPS}
+copies:
.for i in ${LDIRS} ${LSUBDIRS} ${LSUBSUBDIRS} crypto machine machine/pc \
${_MARCHS}
if [ -d ${DESTDIR}${INCLUDEDIR}/$i ]; then \
@@ -235,7 +230,7 @@ copies: ${META_DEPS}
${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 teken.h \
${DESTDIR}${INCLUDEDIR}/teken
-symlinks: ${META_DEPS}
+symlinks:
@${ECHO} "Setting up symlinks to kernel source tree..."
.for i in ${LDIRS}
cd ${.CURDIR}/../sys/$i; \
@@ -349,6 +344,11 @@ symlinks: ${META_DEPS}
${DESTDIR}${INCLUDEDIR}/rpc; \
done
+.include <bsd.prog.mk>
+
+installincludes: ${SHARED}
+${SHARED}: compat
+
.if ${MACHINE} == "host" && !defined(_SKIP_BUILD)
# we're here because we are building a sysroot...
# we need MACHINE et al set correctly
diff --git a/lib/libc/aarch64/sys/brk.S b/lib/libc/aarch64/sys/brk.S
index 1e9a215..c403b43 100644
--- a/lib/libc/aarch64/sys/brk.S
+++ b/lib/libc/aarch64/sys/brk.S
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
.data
.align 3
.globl _C_LABEL(minbrk)
+ .hidden _C_LABEL(minbrk)
.type _C_LABEL(minbrk),#object
_C_LABEL(minbrk):
.quad _C_LABEL(_end)
diff --git a/lib/libc/aarch64/sys/cerror.S b/lib/libc/aarch64/sys/cerror.S
index 26c61bc..9d87275 100644
--- a/lib/libc/aarch64/sys/cerror.S
+++ b/lib/libc/aarch64/sys/cerror.S
@@ -29,6 +29,7 @@
__FBSDID("$FreeBSD$");
ENTRY(cerror)
+ .hidden cerror
sub sp, sp, #16
stp x0, lr, [sp]
bl _C_LABEL(__error)
diff --git a/lib/libc/aarch64/sys/sbrk.S b/lib/libc/aarch64/sys/sbrk.S
index 4880cc2..87b82d4 100644
--- a/lib/libc/aarch64/sys/sbrk.S
+++ b/lib/libc/aarch64/sys/sbrk.S
@@ -37,6 +37,7 @@ __FBSDID("$FreeBSD$");
.data
.align 3
.global _C_LABEL(curbrk)
+ .hidden _C_LABEL(curbrk)
.type _C_LABEL(curbrk),#object
_C_LABEL(curbrk):
.quad _C_LABEL(_end)
diff --git a/lib/libcam/camlib.c b/lib/libcam/camlib.c
index b7024a6..8986230 100644
--- a/lib/libcam/camlib.c
+++ b/lib/libcam/camlib.c
@@ -102,7 +102,7 @@ cam_freeccb(union ccb *ccb)
* /dev/foo0
* foo0
* nfoo0
- *
+ *
* Some peripheral drivers create separate device nodes with 'n' prefix for
* non-rewind operations. Currently only sa(4) tape driver has this feature.
* We extract pure peripheral name as device name for this special case.
@@ -194,7 +194,7 @@ cam_get_device(const char *path, char *dev_name, int devnamelen, int *unit)
/*
* At this point, if the last character of the string isn't a
- * number, we know the user either didn't give us a device number,
+ * number, we know the user either didn't give us a device number,
* or he gave us a device name/number format we don't recognize.
*/
if (!isdigit(tmpstr[strlen(tmpstr) - 1])) {
@@ -275,7 +275,7 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun,
int fd, bufsize;
if ((fd = open(XPT_DEVICE, O_RDWR)) < 0) {
- snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
"%s: couldn't open %s\n%s: %s", func_name, XPT_DEVICE,
func_name, strerror(errno));
return(NULL);
@@ -292,7 +292,7 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun,
ccb.cdm.match_buf_len = bufsize;
ccb.cdm.matches = (struct dev_match_result *)malloc(bufsize);
if (ccb.cdm.matches == NULL) {
- snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
"%s: couldn't malloc match buffer", func_name);
close(fd);
return(NULL);
@@ -305,14 +305,14 @@ cam_open_btl(path_id_t path_id, target_id_t target_id, lun_id_t target_lun,
ccb.cdm.patterns = (struct dev_match_pattern *)malloc(
sizeof(struct dev_match_pattern));
if (ccb.cdm.patterns == NULL) {
- snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
"%s: couldn't malloc pattern buffer", func_name);
free(ccb.cdm.matches);
close(fd);
return(NULL);
}
ccb.cdm.patterns[0].type = DEV_MATCH_PERIPH;
- match_pat = &ccb.cdm.patterns[0].pattern.periph_pattern;
+ match_pat = &ccb.cdm.patterns[0].pattern.periph_pattern;
/*
* We're looking for the passthrough device associated with this
@@ -421,7 +421,7 @@ cam_lookup_pass(const char *dev_name, int unit, int flags,
* passthrough device.
*/
if ((fd = open(XPT_DEVICE, O_RDWR)) < 0) {
- snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
"%s: couldn't open %s\n%s: %s", func_name, XPT_DEVICE,
func_name, strerror(errno));
return(NULL);
@@ -435,7 +435,7 @@ cam_lookup_pass(const char *dev_name, int unit, int flags,
ccb.cgdl.unit_number = unit;
/*
- * Attempt to get the passthrough device. This ioctl will fail if
+ * Attempt to get the passthrough device. This ioctl will fail if
* the device name is null, if the device doesn't exist, or if the
* passthrough driver isn't in the kernel.
*/
@@ -512,7 +512,7 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
}
device->fd = -1;
malloced_device = 1;
- }
+ }
/*
* If the user passed in a path, save it for him.
@@ -551,7 +551,7 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
* we don't have to set any fields.
*/
ccb.ccb_h.func_code = XPT_GDEVLIST;
-
+
/*
* We're only doing this to get some information on the device in
* question. Otherwise, we'd have to pass in yet another
@@ -611,7 +611,7 @@ cam_real_open_device(const char *path, int flags, struct cam_device *device,
goto crod_bailout;
}
device->pd_type = SID_TYPE(&ccb.cgd.inq_data);
- bcopy(&ccb.cgd.inq_data, &device->inq_data,
+ bcopy(&ccb.cgd.inq_data, &device->inq_data,
sizeof(struct scsi_inquiry_data));
device->serial_num_len = ccb.cgd.serial_num_len;
bcopy(&ccb.cgd.serial_num, &device->serial_num, device->serial_num_len);
@@ -719,7 +719,7 @@ cam_device_dup(struct cam_device *device)
newdev = malloc(sizeof(struct cam_device));
if (newdev == NULL) {
- snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
+ snprintf(cam_errbuf, CAM_ERRBUF_SIZE,
"%s: couldn't malloc CAM device structure", func_name);
return(NULL);
}
diff --git a/lib/libcam/camlib.h b/lib/libcam/camlib.h
index e505c77..4fa6a67 100644
--- a/lib/libcam/camlib.h
+++ b/lib/libcam/camlib.h
@@ -83,7 +83,7 @@ extern char cam_errbuf[];
struct cam_device {
char device_path[MAXPATHLEN];/*
- * Pathname of the device
+ * Pathname of the device
* given by the user. This
* may be null if the
* user states the device
@@ -98,15 +98,15 @@ struct cam_device {
* Unit number given by
* the user.
*/
- char device_name[DEV_IDLEN+1];/*
- * Name of the device,
- * e.g. 'pass'
+ char device_name[DEV_IDLEN+1];/*
+ * Name of the device,
+ * e.g. 'pass'
*/
u_int32_t dev_unit_num; /* Unit number of the passthrough
* device associated with this
* particular device.
*/
-
+
char sim_name[SIM_IDLEN+1]; /* Controller name, e.g. 'ahc' */
u_int32_t sim_unit_number; /* Controller unit number */
u_int32_t bus_id; /* Controller bus number */
@@ -142,7 +142,7 @@ int cam_send_ccb(struct cam_device *device, union ccb *ccb);
char * cam_path_string(struct cam_device *dev, char *str,
int len);
struct cam_device * cam_device_dup(struct cam_device *device);
-void cam_device_copy(struct cam_device *src,
+void cam_device_copy(struct cam_device *src,
struct cam_device *dst);
int cam_get_device(const char *path, char *dev_name,
int devnamelen, int *unit);
diff --git a/lib/libcasper/services/cap_dns/cap_dns.c b/lib/libcasper/services/cap_dns/cap_dns.c
index 873af4c..0ecf047 100644
--- a/lib/libcasper/services/cap_dns/cap_dns.c
+++ b/lib/libcasper/services/cap_dns/cap_dns.c
@@ -632,6 +632,7 @@ dns_getaddrinfo(const nvlist_t *limits, const nvlist_t *nvlin, nvlist_t *nvlout)
hints.ai_addrlen = 0;
hints.ai_addr = NULL;
hints.ai_canonname = NULL;
+ hints.ai_next = NULL;
hintsp = &hints;
family = hints.ai_family;
} else {
diff --git a/lib/libgssapi/gss_add_cred.c b/lib/libgssapi/gss_add_cred.c
index 4dcca18..34e29b1 100644
--- a/lib/libgssapi/gss_add_cred.c
+++ b/lib/libgssapi/gss_add_cred.c
@@ -121,7 +121,7 @@ gss_add_cred(OM_uint32 *minor_status,
* gss_add_cred for that mechanism, otherwise we copy the mc
* to new_cred.
*/
- target_mc = 0;
+ target_mc = NULL;
if (cred) {
SLIST_FOREACH(mc, &cred->gc_mc, gmc_link) {
if (gss_oid_equal(mc->gmc_mech_oid, desired_mech)) {
@@ -151,7 +151,7 @@ gss_add_cred(OM_uint32 *minor_status,
return (major_status);
}
} else {
- mn = 0;
+ mn = NULL;
}
m = _gss_find_mech_switch(desired_mech);
diff --git a/lib/libgssapi/gss_encapsulate_token.c b/lib/libgssapi/gss_encapsulate_token.c
index ed0e217..0e33e19 100644
--- a/lib/libgssapi/gss_encapsulate_token.c
+++ b/lib/libgssapi/gss_encapsulate_token.c
@@ -47,7 +47,7 @@ gss_encapsulate_token(const gss_buffer_t input_token, gss_OID oid,
* First time around, we calculate the size, second time, we
* encode the token.
*/
- p = 0;
+ p = NULL;
for (i = 0; i < 2; i++) {
len = 0;
diff --git a/lib/libgssapi/gss_get_mic.c b/lib/libgssapi/gss_get_mic.c
index dff3b54..b55a796 100644
--- a/lib/libgssapi/gss_get_mic.c
+++ b/lib/libgssapi/gss_get_mic.c
@@ -40,13 +40,14 @@ gss_get_mic(OM_uint32 *minor_status,
gss_buffer_t message_token)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
- struct _gss_mech_switch *m = ctx->gc_mech;
+ struct _gss_mech_switch *m;
_gss_buffer_zero(message_token);
if (ctx == NULL) {
*minor_status = 0;
return (GSS_S_NO_CONTEXT);
}
+ m = ctx->gc_mech;
return (m->gm_get_mic(minor_status, ctx->gc_ctx, qop_req,
message_buffer, message_token));
diff --git a/lib/libgssapi/gss_inquire_context.c b/lib/libgssapi/gss_inquire_context.c
index c9f2a0c..59e03e8 100644
--- a/lib/libgssapi/gss_inquire_context.c
+++ b/lib/libgssapi/gss_inquire_context.c
@@ -99,7 +99,7 @@ gss_inquire_context(OM_uint32 *minor_status,
if (src_name)
gss_release_name(minor_status, src_name);
m->gm_release_name(minor_status, &src_mn);
- minor_status = 0;
+ minor_status = NULL;
return (GSS_S_FAILURE);
}
*targ_name = (gss_name_t) name;
diff --git a/lib/libgssapi/gss_mech_switch.c b/lib/libgssapi/gss_mech_switch.c
index d07db88..2d742e7 100644
--- a/lib/libgssapi/gss_mech_switch.c
+++ b/lib/libgssapi/gss_mech_switch.c
@@ -83,7 +83,7 @@ _gss_string_to_oid(const char* s, gss_OID oid)
* out the size. Second time around, we actually encode the
* number.
*/
- res = 0;
+ res = NULL;
for (i = 0; i < 2; i++) {
byte_count = 0;
for (p = s, j = 0; p; p = q, j++) {
diff --git a/lib/libgssapi/gss_pseudo_random.c b/lib/libgssapi/gss_pseudo_random.c
index c250d71..c746823 100644
--- a/lib/libgssapi/gss_pseudo_random.c
+++ b/lib/libgssapi/gss_pseudo_random.c
@@ -48,7 +48,7 @@ gss_pseudo_random(OM_uint32 *minor_status,
gss_buffer_t prf_out)
{
struct _gss_context *ctx = (struct _gss_context *) context;
- struct _gss_mech_switch *m = ctx->gc_mech;
+ struct _gss_mech_switch *m;
OM_uint32 major_status;
_gss_buffer_zero(prf_out);
@@ -58,6 +58,7 @@ gss_pseudo_random(OM_uint32 *minor_status,
*minor_status = 0;
return GSS_S_NO_CONTEXT;
}
+ m = ctx->gc_mech;
if (m->gm_pseudo_random == NULL)
return GSS_S_UNAVAILABLE;
diff --git a/lib/libgssapi/gss_verify_mic.c b/lib/libgssapi/gss_verify_mic.c
index fa3d68d..704d7fc 100644
--- a/lib/libgssapi/gss_verify_mic.c
+++ b/lib/libgssapi/gss_verify_mic.c
@@ -39,7 +39,7 @@ gss_verify_mic(OM_uint32 *minor_status,
gss_qop_t *qop_state)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
- struct _gss_mech_switch *m = ctx->gc_mech;
+ struct _gss_mech_switch *m;
if (qop_state)
*qop_state = 0;
@@ -47,6 +47,7 @@ gss_verify_mic(OM_uint32 *minor_status,
*minor_status = 0;
return (GSS_S_NO_CONTEXT);
}
+ m = ctx->gc_mech;
return (m->gm_verify_mic(minor_status, ctx->gc_ctx,
message_buffer, token_buffer, qop_state));
diff --git a/lib/libgssapi/gss_wrap.c b/lib/libgssapi/gss_wrap.c
index 2f94316..1cf046a 100644
--- a/lib/libgssapi/gss_wrap.c
+++ b/lib/libgssapi/gss_wrap.c
@@ -42,7 +42,7 @@ gss_wrap(OM_uint32 *minor_status,
gss_buffer_t output_message_buffer)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
- struct _gss_mech_switch *m = ctx->gc_mech;
+ struct _gss_mech_switch *m;
if (conf_state)
*conf_state = 0;
@@ -51,6 +51,7 @@ gss_wrap(OM_uint32 *minor_status,
*minor_status = 0;
return (GSS_S_NO_CONTEXT);
}
+ m = ctx->gc_mech;
return (m->gm_wrap(minor_status, ctx->gc_ctx,
conf_req_flag, qop_req, input_message_buffer,
diff --git a/lib/libgssapi/gss_wrap_size_limit.c b/lib/libgssapi/gss_wrap_size_limit.c
index 15a8706..7038a57 100644
--- a/lib/libgssapi/gss_wrap_size_limit.c
+++ b/lib/libgssapi/gss_wrap_size_limit.c
@@ -40,13 +40,14 @@ gss_wrap_size_limit(OM_uint32 *minor_status,
OM_uint32 *max_input_size)
{
struct _gss_context *ctx = (struct _gss_context *) context_handle;
- struct _gss_mech_switch *m = ctx->gc_mech;
+ struct _gss_mech_switch *m;
*max_input_size = 0;
if (ctx == NULL) {
*minor_status = 0;
return (GSS_S_NO_CONTEXT);
}
+ m = ctx->gc_mech;
return (m->gm_wrap_size_limit(minor_status, ctx->gc_ctx,
conf_req_flag, qop_req, req_output_size, max_input_size));
diff --git a/lib/libmagic/Makefile b/lib/libmagic/Makefile
index d77de6c4..6500542 100644
--- a/lib/libmagic/Makefile
+++ b/lib/libmagic/Makefile
@@ -40,7 +40,7 @@ magic.mgc: mkmagic magic
CLEANFILES+= mkmagic
build-tools: mkmagic
-mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c
+mkmagic: apprentice.c cdf_time.c encoding.c funcs.c magic.c print.c ${BUILD_TOOLS_META}
${CC} ${CFLAGS} -DCOMPILE_ONLY ${LDFLAGS} -o ${.TARGET} ${.ALLSRC} \
${LDADD}
diff --git a/lib/libpam/Makefile b/lib/libpam/Makefile
index 5c3a2ae..fa73b95 100644
--- a/lib/libpam/Makefile
+++ b/lib/libpam/Makefile
@@ -24,8 +24,11 @@
#
# $FreeBSD$
-# The modules must be built first, because they are built into the
-# static version of libpam.
-SUBDIR+= modules libpam static_modules
+# The modules link in libpam. They build the static modules as well.
+SUBDIR+= libpam modules
+SUBDIR_DEPEND_modules= libpam
+SUBDIR+= static_libpam
+SUBDIR_DEPEND_static_libpam= modules
+SUBDIR_PARALLEL=
.include <bsd.subdir.mk>
diff --git a/lib/libpam/libpam/Makefile b/lib/libpam/libpam/Makefile
index c7122c7..531feab 100644
--- a/lib/libpam/libpam/Makefile
+++ b/lib/libpam/libpam/Makefile
@@ -39,7 +39,11 @@ PACKAGE=lib${LIB}
OPENPAM= ${.CURDIR}/../../../contrib/openpam
.PATH: ${OPENPAM}/include ${OPENPAM}/lib/libpam ${OPENPAM}/doc/man
-LIB= pam
+# static_libpam will build libpam.a
+.if !defined(LIB)
+SHLIB= pam
+.endif
+
MK_PROFILE=no
SRCS= openpam_asprintf.c \
@@ -99,7 +103,7 @@ SRCS= openpam_asprintf.c \
# Local additions
SRCS+= pam_debug_log.c
-MAN= openpam.3 \
+MAN?= openpam.3 \
openpam_borrow_cred.3 \
openpam_free_data.3 \
openpam_free_envlist.3 \
@@ -151,10 +155,10 @@ MAN= openpam.3 \
pam_vprompt.3 \
pam.conf.5
-MLINKS= pam.conf.5 pam.d.5
+MLINKS?= pam.conf.5 pam.d.5
CSTD?= c99
-CFLAGS+= -I${.CURDIR} -I${OPENPAM}/include
+CFLAGS+= -I${OPENPAM}/include
CFLAGS+= -DLIB_MAJ=${SHLIB_MAJOR}
CFLAGS+= -DHAVE_DLFUNC=1
CFLAGS+= -DHAVE_FDLOPEN=1
@@ -173,7 +177,7 @@ HEADERS= security/openpam.h \
ADD_HEADERS= security/pam_mod_misc.h
# Headers
-INCS= ${HEADERS} ${ADD_HEADERS}
+INCS?= ${HEADERS} ${ADD_HEADERS}
INCSDIR= ${INCLUDEDIR}/security
.include <src.opts.mk>
diff --git a/lib/libpam/modules/Makefile b/lib/libpam/modules/Makefile
index cacf011..ee1359b 100644
--- a/lib/libpam/modules/Makefile
+++ b/lib/libpam/modules/Makefile
@@ -27,5 +27,6 @@
.include "modules.inc"
SUBDIR= ${MODULES}
+SUBDIR_PARALLEL=
.include <bsd.subdir.mk>
diff --git a/lib/libpam/modules/Makefile.inc b/lib/libpam/modules/Makefile.inc
index 2da5a7b..899c3cb 100644
--- a/lib/libpam/modules/Makefile.inc
+++ b/lib/libpam/modules/Makefile.inc
@@ -7,14 +7,7 @@ MK_PROFILE= no
CFLAGS+= -I${PAMDIR}/include -I${.CURDIR}/../../libpam
-# This is nasty.
-# For the static case, libpam.a depends on the modules.
-# For the dynamic case, the modules depend on libpam.so.N
-.if defined(_NO_LIBPAM_SO_YET)
-NO_PIC=
-.else
SHLIB_NAME?= ${LIB}.so.${SHLIB_MAJOR}
LIBADD+= pam
-.endif
.include "../Makefile.inc"
diff --git a/lib/libpam/static_modules/Makefile b/lib/libpam/static_libpam/Makefile
index 429e660..f7180e9 100644
--- a/lib/libpam/static_modules/Makefile
+++ b/lib/libpam/static_libpam/Makefile
@@ -35,15 +35,17 @@
#
# $FreeBSD$
-OPENPAM= ${.CURDIR:H:H:H}/contrib/openpam
-.PATH: ${OPENPAM}/lib
-.PATH: ${OPENPAM}/lib/libpam
+.PATH: ${.CURDIR}/../libpam
-all:
-
-SRCS = openpam_static.c
+# Only build the static library.
+LIB= pam
+NO_PIC=
+# Avoid redundancy with the master Makefile.
MAN=
+INCS=
+MLINKS=
+MK_TESTS= no
#
# Static modules
@@ -61,11 +63,7 @@ STATICOBJS+= openpam_static_modules.o
CLEANFILES+= openpam_static.o \
openpam_static_modules.o
-.include <bsd.prog.mk>
-
-.if empty(_SKIP_BUILD)
openpam_static_modules.o: openpam_static.o ${STATIC_MODULES}
${LD} -o ${.TARGET} -r --whole-archive ${.ALLSRC}
-all: ${STATICOBJS}
-.endif
+.include "${.CURDIR}/../libpam/Makefile"
diff --git a/lib/libpam/static_modules/Makefile.depend b/lib/libpam/static_libpam/Makefile.depend
index 373bac4..373bac4 100644
--- a/lib/libpam/static_modules/Makefile.depend
+++ b/lib/libpam/static_libpam/Makefile.depend
diff --git a/lib/libthr/arch/riscv/include/pthread_md.h b/lib/libthr/arch/riscv/include/pthread_md.h
index 86eccc1..3f51078 100644
--- a/lib/libthr/arch/riscv/include/pthread_md.h
+++ b/lib/libthr/arch/riscv/include/pthread_md.h
@@ -46,7 +46,7 @@
#define CPU_SPINWAIT
#define DTV_OFFSET offsetof(struct tcb, tcb_dtv)
-#define TP_OFFSET 0x10
+#define TP_OFFSET sizeof(struct tcb)
/*
* Variant I tcb. The structure layout is fixed, don't blindly
diff --git a/lib/libxo/add.man b/lib/libxo/add.man
index 0e032f5..d314685 100644
--- a/lib/libxo/add.man
+++ b/lib/libxo/add.man
@@ -3,10 +3,10 @@
.Fx
uses
.Nm libxo
-version 0.4.6.
+version 0.6.1.
Complete documentation can be found on github:
.Bd -literal -offset indent
-http://juniper.github.io/libxo/0.4.6/libxo\-manual.html
+http://juniper.github.io/libxo/0.6.1/libxo\-manual.html
.Ed
.Pp
.Nm libxo
diff --git a/lib/libxo/xo_config.h b/lib/libxo/xo_config.h
index 8e718fd..b26fded 100644
--- a/lib/libxo/xo_config.h
+++ b/lib/libxo/xo_config.h
@@ -88,6 +88,9 @@
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
+/* Define to 1 if you have the <monitor.h> header file. */
+/* #undef HAVE_MONITOR_H */
+
/* Support printflike */
/* #undef HAVE_PRINTFLIKE */
@@ -180,16 +183,16 @@
/* #undef LIBXO_TEXT_ONLY */
/* Version number as dotted value */
-#define LIBXO_VERSION "0.4.6"
+#define LIBXO_VERSION "0.6.1"
/* Version number extra information */
#define LIBXO_VERSION_EXTRA ""
/* Version number as a number */
-#define LIBXO_VERSION_NUMBER 4006
+#define LIBXO_VERSION_NUMBER 6001
/* Version number as string */
-#define LIBXO_VERSION_STRING "4006"
+#define LIBXO_VERSION_STRING "6001"
/* Enable local wcwidth implementation */
#define LIBXO_WCWIDTH 1
@@ -207,7 +210,7 @@
#define PACKAGE_NAME "libxo"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libxo 0.4.6"
+#define PACKAGE_STRING "libxo 0.6.1"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libxo"
@@ -216,7 +219,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
-#define PACKAGE_VERSION "0.4.6"
+#define PACKAGE_VERSION "0.6.1"
/* If using the C implementation of alloca, define if you know the
direction of stack growth for your system; otherwise it will be
@@ -230,7 +233,10 @@
#define STDC_HEADERS 1
/* Version number of package */
-#define VERSION "0.4.6"
+#define VERSION "0.6.1"
+
+/* Retain hash bucket size */
+/* #undef XO_RETAIN_SIZE */
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
diff --git a/lib/libypclnt/ypclnt_passwd.c b/lib/libypclnt/ypclnt_passwd.c
index c7ee7ea..86844eb 100644
--- a/lib/libypclnt/ypclnt_passwd.c
+++ b/lib/libypclnt/ypclnt_passwd.c
@@ -65,7 +65,7 @@ int
ypclnt_havepasswdd(ypclnt_t *ypclnt)
{
struct netconfig *nc = NULL;
- void *localhandle = 0;
+ void *localhandle = NULL;
CLIENT *clnt = NULL;
int ret;
@@ -139,7 +139,7 @@ yppasswd_local(ypclnt_t *ypclnt, const struct passwd *pwd)
struct master_yppasswd yppwd;
struct rpc_err rpcerr;
struct netconfig *nc = NULL;
- void *localhandle = 0;
+ void *localhandle = NULL;
CLIENT *clnt = NULL;
int ret, *result;
diff --git a/lib/msun/tests/Makefile b/lib/msun/tests/Makefile
index 8bd4d93..447cdba 100644
--- a/lib/msun/tests/Makefile
+++ b/lib/msun/tests/Makefile
@@ -1,5 +1,7 @@
# $FreeBSD$
+.include <bsd.own.mk>
+
PACKAGE=tests
FILESGROUPS= TESTS
TESTSPACKAGE= ${PACKAGE}
@@ -50,7 +52,10 @@ TAP_TESTS_C+= ctrig_test
TAP_TESTS_C+= exponential_test
TAP_TESTS_C+= fenv_test
TAP_TESTS_C+= fma_test
+# clang 3.8.0 fails always fails this test. See: bug 208703
+.if ! (${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} == 30800)
TAP_TESTS_C+= fmaxmin_test
+.endif
TAP_TESTS_C+= ilogb_test
TAP_TESTS_C+= invtrig_test
TAP_TESTS_C+= invctrig_test
diff --git a/lib/ncurses/ncurses/Makefile b/lib/ncurses/ncurses/Makefile
index 6d720ed..c361e29 100644
--- a/lib/ncurses/ncurses/Makefile
+++ b/lib/ncurses/ncurses/Makefile
@@ -390,10 +390,10 @@ keys.list: MKkeys_list.sh Caps
# Build tools
build-tools: make_hash make_keys
-make_keys: make_keys.c names.c ncurses_def.h ${HEADERS}
+make_keys: make_keys.c names.c ncurses_def.h ${HEADERS} ${BUILD_TOOLS_META}
${CC} -o $@ ${CFLAGS} ${NCURSES_DIR}/ncurses/tinfo/make_keys.c
-make_hash: make_hash.c hashsize.h ncurses_def.h ${HEADERS}
+make_hash: make_hash.c hashsize.h ncurses_def.h ${HEADERS} ${BUILD_TOOLS_META}
${CC} -o $@ ${CFLAGS} -DMAIN_PROGRAM \
${NCURSES_DIR}/ncurses/tinfo/make_hash.c
diff --git a/release/Makefile b/release/Makefile
index ba1ca80..a8efa2c 100644
--- a/release/Makefile
+++ b/release/Makefile
@@ -200,7 +200,7 @@ bootonly: packagesystem
MK_GAMES=no MK_GROFF=no \
MK_INSTALLLIB=no MK_LIB32=no MK_MAIL=no \
MK_NCP=no MK_TOOLCHAIN=no MK_PROFILE=no \
- MK_INSTALLIB=no MK_RESCUE=no MK_DICT=no \
+ MK_RESCUE=no MK_DICT=no \
MK_KERNEL_SYMBOLS=no MK_TESTS=no MK_DEBUG_FILES=no
# Copy manifest only (no distfiles) to get checksums
mkdir -p ${.TARGET}/usr/freebsd-dist
diff --git a/sbin/devd/devd.conf.5 b/sbin/devd/devd.conf.5
index 83c4c76..b358dcb 100644
--- a/sbin/devd/devd.conf.5
+++ b/sbin/devd/devd.conf.5
@@ -41,7 +41,7 @@
.\" ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
.\" SOFTWARE.
.\"
-.Dd March 28, 2016
+.Dd April 14, 2016
.Dt DEVD.CONF 5
.Os
.Sh NAME
@@ -501,6 +501,23 @@ Information about the state of the system.
Notification that the system has woken from the suspended state.
.El
.El
+.Pp
+.It Li CAM
+Events related to the
+.Xr cam 4
+system.
+.Bl -tag -width ".Sy Subsystem" -compact
+.It Sy Subsystem
+.It Li periph
+Events related to peripheral devices.
+.Bl -tag -width ".li timeout" -compact
+.It Sy Type
+.It Li error
+Generic errors.
+.It Li timeout
+Command timeouts.
+.El
+.El
.El
.Pp
A link state change to UP on the interface
@@ -630,4 +647,5 @@ has many additional examples.
.Xr coretemp 4 ,
.Xr devfs 5 ,
.Xr re_format 7 ,
-.Xr devd 8
+.Xr devd 8 ,
+.Xr cam 4
diff --git a/sbin/dump/optr.c b/sbin/dump/optr.c
index 311e255..bffcdc8 100644
--- a/sbin/dump/optr.c
+++ b/sbin/dump/optr.c
@@ -403,7 +403,7 @@ lastdump(int arg) /* w ==> just what to do; W ==> most recent dumps */
dumpme = tnow > (dtwalk->dd_ddate - (tlast->tm_hour * 3600)
- (tlast->tm_min * 60) - tlast->tm_sec
+ (dt->fs_freq * 86400));
- };
+ }
if (arg != 'w' || dumpme)
(void) printf(
"%c %8s\t(%6s) Last dump: Level %d, Date %s\n",
diff --git a/sbin/fsck_ffs/globs.c b/sbin/fsck_ffs/globs.c
index e910bc9..af3b72b 100644
--- a/sbin/fsck_ffs/globs.c
+++ b/sbin/fsck_ffs/globs.c
@@ -118,7 +118,7 @@ fsckinit(void)
bzero(totalreadcnt, sizeof(long) * BT_NUMBUFTYPES);
bzero(readtime, sizeof(struct timespec) * BT_NUMBUFTYPES);
bzero(totalreadtime, sizeof(struct timespec) * BT_NUMBUFTYPES);
- bzero(&startprog, sizeof(struct timespec));;
+ bzero(&startprog, sizeof(struct timespec));
bzero(&sblk, sizeof(struct bufarea));
pdirbp = NULL;
pbp = NULL;
diff --git a/sbin/ifconfig/sfp.c b/sbin/ifconfig/sfp.c
index d92ee2c..0fa29a3 100644
--- a/sbin/ifconfig/sfp.c
+++ b/sbin/ifconfig/sfp.c
@@ -911,6 +911,6 @@ sfp_status(int s, struct ifreq *ifr, int verbose)
break;
default:
print_sfp_status(&ii, verbose);
- };
+ }
}
diff --git a/sbin/ipfw/ipfw2.c b/sbin/ipfw/ipfw2.c
index 95a96ad..21b6229 100644
--- a/sbin/ipfw/ipfw2.c
+++ b/sbin/ipfw/ipfw2.c
@@ -234,6 +234,9 @@ static struct _s_x ether_types[] = {
{ NULL, 0 }
};
+static struct _s_x rule_eactions[] = {
+ { NULL, 0 } /* terminator */
+};
static struct _s_x rule_actions[] = {
{ "accept", TOK_ACCEPT },
@@ -265,6 +268,7 @@ static struct _s_x rule_actions[] = {
{ "setdscp", TOK_SETDSCP },
{ "call", TOK_CALL },
{ "return", TOK_RETURN },
+ { "eaction", TOK_EACTION },
{ NULL, 0 } /* terminator */
};
@@ -381,6 +385,8 @@ static uint16_t pack_table(struct tidx *tstate, char *name);
static char *table_search_ctlv(ipfw_obj_ctlv *ctlv, uint16_t idx);
static void object_sort_ctlv(ipfw_obj_ctlv *ctlv);
+static char *object_search_ctlv(ipfw_obj_ctlv *ctlv, uint16_t idx,
+ uint16_t type);
/*
* Simple string buffer API.
@@ -634,7 +640,7 @@ do_get3(int optname, ip_fw3_opheader *op3, size_t *optlen)
* with the string (-1 in case of failure).
*/
int
-match_token(struct _s_x *table, char *string)
+match_token(struct _s_x *table, const char *string)
{
struct _s_x *pt;
uint i = strlen(string);
@@ -646,7 +652,7 @@ match_token(struct _s_x *table, char *string)
}
/**
- * match_token takes a table and a string, returns the value associated
+ * match_token_relaxed takes a table and a string, returns the value associated
* with the string for the best match.
*
* Returns:
@@ -655,7 +661,7 @@ match_token(struct _s_x *table, char *string)
* -2 if more than one records match @string.
*/
int
-match_token_relaxed(struct _s_x *table, char *string)
+match_token_relaxed(struct _s_x *table, const char *string)
{
struct _s_x *pt, *m;
int i, c;
@@ -676,6 +682,18 @@ match_token_relaxed(struct _s_x *table, char *string)
return (c > 0 ? -2: -1);
}
+int
+get_token(struct _s_x *table, const char *string, const char *errbase)
+{
+ int tcmd;
+
+ if ((tcmd = match_token_relaxed(table, string)) < 0)
+ errx(EX_USAGE, "%s %s %s",
+ (tcmd == 0) ? "invalid" : "ambiguous", errbase, string);
+
+ return (tcmd);
+}
+
/**
* match_value takes a table and a value, returns the string associated
* with the value (NULL in case of failure).
@@ -1383,7 +1401,7 @@ show_static_rule(struct cmdline_opts *co, struct format_opts *fo,
{
static int twidth = 0;
int l;
- ipfw_insn *cmd, *tagptr = NULL;
+ ipfw_insn *cmd, *has_eaction = NULL, *tagptr = NULL;
const char *comment = NULL; /* ptr to comment if we have one */
int proto = 0; /* default */
int flags = 0; /* prerequisites */
@@ -1484,7 +1502,7 @@ show_static_rule(struct cmdline_opts *co, struct format_opts *fo,
if (cmd->arg1 == ICMP6_UNREACH_RST)
bprintf(bp, "reset6");
else
- print_unreach6_code(cmd->arg1);
+ print_unreach6_code(bp, cmd->arg1);
break;
case O_SKIPTO:
@@ -1567,6 +1585,52 @@ show_static_rule(struct cmdline_opts *co, struct format_opts *fo,
bprint_uint_arg(bp, "setfib ", cmd->arg1 & 0x7FFF);
break;
+ case O_EXTERNAL_ACTION: {
+ const char *ename;
+
+ /*
+ * The external action can consists of two following
+ * each other opcodes - O_EXTERNAL_ACTION and
+ * O_EXTERNAL_INSTANCE. The first contains the ID of
+ * name of external action. The second contains the ID
+ * of name of external action instance.
+ * NOTE: in case when external action has no named
+ * instances support, the second opcode isn't needed.
+ */
+ has_eaction = cmd;
+ ename = object_search_ctlv(fo->tstate, cmd->arg1,
+ IPFW_TLV_EACTION);
+ if (match_token(rule_eactions, ename) != -1)
+ bprintf(bp, "%s", ename);
+ else
+ bprintf(bp, "eaction %s", ename);
+ break;
+ }
+
+ case O_EXTERNAL_INSTANCE: {
+ const char *ename;
+
+ if (has_eaction == NULL)
+ break;
+ /*
+ * XXX: we need to teach ipfw(9) to rewrite opcodes
+ * in the user buffer on rule addition. When we add
+ * the rule, we specify zero TLV type for
+ * O_EXTERNAL_INSTANCE object. To show correct
+ * rule after `ipfw add` we need to search instance
+ * name with zero type. But when we do `ipfw show`
+ * we calculate TLV type using IPFW_TLV_EACTION_NAME()
+ * macro.
+ */
+ ename = object_search_ctlv(fo->tstate, cmd->arg1, 0);
+ if (ename == NULL)
+ ename = object_search_ctlv(fo->tstate,
+ cmd->arg1,
+ IPFW_TLV_EACTION_NAME(has_eaction->arg1));
+ bprintf(bp, " %s", ename);
+ break;
+ }
+
case O_SETDSCP:
{
const char *code;
@@ -2730,6 +2794,42 @@ struct tidx {
uint8_t set;
};
+int
+ipfw_check_object_name(const char *name)
+{
+ int c, i, l;
+
+ /*
+ * Check that name is null-terminated and contains
+ * valid symbols only. Valid mask is:
+ * [a-zA-Z0-9\-_\.]{1,63}
+ */
+ l = strlen(name);
+ if (l == 0 || l >= 64)
+ return (EINVAL);
+ for (i = 0; i < l; i++) {
+ c = name[i];
+ if (isalpha(c) || isdigit(c) || c == '_' ||
+ c == '-' || c == '.')
+ continue;
+ return (EINVAL);
+ }
+ return (0);
+}
+
+static int
+eaction_check_name(const char *name)
+{
+
+ if (ipfw_check_object_name(name) != 0)
+ return (EINVAL);
+ /* Restrict some 'special' names */
+ if (match_token(rule_actions, name) != -1 &&
+ match_token(rule_action_params, name) != -1)
+ return (EINVAL);
+ return (0);
+}
+
static uint16_t
pack_object(struct tidx *tstate, char *name, int otype)
{
@@ -3833,7 +3933,46 @@ chkarg:
break;
default:
- errx(EX_DATAERR, "invalid action %s\n", av[-1]);
+ av--;
+ if (match_token(rule_eactions, *av) == -1)
+ errx(EX_DATAERR, "invalid action %s\n", *av);
+ /*
+ * External actions support.
+ * XXX: we support only syntax with instance name.
+ * For known external actions (from rule_eactions list)
+ * we can handle syntax directly. But with `eaction'
+ * keyword we can use only `eaction <name> <instance>'
+ * syntax.
+ */
+ case TOK_EACTION: {
+ uint16_t idx;
+
+ NEED1("Missing eaction name");
+ if (eaction_check_name(*av) != 0)
+ errx(EX_DATAERR, "Invalid eaction name %s", *av);
+ idx = pack_object(tstate, *av, IPFW_TLV_EACTION);
+ if (idx == 0)
+ errx(EX_DATAERR, "pack_object failed");
+ fill_cmd(action, O_EXTERNAL_ACTION, 0, idx);
+ av++;
+ NEED1("Missing eaction instance name");
+ action = next_cmd(action, &ablen);
+ action->len = 1;
+ CHECK_ACTLEN;
+ if (eaction_check_name(*av) != 0)
+ errx(EX_DATAERR, "Invalid eaction instance name %s",
+ *av);
+ /*
+ * External action instance object has TLV type depended
+ * from the external action name object index. Since we
+ * currently don't know this index, use zero as TLV type.
+ */
+ idx = pack_object(tstate, *av, 0);
+ if (idx == 0)
+ errx(EX_DATAERR, "pack_object failed");
+ fill_cmd(action, O_EXTERNAL_INSTANCE, 0, idx);
+ av++;
+ }
}
action = next_cmd(action, &ablen);
@@ -4758,7 +4897,7 @@ object_search_ctlv(ipfw_obj_ctlv *ctlv, uint16_t idx, uint16_t type)
ntlv = bsearch(&key, (ctlv + 1), ctlv->count, ctlv->objsize,
compare_object_kntlv);
- if (ntlv != 0)
+ if (ntlv != NULL)
return (ntlv->name);
return (NULL);
@@ -5019,7 +5158,7 @@ ipfw_list_objects(int ac, char *av[])
printf("There are no objects\n");
ntlv = (ipfw_obj_ntlv *)(olh + 1);
for (i = 0; i < olh->count; i++) {
- printf(" kidx: %4d\ttype: %2d\tname: %s\n", ntlv->idx,
+ printf(" kidx: %4d\ttype: %6d\tname: %s\n", ntlv->idx,
ntlv->head.type, ntlv->name);
ntlv++;
}
diff --git a/sbin/ipfw/ipfw2.h b/sbin/ipfw/ipfw2.h
index 86f2a41..d18803d 100644
--- a/sbin/ipfw/ipfw2.h
+++ b/sbin/ipfw/ipfw2.h
@@ -83,6 +83,7 @@ enum tokens {
TOK_ACCEPT,
TOK_COUNT,
+ TOK_EACTION,
TOK_PIPE,
TOK_LINK,
TOK_QUEUE,
@@ -261,8 +262,9 @@ int _substrcmp2(const char *str1, const char* str2, const char* str3);
int stringnum_cmp(const char *a, const char *b);
/* utility functions */
-int match_token(struct _s_x *table, char *string);
-int match_token_relaxed(struct _s_x *table, char *string);
+int match_token(struct _s_x *table, const char *string);
+int match_token_relaxed(struct _s_x *table, const char *string);
+int get_token(struct _s_x *table, const char *string, const char *errbase);
char const *match_value(struct _s_x *p, int value);
size_t concat_tokens(char *buf, size_t bufsize, struct _s_x *table,
char *delimiter);
@@ -313,6 +315,7 @@ void ipfw_flush(int force);
void ipfw_zero(int ac, char *av[], int optname);
void ipfw_list(int ac, char *av[], int show_counters);
void ipfw_internal_handler(int ac, char *av[]);
+int ipfw_check_object_name(const char *name);
#ifdef PF
/* altq.c */
@@ -329,7 +332,7 @@ void dummynet_flush(void);
int ipfw_delete_pipe(int pipe_or_queue, int n);
/* ipv6.c */
-void print_unreach6_code(uint16_t code);
+void print_unreach6_code(struct buf_pr *bp, uint16_t code);
void print_ip6(struct buf_pr *bp, struct _ipfw_insn_ip6 *cmd, char const *s);
void print_flow6id(struct buf_pr *bp, struct _ipfw_insn_u32 *cmd);
void print_icmp6types(struct buf_pr *bp, struct _ipfw_insn_u32 *cmd);
@@ -345,7 +348,7 @@ int fill_ext6hdr(struct _ipfw_insn *cmd, char *av);
/* tables.c */
struct _ipfw_obj_ctlv;
-int table_check_name(char *tablename);
+int table_check_name(const char *tablename);
void ipfw_list_ta(int ac, char *av[]);
void ipfw_list_values(int ac, char *av[]);
diff --git a/sbin/ipfw/ipv6.c b/sbin/ipfw/ipv6.c
index 36ee675..c04dd70 100644
--- a/sbin/ipfw/ipv6.c
+++ b/sbin/ipfw/ipv6.c
@@ -71,14 +71,14 @@ fill_unreach6_code(u_short *codep, char *str)
}
void
-print_unreach6_code(uint16_t code)
+print_unreach6_code(struct buf_pr *bp, uint16_t code)
{
char const *s = match_value(icmp6codes, code);
if (s != NULL)
- printf("unreach6 %s", s);
+ bprintf(bp, "unreach6 %s", s);
else
- printf("unreach6 %u", code);
+ bprintf(bp, "unreach6 %u", code);
}
/*
diff --git a/sbin/ipfw/tables.c b/sbin/ipfw/tables.c
index 7eff340..2264e32 100644
--- a/sbin/ipfw/tables.c
+++ b/sbin/ipfw/tables.c
@@ -53,8 +53,8 @@ static void table_lock(ipfw_obj_header *oh, int lock);
static int table_swap(ipfw_obj_header *oh, char *second);
static int table_get_info(ipfw_obj_header *oh, ipfw_xtable_info *i);
static int table_show_info(ipfw_xtable_info *i, void *arg);
-static void table_fill_ntlv(ipfw_obj_ntlv *ntlv, char *name, uint32_t set,
- uint16_t uidx);
+static void table_fill_ntlv(ipfw_obj_ntlv *ntlv, const char *name,
+ uint32_t set, uint16_t uidx);
static int table_flush_one(ipfw_xtable_info *i, void *arg);
static int table_show_one(ipfw_xtable_info *i, void *arg);
@@ -130,18 +130,6 @@ lookup_host (char *host, struct in_addr *ipaddr)
return(0);
}
-static int
-get_token(struct _s_x *table, char *string, char *errbase)
-{
- int tcmd;
-
- if ((tcmd = match_token_relaxed(table, string)) < 0)
- errx(EX_USAGE, "%s %s %s",
- (tcmd == 0) ? "invalid" : "ambiguous", errbase, string);
-
- return (tcmd);
-}
-
/*
* This one handles all table-related commands
* ipfw table NAME create ...
@@ -293,7 +281,8 @@ ipfw_table_handler(int ac, char *av[])
}
static void
-table_fill_ntlv(ipfw_obj_ntlv *ntlv, char *name, uint32_t set, uint16_t uidx)
+table_fill_ntlv(ipfw_obj_ntlv *ntlv, const char *name, uint32_t set,
+ uint16_t uidx)
{
ntlv->head.type = IPFW_TLV_TBL_NAME;
@@ -1994,30 +1983,14 @@ ipfw_list_values(int ac, char *av[])
}
int
-table_check_name(char *tablename)
+table_check_name(const char *tablename)
{
- int c, i, l;
- /*
- * Check if tablename is null-terminated and contains
- * valid symbols only. Valid mask is:
- * [a-zA-Z0-9\-_\.]{1,63}
- */
- l = strlen(tablename);
- if (l == 0 || l >= 64)
+ if (ipfw_check_object_name(tablename) != 0)
return (EINVAL);
- for (i = 0; i < l; i++) {
- c = tablename[i];
- if (isalpha(c) || isdigit(c) || c == '_' ||
- c == '-' || c == '.')
- continue;
- return (EINVAL);
- }
-
/* Restrict some 'special' names */
if (strcmp(tablename, "all") == 0)
return (EINVAL);
-
return (0);
}
diff --git a/sbin/mount_nfs/mount_nfs.c b/sbin/mount_nfs/mount_nfs.c
index 810cf59..149d127 100644
--- a/sbin/mount_nfs/mount_nfs.c
+++ b/sbin/mount_nfs/mount_nfs.c
@@ -1027,7 +1027,7 @@ xdr_fh(XDR *xdrsp, struct nfhret *np)
if (!authfnd && (authcnt > 0 || np->auth != AUTH_SYS))
np->stat = EAUTH;
return (1);
- };
+ }
return (0);
}
diff --git a/sbin/pfctl/parse.y b/sbin/pfctl/parse.y
index 9b22a6b..a03ddbc 100644
--- a/sbin/pfctl/parse.y
+++ b/sbin/pfctl/parse.y
@@ -1605,13 +1605,22 @@ bandwidth : STRING {
bps = strtod($1, &cp);
if (cp != NULL) {
+ if (strlen(cp) > 1) {
+ char *cu = cp + 1;
+ if (!strcmp(cu, "Bit") ||
+ !strcmp(cu, "B") ||
+ !strcmp(cu, "bit") ||
+ !strcmp(cu, "b")) {
+ *cu = 0;
+ }
+ }
if (!strcmp(cp, "b"))
; /* nothing */
- else if (!strcmp(cp, "Kb"))
+ else if (!strcmp(cp, "K"))
bps *= 1000;
- else if (!strcmp(cp, "Mb"))
+ else if (!strcmp(cp, "M"))
bps *= 1000 * 1000;
- else if (!strcmp(cp, "Gb"))
+ else if (!strcmp(cp, "G"))
bps *= 1000 * 1000 * 1000;
else if (!strcmp(cp, "%")) {
if (bps < 0 || bps > 100) {
diff --git a/sbin/reboot/nextboot.8 b/sbin/reboot/nextboot.8
index d006c3f..8b72b9a 100644
--- a/sbin/reboot/nextboot.8
+++ b/sbin/reboot/nextboot.8
@@ -32,9 +32,8 @@
.Nd "specify an alternate kernel and boot flags for the next reboot"
.Sh SYNOPSIS
.Nm
-.Op Fl a
+.Op Fl af
.Op Fl e Ar variable=value
-.Op Fl f
.Op Fl k Ar kernel
.Op Fl o Ar options
.Nm
diff --git a/sbin/reboot/nextboot.sh b/sbin/reboot/nextboot.sh
index a90fdeb..d9bbb25 100644
--- a/sbin/reboot/nextboot.sh
+++ b/sbin/reboot/nextboot.sh
@@ -50,7 +50,7 @@ add_kenv()
display_usage() {
cat <<-EOF
- Usage: nextboot [-e variable=value] [-f] [-k kernel] [-o options]
+ Usage: nextboot [-af] [-e variable=value] [-k kernel] [-o options]
nextboot -D
EOF
}
diff --git a/sbin/savecore/savecore.c b/sbin/savecore/savecore.c
index 7809c58..1d00ed2 100644
--- a/sbin/savecore/savecore.c
+++ b/sbin/savecore/savecore.c
@@ -436,7 +436,7 @@ DoFile(const char *savedir, const char *device)
{
xo_handle_t *xostdout, *xoinfo;
static char infoname[PATH_MAX], corename[PATH_MAX], linkname[PATH_MAX];
- static char *buf = NULL;
+ static char *buf = NULL, *temp = NULL;
struct kerneldumpheader kdhf, kdhl;
off_t mediasize, dumpsize, firsthd, lasthd;
FILE *info, *fp;
@@ -490,14 +490,29 @@ DoFile(const char *savedir, const char *device)
printf("sectorsize = %u\n", sectorsize);
}
+ if (sectorsize < sizeof(kdhl)) {
+ syslog(LOG_ERR,
+ "Sector size is less the kernel dump header %zu",
+ sizeof(kdhl));
+ goto closefd;
+ }
+
lasthd = mediasize - sectorsize;
+ if (temp == NULL) {
+ temp = malloc(sectorsize);
+ if (temp == NULL) {
+ syslog(LOG_ERR, "%m");
+ return;
+ }
+ }
if (lseek(fd, lasthd, SEEK_SET) != lasthd ||
- read(fd, &kdhl, sizeof(kdhl)) != sizeof(kdhl)) {
+ read(fd, temp, sectorsize) != (ssize_t)sectorsize) {
syslog(LOG_ERR,
"error reading last dump header at offset %lld in %s: %m",
(long long)lasthd, device);
goto closefd;
}
+ memcpy(&kdhl, temp, sizeof(kdhl));
istextdump = 0;
if (strncmp(kdhl.magic, TEXTDUMPMAGIC, sizeof kdhl) == 0) {
if (verbose)
@@ -567,15 +582,16 @@ DoFile(const char *savedir, const char *device)
goto closefd;
}
dumpsize = dtoh64(kdhl.dumplength);
- firsthd = lasthd - dumpsize - sizeof kdhf;
+ firsthd = lasthd - dumpsize - sectorsize;
if (lseek(fd, firsthd, SEEK_SET) != firsthd ||
- read(fd, &kdhf, sizeof(kdhf)) != sizeof(kdhf)) {
+ read(fd, temp, sectorsize) != (ssize_t)sectorsize) {
syslog(LOG_ERR,
"error reading first dump header at offset %lld in %s: %m",
(long long)firsthd, device);
nerr++;
goto closefd;
}
+ memcpy(&kdhf, temp, sizeof(kdhf));
if (verbose >= 2) {
printf("First dump headers:\n");
@@ -586,7 +602,7 @@ DoFile(const char *savedir, const char *device)
printf("\n");
}
- if (memcmp(&kdhl, &kdhf, sizeof kdhl)) {
+ if (memcmp(&kdhl, &kdhf, sizeof(kdhl))) {
syslog(LOG_ERR,
"first and last dump headers disagree on %s", device);
nerr++;
@@ -603,7 +619,7 @@ DoFile(const char *savedir, const char *device)
exit(0);
}
- if (kdhl.panicstring[0])
+ if (kdhl.panicstring[0] != '\0')
syslog(LOG_ALERT, "reboot after panic: %*s",
(int)sizeof(kdhl.panicstring), kdhl.panicstring);
else
@@ -724,9 +740,10 @@ nuke:
if (!keep) {
if (verbose)
printf("clearing dump header\n");
- memcpy(kdhl.magic, KERNELDUMPMAGIC_CLEARED, sizeof kdhl.magic);
+ memcpy(kdhl.magic, KERNELDUMPMAGIC_CLEARED, sizeof(kdhl.magic));
+ memcpy(temp, &kdhl, sizeof(kdhl));
if (lseek(fd, lasthd, SEEK_SET) != lasthd ||
- write(fd, &kdhl, sizeof(kdhl)) != sizeof(kdhl))
+ write(fd, temp, sectorsize) != (ssize_t)sectorsize)
syslog(LOG_ERR,
"error while clearing the dump header: %m");
}
diff --git a/share/examples/Makefile b/share/examples/Makefile
index 827afa9..f926107 100644
--- a/share/examples/Makefile
+++ b/share/examples/Makefile
@@ -223,7 +223,7 @@ beforeinstall: ${SHARED} etc-examples
META_TARGETS+= copies symlinks
.ORDER: ${SHARED} etc-examples
-copies: ${META_DEPS}
+copies:
.for i in ${LDIRS}
if [ -L ${DESTDIR}${BINDIR}/$i ]; then \
rm -f ${DESTDIR}${BINDIR}/$i; \
@@ -236,7 +236,7 @@ copies: ${META_DEPS}
${.CURDIR}/${file} ${DESTDIR}${BINDIR}/${file}
.endfor
-symlinks: ${META_DEPS}
+symlinks:
.for i in ${LDIRS}
rm -rf ${DESTDIR}${BINDIR}/$i
ln -s ${.CURDIR}/$i ${DESTDIR}${BINDIR}/$i
diff --git a/share/man/man4/dtrace_tcp.4 b/share/man/man4/dtrace_tcp.4
index d7ab30c..d230066 100644
--- a/share/man/man4/dtrace_tcp.4
+++ b/share/man/man4/dtrace_tcp.4
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd July 5, 2015
+.Dd April 15, 2016
.Dt DTRACE_TCP 4
.Os
.Sh NAME
@@ -217,17 +217,17 @@ Next sequence number for send.
Sequence number of received and acknowledged data.
.It Vt uint32_t tcps_rnxt
Next expected sequence number for receive.
-.It Vt uint32_t tcps_swnd
+.It Vt u_long tcps_swnd
TCP send window size.
.It Vt int32_t tcps_snd_ws
Window scaling factor for the TCP send window.
-.It Vt uint32_t tcps_rwnd
+.It Vt u_long tcps_rwnd
TCP receive window size.
.It Vt int32_t tcps_rcv_ws
Window scaling factor for the TCP receive window.
-.It Vt uint32_t tcps_cwnd
+.It Vt u_long tcps_cwnd
TCP congestion window size.
-.It Vt uint32_t tcps_cwnd_ssthresh
+.It Vt u_long tcps_cwnd_ssthresh
Congestion window threshold at which slow start ends and congestion avoidance
begins.
.It Vt uint32_t tcps_sack_fack
diff --git a/share/man/man5/src.conf.5 b/share/man/man5/src.conf.5
index e638803..e9326f2 100644
--- a/share/man/man5/src.conf.5
+++ b/share/man/man5/src.conf.5
@@ -1,7 +1,7 @@
.\" DO NOT EDIT-- this file is automatically generated.
.\" from FreeBSD: head/tools/build/options/makeman 292283 2015-12-15 18:42:30Z bdrewery
.\" $FreeBSD$
-.Dd April 11, 2016
+.Dd April 14, 2016
.Dt SRC.CONF 5
.Os
.Sh NAME
@@ -473,12 +473,12 @@ executable binary and shared library.
.\" from FreeBSD: head/tools/build/options/WITHOUT_DICT 156932 2006-03-21 07:50:50Z ru
Set to not build the Webster dictionary files.
.It Va WITH_DIRDEPS_BUILD
-.\" from FreeBSD: head/tools/build/options/WITH_DIRDEPS_BUILD 297843 2016-04-12 03:37:42Z bdrewery
-Enable building in meta mode.
-This is an experimental build feature.
+.\" from FreeBSD: head/tools/build/options/WITH_DIRDEPS_BUILD 298007 2016-04-14 22:00:49Z bdrewery
+This is an experimental build system.
For details see
http://www.crufty.net/sjg/docs/freebsd-meta-mode.htm.
-.Pp
+Build commands can be seen from the top-level with:
+.Dl make show-valid-targets
The build is driven by dirdeps.mk using
.Va DIRDEPS
stored in
@@ -498,20 +498,16 @@ and child directories.
.Va NO_DIRDEPS_BELOW
will skip building any dirdeps and only build the current directory.
.Pp
-As each target is made
-.Xr make 1
-produces a meta file which is used to capture (and compare)
-the command line,
-as well as any command output.
-If
-.Xr filemon 4
-is available the meta file will also capture a record of files
-used to produce the target by tracking syscalls.
+This also utilizes the
+.Va WITH_META_MODE
+logic for incremental builds.
.Pp
The build will hide commands ran unless
.Va NO_SILENT
is defined.
.Pp
+Note that there is currently no mass install feature for this.
+.Pp
When set, it also enforces the following options:
.Pp
.Bl -item -compact
@@ -821,11 +817,14 @@ Set to not build
.\" from FreeBSD: head/tools/build/options/WITHOUT_INET_SUPPORT 221266 2011-04-30 17:58:28Z bz
Set to build libraries, programs, and kernel modules without IPv4 support.
.It Va WITHOUT_INSTALLLIB
-.\" from FreeBSD: head/tools/build/options/WITHOUT_INSTALLLIB 174497 2007-12-09 21:56:21Z dougb
+.\" from FreeBSD: head/tools/build/options/WITHOUT_INSTALLLIB 297941 2016-04-13 21:01:58Z bdrewery
Set this if you do not want to install optional libraries.
For example when creating a
.Xr nanobsd 8
image.
+.Bf -symbolic
+The option does not work for build targets.
+.Ef
.It Va WITH_INSTALL_AS_USER
.\" from FreeBSD: head/tools/build/options/WITH_INSTALL_AS_USER 238021 2012-07-02 20:24:01Z marcel
Set to make install targets succeed for non-root users by installing
@@ -1059,19 +1058,48 @@ Set to not build utilities for manual pages,
.Xr manctl 8 ,
and related support files.
.It Va WITH_META_MODE
-.\" from FreeBSD: head/tools/build/options/WITH_META_MODE 297844 2016-04-12 03:40:13Z bdrewery
-Create meta files when not doing DIRDEPS_BUILD.
+.\" from FreeBSD: head/tools/build/options/WITH_META_MODE 298007 2016-04-14 22:00:49Z bdrewery
+Creates
+.Xr make 1
+meta files when building, which can provide a reliable incremental build when
+using
+.Xr filemon 4 .
+The meta file is created in the OBJDIR as
+.Pa target.meta .
+These meta files track the command ran, its output, and the current directory.
When the
.Xr filemon 4
-module is loaded, dependencies will be tracked for all commands.
-If any command, its dependencies, or files it generates are missing then
-the target will be considered out-of-date and rebuilt.
+module is loaded, any files used by the commands executed will be tracked as
+dependencies for the target in its meta file.
+The target will be considered out-of-date and rebuilt if any of the following
+are true compared to the last build:
+.Bl -bullet -compact
+.It
+The command to execute changes.
+.It
+The current working directory changes.
+.It
+The target's meta file is missing.
+.It
+[requires
+.Xr filemon 4 ]
+Files read, executed or linked to are newer than the target.
+.It
+[requires
+.Xr filemon 4 ]
+Files read, written, executed or linked are missing.
+.El
The meta files can also be useful for debugging.
.Pp
The build will hide commands ran unless
.Va NO_SILENT
is defined.
.Pp
+The build operates as it normally would otherwise.
+This option originally invoked a different build system but that was renamed
+to
+.Va WITH_DIRDEPS_BUILD .
+.Pp
This must be set in the environment, make command line, or
.Pa /etc/src-env.conf ,
not
@@ -1435,13 +1463,10 @@ and
Set to not build or install
.Xr timed 8 .
.It Va WITHOUT_TOOLCHAIN
-.\" from FreeBSD: head/tools/build/options/WITHOUT_TOOLCHAIN 273172 2014-10-16 15:55:13Z brooks
+.\" from FreeBSD: head/tools/build/options/WITHOUT_TOOLCHAIN 297939 2016-04-13 20:55:05Z bdrewery
Set to not install header or
programs used for program development,
compilers, debuggers etc.
-.Bf -symbolic
-The option does not work for build targets.
-.Ef
When set, it also enforces the following options:
.Pp
.Bl -item -compact
diff --git a/share/man/man7/build.7 b/share/man/man7/build.7
index 36603da..a605c28 100644
--- a/share/man/man7/build.7
+++ b/share/man/man7/build.7
@@ -24,7 +24,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd March 29, 2016
+.Dd April 14, 2016
.Dt BUILD 7
.Os
.Sh NAME
@@ -539,6 +539,14 @@ instead of
.Dq make cleandir .
.It Va NO_CLEAN
If set, no object tree files are cleaned at all.
+This is the default when
+.Va WITH_META_MODE
+is used with
+.Xr filemon 4
+loaded.
+See
+.Xr src.conf 5
+for more details.
Setting
.Va NO_CLEAN
implies
diff --git a/share/mk/bsd.README b/share/mk/bsd.README
index bda9a8c..e386955 100644
--- a/share/mk/bsd.README
+++ b/share/mk/bsd.README
@@ -314,9 +314,27 @@ PROGS_CXX PROG and PROGS_CXX in one Makefile. To define
LDADD.foo= -lutil
SRCS.bar= bar_src.c
- The supported variables are BINDIR BINGRP BINMODE BINOWN
- CFLAGS CXXFLAGS DPADD DPSRCS LDADD
- LDFLAGS LIBADD MAN MLINKS PROGNAME SRCS.
+ The supported variables are:
+ - BINDIR
+ - BINGRP
+ - BINMODE
+ - BINOWN
+ - CFLAGS
+ - CXXFLAGS
+ - DEBUG_FLAGS
+ - DPADD
+ - DPSRCS
+ - LDADD
+ - LDFLAGS
+ - LIBADD
+ - LINKS
+ - MAN
+ - MLINKS
+ - NO_WERROR
+ - PROGNAME
+ - SRCS
+ - STRIP
+ - WARNS
PROGNAME The name that the above program will be installed as, if
different from ${PROG}.
@@ -401,12 +419,16 @@ with the current needs of the BSD tree.
It sets/uses the following variables:
-LIB The name of the library to build.
+LIB The name of the library to build. Both a shared and static
+ library will be built. NO_PIC can be set to only build a
+ static library.
LIB_CXX The name of the library to build. It also causes
<bsd.lib.mk> to link the library with the
standard C++ library. LIB_CXX overrides the value
- of LIB if LIB is also set.
+ of LIB if LIB is also set. Both a shared and static library
+ will be built. NO_PIC can be set to only build a static
+ library.
LIBDIR Target directory for libraries.
@@ -431,6 +453,10 @@ SRCS List of source files to build the library. Suffix types
to .c files of the same name. (This is not the default for
versions of make.)
+SHLIB Like LIB but only builds a shared library.
+
+SHLIB_CXX Like LIB_CXX but only builds a shared library.
+
SHLIB_LDSCRIPT Template file to generate shared library linker script.
Unless used, a simple symlink is created to the real
shared object.
diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk
index 50ed33c..d80cb9d 100644
--- a/share/mk/bsd.dep.mk
+++ b/share/mk/bsd.dep.mk
@@ -174,7 +174,7 @@ DEPEND_CFLAGS+= -MT${.TARGET}
.if defined(.PARSEDIR)
# Only add in DEPEND_CFLAGS for CFLAGS on files we expect from DEPENDOBJS
# as those are the only ones we will include.
-DEPEND_CFLAGS_CONDITION= !empty(DEPENDOBJS:M${.TARGET:${DEPEND_FILTER}})
+DEPEND_CFLAGS_CONDITION= "${DEPENDOBJS:M${.TARGET:${DEPEND_FILTER}}}" != ""
CFLAGS+= ${${DEPEND_CFLAGS_CONDITION}:?${DEPEND_CFLAGS}:}
.else
CFLAGS+= ${DEPEND_CFLAGS}
diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk
index 2169925..caf8942 100644
--- a/share/mk/bsd.lib.mk
+++ b/share/mk/bsd.lib.mk
@@ -4,12 +4,17 @@
.include <bsd.init.mk>
-.if defined(LIB_CXX)
-LIB= ${LIB_CXX}
+.if defined(LIB_CXX) || defined(SHLIB_CXX)
_LD= ${CXX}
.else
_LD= ${CC}
.endif
+.if defined(LIB_CXX)
+LIB= ${LIB_CXX}
+.endif
+.if defined(SHLIB_CXX)
+SHLIB= ${SHLIB_CXX}
+.endif
LIB_PRIVATE= ${PRIVATELIB:Dprivate}
# Set up the variables controlling shared libraries. After this section,
diff --git a/share/mk/bsd.progs.mk b/share/mk/bsd.progs.mk
index 00dd566..d26ba76 100644
--- a/share/mk/bsd.progs.mk
+++ b/share/mk/bsd.progs.mk
@@ -23,8 +23,8 @@ PROGS += ${PROGS_CXX}
.if defined(PROG)
# just one of many
PROG_OVERRIDE_VARS += BINDIR BINGRP BINOWN BINMODE DPSRCS MAN NO_WERROR \
- PROGNAME SRCS WARNS
-PROG_VARS += CFLAGS CXXFLAGS DPADD LDADD LIBADD LINKS \
+ PROGNAME SRCS STRIP WARNS
+PROG_VARS += CFLAGS CXXFLAGS DEBUG_FLAGS DPADD LDADD LIBADD LINKS \
LDFLAGS MLINKS ${PROG_OVERRIDE_VARS}
.for v in ${PROG_VARS:O:u}
.if empty(${PROG_OVERRIDE_VARS:M$v})
diff --git a/share/mk/bsd.sys.mk b/share/mk/bsd.sys.mk
index 8471699..5660bd4 100644
--- a/share/mk/bsd.sys.mk
+++ b/share/mk/bsd.sys.mk
@@ -297,3 +297,10 @@ STAGE_SYMLINKS.links= ${SYMLINKS}
.endif
.endif
+.if defined(META_TARGETS)
+.for _tgt in ${META_TARGETS}
+.if target(${_tgt})
+${_tgt}: ${META_DEPS}
+.endif
+.endfor
+.endif
diff --git a/share/mk/local.sys.mk b/share/mk/local.sys.mk
index f6a9824..e3d212c 100644
--- a/share/mk/local.sys.mk
+++ b/share/mk/local.sys.mk
@@ -32,9 +32,16 @@ OBJTOP?= ${.OBJDIR:S,${.CURDIR},,}${SRCTOP}
.if ${.MAKE.MODE:Mmeta*} != ""
# we can afford to use cookies to prevent some targets
# re-running needlessly but only when using filemon.
+# Targets that should support the meta mode cookie handling should just be
+# added to META_TARGETS. If bsd.sys.mk cannot be included then ${META_DEPS}
+# should be added as a target dependency as well. Otherwise the target
+# is added to in bsd.sys.mk since it comes last.
.if ${.MAKE.MODE:Mnofilemon} == ""
-META_COOKIE_COND= empty(.TARGET:M${.OBJDIR})
-META_COOKIE= ${COOKIE.${.TARGET}:U${${META_COOKIE_COND}:?${.OBJDIR}/${.TARGET}:${.TARGET}}}
+# Prepend .OBJDIR if not already there.
+_META_COOKIE_COND= "${.TARGET:M${.OBJDIR}/*}" == ""
+_META_COOKIE_DEFAULT= ${${_META_COOKIE_COND}:?${.OBJDIR}/${.TARGET}:${.TARGET}}
+# Use the default if COOKIE.${.TARGET} is not defined.
+META_COOKIE= ${COOKIE.${.TARGET}:U${_META_COOKIE_DEFAULT}}
META_COOKIE_RM= @rm -f ${META_COOKIE}
META_COOKIE_TOUCH= @touch ${META_COOKIE}
CLEANFILES+= ${META_TARGETS}
diff --git a/share/sendmail/Makefile b/share/sendmail/Makefile
index 2b1ae07..1dac259 100644
--- a/share/sendmail/Makefile
+++ b/share/sendmail/Makefile
@@ -19,7 +19,7 @@ all clean cleandir depend lint tags:
beforeinstall: ${SHARED}
META_TARGETS+= copies symlinks
-copies: ${META_DEPS}
+copies:
if [ -L ${DDIR}/${CFDIR} ]; then rm -f ${DDIR}/${CFDIR}; fi
.for dir in ${CFDIRS}
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 755 -d ${DDIR}/${dir}
@@ -28,7 +28,7 @@ copies: ${META_DEPS}
${INSTALL} -o ${BINOWN} -g ${BINGRP} -m 444 ${SENDMAIL_DIR}/${file} ${DDIR}/${file}
.endfor
-symlinks: ${META_DEPS}
+symlinks:
rm -rf ${DDIR}/${CFDIR}; ln -s ${SENDMAIL_DIR}/${CFDIR} ${DDIR}/${CFDIR}
.include <bsd.prog.mk>
diff --git a/share/syscons/scrnmaps/Makefile b/share/syscons/scrnmaps/Makefile
index 1c5dc88..1e14e50 100644
--- a/share/syscons/scrnmaps/Makefile
+++ b/share/syscons/scrnmaps/Makefile
@@ -19,7 +19,7 @@ ${SCRMAPS}: ${.TARGET:R}.mk
uuencode ${.TARGET:R}.tmp ${.TARGET:R} > ${.TARGET}
rm -f ${.TARGET:R}.tmp
-${SCRMAPS_MK}: ${.TARGET:R} mkscrfil.c
+${SCRMAPS_MK}: ${.TARGET:R} mkscrfil.c ${BUILD_TOOLS_META}
${CC} ${CFLAGS} -I${.CURDIR} -DFIL=\"${.TARGET:R}\" ${LDFLAGS} \
-o ${.TARGET} ${.CURDIR}/mkscrfil.c
diff --git a/share/zoneinfo/Makefile b/share/zoneinfo/Makefile
index 1ca7ea6..356d0ad 100644
--- a/share/zoneinfo/Makefile
+++ b/share/zoneinfo/Makefile
@@ -72,7 +72,7 @@ all: zoneinfo
.endif
META_TARGETS+= zoneinfo install-zoneinfo
-zoneinfo: yearistype ${TDATA} ${META_DEPS}
+zoneinfo: yearistype ${TDATA}
mkdir -p ${TZBUILDDIR}
cd ${TZBUILDDIR}; mkdir -p ${TZBUILDSUBDIRS}
umask 022; cd ${.CURDIR}; \
@@ -80,7 +80,7 @@ zoneinfo: yearistype ${TDATA} ${META_DEPS}
${LEAPFILE} -y ${.OBJDIR}/yearistype ${TZFILES}
beforeinstall: install-zoneinfo
-install-zoneinfo: ${META_DEPS}
+install-zoneinfo:
cd ${TZBUILDDIR} && \
find -s * -type f -print -exec ${INSTALL} \
-o ${BINOWN} -g ${BINGRP} -m ${NOBINMODE} \
diff --git a/sys/amd64/amd64/apic_vector.S b/sys/amd64/amd64/apic_vector.S
index a1279e6..b3ca520 100644
--- a/sys/amd64/amd64/apic_vector.S
+++ b/sys/amd64/amd64/apic_vector.S
@@ -174,22 +174,6 @@ IDTVEC(xen_intr_upcall)
jmp doreti
#endif
-#ifdef HYPERV
-/*
- * This is the Hyper-V vmbus channel direct callback interrupt.
- * Only used when it is running on Hyper-V.
- */
- .text
- SUPERALIGN_TEXT
-IDTVEC(hv_vmbus_callback)
- PUSH_FRAME
- FAKE_MCOUNT(TF_RIP(%rsp))
- movq %rsp, %rdi
- call hv_vector_handler
- MEXITCOUNT
- jmp doreti
-#endif
-
#ifdef SMP
/*
* Global address space TLB shootdown.
diff --git a/sys/amd64/amd64/exception.S b/sys/amd64/amd64/exception.S
index caabfd9..fd8cdac 100644
--- a/sys/amd64/amd64/exception.S
+++ b/sys/amd64/amd64/exception.S
@@ -659,6 +659,7 @@ MCOUNT_LABEL(eintr)
.text
SUPERALIGN_TEXT
.type doreti,@function
+ .globl doreti
doreti:
FAKE_MCOUNT($bintr) /* init "from" bintr -> doreti */
/*
diff --git a/sys/amd64/amd64/minidump_machdep.c b/sys/amd64/amd64/minidump_machdep.c
index cc32cdc..df04f42 100644
--- a/sys/amd64/amd64/minidump_machdep.c
+++ b/sys/amd64/amd64/minidump_machdep.c
@@ -56,9 +56,6 @@ CTASSERT(sizeof(struct kerneldumpheader) == 512);
*/
#define SIZEOF_METADATA (64*1024)
-#define MD_ALIGN(x) (((off_t)(x) + PAGE_MASK) & ~PAGE_MASK)
-#define DEV_ALIGN(x) (((off_t)(x) + (DEV_BSIZE-1)) & ~(DEV_BSIZE-1))
-
uint64_t *vm_page_dump;
int vm_page_dump_size;
@@ -222,6 +219,7 @@ minidumpsys(struct dumperinfo *di)
int error;
uint64_t bits;
uint64_t *pml4, *pdp, *pd, *pt, pa;
+ size_t size;
int i, ii, j, k, n, bit;
int retry_count;
struct minidumphdr mdhdr;
@@ -319,12 +317,12 @@ minidumpsys(struct dumperinfo *di)
dumpsize += PAGE_SIZE;
/* Determine dump offset on device. */
- if (di->mediasize < SIZEOF_METADATA + dumpsize + sizeof(kdh) * 2) {
+ if (di->mediasize < SIZEOF_METADATA + dumpsize + di->blocksize * 2) {
error = E2BIG;
goto fail;
}
dumplo = di->mediaoffset + di->mediasize - dumpsize;
- dumplo -= sizeof(kdh) * 2;
+ dumplo -= di->blocksize * 2;
progress = dumpsize;
/* Initialize mdhdr */
@@ -344,10 +342,10 @@ minidumpsys(struct dumperinfo *di)
ptoa((uintmax_t)physmem) / 1048576);
/* Dump leader */
- error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh));
+ error = dump_write_pad(di, &kdh, 0, dumplo, sizeof(kdh), &size);
if (error)
goto fail;
- dumplo += sizeof(kdh);
+ dumplo += size;
/* Dump my header */
bzero(&fakepd, sizeof(fakepd));
@@ -432,10 +430,10 @@ minidumpsys(struct dumperinfo *di)
goto fail;
/* Dump trailer */
- error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh));
+ error = dump_write_pad(di, &kdh, 0, dumplo, sizeof(kdh), &size);
if (error)
goto fail;
- dumplo += sizeof(kdh);
+ dumplo += size;
/* Signal completion, signoff and exit stage left. */
dump_write(di, NULL, 0, 0, 0);
diff --git a/sys/amd64/conf/GENERIC b/sys/amd64/conf/GENERIC
index 0ed672d..272da43 100644
--- a/sys/amd64/conf/GENERIC
+++ b/sys/amd64/conf/GENERIC
@@ -350,8 +350,6 @@ device virtio_scsi # VirtIO SCSI device
device virtio_balloon # VirtIO Memory Balloon device
# HyperV drivers and enchancement support
-# NOTE: HYPERV depends on hyperv. They must be added or removed together.
-options HYPERV # Hyper-V kernel infrastructure
device hyperv # HyperV drivers
# Xen HVM Guest Optimizations
diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES
index 3e7876a..c87ad64 100644
--- a/sys/amd64/conf/NOTES
+++ b/sys/amd64/conf/NOTES
@@ -515,7 +515,6 @@ device virtio_random # VirtIO Entropy device
device virtio_console # VirtIO Console device
# Microsoft Hyper-V enchancement support
-options HYPERV # Hyper-V kernel infrastructure
device hyperv # HyperV drivers
# Xen HVM Guest Optimizations
diff --git a/sys/arm/allwinner/a10_common.c b/sys/arm/allwinner/a10_common.c
index d20853a..82be0c0 100644
--- a/sys/arm/allwinner/a10_common.c
+++ b/sys/arm/allwinner/a10_common.c
@@ -42,7 +42,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int
fdt_aintc_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
@@ -69,4 +69,4 @@ fdt_pic_decode_t fdt_pic_table[] = {
NULL
};
-#endif /* ARM_INTRNG */
+#endif /* INTRNG */
diff --git a/sys/arm/altera/socfpga/socfpga_common.c b/sys/arm/altera/socfpga/socfpga_common.c
index 3615c94..740d342 100644
--- a/sys/arm/altera/socfpga/socfpga_common.c
+++ b/sys/arm/altera/socfpga/socfpga_common.c
@@ -74,7 +74,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int
fdt_pic_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
int *pol)
diff --git a/sys/arm/amlogic/aml8726/aml8726_machdep.c b/sys/arm/amlogic/aml8726/aml8726_machdep.c
index 1ad25b4..5037180 100644
--- a/sys/arm/amlogic/aml8726/aml8726_machdep.c
+++ b/sys/arm/amlogic/aml8726/aml8726_machdep.c
@@ -184,7 +184,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifndef ARM_INTRNG
+#ifndef INTRNG
#ifndef DEV_GIC
static int
fdt_pic_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
@@ -213,4 +213,4 @@ fdt_pic_decode_t fdt_pic_table[] = {
#endif
NULL
};
-#endif /* ARM_INTRNG */
+#endif /* INTRNG */
diff --git a/sys/arm/annapurna/alpine/common.c b/sys/arm/annapurna/alpine/common.c
index 5d45b55..cf90556 100644
--- a/sys/arm/annapurna/alpine/common.c
+++ b/sys/arm/annapurna/alpine/common.c
@@ -136,7 +136,7 @@ infinite:
while (1) {}
}
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int
alpine_pic_decode_fdt(uint32_t iparent, uint32_t *intr, int *interrupt,
int *trig, int *pol)
diff --git a/sys/arm/arm/gic.c b/sys/arm/arm/gic.c
index 5c0aece..85d1557 100644
--- a/sys/arm/arm/gic.c
+++ b/sys/arm/arm/gic.c
@@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$");
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/smp.h>
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#include <sys/sched.h>
#endif
#include <machine/bus.h>
@@ -62,7 +62,7 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#include "pic_if.h"
#endif
@@ -116,12 +116,14 @@ __FBSDID("$FreeBSD$");
#define GIC_DEFAULT_ICFGR_INIT 0x00000000
#endif
-#ifdef ARM_INTRNG
+#ifdef INTRNG
struct gic_irqsrc {
struct intr_irqsrc gi_isrc;
uint32_t gi_irq;
enum intr_polarity gi_pol;
enum intr_trigger gi_trig;
+#define GI_FLAG_EARLY_EOI (1 << 0)
+ u_int gi_flags;
};
static u_int gic_irq_cpu;
@@ -134,9 +136,22 @@ u_int sgi_first_unused = GIC_FIRST_SGI;
#endif
#endif
+#ifdef INTRNG
+struct arm_gic_range {
+ uint64_t bus;
+ uint64_t host;
+ uint64_t size;
+};
+
+struct arm_gic_devinfo {
+ struct ofw_bus_devinfo obdinfo;
+ struct resource_list rl;
+};
+#endif
+
struct arm_gic_softc {
device_t gic_dev;
-#ifdef ARM_INTRNG
+#ifdef INTRNG
void * gic_intrhand;
struct gic_irqsrc * gic_irqs;
#endif
@@ -151,16 +166,24 @@ struct arm_gic_softc {
#ifdef GIC_DEBUG_SPURIOUS
uint32_t last_irq[MAXCPU];
#endif
+
+#ifdef INTRNG
+ /* FDT child data */
+ pcell_t addr_cells;
+ pcell_t size_cells;
+ int nranges;
+ struct arm_gic_range * ranges;
+#endif
};
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#define GIC_INTR_ISRC(sc, irq) (&sc->gic_irqs[irq].gi_isrc)
#endif
static struct resource_spec arm_gic_spec[] = {
{ SYS_RES_MEMORY, 0, RF_ACTIVE }, /* Distributor registers */
{ SYS_RES_MEMORY, 1, RF_ACTIVE }, /* CPU Interrupt Intf. registers */
-#ifdef ARM_INTRNG
+#ifdef INTRNG
{ SYS_RES_IRQ, 0, RF_ACTIVE | RF_OPTIONAL }, /* Parent interrupt */
#endif
{ -1, 0 }
@@ -181,7 +204,7 @@ static struct arm_gic_softc *gic_sc = NULL;
#define gic_d_write_4(_sc, _reg, _val) \
bus_space_write_4((_sc)->gic_d_bst, (_sc)->gic_d_bsh, (_reg), (_val))
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int gic_config_irq(int irq, enum intr_trigger trig,
enum intr_polarity pol);
static void gic_post_filter(void *);
@@ -195,6 +218,7 @@ static struct ofw_compat_data compat_data[] = {
{"arm,cortex-a7-gic", true},
{"arm,arm11mp-gic", true},
{"brcm,brahma-b15-gic", true},
+ {"qcom,msm-qgic2", true},
{NULL, false}
};
@@ -211,7 +235,7 @@ arm_gic_probe(device_t dev)
return (BUS_PROBE_DEFAULT);
}
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static inline void
gic_irq_unmask(struct arm_gic_softc *sc, u_int irq)
{
@@ -251,7 +275,7 @@ gic_cpu_mask(struct arm_gic_softc *sc)
}
#ifdef SMP
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static void
arm_gic_init_secondary(device_t dev)
{
@@ -323,10 +347,10 @@ arm_gic_init_secondary(device_t dev)
gic_d_write_4(sc, GICD_ISENABLER(29 >> 5), (1UL << (29 & 0x1F)));
gic_d_write_4(sc, GICD_ISENABLER(30 >> 5), (1UL << (30 & 0x1F)));
}
-#endif /* ARM_INTRNG */
+#endif /* INTRNG */
#endif /* SMP */
-#ifndef ARM_INTRNG
+#ifndef INTRNG
int
gic_decode_fdt(phandle_t iparent, pcell_t *intr, int *interrupt,
int *trig, int *pol)
@@ -387,7 +411,7 @@ gic_decode_fdt(phandle_t iparent, pcell_t *intr, int *interrupt,
}
#endif
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static inline intptr_t
gic_xref(device_t dev)
{
@@ -437,6 +461,107 @@ arm_gic_register_isrcs(struct arm_gic_softc *sc, uint32_t num)
sc->nirqs = num;
return (0);
}
+
+static int
+arm_gic_fill_ranges(phandle_t node, struct arm_gic_softc *sc)
+{
+ pcell_t host_cells;
+ cell_t *base_ranges;
+ ssize_t nbase_ranges;
+ int i, j, k;
+
+ host_cells = 1;
+ OF_getencprop(OF_parent(node), "#address-cells", &host_cells,
+ sizeof(host_cells));
+ sc->addr_cells = 2;
+ OF_getencprop(node, "#address-cells", &sc->addr_cells,
+ sizeof(sc->addr_cells));
+ sc->size_cells = 2;
+ OF_getencprop(node, "#size-cells", &sc->size_cells,
+ sizeof(sc->size_cells));
+
+ nbase_ranges = OF_getproplen(node, "ranges");
+ if (nbase_ranges < 0)
+ return (-1);
+ sc->nranges = nbase_ranges / sizeof(cell_t) /
+ (sc->addr_cells + host_cells + sc->size_cells);
+ if (sc->nranges == 0)
+ return (0);
+
+ sc->ranges = malloc(sc->nranges * sizeof(sc->ranges[0]),
+ M_DEVBUF, M_WAITOK);
+ base_ranges = malloc(nbase_ranges, M_DEVBUF, M_WAITOK);
+ OF_getencprop(node, "ranges", base_ranges, nbase_ranges);
+
+ for (i = 0, j = 0; i < sc->nranges; i++) {
+ sc->ranges[i].bus = 0;
+ for (k = 0; k < sc->addr_cells; k++) {
+ sc->ranges[i].bus <<= 32;
+ sc->ranges[i].bus |= base_ranges[j++];
+ }
+ sc->ranges[i].host = 0;
+ for (k = 0; k < host_cells; k++) {
+ sc->ranges[i].host <<= 32;
+ sc->ranges[i].host |= base_ranges[j++];
+ }
+ sc->ranges[i].size = 0;
+ for (k = 0; k < sc->size_cells; k++) {
+ sc->ranges[i].size <<= 32;
+ sc->ranges[i].size |= base_ranges[j++];
+ }
+ }
+
+ free(base_ranges, M_DEVBUF);
+ return (sc->nranges);
+}
+
+static bool
+arm_gic_add_children(device_t dev)
+{
+ struct arm_gic_softc *sc;
+ struct arm_gic_devinfo *dinfo;
+ phandle_t child, node;
+ device_t cdev;
+
+ sc = device_get_softc(dev);
+ node = ofw_bus_get_node(dev);
+
+ /* If we have no children don't probe for them */
+ child = OF_child(node);
+ if (child == 0)
+ return (false);
+
+ if (arm_gic_fill_ranges(node, sc) < 0) {
+ device_printf(dev, "Have a child, but no ranges\n");
+ return (false);
+ }
+
+ for (; child != 0; child = OF_peer(child)) {
+ dinfo = malloc(sizeof(*dinfo), M_DEVBUF, M_WAITOK | M_ZERO);
+
+ if (ofw_bus_gen_setup_devinfo(&dinfo->obdinfo, child) != 0) {
+ free(dinfo, M_DEVBUF);
+ continue;
+ }
+
+ resource_list_init(&dinfo->rl);
+ ofw_bus_reg_to_rl(dev, child, sc->addr_cells,
+ sc->size_cells, &dinfo->rl);
+
+ cdev = device_add_child(dev, NULL, -1);
+ if (cdev == NULL) {
+ device_printf(dev, "<%s>: device_add_child failed\n",
+ dinfo->obdinfo.obd_name);
+ resource_list_free(&dinfo->rl);
+ ofw_bus_gen_destroy_devinfo(&dinfo->obdinfo);
+ free(dinfo, M_DEVBUF);
+ continue;
+ }
+ device_set_ivars(cdev, dinfo);
+ }
+
+ return (true);
+}
#endif
static int
@@ -445,7 +570,7 @@ arm_gic_attach(device_t dev)
struct arm_gic_softc *sc;
int i;
uint32_t icciidr, mask, nirqs;
-#ifdef ARM_INTRNG
+#ifdef INTRNG
phandle_t pxref;
intptr_t xref = gic_xref(dev);
#endif
@@ -481,7 +606,7 @@ arm_gic_attach(device_t dev)
nirqs = gic_d_read_4(sc, GICD_TYPER);
nirqs = 32 * ((nirqs & 0x1f) + 1);
-#ifdef ARM_INTRNG
+#ifdef INTRNG
if (arm_gic_register_isrcs(sc, nirqs)) {
device_printf(dev, "could not register irqs\n");
goto cleanup;
@@ -537,7 +662,7 @@ arm_gic_attach(device_t dev)
/* Enable interrupt distribution */
gic_d_write_4(sc, GICD_CTLR, 0x01);
-#ifndef ARM_INTRNG
+#ifndef INTRNG
return (0);
#else
/*
@@ -578,6 +703,13 @@ arm_gic_attach(device_t dev)
}
OF_device_register_xref(xref, dev);
+
+ /* If we have children probe and attach them */
+ if (arm_gic_add_children(dev)) {
+ bus_generic_probe(dev);
+ return (bus_generic_attach(dev));
+ }
+
return (0);
cleanup:
@@ -591,7 +723,76 @@ cleanup:
#endif
}
-#ifdef ARM_INTRNG
+#ifdef INTRNG
+static struct resource *
+arm_gic_alloc_resource(device_t bus, device_t child, int type, int *rid,
+ rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
+{
+ struct arm_gic_softc *sc;
+ struct arm_gic_devinfo *di;
+ struct resource_list_entry *rle;
+ int j;
+
+ KASSERT(type == SYS_RES_MEMORY, ("Invalid resoure type %x", type));
+
+ sc = device_get_softc(bus);
+
+ /*
+ * Request for the default allocation with a given rid: use resource
+ * list stored in the local device info.
+ */
+ if (RMAN_IS_DEFAULT_RANGE(start, end)) {
+ if ((di = device_get_ivars(child)) == NULL)
+ return (NULL);
+
+ if (type == SYS_RES_IOPORT)
+ type = SYS_RES_MEMORY;
+
+ rle = resource_list_find(&di->rl, type, *rid);
+ if (rle == NULL) {
+ if (bootverbose)
+ device_printf(bus, "no default resources for "
+ "rid = %d, type = %d\n", *rid, type);
+ return (NULL);
+ }
+ start = rle->start;
+ end = rle->end;
+ count = rle->count;
+ }
+
+ /* Remap through ranges property */
+ for (j = 0; j < sc->nranges; j++) {
+ if (start >= sc->ranges[j].bus && end <
+ sc->ranges[j].bus + sc->ranges[j].size) {
+ start -= sc->ranges[j].bus;
+ start += sc->ranges[j].host;
+ end -= sc->ranges[j].bus;
+ end += sc->ranges[j].host;
+ break;
+ }
+ }
+ if (j == sc->nranges && sc->nranges != 0) {
+ if (bootverbose)
+ device_printf(bus, "Could not map resource "
+ "%#jx-%#jx\n", (uintmax_t)start, (uintmax_t)end);
+
+ return (NULL);
+ }
+
+ return (bus_generic_alloc_resource(bus, child, type, rid, start, end,
+ count, flags));
+}
+
+static const struct ofw_bus_devinfo *
+arm_gic_ofw_get_devinfo(device_t bus __unused, device_t child)
+{
+ struct arm_gic_devinfo *di;
+
+ di = device_get_ivars(child);
+
+ return (&di->obdinfo);
+}
+
static int
arm_gic_intr(void *arg)
{
@@ -654,12 +855,12 @@ dispatch_irq:
#ifdef GIC_DEBUG_SPURIOUS
sc->last_irq[PCPU_GET(cpuid)] = irq;
#endif
- if (gi->gi_trig == INTR_TRIGGER_EDGE)
+ if ((gi->gi_flags & GI_FLAG_EARLY_EOI) == GI_FLAG_EARLY_EOI)
gic_c_write_4(sc, GICC_EOIR, irq_active_reg);
if (intr_isrc_dispatch(&gi->gi_isrc, tf) != 0) {
gic_irq_mask(sc, irq);
- if (gi->gi_trig != INTR_TRIGGER_EDGE)
+ if ((gi->gi_flags & GI_FLAG_EARLY_EOI) != GI_FLAG_EARLY_EOI)
gic_c_write_4(sc, GICC_EOIR, irq_active_reg);
device_printf(sc->gic_dev, "Stray irq %u disabled\n", irq);
}
@@ -888,6 +1089,9 @@ arm_gic_setup_intr(device_t dev, struct intr_irqsrc *isrc,
gi->gi_pol = pol;
gi->gi_trig = trig;
+ /* Edge triggered interrupts need an early EOI sent */
+ if (gi->gi_pol == INTR_TRIGGER_EDGE)
+ gi->gi_flags |= GI_FLAG_EARLY_EOI;
/*
* XXX - In case that per CPU interrupt is going to be enabled in time
@@ -961,7 +1165,7 @@ arm_gic_post_filter(device_t dev, struct intr_irqsrc *isrc)
struct gic_irqsrc *gi = (struct gic_irqsrc *)isrc;
/* EOI for edge-triggered done earlier. */
- if (gi->gi_trig == INTR_TRIGGER_EDGE)
+ if ((gi->gi_flags & GI_FLAG_EARLY_EOI) == GI_FLAG_EARLY_EOI)
return;
arm_irq_memory_barrier(0);
@@ -1225,13 +1429,28 @@ pic_ipi_clear(int ipi)
arm_gic_ipi_clear(gic_sc->gic_dev, ipi);
}
#endif
-#endif /* ARM_INTRNG */
+#endif /* INTRNG */
static device_method_t arm_gic_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, arm_gic_probe),
DEVMETHOD(device_attach, arm_gic_attach),
-#ifdef ARM_INTRNG
+
+#ifdef INTRNG
+ /* Bus interface */
+ DEVMETHOD(bus_add_child, bus_generic_add_child),
+ DEVMETHOD(bus_alloc_resource, arm_gic_alloc_resource),
+ DEVMETHOD(bus_release_resource, bus_generic_release_resource),
+ DEVMETHOD(bus_activate_resource,bus_generic_activate_resource),
+
+ /* ofw_bus interface */
+ DEVMETHOD(ofw_bus_get_devinfo, arm_gic_ofw_get_devinfo),
+ DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat),
+ DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model),
+ DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name),
+ DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node),
+ DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type),
+
/* Interrupt controller interface */
DEVMETHOD(pic_disable_intr, arm_gic_disable_intr),
DEVMETHOD(pic_enable_intr, arm_gic_enable_intr),
@@ -1263,3 +1482,89 @@ EARLY_DRIVER_MODULE(gic, simplebus, arm_gic_driver, arm_gic_devclass, 0, 0,
BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
EARLY_DRIVER_MODULE(gic, ofwbus, arm_gic_driver, arm_gic_devclass, 0, 0,
BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
+
+#ifdef INTRNG
+/*
+ * GICv2m support -- the GICv2 MSI/MSI-X controller.
+ */
+
+#define GICV2M_MSI_TYPER 0x008
+#define MSI_TYPER_SPI_BASE(x) (((x) >> 16) & 0x3ff)
+#define MSI_TYPER_SPI_COUNT(x) (((x) >> 0) & 0x3ff)
+#define GICv2M_MSI_SETSPI_NS 0x040
+#define GICV2M_MSI_IIDR 0xFCC
+
+struct arm_gicv2m_softc {
+ struct resource *sc_mem;
+ struct mtx sc_mutex;
+ u_int sc_spi_start;
+ u_int sc_spi_count;
+ u_int sc_spi_offset;
+};
+
+static struct ofw_compat_data gicv2m_compat_data[] = {
+ {"arm,gic-v2m-frame", true},
+ {NULL, false}
+};
+
+static int
+arm_gicv2m_probe(device_t dev)
+{
+
+ if (!ofw_bus_status_okay(dev))
+ return (ENXIO);
+
+ if (!ofw_bus_search_compatible(dev, gicv2m_compat_data)->ocd_data)
+ return (ENXIO);
+
+ device_set_desc(dev, "ARM Generic Interrupt Controller MSI/MSIX");
+ return (BUS_PROBE_DEFAULT);
+}
+
+static int
+arm_gicv2m_attach(device_t dev)
+{
+ struct arm_gicv2m_softc *sc;
+ uint32_t typer;
+ int rid;
+
+ sc = device_get_softc(dev);
+
+ rid = 0;
+ sc->sc_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
+ RF_ACTIVE);
+ if (sc->sc_mem == NULL) {
+ device_printf(dev, "Unable to allocate resources\n");
+ return (ENXIO);
+ }
+
+ typer = bus_read_4(sc->sc_mem, GICV2M_MSI_TYPER);
+ sc->sc_spi_start = MSI_TYPER_SPI_BASE(typer);
+ sc->sc_spi_count = MSI_TYPER_SPI_COUNT(typer);
+
+ mtx_init(&sc->sc_mutex, "GICv2m lock", "", MTX_DEF);
+
+ if (bootverbose)
+ device_printf(dev, "using spi %u to %u\n", sc->sc_spi_start,
+ sc->sc_spi_start + sc->sc_spi_count - 1);
+
+ return (0);
+}
+
+static device_method_t arm_gicv2m_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, arm_gicv2m_probe),
+ DEVMETHOD(device_attach, arm_gicv2m_attach),
+
+ /* End */
+ DEVMETHOD_END
+};
+
+DEFINE_CLASS_0(gicv2m, arm_gicv2m_driver, arm_gicv2m_methods,
+ sizeof(struct arm_gicv2m_softc));
+
+static devclass_t arm_gicv2m_devclass;
+
+EARLY_DRIVER_MODULE(gicv2m, gic, arm_gicv2m_driver,
+ arm_gicv2m_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
+#endif
diff --git a/sys/arm/arm/machdep_intr.c b/sys/arm/arm/machdep_intr.c
index 504d262..b21dfa1 100644
--- a/sys/arm/arm/machdep_intr.c
+++ b/sys/arm/arm/machdep_intr.c
@@ -49,7 +49,7 @@ __FBSDID("$FreeBSD$");
#include <machine/cpu.h>
#include <machine/smp.h>
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#include "pic_if.h"
#ifdef SMP
@@ -131,7 +131,7 @@ arm_irq_memory_barrier(uintptr_t irq)
cpu_l2cache_drain_writebuf();
}
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#ifdef SMP
static inline struct intr_ipi *
intr_ipi_lookup(u_int ipi)
diff --git a/sys/arm/arm/mp_machdep.c b/sys/arm/arm/mp_machdep.c
index 699881c..db52622 100644
--- a/sys/arm/arm/mp_machdep.c
+++ b/sys/arm/arm/mp_machdep.c
@@ -74,7 +74,7 @@ volatile int mp_naps;
/* Set to 1 once we're ready to let the APs out of the pen. */
volatile int aps_ready = 0;
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int ipi_handler(void *arg);
#endif
void set_stackptrs(int cpu);
@@ -152,7 +152,7 @@ init_secondary(int cpu)
{
struct pcpu *pc;
uint32_t loop_counter;
-#ifndef ARM_INTRNG
+#ifndef INTRNG
int start = 0, end = 0;
#endif
uint32_t actlr_mask, actlr_set;
@@ -207,7 +207,7 @@ init_secondary(int cpu)
mtx_unlock_spin(&ap_boot_mtx);
-#ifndef ARM_INTRNG
+#ifndef INTRNG
/* Enable ipi */
#ifdef IPI_IRQ_START
start = IPI_IRQ_START;
@@ -243,7 +243,7 @@ init_secondary(int cpu)
/* NOTREACHED */
}
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static void
ipi_rendezvous(void *dummy __unused)
{
@@ -421,14 +421,14 @@ static void
release_aps(void *dummy __unused)
{
uint32_t loop_counter;
-#ifndef ARM_INTRNG
+#ifndef INTRNG
int start = 0, end = 0;
#endif
if (mp_ncpus == 1)
return;
-#ifdef ARM_INTRNG
+#ifdef INTRNG
intr_pic_ipi_setup(IPI_RENDEZVOUS, "rendezvous", ipi_rendezvous, NULL);
intr_pic_ipi_setup(IPI_AST, "ast", ipi_ast, NULL);
intr_pic_ipi_setup(IPI_STOP, "stop", ipi_stop, NULL);
@@ -501,7 +501,7 @@ ipi_all_but_self(u_int ipi)
other_cpus = all_cpus;
CPU_CLR(PCPU_GET(cpuid), &other_cpus);
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
-#ifdef ARM_INTRNG
+#ifdef INTRNG
intr_ipi_send(other_cpus, ipi);
#else
pic_ipi_send(other_cpus, ipi);
@@ -517,7 +517,7 @@ ipi_cpu(int cpu, u_int ipi)
CPU_SET(cpu, &cpus);
CTR3(KTR_SMP, "%s: cpu: %d, ipi: %x", __func__, cpu, ipi);
-#ifdef ARM_INTRNG
+#ifdef INTRNG
intr_ipi_send(cpus, ipi);
#else
pic_ipi_send(cpus, ipi);
@@ -529,7 +529,7 @@ ipi_selected(cpuset_t cpus, u_int ipi)
{
CTR2(KTR_SMP, "%s: ipi: %x", __func__, ipi);
-#ifdef ARM_INTRNG
+#ifdef INTRNG
intr_ipi_send(cpus, ipi);
#else
pic_ipi_send(cpus, ipi);
diff --git a/sys/arm/arm/nexus.c b/sys/arm/arm/nexus.c
index b718c1d..a84e0a8 100644
--- a/sys/arm/arm/nexus.c
+++ b/sys/arm/arm/nexus.c
@@ -86,14 +86,14 @@ static struct resource *nexus_alloc_resource(device_t, device_t, int, int *,
static int nexus_activate_resource(device_t, device_t, int, int,
struct resource *);
static bus_space_tag_t nexus_get_bus_tag(device_t, device_t);
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#ifdef SMP
static int nexus_bind_intr(device_t, device_t, struct resource *, int);
#endif
#endif
static int nexus_config_intr(device_t dev, int irq, enum intr_trigger trig,
enum intr_polarity pol);
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static int nexus_describe_intr(device_t dev, device_t child,
struct resource *irq, void *cookie, const char *descr);
#endif
@@ -126,7 +126,7 @@ static device_method_t nexus_methods[] = {
DEVMETHOD(bus_setup_intr, nexus_setup_intr),
DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
DEVMETHOD(bus_get_bus_tag, nexus_get_bus_tag),
-#ifdef ARM_INTRNG
+#ifdef INTRNG
DEVMETHOD(bus_describe_intr, nexus_describe_intr),
#ifdef SMP
DEVMETHOD(bus_bind_intr, nexus_bind_intr),
@@ -234,7 +234,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0)
+ if (rv == NULL)
return (NULL);
rman_set_rid(rv, *rid);
@@ -280,7 +280,7 @@ nexus_config_intr(device_t dev, int irq, enum intr_trigger trig,
{
int ret = ENODEV;
-#ifdef ARM_INTRNG
+#ifdef INTRNG
device_printf(dev, "bus_config_intr is obsolete and not supported!\n");
ret = EOPNOTSUPP;
#else
@@ -294,14 +294,14 @@ static int
nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags,
driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep)
{
-#ifndef ARM_INTRNG
+#ifndef INTRNG
int irq;
#endif
if ((rman_get_flags(res) & RF_SHAREABLE) == 0)
flags |= INTR_EXCL;
-#ifdef ARM_INTRNG
+#ifdef INTRNG
return(intr_setup_irq(child, res, filt, intr, arg, flags, cookiep));
#else
for (irq = rman_get_start(res); irq <= rman_get_end(res); irq++) {
@@ -317,14 +317,14 @@ static int
nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih)
{
-#ifdef ARM_INTRNG
+#ifdef INTRNG
return (intr_teardown_irq(child, r, ih));
#else
return (arm_remove_irqhandler(rman_get_start(r), ih));
#endif
}
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static int
nexus_describe_intr(device_t dev, device_t child, struct resource *irq,
void *cookie, const char *descr)
diff --git a/sys/arm/arm/pmap-v4.c b/sys/arm/arm/pmap-v4.c
index 529e9f1..2d9a941 100644
--- a/sys/arm/arm/pmap-v4.c
+++ b/sys/arm/arm/pmap-v4.c
@@ -265,7 +265,7 @@ void (*pmap_copy_page_offs_func)(vm_paddr_t a_phys,
int cnt);
void (*pmap_zero_page_func)(vm_paddr_t, int, int);
-struct msgbuf *msgbufp = 0;
+struct msgbuf *msgbufp = NULL;
/*
* Crashdump maps.
@@ -842,7 +842,7 @@ pmap_alloc_l2_bucket(pmap_t pm, vm_offset_t va)
ptep = uma_zalloc(l2zone, M_NOWAIT);
rw_wlock(&pvh_global_lock);
PMAP_LOCK(pm);
- if (l2b->l2b_kva != 0) {
+ if (l2b->l2b_kva != NULL) {
/* We lost the race. */
l2->l2_occupancy--;
uma_zfree(l2zone, ptep);
diff --git a/sys/arm/arm/pmap-v6.c b/sys/arm/arm/pmap-v6.c
index 609b291..9fb0b20 100644
--- a/sys/arm/arm/pmap-v6.c
+++ b/sys/arm/arm/pmap-v6.c
@@ -310,15 +310,15 @@ static pt2_entry_t *CMAP3;
static caddr_t CADDR3;
caddr_t _tmppt = 0;
-struct msgbuf *msgbufp = 0; /* XXX move it to machdep.c */
+struct msgbuf *msgbufp = NULL; /* XXX move it to machdep.c */
/*
* Crashdump maps.
*/
static caddr_t crashdumpmap;
-static pt2_entry_t *PMAP1 = 0, *PMAP2;
-static pt2_entry_t *PADDR1 = 0, *PADDR2;
+static pt2_entry_t *PMAP1 = NULL, *PMAP2;
+static pt2_entry_t *PADDR1 = NULL, *PADDR2;
#ifdef DDB
static pt2_entry_t *PMAP3;
static pt2_entry_t *PADDR3;
diff --git a/sys/arm/at91/at91_common.c b/sys/arm/at91/at91_common.c
index bc13196..37f94d7 100644
--- a/sys/arm/at91/at91_common.c
+++ b/sys/arm/at91/at91_common.c
@@ -53,7 +53,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int
fdt_aic_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
int *pol)
diff --git a/sys/arm/at91/at91_mci.c b/sys/arm/at91/at91_mci.c
index ba6040f..cf884b9 100644
--- a/sys/arm/at91/at91_mci.c
+++ b/sys/arm/at91/at91_mci.c
@@ -526,16 +526,16 @@ at91_mci_deactivate(device_t dev)
sc = device_get_softc(dev);
if (sc->intrhand)
bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
- sc->intrhand = 0;
+ sc->intrhand = NULL;
bus_generic_detach(sc->dev);
if (sc->mem_res)
bus_release_resource(dev, SYS_RES_MEMORY,
rman_get_rid(sc->mem_res), sc->mem_res);
- sc->mem_res = 0;
+ sc->mem_res = NULL;
if (sc->irq_res)
bus_release_resource(dev, SYS_RES_IRQ,
rman_get_rid(sc->irq_res), sc->irq_res);
- sc->irq_res = 0;
+ sc->irq_res = NULL;
return;
}
diff --git a/sys/arm/at91/at91_pio.c b/sys/arm/at91/at91_pio.c
index 0de46c5..0d9bd46 100644
--- a/sys/arm/at91/at91_pio.c
+++ b/sys/arm/at91/at91_pio.c
@@ -240,16 +240,16 @@ at91_pio_deactivate(device_t dev)
sc = device_get_softc(dev);
if (sc->intrhand)
bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
- sc->intrhand = 0;
+ sc->intrhand = NULL;
bus_generic_detach(sc->dev);
if (sc->mem_res)
bus_release_resource(dev, SYS_RES_MEMORY,
rman_get_rid(sc->mem_res), sc->mem_res);
- sc->mem_res = 0;
+ sc->mem_res = NULL;
if (sc->irq_res)
bus_release_resource(dev, SYS_RES_IRQ,
rman_get_rid(sc->irq_res), sc->irq_res);
- sc->irq_res = 0;
+ sc->irq_res = NULL;
}
static void
diff --git a/sys/arm/at91/at91_pmc.c b/sys/arm/at91/at91_pmc.c
index 16f62ec..e93e3b7 100644
--- a/sys/arm/at91/at91_pmc.c
+++ b/sys/arm/at91/at91_pmc.c
@@ -636,7 +636,7 @@ at91_pmc_deactivate(device_t dev)
if (sc->mem_res)
bus_release_resource(dev, SYS_RES_IOPORT,
rman_get_rid(sc->mem_res), sc->mem_res);
- sc->mem_res = 0;
+ sc->mem_res = NULL;
}
static int
diff --git a/sys/arm/at91/at91_rtc.c b/sys/arm/at91/at91_rtc.c
index 6ed044a..7bb80b9 100644
--- a/sys/arm/at91/at91_rtc.c
+++ b/sys/arm/at91/at91_rtc.c
@@ -232,18 +232,18 @@ at91_rtc_deactivate(device_t dev)
WR4(sc, RTC_IDR, 0xffffffff);
if (sc->intrhand)
bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
- sc->intrhand = 0;
+ sc->intrhand = NULL;
#endif
bus_generic_detach(sc->dev);
if (sc->mem_res)
bus_release_resource(dev, SYS_RES_MEMORY,
rman_get_rid(sc->mem_res), sc->mem_res);
- sc->mem_res = 0;
+ sc->mem_res = NULL;
#ifdef AT91_RTC_USE_INTERRUPTS
if (sc->irq_res)
bus_release_resource(dev, SYS_RES_IRQ,
rman_get_rid(sc->irq_res), sc->irq_res);
- sc->irq_res = 0;
+ sc->irq_res = NULL;
#endif
return;
}
diff --git a/sys/arm/at91/at91_ssc.c b/sys/arm/at91/at91_ssc.c
index 8a32f55..d79020b 100644
--- a/sys/arm/at91/at91_ssc.c
+++ b/sys/arm/at91/at91_ssc.c
@@ -193,16 +193,16 @@ at91_ssc_deactivate(device_t dev)
sc = device_get_softc(dev);
if (sc->intrhand)
bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
- sc->intrhand = 0;
+ sc->intrhand = NULL;
bus_generic_detach(sc->dev);
if (sc->mem_res)
bus_release_resource(dev, SYS_RES_IOPORT,
rman_get_rid(sc->mem_res), sc->mem_res);
- sc->mem_res = 0;
+ sc->mem_res = NULL;
if (sc->irq_res)
bus_release_resource(dev, SYS_RES_IRQ,
rman_get_rid(sc->irq_res), sc->irq_res);
- sc->irq_res = 0;
+ sc->irq_res = NULL;
return;
}
diff --git a/sys/arm/at91/at91_twi.c b/sys/arm/at91/at91_twi.c
index f9a7294..28676fc 100644
--- a/sys/arm/at91/at91_twi.c
+++ b/sys/arm/at91/at91_twi.c
@@ -216,16 +216,16 @@ at91_twi_deactivate(device_t dev)
sc = device_get_softc(dev);
if (sc->intrhand)
bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
- sc->intrhand = 0;
+ sc->intrhand = NULL;
bus_generic_detach(sc->dev);
if (sc->mem_res)
bus_release_resource(dev, SYS_RES_MEMORY,
rman_get_rid(sc->mem_res), sc->mem_res);
- sc->mem_res = 0;
+ sc->mem_res = NULL;
if (sc->irq_res)
bus_release_resource(dev, SYS_RES_IRQ,
rman_get_rid(sc->irq_res), sc->irq_res);
- sc->irq_res = 0;
+ sc->irq_res = NULL;
return;
}
diff --git a/sys/arm/at91/if_ate.c b/sys/arm/at91/if_ate.c
index ac200b4..082b24f 100644
--- a/sys/arm/at91/if_ate.c
+++ b/sys/arm/at91/if_ate.c
@@ -1184,7 +1184,7 @@ atestart_locked(struct ifnet *ifp)
}
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
- if (m == 0)
+ if (m == NULL)
break;
e = bus_dmamap_load_mbuf_sg(sc->mtag, sc->tx_map[sc->txhead], m,
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_common.c b/sys/arm/broadcom/bcm2835/bcm2835_common.c
index bcb84b7..e7ce52b 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_common.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_common.c
@@ -50,7 +50,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int
fdt_intc_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
int *pol)
@@ -78,4 +78,4 @@ fdt_pic_decode_t fdt_pic_table[] = {
&fdt_intc_decode_ic,
NULL
};
-#endif /* ARM_INTRNG */
+#endif /* INTRNG */
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_gpio.c b/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
index d448fc5..7c67a38 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
#include "gpio_if.h"
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#include "pic_if.h"
#endif
@@ -84,7 +84,7 @@ struct bcm_gpio_sysctl {
uint32_t pin;
};
-#ifdef ARM_INTRNG
+#ifdef INTRNG
struct bcm_gpio_irqsrc {
struct intr_irqsrc bgi_isrc;
uint32_t bgi_irq;
@@ -105,11 +105,11 @@ struct bcm_gpio_softc {
int sc_ro_npins;
int sc_ro_pins[BCM_GPIO_PINS];
struct gpio_pin sc_gpio_pins[BCM_GPIO_PINS];
-#ifndef ARM_INTRNG
+#ifndef INTRNG
struct intr_event * sc_events[BCM_GPIO_PINS];
#endif
struct bcm_gpio_sysctl sc_sysctl[BCM_GPIO_PINS];
-#ifdef ARM_INTRNG
+#ifdef INTRNG
struct bcm_gpio_irqsrc sc_isrcs[BCM_GPIO_PINS];
#else
enum intr_trigger sc_irq_trigger[BCM_GPIO_PINS];
@@ -153,7 +153,7 @@ enum bcm_gpio_pud {
static struct bcm_gpio_softc *bcm_gpio_sc = NULL;
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static int bcm_gpio_intr_bank0(void *arg);
static int bcm_gpio_intr_bank1(void *arg);
static int bcm_gpio_pic_attach(struct bcm_gpio_softc *sc);
@@ -691,7 +691,7 @@ bcm_gpio_get_reserved_pins(struct bcm_gpio_softc *sc)
return (0);
}
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int
bcm_gpio_intr(void *arg)
{
@@ -741,7 +741,7 @@ bcm_gpio_probe(device_t dev)
return (BUS_PROBE_DEFAULT);
}
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static int
bcm_gpio_intr_attach(device_t dev)
{
@@ -862,7 +862,7 @@ bcm_gpio_attach(device_t dev)
sc->sc_gpio_pins[i].gp_pin = j;
sc->sc_gpio_pins[i].gp_caps = BCM_GPIO_DEFAULT_CAPS;
sc->sc_gpio_pins[i].gp_flags = bcm_gpio_func_flag(func);
-#ifndef ARM_INTRNG
+#ifndef INTRNG
/* The default is active-low interrupts. */
sc->sc_irq_trigger[i] = INTR_TRIGGER_LEVEL;
sc->sc_irq_polarity[i] = INTR_POLARITY_LOW;
@@ -892,7 +892,7 @@ bcm_gpio_detach(device_t dev)
return (EBUSY);
}
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static inline void
bcm_gpio_isrc_eoi(struct bcm_gpio_softc *sc, struct bcm_gpio_irqsrc *bgi)
{
@@ -1372,7 +1372,7 @@ static device_method_t bcm_gpio_methods[] = {
DEVMETHOD(gpio_pin_set, bcm_gpio_pin_set),
DEVMETHOD(gpio_pin_toggle, bcm_gpio_pin_toggle),
-#ifdef ARM_INTRNG
+#ifdef INTRNG
/* Interrupt controller interface */
DEVMETHOD(pic_disable_intr, bcm_gpio_pic_disable_intr),
DEVMETHOD(pic_enable_intr, bcm_gpio_pic_enable_intr),
diff --git a/sys/arm/broadcom/bcm2835/bcm2835_intr.c b/sys/arm/broadcom/bcm2835/bcm2835_intr.c
index 936dc52..8124c96 100644
--- a/sys/arm/broadcom/bcm2835/bcm2835_intr.c
+++ b/sys/arm/broadcom/bcm2835/bcm2835_intr.c
@@ -52,7 +52,7 @@ __FBSDID("$FreeBSD$");
#include <arm/broadcom/bcm2835/bcm2836.h>
#endif
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#include "pic_if.h"
#endif
@@ -105,7 +105,7 @@ __FBSDID("$FreeBSD$");
#define BANK1_END (BANK1_START + 32 - 1)
#define BANK2_START (BANK1_START + 32)
#define BANK2_END (BANK2_START + 32 - 1)
-#ifndef ARM_INTRNG
+#ifndef INTRNG
#define BANK3_START (BANK2_START + 32)
#define BANK3_END (BANK3_START + 32 - 1)
#endif
@@ -113,7 +113,7 @@ __FBSDID("$FreeBSD$");
#define IS_IRQ_BASIC(n) (((n) >= 0) && ((n) < BANK1_START))
#define IS_IRQ_BANK1(n) (((n) >= BANK1_START) && ((n) <= BANK1_END))
#define IS_IRQ_BANK2(n) (((n) >= BANK2_START) && ((n) <= BANK2_END))
-#ifndef ARM_INTRNG
+#ifndef INTRNG
#define ID_IRQ_BCM2836(n) (((n) >= BANK3_START) && ((n) <= BANK3_END))
#endif
#define IRQ_BANK1(n) ((n) - BANK1_START)
@@ -125,7 +125,7 @@ __FBSDID("$FreeBSD$");
#define dprintf(fmt, args...)
#endif
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#define BCM_INTC_NIRQS 72 /* 8 + 32 + 32 */
struct bcm_intc_irqsrc {
@@ -142,7 +142,7 @@ struct bcm_intc_softc {
struct resource * intc_res;
bus_space_tag_t intc_bst;
bus_space_handle_t intc_bsh;
-#ifdef ARM_INTRNG
+#ifdef INTRNG
struct resource * intc_irq_res;
void * intc_irq_hdl;
struct bcm_intc_irqsrc intc_isrcs[BCM_INTC_NIRQS];
@@ -156,7 +156,7 @@ static struct bcm_intc_softc *bcm_intc_sc = NULL;
#define intc_write_4(_sc, reg, val) \
bus_space_write_4((_sc)->intc_bst, (_sc)->intc_bsh, (reg), (val))
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static inline void
bcm_intc_isrc_mask(struct bcm_intc_softc *sc, struct bcm_intc_irqsrc *bii)
{
@@ -360,7 +360,7 @@ bcm_intc_attach(device_t dev)
{
struct bcm_intc_softc *sc = device_get_softc(dev);
int rid = 0;
-#ifdef ARM_INTRNG
+#ifdef INTRNG
intptr_t xref;
#endif
sc->sc_dev = dev;
@@ -374,7 +374,7 @@ bcm_intc_attach(device_t dev)
return (ENXIO);
}
-#ifdef ARM_INTRNG
+#ifdef INTRNG
xref = OF_xref_from_node(ofw_bus_get_node(dev));
if (bcm_intc_pic_register(sc, xref) != 0) {
bus_release_resource(dev, SYS_RES_MEMORY, 0, sc->intc_res);
@@ -412,7 +412,7 @@ static device_method_t bcm_intc_methods[] = {
DEVMETHOD(device_probe, bcm_intc_probe),
DEVMETHOD(device_attach, bcm_intc_attach),
-#ifdef ARM_INTRNG
+#ifdef INTRNG
DEVMETHOD(pic_disable_intr, bcm_intc_disable_intr),
DEVMETHOD(pic_enable_intr, bcm_intc_enable_intr),
DEVMETHOD(pic_map_intr, bcm_intc_map_intr),
@@ -434,7 +434,7 @@ static devclass_t bcm_intc_devclass;
DRIVER_MODULE(intc, simplebus, bcm_intc_driver, bcm_intc_devclass, 0, 0);
-#ifndef ARM_INTRNG
+#ifndef INTRNG
int
arm_get_next_irq(int last_irq)
{
diff --git a/sys/arm/broadcom/bcm2835/bcm2836.c b/sys/arm/broadcom/bcm2835/bcm2836.c
index f9a2fcc..16c1e4b 100644
--- a/sys/arm/broadcom/bcm2835/bcm2836.c
+++ b/sys/arm/broadcom/bcm2835/bcm2836.c
@@ -53,7 +53,7 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/ofw/ofw_bus.h>
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#include "pic_if.h"
#else
#include <arm/broadcom/bcm2835/bcm2836.h>
@@ -72,7 +72,7 @@ __FBSDID("$FreeBSD$");
#define MAILBOX0_IRQEN (1 << 0)
#endif
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#define BCM_LINTC_CONTROL_REG 0x00
#define BCM_LINTC_PRESCALER_REG 0x08
#define BCM_LINTC_GPU_ROUTING_REG 0x0c
diff --git a/sys/arm/broadcom/bcm2835/bcm2836.h b/sys/arm/broadcom/bcm2835/bcm2836.h
index 14abfe2..6068975 100644
--- a/sys/arm/broadcom/bcm2835/bcm2836.h
+++ b/sys/arm/broadcom/bcm2835/bcm2836.h
@@ -30,7 +30,7 @@
#ifndef _BCM2815_BCM2836_H
#define _BCM2815_BCM2836_H
-#ifndef ARM_INTRNG
+#ifndef INTRNG
#define BCM2836_GPU_IRQ 8
int bcm2836_get_next_irq(int);
diff --git a/sys/arm/broadcom/bcm2835/bcm2836_mp.c b/sys/arm/broadcom/bcm2835/bcm2836_mp.c
index a361319..bbbc514 100644
--- a/sys/arm/broadcom/bcm2835/bcm2836_mp.c
+++ b/sys/arm/broadcom/bcm2835/bcm2836_mp.c
@@ -139,7 +139,7 @@ platform_mp_start_ap(void)
}
}
-#ifndef ARM_INTRNG
+#ifndef INTRNG
void
pic_ipi_send(cpuset_t cpus, u_int ipi)
{
diff --git a/sys/arm/cavium/cns11xx/if_ece.c b/sys/arm/cavium/cns11xx/if_ece.c
index 20bc07e..2ae3d22 100644
--- a/sys/arm/cavium/cns11xx/if_ece.c
+++ b/sys/arm/cavium/cns11xx/if_ece.c
@@ -1064,8 +1064,8 @@ clear_mac_entries(struct ece_softc *ec, int include_this_mac)
struct mac_list * current;
char mac[ETHER_ADDR_LEN];
- current = 0;
- mac_list_header = 0;
+ current = NULL;
+ mac_list_header = NULL;
table_end = read_mac_entry(ec, mac, 1);
while (!table_end) {
@@ -1608,7 +1608,7 @@ ece_encap(struct ece_softc *sc, struct mbuf *m0)
struct ifnet *ifp;
bus_dma_segment_t segs[MAX_FRAGMENT];
bus_dmamap_t mapp;
- eth_tx_desc_t *desc = 0;
+ eth_tx_desc_t *desc = NULL;
int csum_flags;
int desc_no;
int error;
diff --git a/sys/arm/conf/A20 b/sys/arm/conf/A20
index 8f56523..f28080c 100644
--- a/sys/arm/conf/A20
+++ b/sys/arm/conf/A20
@@ -23,7 +23,7 @@ ident A20
include "std.armv6"
include "../allwinner/a20/std.a20"
-options ARM_INTRNG
+options INTRNG
options SOC_ALLWINNER_A20
diff --git a/sys/arm/conf/ALPINE b/sys/arm/conf/ALPINE
index fa30865..55e4468d3 100644
--- a/sys/arm/conf/ALPINE
+++ b/sys/arm/conf/ALPINE
@@ -37,7 +37,7 @@ options DDB #Enable the kernel debugger
# Interrupt controller
device gic
-options ARM_INTRNG
+options INTRNG
# Pseudo devices
device loop
diff --git a/sys/arm/conf/ARMADA38X b/sys/arm/conf/ARMADA38X
index 13c3aa2..1903e62 100644
--- a/sys/arm/conf/ARMADA38X
+++ b/sys/arm/conf/ARMADA38X
@@ -62,7 +62,7 @@ device pci
# Interrupt controllers
device gic
-options ARM_INTRNG
+options INTRNG
# Timers
device mpcore_timer
diff --git a/sys/arm/conf/BEAGLEBONE b/sys/arm/conf/BEAGLEBONE
index 1885c0c..4497b0ff 100644
--- a/sys/arm/conf/BEAGLEBONE
+++ b/sys/arm/conf/BEAGLEBONE
@@ -28,7 +28,7 @@ include "../ti/am335x/std.am335x"
makeoptions MODULES_EXTRA="dtb/am335x am335x_dmtpps"
-options ARM_INTRNG
+options INTRNG
options HZ=100
options SCHED_4BSD # 4BSD scheduler
diff --git a/sys/arm/conf/EXYNOS5.common b/sys/arm/conf/EXYNOS5.common
index 770a690..c997916 100644
--- a/sys/arm/conf/EXYNOS5.common
+++ b/sys/arm/conf/EXYNOS5.common
@@ -87,7 +87,7 @@ device dwmmc
# Interrupt controller
device gic
-options ARM_INTRNG
+options INTRNG
# ARM Generic Timer
device generic_timer
diff --git a/sys/arm/conf/IMX6 b/sys/arm/conf/IMX6
index 6b383e2..bc1145f 100644
--- a/sys/arm/conf/IMX6
+++ b/sys/arm/conf/IMX6
@@ -22,7 +22,7 @@ ident IMX6
include "std.armv6"
include "../freescale/imx/std.imx6"
-options ARM_INTRNG
+options INTRNG
options SOC_IMX6
diff --git a/sys/arm/conf/ODROIDC1 b/sys/arm/conf/ODROIDC1
index 550da87..16802d3 100644
--- a/sys/arm/conf/ODROIDC1
+++ b/sys/arm/conf/ODROIDC1
@@ -26,7 +26,7 @@ options SMP # Enable multiple cores
# Interrupt controller
device gic
-options ARM_INTRNG
+options INTRNG
options FDT_DTB_STATIC
makeoptions FDT_DTS_FILE=odroidc1.dts
diff --git a/sys/arm/conf/PANDABOARD b/sys/arm/conf/PANDABOARD
index 4eaa471..69a8252 100644
--- a/sys/arm/conf/PANDABOARD
+++ b/sys/arm/conf/PANDABOARD
@@ -60,7 +60,7 @@ options DDB # Enable the kernel debugger
device fdt_pinctrl
# Interrupt controller
device gic
-options ARM_INTRNG
+options INTRNG
# ARM MPCore timer
device mpcore_timer
diff --git a/sys/arm/conf/RK3188 b/sys/arm/conf/RK3188
index ec6ddb8..e3e5ac8 100644
--- a/sys/arm/conf/RK3188
+++ b/sys/arm/conf/RK3188
@@ -47,7 +47,7 @@ options ROOTDEVNAME=\"ufs:/dev/mmcsd0\"
# Interrupt controller
device gic
-options ARM_INTRNG
+options INTRNG
# ARM MPCore timer
device mpcore_timer
diff --git a/sys/arm/conf/RPI-B b/sys/arm/conf/RPI-B
index 9bc2636..5f6bc27 100644
--- a/sys/arm/conf/RPI-B
+++ b/sys/arm/conf/RPI-B
@@ -24,7 +24,7 @@ include "std.armv6"
include "../broadcom/bcm2835/std.rpi"
include "../broadcom/bcm2835/std.bcm2835"
-options ARM_INTRNG
+options INTRNG
options HZ=100
options SCHED_4BSD # 4BSD scheduler
diff --git a/sys/arm/conf/RPI2 b/sys/arm/conf/RPI2
index 3cee50d..e669580 100644
--- a/sys/arm/conf/RPI2
+++ b/sys/arm/conf/RPI2
@@ -24,7 +24,7 @@ include "std.armv6"
include "../broadcom/bcm2835/std.rpi"
include "../broadcom/bcm2835/std.bcm2836"
-options ARM_INTRNG
+options INTRNG
options HZ=100
options SCHED_ULE # ULE scheduler
diff --git a/sys/arm/conf/SOCKIT.common b/sys/arm/conf/SOCKIT.common
index 3365929..3db9457 100644
--- a/sys/arm/conf/SOCKIT.common
+++ b/sys/arm/conf/SOCKIT.common
@@ -53,7 +53,7 @@ options INVARIANT_SUPPORT # Extra sanity checks of internal structures, require
# Interrupt controller
device gic
-options ARM_INTRNG
+options INTRNG
# ARM MPCore timer
device mpcore_timer
diff --git a/sys/arm/conf/VIRT b/sys/arm/conf/VIRT
index aabe636..374af87 100644
--- a/sys/arm/conf/VIRT
+++ b/sys/arm/conf/VIRT
@@ -47,7 +47,7 @@ options INVARIANT_SUPPORT # Extra sanity checks of internal structures, require
# Interrupt controller
device gic
-options ARM_INTRNG
+options INTRNG
# ARM Generic Timer
device generic_timer
diff --git a/sys/arm/conf/VSATV102 b/sys/arm/conf/VSATV102
index 96e3ba4..c08060a 100644
--- a/sys/arm/conf/VSATV102
+++ b/sys/arm/conf/VSATV102
@@ -26,7 +26,7 @@ options SMP # Enable multiple cores
# Interrupt controller
device gic
-options ARM_INTRNG
+options INTRNG
options FDT_DTB_STATIC
makeoptions FDT_DTS_FILE=vsatv102-m6.dts
diff --git a/sys/arm/conf/VYBRID b/sys/arm/conf/VYBRID
index 471b8d5..3e15e42 100644
--- a/sys/arm/conf/VYBRID
+++ b/sys/arm/conf/VYBRID
@@ -62,7 +62,7 @@ options NO_SWAPPING
# Interrupt controller
device gic
-options ARM_INTRNG
+options INTRNG
# ARM MPCore timer
device mpcore_timer
diff --git a/sys/arm/conf/ZEDBOARD b/sys/arm/conf/ZEDBOARD
index 41ec23a..1c024cc 100644
--- a/sys/arm/conf/ZEDBOARD
+++ b/sys/arm/conf/ZEDBOARD
@@ -52,7 +52,7 @@ options ROOTDEVNAME=\"ufs:mmcsd0s2a\"
# Interrupt controller
device gic
-options ARM_INTRNG
+options INTRNG
# Cache controller
device pl310 # PL310 L2 cache controller
diff --git a/sys/arm/freescale/imx/imx6_machdep.c b/sys/arm/freescale/imx/imx6_machdep.c
index 061355d..d5417c2 100644
--- a/sys/arm/freescale/imx/imx6_machdep.c
+++ b/sys/arm/freescale/imx/imx6_machdep.c
@@ -58,7 +58,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
static uint32_t gpio1_node;
-#ifndef ARM_INTRNG
+#ifndef INTRNG
/*
* Work around the linux workaround for imx6 erratum 006687, in which some
* ethernet interrupts don't go to the GPC and thus won't wake the system from
diff --git a/sys/arm/freescale/imx/imx_common.c b/sys/arm/freescale/imx/imx_common.c
index 50922e6..c423873 100644
--- a/sys/arm/freescale/imx/imx_common.c
+++ b/sys/arm/freescale/imx/imx_common.c
@@ -54,7 +54,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int
fdt_intc_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
int *pol)
@@ -71,4 +71,4 @@ fdt_pic_decode_t fdt_pic_table[] = {
&fdt_intc_decode_ic,
NULL
};
-#endif /* ARM_INTRNG */
+#endif /* INTRNG */
diff --git a/sys/arm/freescale/imx/imx_gpio.c b/sys/arm/freescale/imx/imx_gpio.c
index df0f2ad..ba82f5c 100644
--- a/sys/arm/freescale/imx/imx_gpio.c
+++ b/sys/arm/freescale/imx/imx_gpio.c
@@ -60,7 +60,7 @@ __FBSDID("$FreeBSD$");
#include "gpio_if.h"
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#include "pic_if.h"
#endif
@@ -91,7 +91,7 @@ __FBSDID("$FreeBSD$");
#define DEFAULT_CAPS (GPIO_PIN_INPUT | GPIO_PIN_OUTPUT)
#define NGPIO 32
-#ifdef ARM_INTRNG
+#ifdef INTRNG
struct gpio_irqsrc {
struct intr_irqsrc gi_isrc;
u_int gi_irq;
@@ -110,7 +110,7 @@ struct imx51_gpio_softc {
bus_space_handle_t sc_ioh;
int gpio_npins;
struct gpio_pin gpio_pins[NGPIO];
-#ifdef ARM_INTRNG
+#ifdef INTRNG
struct gpio_irqsrc gpio_pic_irqsrc[NGPIO];
#endif
};
@@ -155,7 +155,7 @@ static int imx51_gpio_pin_set(device_t, uint32_t, unsigned int);
static int imx51_gpio_pin_get(device_t, uint32_t, unsigned int *);
static int imx51_gpio_pin_toggle(device_t, uint32_t pin);
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static int
gpio_pic_map_fdt(device_t dev, u_int ncells, pcell_t *cells, u_int *irqp,
enum intr_polarity *polp, enum intr_trigger *trigp)
@@ -653,7 +653,7 @@ imx51_gpio_attach(device_t dev)
*/
WRITE4(sc, IMX_GPIO_IMR_REG, 0);
for (irq = 0; irq < 2; irq++) {
-#ifdef ARM_INTRNG
+#ifdef INTRNG
if ((bus_setup_intr(dev, sc->sc_res[1 + irq], INTR_TYPE_CLK,
gpio_pic_filter, NULL, sc, &sc->gpio_ih[irq]))) {
device_printf(dev,
@@ -675,7 +675,7 @@ imx51_gpio_attach(device_t dev)
"imx_gpio%d.%d", unit, i);
}
-#ifdef ARM_INTRNG
+#ifdef INTRNG
gpio_pic_register_isrcs(sc);
intr_pic_register(dev, OF_xref_from_node(ofw_bus_get_node(dev)));
#endif
@@ -713,7 +713,7 @@ static device_method_t imx51_gpio_methods[] = {
DEVMETHOD(device_attach, imx51_gpio_attach),
DEVMETHOD(device_detach, imx51_gpio_detach),
-#ifdef ARM_INTRNG
+#ifdef INTRNG
/* Interrupt controller interface */
DEVMETHOD(pic_disable_intr, gpio_pic_disable_intr),
DEVMETHOD(pic_enable_intr, gpio_pic_enable_intr),
diff --git a/sys/arm/freescale/vybrid/vf_common.c b/sys/arm/freescale/vybrid/vf_common.c
index 913902a..494f5d6 100644
--- a/sys/arm/freescale/vybrid/vf_common.c
+++ b/sys/arm/freescale/vybrid/vf_common.c
@@ -66,7 +66,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int
fdt_pic_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
int *pol)
diff --git a/sys/arm/include/intr.h b/sys/arm/include/intr.h
index e81bc7d..7a91525 100644
--- a/sys/arm/include/intr.h
+++ b/sys/arm/include/intr.h
@@ -43,7 +43,7 @@
#include <dev/ofw/openfirm.h>
#endif
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#ifndef NIRQ
#define NIRQ 1024 /* XXX - It should be an option. */
@@ -63,7 +63,7 @@ void intr_ipi_setup(u_int, const char *, intr_ipi_handler_t *, void *,
int intr_pic_ipi_setup(u_int, const char *, intr_ipi_handler_t *, void *);
#endif
-#else /* ARM_INTRNG */
+#else /* INTRNG */
/* XXX move to std.* files? */
#ifdef CPU_XSCALE_81342
@@ -111,7 +111,7 @@ int gic_decode_fdt(phandle_t, pcell_t *, int *, int *, int *);
int intr_fdt_map_irq(phandle_t, pcell_t *, int);
#endif
-#endif /* ARM_INTRNG */
+#endif /* INTRNG */
void arm_irq_memory_barrier(uintptr_t);
diff --git a/sys/arm/include/smp.h b/sys/arm/include/smp.h
index e685cc3..704fffa 100644
--- a/sys/arm/include/smp.h
+++ b/sys/arm/include/smp.h
@@ -6,7 +6,7 @@
#include <sys/_cpuset.h>
#include <machine/pcb.h>
-#ifdef ARM_INTRNG
+#ifdef INTRNG
enum {
IPI_AST,
IPI_PREEMPT,
@@ -37,7 +37,7 @@ void ipi_cpu(int cpu, u_int ipi);
void ipi_selected(cpuset_t cpus, u_int ipi);
/* PIC interface */
-#ifndef ARM_INTRNG
+#ifndef INTRNG
void pic_ipi_send(cpuset_t cpus, u_int ipi);
void pic_ipi_clear(int ipi);
int pic_ipi_read(int arg);
diff --git a/sys/arm/lpc/lpc_intc.c b/sys/arm/lpc/lpc_intc.c
index d4b2517..db7c300 100644
--- a/sys/arm/lpc/lpc_intc.c
+++ b/sys/arm/lpc/lpc_intc.c
@@ -231,7 +231,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int
fdt_pic_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
int *pol)
diff --git a/sys/arm/mv/mpic.c b/sys/arm/mv/mpic.c
index 4f246a4..4c5856a 100644
--- a/sys/arm/mv/mpic.c
+++ b/sys/arm/mv/mpic.c
@@ -60,7 +60,7 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus_subr.h>
#include <dev/fdt/fdt_common.h>
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#include "pic_if.h"
#endif
@@ -98,7 +98,7 @@ __FBSDID("$FreeBSD$");
#define MPIC_PPI 32
-#ifdef ARM_INTRNG
+#ifdef INTRNG
struct mv_mpic_irqsrc {
struct intr_irqsrc mmi_isrc;
u_int mmi_irq;
@@ -115,7 +115,7 @@ struct mv_mpic_softc {
bus_space_tag_t drbl_bst;
bus_space_handle_t drbl_bsh;
struct mtx mtx;
-#ifdef ARM_INTRNG
+#ifdef INTRNG
struct mv_mpic_irqsrc * mpic_isrcs;
#endif
int nirqs;
@@ -151,7 +151,7 @@ static void mpic_mask_irq_err(uintptr_t nb);
static void mpic_unmask_irq_err(uintptr_t nb);
static int mpic_intr(void *arg);
static void mpic_unmask_msi(void);
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static void arm_mask_irq_err(uintptr_t);
static void arm_unmask_irq_err(uintptr_t);
#endif
@@ -185,7 +185,7 @@ mv_mpic_probe(device_t dev)
return (0);
}
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static int
mv_mpic_register_isrcs(struct mv_mpic_softc *sc)
{
@@ -241,7 +241,7 @@ mv_mpic_attach(device_t dev)
device_printf(dev, "could not allocate resources\n");
return (ENXIO);
}
-#ifdef ARM_INTRNG
+#ifdef INTRNG
if (sc->mpic_res[3] == NULL)
device_printf(dev, "No interrupt to use.\n");
else
@@ -268,7 +268,7 @@ mv_mpic_attach(device_t dev)
val = MPIC_READ(mv_mpic_sc, MPIC_CTRL);
sc->nirqs = MPIC_CTRL_NIRQS(val);
-#ifdef ARM_INTRNG
+#ifdef INTRNG
if (mv_mpic_register_isrcs(sc) != 0) {
device_printf(dev, "could not register PIC ISRCs\n");
bus_release_resources(dev, mv_mpic_spec, sc->mpic_res);
@@ -286,7 +286,7 @@ mv_mpic_attach(device_t dev)
return (0);
}
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static int
mpic_intr(void *arg)
{
@@ -370,7 +370,7 @@ static device_method_t mv_mpic_methods[] = {
DEVMETHOD(device_probe, mv_mpic_probe),
DEVMETHOD(device_attach, mv_mpic_attach),
-#ifdef ARM_INTRNG
+#ifdef INTRNG
DEVMETHOD(pic_disable_intr, mpic_disable_intr),
DEVMETHOD(pic_enable_intr, mpic_enable_intr),
DEVMETHOD(pic_map_intr, mpic_map_intr),
@@ -391,7 +391,7 @@ static devclass_t mv_mpic_devclass;
EARLY_DRIVER_MODULE(mpic, simplebus, mv_mpic_driver, mv_mpic_devclass, 0, 0,
BUS_PASS_INTERRUPT);
-#ifndef ARM_INTRNG
+#ifndef INTRNG
int
arm_get_next_irq(int last)
{
diff --git a/sys/arm/mv/mv_common.c b/sys/arm/mv/mv_common.c
index a1d2a2d..5a19993 100644
--- a/sys/arm/mv/mv_common.c
+++ b/sys/arm/mv/mv_common.c
@@ -2282,7 +2282,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int
fdt_pic_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
int *pol)
diff --git a/sys/arm/nvidia/tegra124/std.tegra124 b/sys/arm/nvidia/tegra124/std.tegra124
index 127b001..35de225 100644
--- a/sys/arm/nvidia/tegra124/std.tegra124
+++ b/sys/arm/nvidia/tegra124/std.tegra124
@@ -6,7 +6,7 @@ makeoptions CONF_CFLAGS="-march=armv7a"
options KERNVIRTADDR = 0xc0200000
makeoptions KERNVIRTADDR = 0xc0200000
-options ARM_INTRNG
+options INTRNG
options IPI_IRQ_START=0
options IPI_IRQ_END=15
diff --git a/sys/arm/qemu/virt_common.c b/sys/arm/qemu/virt_common.c
index 572fee8..03cba30 100644
--- a/sys/arm/qemu/virt_common.c
+++ b/sys/arm/qemu/virt_common.c
@@ -41,7 +41,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifndef ARM_INTRNG
+#ifndef INTRNG
fdt_pic_decode_t fdt_pic_table[] = {
&gic_decode_fdt,
NULL
diff --git a/sys/arm/rockchip/rk30xx_common.c b/sys/arm/rockchip/rk30xx_common.c
index 723c429..aa66b72 100644
--- a/sys/arm/rockchip/rk30xx_common.c
+++ b/sys/arm/rockchip/rk30xx_common.c
@@ -42,7 +42,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int
fdt_aintc_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
int *pol)
diff --git a/sys/arm/samsung/exynos/exynos5_common.c b/sys/arm/samsung/exynos/exynos5_common.c
index 8818f04..b91e083 100644
--- a/sys/arm/samsung/exynos/exynos5_common.c
+++ b/sys/arm/samsung/exynos/exynos5_common.c
@@ -53,7 +53,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int
fdt_pic_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
int *pol)
diff --git a/sys/arm/ti/aintc.c b/sys/arm/ti/aintc.c
index 8a544d0..ebe4864 100644
--- a/sys/arm/ti/aintc.c
+++ b/sys/arm/ti/aintc.c
@@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$");
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#include "pic_if.h"
#endif
@@ -68,7 +68,7 @@ __FBSDID("$FreeBSD$");
#define INTC_NIRQS 128
-#ifdef ARM_INTRNG
+#ifdef INTRNG
struct ti_aintc_irqsrc {
struct intr_irqsrc tai_isrc;
u_int tai_irq;
@@ -81,7 +81,7 @@ struct ti_aintc_softc {
bus_space_tag_t aintc_bst;
bus_space_handle_t aintc_bsh;
uint8_t ver;
-#ifdef ARM_INTRNG
+#ifdef INTRNG
struct ti_aintc_irqsrc aintc_isrcs[INTC_NIRQS];
#endif
};
@@ -105,7 +105,7 @@ static struct ofw_compat_data compat_data[] = {
{NULL, 0},
};
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static inline void
ti_aintc_irq_eoi(struct ti_aintc_softc *sc)
{
@@ -295,7 +295,7 @@ ti_aintc_attach(device_t dev)
/*Set Priority Threshold */
aintc_write_4(sc, INTC_THRESHOLD, 0xFF);
-#ifndef ARM_INTRNG
+#ifndef INTRNG
arm_post_filter = aintc_post_filter;
#else
if (ti_aintc_pic_attach(sc) != 0) {
@@ -310,7 +310,7 @@ static device_method_t ti_aintc_methods[] = {
DEVMETHOD(device_probe, ti_aintc_probe),
DEVMETHOD(device_attach, ti_aintc_attach),
-#ifdef ARM_INTRNG
+#ifdef INTRNG
DEVMETHOD(pic_disable_intr, ti_aintc_disable_intr),
DEVMETHOD(pic_enable_intr, ti_aintc_enable_intr),
DEVMETHOD(pic_map_intr, ti_aintc_map_intr),
@@ -334,7 +334,7 @@ EARLY_DRIVER_MODULE(aintc, simplebus, ti_aintc_driver, ti_aintc_devclass,
0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
SIMPLEBUS_PNP_INFO(compat_data);
-#ifndef ARM_INTRNG
+#ifndef INTRNG
int
arm_get_next_irq(int last_irq)
{
diff --git a/sys/arm/ti/omap4/omap4_prcm_clks.c b/sys/arm/ti/omap4/omap4_prcm_clks.c
index fc5fb97..e83e6ee 100644
--- a/sys/arm/ti/omap4/omap4_prcm_clks.c
+++ b/sys/arm/ti/omap4/omap4_prcm_clks.c
@@ -366,9 +366,9 @@ static struct omap4_clk_details g_omap4_clk_details[] = {
OMAP4_GENERIC_CLOCK_DETAILS(UART2_CLK, FREQ_48MHZ, CM2_INSTANCE,
(L4PER_CM2_OFFSET + 0x0148), CLKCTRL_MODULEMODE_ENABLE),
OMAP4_GENERIC_CLOCK_DETAILS(UART3_CLK, FREQ_48MHZ, CM2_INSTANCE,
- (L4PER_CM2_OFFSET + 0x0140), CLKCTRL_MODULEMODE_ENABLE),
+ (L4PER_CM2_OFFSET + 0x0150), CLKCTRL_MODULEMODE_ENABLE),
OMAP4_GENERIC_CLOCK_DETAILS(UART4_CLK, FREQ_48MHZ, CM2_INSTANCE,
- (L4PER_CM2_OFFSET + 0x0148), CLKCTRL_MODULEMODE_ENABLE),
+ (L4PER_CM2_OFFSET + 0x0158), CLKCTRL_MODULEMODE_ENABLE),
/* General purpose timers */
OMAP4_GENERIC_CLOCK_DETAILS(TIMER1_CLK, -1, PRM_INSTANCE,
diff --git a/sys/arm/ti/ti_common.c b/sys/arm/ti/ti_common.c
index aaf9a6a..41c5a72 100644
--- a/sys/arm/ti/ti_common.c
+++ b/sys/arm/ti/ti_common.c
@@ -53,7 +53,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifndef ARM_INTRNG
+#ifndef INTRNG
#ifdef SOC_TI_AM335X
static int
fdt_aintc_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
@@ -81,4 +81,4 @@ fdt_pic_decode_t fdt_pic_table[] = {
#endif
NULL
};
-#endif /* !ARM_INTRNG */
+#endif /* !INTRNG */
diff --git a/sys/arm/ti/ti_gpio.c b/sys/arm/ti/ti_gpio.c
index 633fbf0..54e5042 100644
--- a/sys/arm/ti/ti_gpio.c
+++ b/sys/arm/ti/ti_gpio.c
@@ -66,7 +66,7 @@ __FBSDID("$FreeBSD$");
#include "gpio_if.h"
#include "ti_gpio_if.h"
-#ifdef ARM_INTRNG
+#ifdef INTRNG
#include "pic_if.h"
#endif
@@ -121,7 +121,7 @@ __FBSDID("$FreeBSD$");
static int ti_gpio_intr(void *arg);
static int ti_gpio_detach(device_t);
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static int ti_gpio_pic_attach(struct ti_gpio_softc *sc);
static int ti_gpio_pic_detach(struct ti_gpio_softc *sc);
#endif
@@ -546,7 +546,7 @@ ti_gpio_pin_toggle(device_t dev, uint32_t pin)
return (0);
}
-#ifndef ARM_INTRNG
+#ifndef INTRNG
/**
* ti_gpio_intr - ISR for all GPIO modules
* @arg: the soft context pointer
@@ -655,7 +655,7 @@ static int
ti_gpio_attach(device_t dev)
{
struct ti_gpio_softc *sc;
-#ifndef ARM_INTRNG
+#ifndef INTRNG
unsigned int i;
#endif
int err;
@@ -696,7 +696,7 @@ ti_gpio_attach(device_t dev)
return (ENXIO);
}
-#ifdef ARM_INTRNG
+#ifdef INTRNG
if (ti_gpio_pic_attach(sc) != 0) {
device_printf(dev, "WARNING: unable to attach PIC\n");
ti_gpio_detach(dev);
@@ -771,7 +771,7 @@ ti_gpio_detach(device_t dev)
if (sc->sc_mem_res != NULL)
ti_gpio_intr_clr(sc, 0xffffffff);
gpiobus_detach_bus(dev);
-#ifdef ARM_INTRNG
+#ifdef INTRNG
if (sc->sc_isrcs != NULL)
ti_gpio_pic_detach(sc);
#else
@@ -798,7 +798,7 @@ ti_gpio_detach(device_t dev)
return (0);
}
-#ifdef ARM_INTRNG
+#ifdef INTRNG
static inline void
ti_gpio_rwreg_set(struct ti_gpio_softc *sc, uint32_t reg, uint32_t mask)
{
@@ -1300,7 +1300,7 @@ static device_method_t ti_gpio_methods[] = {
DEVMETHOD(gpio_pin_set, ti_gpio_pin_set),
DEVMETHOD(gpio_pin_toggle, ti_gpio_pin_toggle),
-#ifdef ARM_INTRNG
+#ifdef INTRNG
/* Interrupt controller interface */
DEVMETHOD(pic_disable_intr, ti_gpio_pic_disable_intr),
DEVMETHOD(pic_enable_intr, ti_gpio_pic_enable_intr),
diff --git a/sys/arm/ti/ti_gpio.h b/sys/arm/ti/ti_gpio.h
index f16728b..174dd62 100644
--- a/sys/arm/ti/ti_gpio.h
+++ b/sys/arm/ti/ti_gpio.h
@@ -39,7 +39,7 @@
*/
#define MAX_GPIO_INTRS 8
-#ifndef ARM_INTRNG
+#ifndef INTRNG
struct ti_gpio_mask_arg {
void *softc;
int pin;
@@ -61,7 +61,7 @@ struct ti_gpio_irqsrc {
struct ti_gpio_softc {
device_t sc_dev;
device_t sc_busdev;
-#ifndef ARM_INTRNG
+#ifndef INTRNG
/* Interrupt trigger type and level. */
enum intr_trigger *sc_irq_trigger;
enum intr_polarity *sc_irq_polarity;
@@ -74,7 +74,7 @@ struct ti_gpio_softc {
struct resource *sc_mem_res;
int sc_irq_rid;
struct resource *sc_irq_res;
-#ifndef ARM_INTRNG
+#ifndef INTRNG
/* Interrupt events. */
struct intr_event **sc_events;
struct ti_gpio_mask_arg *sc_mask_args;
diff --git a/sys/arm/versatile/versatile_common.c b/sys/arm/versatile/versatile_common.c
index c47c298..aca54b7 100644
--- a/sys/arm/versatile/versatile_common.c
+++ b/sys/arm/versatile/versatile_common.c
@@ -50,7 +50,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int
fdt_intc_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
int *pol)
diff --git a/sys/arm/xilinx/zy7_machdep.c b/sys/arm/xilinx/zy7_machdep.c
index 4b43683..dd179b7 100644
--- a/sys/arm/xilinx/zy7_machdep.c
+++ b/sys/arm/xilinx/zy7_machdep.c
@@ -98,7 +98,7 @@ struct fdt_fixup_entry fdt_fixup_table[] = {
{ NULL, NULL }
};
-#ifndef ARM_INTRNG
+#ifndef INTRNG
static int
fdt_gic_decode_ic(phandle_t node, pcell_t *intr, int *interrupt, int *trig,
int *pol)
diff --git a/sys/arm/xscale/ixp425/ixp425_qmgr.c b/sys/arm/xscale/ixp425/ixp425_qmgr.c
index cb6c8de..822623c 100644
--- a/sys/arm/xscale/ixp425/ixp425_qmgr.c
+++ b/sys/arm/xscale/ixp425/ixp425_qmgr.c
@@ -355,7 +355,7 @@ ixpqmgr_qconfig(int qId, int qEntries, int ne, int nf, int srcSel,
if (cb == NULL) {
/* Reset to dummy callback */
qi->cb = dummyCallback;
- qi->cbarg = 0;
+ qi->cbarg = NULL;
} else {
qi->cb = cb;
qi->cbarg = cbarg;
diff --git a/sys/arm64/arm64/gic_fdt.c b/sys/arm64/arm64/gic_fdt.c
index 34d8009..f92cd83 100644
--- a/sys/arm64/arm64/gic_fdt.c
+++ b/sys/arm64/arm64/gic_fdt.c
@@ -198,7 +198,7 @@ arm_gic_fdt_attach(device_t dev)
static struct resource *
arm_gic_fdt_alloc_resource(device_t bus, device_t child, int type, int *rid,
- u_long start, u_long end, u_long count, u_int flags)
+ rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
{
struct arm_gic_fdt_softc *sc = device_get_softc(bus);
struct gic_devinfo *di;
diff --git a/sys/arm64/arm64/gic_v3_its.c b/sys/arm64/arm64/gic_v3_its.c
index aef6346..c830c99 100644
--- a/sys/arm64/arm64/gic_v3_its.c
+++ b/sys/arm64/arm64/gic_v3_its.c
@@ -565,7 +565,7 @@ its_init_cpu(struct gic_v3_its_softc *sc)
* this function was called during GICv3 secondary initialization.
*/
if (sc == NULL) {
- if (device_is_attached(its_sc->dev)) {
+ if (its_sc != NULL && device_is_attached(its_sc->dev)) {
/*
* XXX ARM64TODO: This is part of the workaround that
* saves ITS software context for further use in
diff --git a/sys/arm64/arm64/nexus.c b/sys/arm64/arm64/nexus.c
index f48a7aa..ec71409 100644
--- a/sys/arm64/arm64/nexus.c
+++ b/sys/arm64/arm64/nexus.c
@@ -250,7 +250,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0)
+ if (rv == NULL)
return (NULL);
rman_set_rid(rv, *rid);
diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index f8a7fdd..2cf3c33 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -221,6 +221,8 @@ struct msgbuf *msgbufp = NULL;
static struct rwlock_padalign pvh_global_lock;
vm_paddr_t dmap_phys_base; /* The start of the dmap region */
+vm_paddr_t dmap_phys_max; /* The limit of the dmap region */
+vm_offset_t dmap_max_addr; /* The virtual address limit of the dmap */
/* This code assumes all L1 DMAP entries will be used */
CTASSERT((DMAP_MIN_ADDRESS & ~L0_OFFSET) == DMAP_MIN_ADDRESS);
@@ -550,15 +552,15 @@ pmap_early_vtophys(vm_offset_t l1pt, vm_offset_t va)
}
static void
-pmap_bootstrap_dmap(vm_offset_t kern_l1, vm_paddr_t kernstart)
+pmap_bootstrap_dmap(vm_offset_t kern_l1, vm_paddr_t min_pa, vm_paddr_t max_pa)
{
vm_offset_t va;
vm_paddr_t pa;
u_int l1_slot;
- pa = dmap_phys_base = kernstart & ~L1_OFFSET;
+ pa = dmap_phys_base = min_pa & ~L1_OFFSET;
va = DMAP_MIN_ADDRESS;
- for (; va < DMAP_MAX_ADDRESS;
+ for (; va < DMAP_MAX_ADDRESS && pa < max_pa;
pa += L1_SIZE, va += L1_SIZE, l1_slot++) {
l1_slot = ((va - DMAP_MIN_ADDRESS) >> L1_SHIFT);
@@ -567,6 +569,10 @@ pmap_bootstrap_dmap(vm_offset_t kern_l1, vm_paddr_t kernstart)
ATTR_IDX(CACHED_MEMORY) | L1_BLOCK);
}
+ /* Set the upper limit of the DMAP region */
+ dmap_phys_max = pa;
+ dmap_max_addr = va;
+
cpu_dcache_wb_range((vm_offset_t)pagetable_dmap,
PAGE_SIZE * DMAP_TABLES);
cpu_tlb_flushID();
@@ -651,7 +657,7 @@ pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_paddr_t kernstart,
pt_entry_t *l2;
vm_offset_t va, freemempos;
vm_offset_t dpcpu, msgbufpv;
- vm_paddr_t pa, min_pa;
+ vm_paddr_t pa, max_pa, min_pa;
int i;
kern_delta = KERNBASE - kernstart;
@@ -671,7 +677,7 @@ pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_paddr_t kernstart,
rw_init(&pvh_global_lock, "pmap pv global");
/* Assume the address we were loaded to is a valid physical address */
- min_pa = KERNBASE - kern_delta;
+ min_pa = max_pa = KERNBASE - kern_delta;
/*
* Find the minimum physical address. physmap is sorted,
@@ -682,11 +688,12 @@ pmap_bootstrap(vm_offset_t l0pt, vm_offset_t l1pt, vm_paddr_t kernstart,
continue;
if (physmap[i] <= min_pa)
min_pa = physmap[i];
- break;
+ if (physmap[i + 1] > max_pa)
+ max_pa = physmap[i + 1];
}
/* Create a direct map region early so we can use it for pa -> va */
- pmap_bootstrap_dmap(l1pt, min_pa);
+ pmap_bootstrap_dmap(l1pt, min_pa, max_pa);
va = KERNBASE;
pa = KERNBASE - kern_delta;
diff --git a/sys/arm64/include/vmparam.h b/sys/arm64/include/vmparam.h
index 8dc8809..3d46ece 100644
--- a/sys/arm64/include/vmparam.h
+++ b/sys/arm64/include/vmparam.h
@@ -162,19 +162,19 @@
#define VM_MIN_KERNEL_ADDRESS (0xffff000000000000UL)
#define VM_MAX_KERNEL_ADDRESS (0xffff008000000000UL)
-/* 2TiB for the direct map region */
+/* 2 TiB maximum for the direct map region */
#define DMAP_MIN_ADDRESS (0xfffffd0000000000UL)
#define DMAP_MAX_ADDRESS (0xffffff0000000000UL)
#define DMAP_MIN_PHYSADDR (dmap_phys_base)
-#define DMAP_MAX_PHYSADDR (dmap_phys_base + (DMAP_MAX_ADDRESS - DMAP_MIN_ADDRESS))
+#define DMAP_MAX_PHYSADDR (dmap_phys_max)
/* True if pa is in the dmap range */
#define PHYS_IN_DMAP(pa) ((pa) >= DMAP_MIN_PHYSADDR && \
(pa) < DMAP_MAX_PHYSADDR)
/* True if va is in the dmap range */
#define VIRT_IN_DMAP(va) ((va) >= DMAP_MIN_ADDRESS && \
- (va) < DMAP_MAX_ADDRESS)
+ (va) < (dmap_max_addr))
#define PHYS_TO_DMAP(pa) \
({ \
@@ -237,6 +237,8 @@
#ifndef LOCORE
extern vm_paddr_t dmap_phys_base;
+extern vm_paddr_t dmap_phys_max;
+extern vm_offset_t dmap_max_addr;
extern u_int tsb_kernel_ldd_phys;
extern vm_offset_t vm_max_kernel_address;
extern vm_offset_t init_pt_va;
diff --git a/sys/boot/efi/loader/arch/amd64/elf64_freebsd.c b/sys/boot/efi/loader/arch/amd64/elf64_freebsd.c
index 1b95cde..a1096d9 100644
--- a/sys/boot/efi/loader/arch/amd64/elf64_freebsd.c
+++ b/sys/boot/efi/loader/arch/amd64/elf64_freebsd.c
@@ -101,6 +101,17 @@ elf64_exec(struct preloaded_file *fp)
char buf[24];
int revision;
+ /*
+ * Report the RSDP to the kernel. While this can be found with
+ * a BIOS boot, the RSDP may be elsewhere when booted from UEFI.
+ * The old code used the 'hints' method to communite this to
+ * the kernel. However, while convenient, the 'hints' method
+ * is fragile and does not work when static hints are compiled
+ * into the kernel. Instead, move to setting different tunables
+ * that start with acpi. The old 'hints' can be removed before
+ * we branch for FreeBSD 12.
+ */
+
rsdp = efi_get_table(&acpi20_guid);
if (rsdp == NULL) {
rsdp = efi_get_table(&acpi_guid);
@@ -108,23 +119,29 @@ elf64_exec(struct preloaded_file *fp)
if (rsdp != NULL) {
sprintf(buf, "0x%016llx", (unsigned long long)rsdp);
setenv("hint.acpi.0.rsdp", buf, 1);
+ setenv("acpi.rsdp", buf, 1);
revision = rsdp->Revision;
if (revision == 0)
revision = 1;
sprintf(buf, "%d", revision);
setenv("hint.acpi.0.revision", buf, 1);
+ setenv("acpi.revision", buf, 1);
strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId));
buf[sizeof(rsdp->OemId)] = '\0';
setenv("hint.acpi.0.oem", buf, 1);
+ setenv("acpi.oem", buf, 1);
sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress);
setenv("hint.acpi.0.rsdt", buf, 1);
+ setenv("acpi.rsdt", buf, 1);
if (revision >= 2) {
/* XXX extended checksum? */
sprintf(buf, "0x%016llx",
(unsigned long long)rsdp->XsdtPhysicalAddress);
setenv("hint.acpi.0.xsdt", buf, 1);
+ setenv("acpi.xsdt", buf, 1);
sprintf(buf, "%d", rsdp->Length);
setenv("hint.acpi.0.xsdt_length", buf, 1);
+ setenv("acpi.xsdt_length", buf, 1);
}
}
diff --git a/sys/boot/fdt/dts/mips/fbsd-mt7620a.dtsi b/sys/boot/fdt/dts/mips/fbsd-mt7620a.dtsi
new file mode 100644
index 0000000..8f4c9d5
--- /dev/null
+++ b/sys/boot/fdt/dts/mips/fbsd-mt7620a.dtsi
@@ -0,0 +1,52 @@
+/* $FreeBSD$ */
+
+/ {
+
+ /*
+ * FreeBSD's stdin and stdout, so we can have a console
+ */
+ chosen {
+ stdin = &uartlite;
+ stdout = &uartlite;
+ };
+
+ /*
+ * OpenWRT doesn't define a clock controller, but we currently need one
+ */
+ clkctrl: cltctrl {
+ compatible = "ralink,rt2880-clock";
+ #clock-cells = <1>;
+ };
+
+ palmbus@10000000 {
+ /*
+ * Make palmbus compatible to our simplebus
+ */
+ compatible = "simple-bus";
+
+ /*
+ * Reference uartlite@c00 as uartlite, so we can address it
+ * within the chosen node above
+ */
+ uartlite: uartlite@c00 {};
+ };
+
+ usbphy: usbphy {
+ clocks = <&clkctrl 22 &clkctrl 25>;
+ clock-names = "host", "device";
+ };
+
+ pcie@10140000 {
+ /*
+ * Our driver is different that OpenWRT's, so we need slightly
+ * different values for the reg property
+ */
+ reg = <0x10140000 0x10000>;
+
+ /*
+ * Also, we need resets and clocks defined, so we can properly
+ * initialize the PCIe
+ */
+ clocks = <&clkctrl 26>;
+ };
+};
diff --git a/sys/boot/fdt/dts/mips/fbsd-mt7620n.dtsi b/sys/boot/fdt/dts/mips/fbsd-mt7620n.dtsi
new file mode 100644
index 0000000..c1d537b
--- /dev/null
+++ b/sys/boot/fdt/dts/mips/fbsd-mt7620n.dtsi
@@ -0,0 +1,38 @@
+/* $FreeBSD$ */
+
+/ {
+
+ /*
+ * FreeBSD's stdin and stdout, so we can have a console
+ */
+ chosen {
+ stdin = &uartlite;
+ stdout = &uartlite;
+ };
+
+ /*
+ * OpenWRT doesn't define a clock controller, but we currently need one
+ */
+ clkctrl: cltctrl {
+ compatible = "ralink,rt2880-clock";
+ #clock-cells = <1>;
+ };
+
+ palmbus@10000000 {
+ /*
+ * Make palmbus compatible to our simplebus
+ */
+ compatible = "simple-bus";
+
+ /*
+ * Reference uartlite@c00 as uartlite, so we can address it
+ * within the chosen node above
+ */
+ uartlite: uartlite@c00 {};
+ };
+
+ usbphy: usbphy {
+ clocks = <&clkctrl 22 &clkctrl 25>;
+ clock-names = "host", "device";
+ };
+};
diff --git a/sys/boot/fdt/dts/mips/fbsd-mt7621.dtsi b/sys/boot/fdt/dts/mips/fbsd-mt7621.dtsi
new file mode 100644
index 0000000..91ae1b1
--- /dev/null
+++ b/sys/boot/fdt/dts/mips/fbsd-mt7621.dtsi
@@ -0,0 +1,102 @@
+/* $FreeBSD$ */
+
+/ {
+
+ /*
+ * FreeBSD's stdin and stdout, so we can have a console
+ */
+ chosen {
+ stdin = &uartlite;
+ stdout = &uartlite;
+ };
+
+ /*
+ * OpenWRT doesn't define a clock controller, but we currently need one
+ */
+ clkctrl: cltctrl {
+ compatible = "ralink,rt2880-clock";
+ #clock-cells = <1>;
+ };
+
+ gic: interrupt-controller@1fbc0000 {
+ /*
+ * OpenWRT does not define the GIC interrupt, but we need it
+ * for now, at least until we re-work our GIC driver
+ */
+ interrupt-parent = <&cpuintc>;
+ interrupts = <2>;
+ };
+
+ palmbus@1E000000 {
+ /*
+ * Make palmbus compatible to our simplebus
+ */
+ compatible = "simple-bus";
+
+ /*
+ * Reference uartlite@c00 as uartlite, so we can address it
+ * within the chosen node above
+ */
+ uartlite: uartlite@c00 {
+ /*
+ * Mark uartlite as compatible to mtk,ns16550a instead
+ * of simply ns16550a so we can autodetect the UART
+ * clock
+ */
+ compatible = "mtk,ns16550a";
+ };
+
+ gpio@600 {
+ /*
+ * Mark gpio as compatible to simple-bus and override
+ * its #size-cells and provide a default ranges property
+ * so we can attach instances of our mtk_gpio_v2 driver
+ * to it for now. Provide exactly the same resources to
+ * the instances of mtk_gpio_v2.
+ */
+ compatible = "simple-bus";
+ ranges = <0x0 0x600 0x100>;
+ #size-cells = <1>;
+
+ interrupt-parent = <&gic>;
+
+ gpio0: bank@0 {
+ reg = <0x0 0x100>;
+ interrupts = <GIC_SHARED 6 IRQ_TYPE_LEVEL_HIGH>;
+ };
+
+ gpio1: bank@1 {
+ reg = <0x0 0x100>;
+ interrupts = <GIC_SHARED 6 IRQ_TYPE_LEVEL_HIGH>;
+ };
+
+ gpio2: bank@2 {
+ reg = <0x0 0x100>;
+ interrupts = <GIC_SHARED 6 IRQ_TYPE_LEVEL_HIGH>;
+ };
+ };
+ };
+
+ xhci@1E1C0000 {
+ /*
+ * A slightly different value for reg size is needed by our
+ * driver for the moment
+ */
+ reg = <0x1e1c0000 0x20000>;
+ };
+
+ pcie@1e140000 {
+ /*
+ * Our driver is different that OpenWRT's, so we need slightly
+ * different values for the reg property
+ */
+ reg = <0x1e140000 0x10000>;
+
+ /*
+ * Also, we need resets and clocks defined, so we can properly
+ * initialize the PCIe
+ */
+ resets = <&rstctrl 24>, <&rstctrl 25>, <&rstctrl 26>;
+ clocks = <&clkctrl 24>, <&clkctrl 25>, <&clkctrl 26>;
+ };
+};
diff --git a/sys/boot/fdt/dts/mips/fbsd-mt7628an.dtsi b/sys/boot/fdt/dts/mips/fbsd-mt7628an.dtsi
new file mode 100644
index 0000000..42401b5
--- /dev/null
+++ b/sys/boot/fdt/dts/mips/fbsd-mt7628an.dtsi
@@ -0,0 +1,88 @@
+/* $FreeBSD$ */
+
+/ {
+
+ /*
+ * FreeBSD's stdin and stdout, so we can have a console
+ */
+ chosen {
+ stdin = &uartlite;
+ stdout = &uartlite;
+ };
+
+ /*
+ * OpenWRT doesn't define a clock controller, but we currently need one
+ */
+ clkctrl: cltctrl {
+ compatible = "ralink,rt2880-clock";
+ #clock-cells = <1>;
+ };
+
+ palmbus@10000000 {
+ /*
+ * Make palmbus compatible to our simplebus
+ */
+ compatible = "simple-bus";
+
+ /*
+ * Reference uart2@e00 as uartlite, so we can address it
+ * within the chosen node above
+ */
+ uartlite: uart2@e00 {
+ /*
+ * Mark uartlite as compatible to mtk,ns16550a instead
+ * of simply ns16550a so we can autodetect the UART
+ * clock
+ */
+ compatible = "mtk,ns16550a";
+ };
+
+ gpio@600 {
+ /*
+ * Mark gpio as compatible to simple-bus and override
+ * its #size-cells and provide a default ranges property
+ * so we can attach instances of our mtk_gpio_v2 driver
+ * to it for now. Provide exactly the same resources to
+ * the instances of mtk_gpio_v2.
+ */
+ compatible = "simple-bus";
+ ranges = <0x0 0x600 0x100>;
+ #size-cells = <1>;
+
+ gpio0: bank@0 {
+ reg = <0x0 0x100>;
+ interrupts = <6>;
+ };
+
+ gpio1: bank@1 {
+ reg = <0x0 0x100>;
+ interrupts = <6>;
+ };
+
+ gpio2: bank@2 {
+ reg = <0x0 0x100>;
+ interrupts = <6>;
+ };
+ };
+ };
+
+ usbphy: usbphy@10120000 {
+ clocks = <&clkctrl 22 &clkctrl 25>;
+ clock-names = "host", "device";
+ };
+
+ pcie@10140000 {
+ /*
+ * Our driver is different that OpenWRT's, so we need slightly
+ * different values for the reg property
+ */
+ reg = <0x10140000 0x10000>;
+
+ /*
+ * Also, we need resets and clocks defined, so we can properly
+ * initialize the PCIe
+ */
+ resets = <&rstctrl 26>, <&rstctrl 27>;
+ clocks = <&clkctrl 26>, <&clkctrl 27>;
+ };
+};
diff --git a/sys/boot/fdt/dts/mips/fbsd-rt2880.dtsi b/sys/boot/fdt/dts/mips/fbsd-rt2880.dtsi
new file mode 100644
index 0000000..96ebafe
--- /dev/null
+++ b/sys/boot/fdt/dts/mips/fbsd-rt2880.dtsi
@@ -0,0 +1,33 @@
+/* $FreeBSD$ */
+
+/ {
+
+ /*
+ * FreeBSD's stdin and stdout, so we can have a console
+ */
+ chosen {
+ stdin = &uartlite;
+ stdout = &uartlite;
+ };
+
+ /*
+ * OpenWRT doesn't define a clock controller, but we currently need one
+ */
+ clkctrl: cltctrl {
+ compatible = "ralink,rt2880-clock";
+ #clock-cells = <1>;
+ };
+
+ palmbus@300000 {
+ /*
+ * Make palmbus compatible to our simplebus
+ */
+ compatible = "simple-bus";
+
+ /*
+ * Reference uartlite@c00 as uartlite, so we can address it
+ * within the chosen node above
+ */
+ uartlite: uartlite@c00 {};
+ };
+};
diff --git a/sys/boot/fdt/dts/mips/fbsd-rt3050.dtsi b/sys/boot/fdt/dts/mips/fbsd-rt3050.dtsi
new file mode 100644
index 0000000..13eb530
--- /dev/null
+++ b/sys/boot/fdt/dts/mips/fbsd-rt3050.dtsi
@@ -0,0 +1,41 @@
+/* $FreeBSD$ */
+
+/ {
+
+ /*
+ * FreeBSD's stdin and stdout, so we can have a console
+ */
+ chosen {
+ stdin = &uartlite;
+ stdout = &uartlite;
+ };
+
+ /*
+ * OpenWRT doesn't define a clock controller, but we currently need one
+ */
+ clkctrl: cltctrl {
+ compatible = "ralink,rt2880-clock";
+ #clock-cells = <1>;
+ };
+
+ palmbus@10000000 {
+ /*
+ * Make palmbus compatible to our simplebus
+ */
+ compatible = "simple-bus";
+
+ /*
+ * Reference uartlite@c00 as uartlite, so we can address it
+ * within the chosen node above
+ */
+ uartlite: uartlite@c00 {};
+ };
+
+ usbphy: usbphy {
+ compatible = "ralink,rt3050-usbphy";
+ resets = <&rstctrl 22>;
+ reset-names = "otg";
+ clocks = <&clkctrl 18>;
+ clock-names = "otg";
+ };
+};
diff --git a/sys/boot/fdt/dts/mips/fbsd-rt3352.dtsi b/sys/boot/fdt/dts/mips/fbsd-rt3352.dtsi
new file mode 100644
index 0000000..a6a6887
--- /dev/null
+++ b/sys/boot/fdt/dts/mips/fbsd-rt3352.dtsi
@@ -0,0 +1,38 @@
+/* $FreeBSD$ */
+
+/ {
+
+ /*
+ * FreeBSD's stdin and stdout, so we can have a console
+ */
+ chosen {
+ stdin = &uartlite;
+ stdout = &uartlite;
+ };
+
+ /*
+ * OpenWRT doesn't define a clock controller, but we currently need one
+ */
+ clkctrl: cltctrl {
+ compatible = "ralink,rt2880-clock";
+ #clock-cells = <1>;
+ };
+
+ palmbus@10000000 {
+ /*
+ * Make palmbus compatible to our simplebus
+ */
+ compatible = "simple-bus";
+
+ /*
+ * Reference uartlite@c00 as uartlite, so we can address it
+ * within the chosen node above
+ */
+ uartlite: uartlite@c00 {};
+ };
+
+ usbphy {
+ clocks = <&clkctrl 18 &clkctrl 20>;
+ clock-names = "host", "device";
+ };
+};
diff --git a/sys/boot/fdt/dts/mips/fbsd-rt3883.dtsi b/sys/boot/fdt/dts/mips/fbsd-rt3883.dtsi
new file mode 100644
index 0000000..de32f9b
--- /dev/null
+++ b/sys/boot/fdt/dts/mips/fbsd-rt3883.dtsi
@@ -0,0 +1,50 @@
+/* $FreeBSD$ */
+
+/ {
+
+ /*
+ * FreeBSD's stdin and stdout, so we can have a console
+ */
+ chosen {
+ stdin = &uartlite;
+ stdout = &uartlite;
+ };
+
+ /*
+ * OpenWRT doesn't define a clock controller, but we currently need one
+ */
+ clkctrl: cltctrl {
+ compatible = "ralink,rt2880-clock";
+ #clock-cells = <1>;
+ };
+
+ palmbus@10000000 {
+ /*
+ * Make palmbus compatible to our simplebus
+ */
+ compatible = "simple-bus";
+
+ /*
+ * Reference uartlite@c00 as uartlite, so we can address it
+ * within the chosen node above
+ */
+ uartlite: uartlite@c00 {};
+ };
+
+ usbphy: usbphy {
+ clocks = <&clkctrl 22 &clkctrl 25>;
+ clock-names = "host", "device";
+ };
+
+ pci@10140000 {
+ #address-cells = <3>;
+ #size-cells = <2>;
+ ranges = <
+ 0x02000000 0 0x00000000 0x20000000 0 0x10000000
+ 0x01000000 0 0x00000000 0x10160000 0 0x00010000
+ >;
+
+ interrupt-parent = <&cpuintc>;
+ interrupts = <4>;
+ };
+};
diff --git a/sys/boot/fdt/dts/mips/fbsd-rt5350.dtsi b/sys/boot/fdt/dts/mips/fbsd-rt5350.dtsi
new file mode 100644
index 0000000..5cc5383
--- /dev/null
+++ b/sys/boot/fdt/dts/mips/fbsd-rt5350.dtsi
@@ -0,0 +1,38 @@
+/* $FreeBSD$ */
+
+/ {
+
+ /*
+ * FreeBSD's stdin and stdout, so we can have a console
+ */
+ chosen {
+ stdin = &uartlite;
+ stdout = &uartlite;
+ };
+
+ /*
+ * OpenWRT doesn't define a clock controller, but we currently need one
+ */
+ clkctrl: cltctrl {
+ compatible = "ralink,rt2880-clock";
+ #clock-cells = <1>;
+ };
+
+ palmbus@10000000 {
+ /*
+ * Make palmbus compatible to our simplebus
+ */
+ compatible = "simple-bus";
+
+ /*
+ * Reference uartlite@c00 as uartlite, so we can address it
+ * within the chosen node above
+ */
+ uartlite: uartlite@c00 {};
+ };
+
+ usbphy {
+ clocks = <&clkctrl 18>;
+ clock-names = "host";
+ };
+};
diff --git a/sys/boot/i386/libi386/biosacpi.c b/sys/boot/i386/libi386/biosacpi.c
index bedc722..8167fca 100644
--- a/sys/boot/i386/libi386/biosacpi.c
+++ b/sys/boot/i386/libi386/biosacpi.c
@@ -60,25 +60,40 @@ biosacpi_detect(void)
if ((rsdp = biosacpi_find_rsdp()) == NULL)
return;
- /* export values from the RSDP */
+ /*
+ * Report the RSDP to the kernel. While this can be found with
+ * a BIOS boot, the RSDP may be elsewhere when booted from UEFI.
+ * The old code used the 'hints' method to communite this to
+ * the kernel. However, while convenient, the 'hints' method
+ * is fragile and does not work when static hints are compiled
+ * into the kernel. Instead, move to setting different tunables
+ * that start with acpi. The old 'hints' can be removed before
+ * we branch for FreeBSD 12.
+ */
sprintf(buf, "0x%08x", VTOP(rsdp));
setenv("hint.acpi.0.rsdp", buf, 1);
+ setenv("acpi.rsdp", buf, 1);
revision = rsdp->Revision;
if (revision == 0)
revision = 1;
sprintf(buf, "%d", revision);
setenv("hint.acpi.0.revision", buf, 1);
+ setenv("acpi.revision", buf, 1);
strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId));
buf[sizeof(rsdp->OemId)] = '\0';
setenv("hint.acpi.0.oem", buf, 1);
+ setenv("acpi.oem", buf, 1);
sprintf(buf, "0x%08x", rsdp->RsdtPhysicalAddress);
setenv("hint.acpi.0.rsdt", buf, 1);
+ setenv("acpi.rsdt", buf, 1);
if (revision >= 2) {
/* XXX extended checksum? */
sprintf(buf, "0x%016llx", rsdp->XsdtPhysicalAddress);
setenv("hint.acpi.0.xsdt", buf, 1);
+ setenv("acpi.xsdt", buf, 1);
sprintf(buf, "%d", rsdp->Length);
setenv("hint.acpi.0.xsdt_length", buf, 1);
+ setenv("acpi.xsdt_length", buf, 1);
}
}
diff --git a/sys/cam/ata/ata_all.c b/sys/cam/ata/ata_all.c
index d5220e8..51231b7 100644
--- a/sys/cam/ata/ata_all.c
+++ b/sys/cam/ata/ata_all.c
@@ -211,29 +211,64 @@ ata_op_string(struct ata_cmd *cmd)
char *
ata_cmd_string(struct ata_cmd *cmd, char *cmd_string, size_t len)
{
+ struct sbuf sb;
+ int error;
- snprintf(cmd_string, len, "%02x %02x %02x %02x "
+ if (len == 0)
+ return ("");
+
+ sbuf_new(&sb, cmd_string, len, SBUF_FIXEDLEN);
+ ata_cmd_sbuf(cmd, &sb);
+
+ error = sbuf_finish(&sb);
+ if (error != 0 && error != ENOMEM)
+ return ("");
+
+ return(sbuf_data(&sb));
+}
+
+void
+ata_cmd_sbuf(struct ata_cmd *cmd, struct sbuf *sb)
+{
+ sbuf_printf(sb, "%02x %02x %02x %02x "
"%02x %02x %02x %02x %02x %02x %02x %02x",
cmd->command, cmd->features,
cmd->lba_low, cmd->lba_mid, cmd->lba_high, cmd->device,
cmd->lba_low_exp, cmd->lba_mid_exp, cmd->lba_high_exp,
cmd->features_exp, cmd->sector_count, cmd->sector_count_exp);
-
- return(cmd_string);
}
char *
ata_res_string(struct ata_res *res, char *res_string, size_t len)
{
+ struct sbuf sb;
+ int error;
+
+ if (len == 0)
+ return ("");
+
+ sbuf_new(&sb, res_string, len, SBUF_FIXEDLEN);
+ ata_res_sbuf(res, &sb);
+
+ error = sbuf_finish(&sb);
+ if (error != 0 && error != ENOMEM)
+ return ("");
+
+ return(sbuf_data(&sb));
+}
+
+int
+ata_res_sbuf(struct ata_res *res, struct sbuf *sb)
+{
- snprintf(res_string, len, "%02x %02x %02x %02x "
+ sbuf_printf(sb, "%02x %02x %02x %02x "
"%02x %02x %02x %02x %02x %02x %02x",
res->status, res->error,
res->lba_low, res->lba_mid, res->lba_high, res->device,
res->lba_low_exp, res->lba_mid_exp, res->lba_high_exp,
res->sector_count, res->sector_count_exp);
- return(res_string);
+ return (0);
}
/*
@@ -242,11 +277,10 @@ ata_res_string(struct ata_res *res, char *res_string, size_t len)
int
ata_command_sbuf(struct ccb_ataio *ataio, struct sbuf *sb)
{
- char cmd_str[(12 * 3) + 1];
- sbuf_printf(sb, "%s. ACB: %s",
- ata_op_string(&ataio->cmd),
- ata_cmd_string(&ataio->cmd, cmd_str, sizeof(cmd_str)));
+ sbuf_printf(sb, "%s. ACB: ",
+ ata_op_string(&ataio->cmd));
+ ata_cmd_sbuf(&ataio->cmd, sb);
return(0);
}
@@ -284,20 +318,6 @@ ata_status_sbuf(struct ccb_ataio *ataio, struct sbuf *sb)
return(0);
}
-/*
- * ata_res_sbuf() returns 0 for success and -1 for failure.
- */
-int
-ata_res_sbuf(struct ccb_ataio *ataio, struct sbuf *sb)
-{
- char res_str[(11 * 3) + 1];
-
- sbuf_printf(sb, "RES: %s",
- ata_res_string(&ataio->res, res_str, sizeof(res_str)));
-
- return(0);
-}
-
void
ata_print_ident(struct ata_params *ident_data)
{
diff --git a/sys/cam/ata/ata_all.h b/sys/cam/ata/ata_all.h
index 91e941c..0eda4f4 100644
--- a/sys/cam/ata/ata_all.h
+++ b/sys/cam/ata/ata_all.h
@@ -46,6 +46,7 @@ struct ata_cmd {
#define CAM_ATAIO_CONTROL 0x04 /* Control, not a command */
#define CAM_ATAIO_NEEDRESULT 0x08 /* Request requires result. */
#define CAM_ATAIO_DMA 0x10 /* DMA command */
+#define CAM_ATAIO_AUX_HACK 0x20 /* Kludge to make FPDMA DSM TRIM work */
u_int8_t command;
u_int8_t features;
@@ -103,10 +104,11 @@ int ata_version(int ver);
char * ata_op_string(struct ata_cmd *cmd);
char * ata_cmd_string(struct ata_cmd *cmd, char *cmd_string, size_t len);
+void ata_cmd_sbuf(struct ata_cmd *cmd, struct sbuf *sb);
char * ata_res_string(struct ata_res *res, char *res_string, size_t len);
int ata_command_sbuf(struct ccb_ataio *ataio, struct sbuf *sb);
int ata_status_sbuf(struct ccb_ataio *ataio, struct sbuf *sb);
-int ata_res_sbuf(struct ccb_ataio *ataio, struct sbuf *sb);
+int ata_res_sbuf(struct ata_res *res, struct sbuf *sb);
void ata_print_ident(struct ata_params *ident_data);
void ata_print_ident_short(struct ata_params *ident_data);
diff --git a/sys/cam/ata/ata_da.c b/sys/cam/ata/ata_da.c
index 38cf46e..05134d7 100644
--- a/sys/cam/ata/ata_da.c
+++ b/sys/cam/ata/ata_da.c
@@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <cam/cam_periph.h>
#include <cam/cam_xpt_periph.h>
#include <cam/cam_sim.h>
+#include <cam/cam_iosched.h>
#include <cam/ata/ata_all.h>
@@ -68,6 +69,8 @@ __FBSDID("$FreeBSD$");
#define ATA_MAX_28BIT_LBA 268435455UL
+extern int iosched_debug;
+
typedef enum {
ADA_STATE_RAHEAD,
ADA_STATE_WCACHE,
@@ -87,17 +90,21 @@ typedef enum {
ADA_FLAG_CAN_CFA = 0x0400,
ADA_FLAG_CAN_POWERMGT = 0x0800,
ADA_FLAG_CAN_DMA48 = 0x1000,
- ADA_FLAG_DIRTY = 0x2000
+ ADA_FLAG_DIRTY = 0x2000,
+ ADA_FLAG_CAN_NCQ_TRIM = 0x4000, /* CAN_TRIM also set */
+ ADA_FLAG_PIM_CAN_NCQ_TRIM = 0x8000
} ada_flags;
typedef enum {
ADA_Q_NONE = 0x00,
ADA_Q_4K = 0x01,
+ ADA_Q_NCQ_TRIM_BROKEN = 0x02,
} ada_quirks;
#define ADA_Q_BIT_STRING \
"\020" \
- "\0014K"
+ "\0014K" \
+ "\002NCQ_TRIM_BROKEN"
typedef enum {
ADA_CCB_RAHEAD = 0x01,
@@ -112,6 +119,23 @@ typedef enum {
#define ccb_state ppriv_field0
#define ccb_bp ppriv_ptr1
+typedef enum {
+ ADA_DELETE_NONE,
+ ADA_DELETE_DISABLE,
+ ADA_DELETE_CFA_ERASE,
+ ADA_DELETE_DSM_TRIM,
+ ADA_DELETE_NCQ_DSM_TRIM,
+ ADA_DELETE_MIN = ADA_DELETE_CFA_ERASE,
+ ADA_DELETE_MAX = ADA_DELETE_NCQ_DSM_TRIM,
+} ada_delete_methods;
+
+static const char *ada_delete_method_names[] =
+ { "NONE", "DISABLE", "CFA_ERASE", "DSM_TRIM", "NCQ_DSM_TRIM" };
+#if 0
+static const char *ada_delete_method_desc[] =
+ { "NONE", "DISABLED", "CFA Erase", "DSM Trim", "DSM Trim via NCQ" };
+#endif
+
struct disk_params {
u_int8_t heads;
u_int8_t secs_per_track;
@@ -128,18 +152,18 @@ struct trim_request {
};
struct ada_softc {
- struct bio_queue_head bio_queue;
- struct bio_queue_head trim_queue;
+ struct cam_iosched_softc *cam_iosched;
int outstanding_cmds; /* Number of active commands */
int refcount; /* Active xpt_action() calls */
ada_state state;
ada_flags flags;
ada_quirks quirks;
- int sort_io_queue;
+ ada_delete_methods delete_method;
int trim_max_ranges;
- int trim_running;
int read_ahead;
int write_cache;
+ int unmappedio;
+ int rotating;
#ifdef ADA_TEST_FAILURE
int force_read_error;
int force_write_error;
@@ -153,6 +177,13 @@ struct ada_softc {
struct sysctl_oid *sysctl_tree;
struct callout sendordered_c;
struct trim_request trim_req;
+#ifdef CAM_IO_STATS
+ struct sysctl_ctx_list sysctl_stats_ctx;
+ struct sysctl_oid *sysctl_stats_tree;
+ u_int timeouts;
+ u_int errors;
+ u_int invalidations;
+#endif
};
struct ada_quirk_entry {
@@ -330,6 +361,38 @@ static struct ada_quirk_entry ada_quirk_table[] =
},
{
/*
+ * Crucial M500 SSDs MU07 firmware
+ * NCQ Trim works
+ */
+ { T_DIRECT, SIP_MEDIA_FIXED, "*", "Crucial CT*M500*", "MU07" },
+ /*quirks*/0
+ },
+ {
+ /*
+ * Crucial M500 SSDs all other firmware
+ * NCQ Trim doesn't work
+ */
+ { T_DIRECT, SIP_MEDIA_FIXED, "*", "Crucial CT*M500*", "*" },
+ /*quirks*/ADA_Q_NCQ_TRIM_BROKEN
+ },
+ {
+ /*
+ * Crucial M550 SSDs
+ * NCQ Trim doesn't work, but only on MU01 firmware
+ */
+ { T_DIRECT, SIP_MEDIA_FIXED, "*", "Crucial CT*M550*", "MU01" },
+ /*quirks*/ADA_Q_NCQ_TRIM_BROKEN
+ },
+ {
+ /*
+ * Crucial MX100 SSDs
+ * NCQ Trim doesn't work, but only on MU01 firmware
+ */
+ { T_DIRECT, SIP_MEDIA_FIXED, "*", "Crucial CT*MX100*", "MU01" },
+ /*quirks*/ADA_Q_NCQ_TRIM_BROKEN
+ },
+ {
+ /*
* Crucial RealSSD C300 SSDs
* 4k optimised
*/
@@ -338,6 +401,14 @@ static struct ada_quirk_entry ada_quirk_table[] =
},
{
/*
+ * FCCT M500 SSDs
+ * NCQ Trim doesn't work
+ */
+ { T_DIRECT, SIP_MEDIA_FIXED, "*", "FCCT*M500*", "*" },
+ /*quirks*/ADA_Q_NCQ_TRIM_BROKEN
+ },
+ {
+ /*
* Intel 320 Series SSDs
* 4k optimised & trim only works in 4k requests + 4k aligned
*/
@@ -402,6 +473,30 @@ static struct ada_quirk_entry ada_quirk_table[] =
},
{
/*
+ * Micron M500 SSDs firmware MU07
+ * NCQ Trim works?
+ */
+ { T_DIRECT, SIP_MEDIA_FIXED, "*", "Micron M500*", "MU07" },
+ /*quirks*/0
+ },
+ {
+ /*
+ * Micron M500 SSDs all other firmware
+ * NCQ Trim doesn't work
+ */
+ { T_DIRECT, SIP_MEDIA_FIXED, "*", "Micron M500*", "*" },
+ /*quirks*/ADA_Q_NCQ_TRIM_BROKEN
+ },
+ {
+ /*
+ * Micron M5[15]0 SSDs
+ * NCQ Trim doesn't work, but only MU01 firmware
+ */
+ { T_DIRECT, SIP_MEDIA_FIXED, "*", "Micron M5[15]0*", "MU01" },
+ /*quirks*/ADA_Q_NCQ_TRIM_BROKEN
+ },
+ {
+ /*
* OCZ Agility 2 SSDs
* 4k optimised & trim only works in 4k requests + 4k aligned
*/
@@ -451,25 +546,33 @@ static struct ada_quirk_entry ada_quirk_table[] =
{
/*
* Samsung 830 Series SSDs
- * 4k optimised
+ * 4k optimised, NCQ TRIM Broken (normal TRIM is fine)
*/
{ T_DIRECT, SIP_MEDIA_FIXED, "*", "SAMSUNG SSD 830 Series*", "*" },
- /*quirks*/ADA_Q_4K
+ /*quirks*/ADA_Q_4K | ADA_Q_NCQ_TRIM_BROKEN
},
{
/*
* Samsung 840 SSDs
- * 4k optimised
+ * 4k optimised, NCQ TRIM Broken (normal TRIM is fine)
*/
{ T_DIRECT, SIP_MEDIA_FIXED, "*", "Samsung SSD 840*", "*" },
- /*quirks*/ADA_Q_4K
+ /*quirks*/ADA_Q_4K | ADA_Q_NCQ_TRIM_BROKEN
},
{
/*
* Samsung 850 SSDs
- * 4k optimised
+ * 4k optimised, NCQ TRIM broken (normal TRIM fine)
*/
{ T_DIRECT, SIP_MEDIA_FIXED, "*", "Samsung SSD 850*", "*" },
+ /*quirks*/ADA_Q_4K | ADA_Q_NCQ_TRIM_BROKEN
+ },
+ {
+ /*
+ * Samsung SM863 Series SSDs (MZ7KM*)
+ * 4k optimised, NCQ believed to be working
+ */
+ { T_DIRECT, SIP_MEDIA_FIXED, "*", "SAMSUNG MZ7KM*", "*" },
/*quirks*/ADA_Q_4K
},
{
@@ -477,11 +580,11 @@ static struct ada_quirk_entry ada_quirk_table[] =
* Samsung 843T Series SSDs (MZ7WD*)
* Samsung PM851 Series SSDs (MZ7TE*)
* Samsung PM853T Series SSDs (MZ7GE*)
- * Samsung SM863 Series SSDs (MZ7KM*)
- * 4k optimised
+ * 4k optimised, NCQ believed to be broken since these are
+ * appear to be built with the same controllers as the 840/850.
*/
{ T_DIRECT, SIP_MEDIA_FIXED, "*", "SAMSUNG MZ7*", "*" },
- /*quirks*/ADA_Q_4K
+ /*quirks*/ADA_Q_4K | ADA_Q_NCQ_TRIM_BROKEN
},
{
/*
@@ -566,8 +669,6 @@ static void adaresume(void *arg);
softc->read_ahead : ada_read_ahead)
#define ADA_WC (softc->write_cache >= 0 ? \
softc->write_cache : ada_write_cache)
-#define ADA_SIO (softc->sort_io_queue >= 0 ? \
- softc->sort_io_queue : cam_sort_io_queues)
/*
* Most platforms map firmware geometry to actual, but some don't. If
@@ -624,6 +725,8 @@ static struct periph_driver adadriver =
TAILQ_HEAD_INITIALIZER(adadriver.units), /* generation */ 0
};
+static int adadeletemethodsysctl(SYSCTL_HANDLER_ARGS);
+
PERIPHDRIVER_DECLARE(ada, adadriver);
static int
@@ -719,11 +822,7 @@ adaschedule(struct cam_periph *periph)
if (softc->state != ADA_STATE_NORMAL)
return;
- /* Check if we have more work to do. */
- if (bioq_first(&softc->bio_queue) ||
- (!softc->trim_running && bioq_first(&softc->trim_queue))) {
- xpt_schedule(periph, CAM_PRIORITY_NORMAL);
- }
+ cam_iosched_schedule(softc->cam_iosched, periph);
}
/*
@@ -756,14 +855,7 @@ adastrategy(struct bio *bp)
/*
* Place it in the queue of disk activities for this disk
*/
- if (bp->bio_cmd == BIO_DELETE) {
- bioq_disksort(&softc->trim_queue, bp);
- } else {
- if (ADA_SIO)
- bioq_disksort(&softc->bio_queue, bp);
- else
- bioq_insert_tail(&softc->bio_queue, bp);
- }
+ cam_iosched_queue_work(softc->cam_iosched, bp);
/*
* Schedule ourselves for performing the work.
@@ -836,6 +928,11 @@ adadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t len
if (softc->flags & ADA_FLAG_CAN_FLUSHCACHE) {
xpt_setup_ccb(&ccb.ccb_h, periph->path, CAM_PRIORITY_NORMAL);
+ /*
+ * Tell the drive to flush its internal cache. if we
+ * can't flush in 5s we have big problems. No need to
+ * wait the default 60s to detect problems.
+ */
ccb.ccb_h.ccb_state = ADA_CCB_DUMP;
cam_fill_ataio(&ccb.ataio,
0,
@@ -844,7 +941,7 @@ adadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t len
0,
NULL,
0,
- ada_default_timeout*1000);
+ 5*1000);
if (softc->flags & ADA_FLAG_CAN_48BIT)
ata_48bit_cmd(&ccb.ataio, ATA_FLUSHCACHE48, 0, 0, 0);
@@ -918,14 +1015,16 @@ adaoninvalidate(struct cam_periph *periph)
* De-register any async callbacks.
*/
xpt_register_async(0, adaasync, periph, periph->path);
+#ifdef CAM_IO_STATS
+ softc->invalidations++;
+#endif
/*
* Return all queued I/O with ENXIO.
* XXX Handle any transactions queued to the card
* with XPT_ABORT_CCB.
*/
- bioq_flush(&softc->bio_queue, NULL, ENXIO);
- bioq_flush(&softc->trim_queue, NULL, ENXIO);
+ cam_iosched_flush(softc->cam_iosched, NULL, ENXIO);
disk_gone(softc->disk);
}
@@ -939,12 +1038,20 @@ adacleanup(struct cam_periph *periph)
cam_periph_unlock(periph);
+ cam_iosched_fini(softc->cam_iosched);
+
/*
* If we can't free the sysctl tree, oh well...
*/
- if ((softc->flags & ADA_FLAG_SCTX_INIT) != 0
- && sysctl_ctx_free(&softc->sysctl_ctx) != 0) {
- xpt_print(periph->path, "can't remove sysctl context\n");
+ if ((softc->flags & ADA_FLAG_SCTX_INIT) != 0) {
+#ifdef CAM_IO_STATS
+ if (sysctl_ctx_free(&softc->sysctl_stats_ctx) != 0)
+ xpt_print(periph->path,
+ "can't remove sysctl stats context\n");
+#endif
+ if (sysctl_ctx_free(&softc->sysctl_ctx) != 0)
+ xpt_print(periph->path,
+ "can't remove sysctl context\n");
}
disk_destroy(softc->disk);
@@ -954,6 +1061,20 @@ adacleanup(struct cam_periph *periph)
}
static void
+adasetdeletemethod(struct ada_softc *softc)
+{
+
+ if (softc->flags & ADA_FLAG_CAN_NCQ_TRIM)
+ softc->delete_method = ADA_DELETE_NCQ_DSM_TRIM;
+ else if (softc->flags & ADA_FLAG_CAN_TRIM)
+ softc->delete_method = ADA_DELETE_DSM_TRIM;
+ else if ((softc->flags & ADA_FLAG_CAN_CFA) && !(softc->flags & ADA_FLAG_CAN_48BIT))
+ softc->delete_method = ADA_DELETE_CFA_ERASE;
+ else
+ softc->delete_method = ADA_DELETE_NONE;
+}
+
+static void
adaasync(void *callback_arg, u_int32_t code,
struct cam_path *path, void *arg)
{
@@ -1018,11 +1139,26 @@ adaasync(void *callback_arg, u_int32_t code,
softc->flags |= ADA_FLAG_CAN_NCQ;
else
softc->flags &= ~ADA_FLAG_CAN_NCQ;
+
if ((cgd.ident_data.support_dsm & ATA_SUPPORT_DSM_TRIM) &&
- (cgd.inq_flags & SID_DMA))
+ (cgd.inq_flags & SID_DMA)) {
softc->flags |= ADA_FLAG_CAN_TRIM;
- else
- softc->flags &= ~ADA_FLAG_CAN_TRIM;
+ /*
+ * If we can do RCVSND_FPDMA_QUEUED commands, we may be able to do
+ * NCQ trims, if we support trims at all. We also need support from
+ * the sim do do things properly. Perhaps we should look at log 13
+ * dword 0 bit 0 and dword 1 bit 0 are set too...
+ */
+ if ((softc->quirks & ADA_Q_NCQ_TRIM_BROKEN) == 0 &&
+ (softc->flags & ADA_FLAG_PIM_CAN_NCQ_TRIM) != 0 &&
+ (cgd.ident_data.satacapabilities2 & ATA_SUPPORT_RCVSND_FPDMA_QUEUED) != 0 &&
+ (softc->flags & ADA_FLAG_CAN_TRIM) != 0)
+ softc->flags |= ADA_FLAG_CAN_NCQ_TRIM;
+ else
+ softc->flags &= ~ADA_FLAG_CAN_NCQ_TRIM;
+ } else
+ softc->flags &= ~(ADA_FLAG_CAN_TRIM | ADA_FLAG_CAN_NCQ_TRIM);
+ adasetdeletemethod(softc);
cam_periph_async(periph, code, path, arg);
break;
@@ -1100,6 +1236,10 @@ adasysctlinit(void *context, int pending)
return;
}
+ SYSCTL_ADD_PROC(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
+ OID_AUTO, "delete_method", CTLTYPE_STRING | CTLFLAG_RW,
+ softc, 0, adadeletemethodsysctl, "A",
+ "BIO_DELETE execution method");
SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
OID_AUTO, "read_ahead", CTLFLAG_RW | CTLFLAG_MPSAFE,
&softc->read_ahead, 0, "Enable disk read ahead.");
@@ -1107,9 +1247,11 @@ adasysctlinit(void *context, int pending)
OID_AUTO, "write_cache", CTLFLAG_RW | CTLFLAG_MPSAFE,
&softc->write_cache, 0, "Enable disk write cache.");
SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
- OID_AUTO, "sort_io_queue", CTLFLAG_RW | CTLFLAG_MPSAFE,
- &softc->sort_io_queue, 0,
- "Sort IO queue to try and optimise disk access patterns");
+ OID_AUTO, "unmapped_io", CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &softc->unmappedio, 0, "Unmapped I/O leaf");
+ SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
+ OID_AUTO, "rotating", CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &softc->rotating, 0, "Rotating media");
#ifdef ADA_TEST_FAILURE
/*
* Add a 'door bell' sysctl which allows one to set it from userland
@@ -1129,6 +1271,31 @@ adasysctlinit(void *context, int pending)
&softc->periodic_read_error, 0,
"Force a read error every N reads (don't set too low).");
#endif
+
+#ifdef CAM_IO_STATS
+ softc->sysctl_stats_tree = SYSCTL_ADD_NODE(&softc->sysctl_stats_ctx,
+ SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "stats",
+ CTLFLAG_RD, 0, "Statistics");
+ SYSCTL_ADD_INT(&softc->sysctl_stats_ctx,
+ SYSCTL_CHILDREN(softc->sysctl_stats_tree),
+ OID_AUTO, "timeouts", CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &softc->timeouts, 0,
+ "Device timeouts reported by the SIM");
+ SYSCTL_ADD_INT(&softc->sysctl_stats_ctx,
+ SYSCTL_CHILDREN(softc->sysctl_stats_tree),
+ OID_AUTO, "errors", CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &softc->errors, 0,
+ "Transport errors reported by the SIM.");
+ SYSCTL_ADD_INT(&softc->sysctl_stats_ctx,
+ SYSCTL_CHILDREN(softc->sysctl_stats_tree),
+ OID_AUTO, "pack_invalidations", CTLFLAG_RD | CTLFLAG_MPSAFE,
+ &softc->invalidations, 0,
+ "Device pack invalidations.");
+#endif
+
+ cam_iosched_sysctl_init(softc->cam_iosched, &softc->sysctl_ctx,
+ softc->sysctl_tree);
+
cam_periph_release(periph);
}
@@ -1148,6 +1315,43 @@ adagetattr(struct bio *bp)
return ret;
}
+static int
+adadeletemethodsysctl(SYSCTL_HANDLER_ARGS)
+{
+ char buf[16];
+ const char *p;
+ struct ada_softc *softc;
+ int i, error, value, methods;
+
+ softc = (struct ada_softc *)arg1;
+
+ value = softc->delete_method;
+ if (value < 0 || value > ADA_DELETE_MAX)
+ p = "UNKNOWN";
+ else
+ p = ada_delete_method_names[value];
+ strncpy(buf, p, sizeof(buf));
+ error = sysctl_handle_string(oidp, buf, sizeof(buf), req);
+ if (error != 0 || req->newptr == NULL)
+ return (error);
+ methods = 1 << ADA_DELETE_DISABLE;
+ if ((softc->flags & ADA_FLAG_CAN_CFA) &&
+ !(softc->flags & ADA_FLAG_CAN_48BIT))
+ methods |= 1 << ADA_DELETE_CFA_ERASE;
+ if (softc->flags & ADA_FLAG_CAN_TRIM)
+ methods |= 1 << ADA_DELETE_DSM_TRIM;
+ if (softc->flags & ADA_FLAG_CAN_NCQ_TRIM)
+ methods |= 1 << ADA_DELETE_NCQ_DSM_TRIM;
+ for (i = 0; i <= ADA_DELETE_MAX; i++) {
+ if (!(methods & (1 << i)) ||
+ strcmp(buf, ada_delete_method_names[i]) != 0)
+ continue;
+ softc->delete_method = i;
+ return (0);
+ }
+ return (EINVAL);
+}
+
static cam_status
adaregister(struct cam_periph *periph, void *arg)
{
@@ -1175,8 +1379,11 @@ adaregister(struct cam_periph *periph, void *arg)
return(CAM_REQ_CMP_ERR);
}
- bioq_init(&softc->bio_queue);
- bioq_init(&softc->trim_queue);
+ if (cam_iosched_init(&softc->cam_iosched, periph) != 0) {
+ printf("adaregister: Unable to probe new device. "
+ "Unable to allocate iosched memory\n");
+ return(CAM_REQ_CMP_ERR);
+ }
if ((cgd->ident_data.capabilities1 & ATA_SUPPORT_DMA) &&
(cgd->inq_flags & SID_DMA))
@@ -1206,6 +1413,8 @@ adaregister(struct cam_periph *periph, void *arg)
if (cgd->ident_data.support.command2 & ATA_SUPPORT_CFA)
softc->flags |= ADA_FLAG_CAN_CFA;
+ adasetdeletemethod(softc);
+
periph->softc = softc;
/*
@@ -1246,10 +1455,12 @@ adaregister(struct cam_periph *periph, void *arg)
"kern.cam.ada.%d.write_cache", periph->unit_number);
TUNABLE_INT_FETCH(announce_buf, &softc->write_cache);
/* Disable queue sorting for non-rotational media by default. */
- if (cgd->ident_data.media_rotation_rate == ATA_RATE_NON_ROTATING)
- softc->sort_io_queue = 0;
- else
- softc->sort_io_queue = -1;
+ if (cgd->ident_data.media_rotation_rate == ATA_RATE_NON_ROTATING) {
+ softc->rotating = 0;
+ } else {
+ softc->rotating = 1;
+ }
+ cam_iosched_set_sort_queue(softc->cam_iosched, softc->rotating ? -1 : 0);
adagetparams(periph, cgd);
softc->disk = disk_alloc();
softc->disk->d_rotation_rate = cgd->ident_data.media_rotation_rate;
@@ -1292,8 +1503,23 @@ adaregister(struct cam_periph *periph, void *arg)
softc->disk->d_delmaxsize = 256 * softc->params.secsize;
} else
softc->disk->d_delmaxsize = maxio;
- if ((cpi.hba_misc & PIM_UNMAPPED) != 0)
+ if ((cpi.hba_misc & PIM_UNMAPPED) != 0) {
softc->disk->d_flags |= DISKFLAG_UNMAPPED_BIO;
+ softc->unmappedio = 1;
+ }
+ /*
+ * If we can do RCVSND_FPDMA_QUEUED commands, we may be able to do
+ * NCQ trims, if we support trims at all. We also need support from
+ * the sim do do things properly. Perhaps we should look at log 13
+ * dword 0 bit 0 and dword 1 bit 0 are set too...
+ */
+ if (cpi.hba_misc & PIM_NCQ_KLUDGE)
+ softc->flags |= ADA_FLAG_PIM_CAN_NCQ_TRIM;
+ if ((softc->quirks & ADA_Q_NCQ_TRIM_BROKEN) == 0 &&
+ (softc->flags & ADA_FLAG_PIM_CAN_NCQ_TRIM) != 0 &&
+ (cgd->ident_data.satacapabilities2 & ATA_SUPPORT_RCVSND_FPDMA_QUEUED) != 0 &&
+ (softc->flags & ADA_FLAG_CAN_TRIM) != 0)
+ softc->flags |= ADA_FLAG_CAN_NCQ_TRIM;
strlcpy(softc->disk->d_descr, cgd->ident_data.model,
MIN(sizeof(softc->disk->d_descr), sizeof(cgd->ident_data.model)));
strlcpy(softc->disk->d_ident, cgd->ident_data.serial,
@@ -1320,6 +1546,7 @@ adaregister(struct cam_periph *periph, void *arg)
softc->disk->d_fwsectors = softc->params.secs_per_track;
softc->disk->d_fwheads = softc->params.heads;
ata_disk_firmware_geom_adjust(softc->disk);
+ adasetdeletemethod(softc);
/*
* Acquire a reference to the periph before we register with GEOM.
@@ -1389,10 +1616,9 @@ adaregister(struct cam_periph *periph, void *arg)
return(CAM_REQ_CMP);
}
-static void
-ada_dsmtrim(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio)
+static int
+ada_dsmtrim_req_create(struct ada_softc *softc, struct bio *bp, struct trim_request *req)
{
- struct trim_request *req = &softc->trim_req;
uint64_t lastlba = (uint64_t)-1;
int c, lastcount = 0, off, ranges = 0;
@@ -1402,8 +1628,6 @@ ada_dsmtrim(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio)
uint64_t lba = bp->bio_pblkno;
int count = bp->bio_bcount / softc->params.secsize;
- bioq_remove(&softc->trim_queue, bp);
-
/* Try to extend the previous range. */
if (lba == lastlba) {
c = min(count, ATA_DSM_RANGE_MAX - lastcount);
@@ -1439,12 +1663,27 @@ ada_dsmtrim(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio)
}
lastlba = lba;
TAILQ_INSERT_TAIL(&req->bps, bp, bio_queue);
- bp = bioq_first(&softc->trim_queue);
- if (bp == NULL ||
- bp->bio_bcount / softc->params.secsize >
- (softc->trim_max_ranges - ranges) * ATA_DSM_RANGE_MAX)
+
+ bp = cam_iosched_next_trim(softc->cam_iosched);
+ if (bp == NULL)
+ break;
+ if (bp->bio_bcount / softc->params.secsize >
+ (softc->trim_max_ranges - ranges) * ATA_DSM_RANGE_MAX) {
+ cam_iosched_put_back_trim(softc->cam_iosched, bp);
break;
+ }
} while (1);
+
+ return (ranges);
+}
+
+static void
+ada_dsmtrim(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio)
+{
+ struct trim_request *req = &softc->trim_req;
+ int ranges;
+
+ ranges = ada_dsmtrim_req_create(softc, bp, req);
cam_fill_ataio(ataio,
ada_retry_count,
adadone,
@@ -1460,6 +1699,30 @@ ada_dsmtrim(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio)
}
static void
+ada_ncq_dsmtrim(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio)
+{
+ struct trim_request *req = &softc->trim_req;
+ int ranges;
+
+ ranges = ada_dsmtrim_req_create(softc, bp, req);
+ cam_fill_ataio(ataio,
+ ada_retry_count,
+ adadone,
+ CAM_DIR_OUT,
+ 0,
+ req->data,
+ ((ranges + ATA_DSM_BLK_RANGES - 1) /
+ ATA_DSM_BLK_RANGES) * ATA_DSM_BLK_SIZE,
+ ada_default_timeout * 1000);
+ ata_ncq_cmd(ataio,
+ ATA_SEND_FPDMA_QUEUED,
+ 0,
+ (ranges + ATA_DSM_BLK_RANGES - 1) / ATA_DSM_BLK_RANGES);
+ ataio->cmd.sector_count_exp = ATA_SFPDMA_DSM;
+ ataio->cmd.flags |= CAM_ATAIO_AUX_HACK;
+}
+
+static void
ada_cfaerase(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio)
{
struct trim_request *req = &softc->trim_req;
@@ -1468,7 +1731,6 @@ ada_cfaerase(struct ada_softc *softc, struct bio *bp, struct ccb_ataio *ataio)
bzero(req, sizeof(*req));
TAILQ_INIT(&req->bps);
- bioq_remove(&softc->trim_queue, bp);
TAILQ_INSERT_TAIL(&req->bps, bp, bio_queue);
cam_fill_ataio(ataio,
@@ -1499,37 +1761,14 @@ adastart(struct cam_periph *periph, union ccb *start_ccb)
struct bio *bp;
u_int8_t tag_code;
- /* Run TRIM if not running yet. */
- if (!softc->trim_running &&
- (bp = bioq_first(&softc->trim_queue)) != 0) {
- if (softc->flags & ADA_FLAG_CAN_TRIM) {
- ada_dsmtrim(softc, bp, ataio);
- } else if ((softc->flags & ADA_FLAG_CAN_CFA) &&
- !(softc->flags & ADA_FLAG_CAN_48BIT)) {
- ada_cfaerase(softc, bp, ataio);
- } else {
- /* This can happen if DMA was disabled. */
- bioq_remove(&softc->trim_queue, bp);
- biofinish(bp, NULL, EOPNOTSUPP);
- xpt_release_ccb(start_ccb);
- adaschedule(periph);
- return;
- }
- softc->trim_running = 1;
- start_ccb->ccb_h.ccb_state = ADA_CCB_TRIM;
- start_ccb->ccb_h.flags |= CAM_UNLOCKED;
- goto out;
- }
- /* Run regular command. */
- bp = bioq_first(&softc->bio_queue);
+ bp = cam_iosched_next_bio(softc->cam_iosched);
if (bp == NULL) {
xpt_release_ccb(start_ccb);
break;
}
- bioq_remove(&softc->bio_queue, bp);
- if ((bp->bio_flags & BIO_ORDERED) != 0
- || (softc->flags & ADA_FLAG_NEED_OTAG) != 0) {
+ if ((bp->bio_flags & BIO_ORDERED) != 0 ||
+ (bp->bio_cmd != BIO_DELETE && (softc->flags & ADA_FLAG_NEED_OTAG) != 0)) {
softc->flags &= ~ADA_FLAG_NEED_OTAG;
softc->flags |= ADA_FLAG_WAS_OTAG;
tag_code = 0;
@@ -1659,6 +1898,27 @@ adastart(struct cam_periph *periph, union ccb *start_ccb)
}
break;
}
+ case BIO_DELETE:
+ switch (softc->delete_method) {
+ case ADA_DELETE_NCQ_DSM_TRIM:
+ ada_ncq_dsmtrim(softc, bp, ataio);
+ break;
+ case ADA_DELETE_DSM_TRIM:
+ ada_dsmtrim(softc, bp, ataio);
+ break;
+ case ADA_DELETE_CFA_ERASE:
+ ada_cfaerase(softc, bp, ataio);
+ break;
+ default:
+ biofinish(bp, NULL, EOPNOTSUPP);
+ xpt_release_ccb(start_ccb);
+ adaschedule(periph);
+ return;
+ }
+ start_ccb->ccb_h.ccb_state = ADA_CCB_TRIM;
+ start_ccb->ccb_h.flags |= CAM_UNLOCKED;
+ cam_iosched_submit_trim(softc->cam_iosched);
+ goto out;
case BIO_FLUSH:
cam_fill_ataio(ataio,
1,
@@ -1742,6 +2002,7 @@ adadone(struct cam_periph *periph, union ccb *done_ccb)
int error;
cam_periph_lock(periph);
+ bp = (struct bio *)done_ccb->ccb_h.ccb_bp;
if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
error = adaerror(done_ccb, 0, 0);
if (error == ERESTART) {
@@ -1755,12 +2016,25 @@ adadone(struct cam_periph *periph, union ccb *done_ccb)
/*reduction*/0,
/*timeout*/0,
/*getcount_only*/0);
+ /*
+ * If we get an error on an NCQ DSM TRIM, fall back
+ * to a non-NCQ DSM TRIM forever. Please note that if
+ * CAN_NCQ_TRIM is set, CAN_TRIM is necessarily set too.
+ * However, for this one trim, we treat it as advisory
+ * and return success up the stack.
+ */
+ if (state == ADA_CCB_TRIM &&
+ error != 0 &&
+ (softc->flags & ADA_FLAG_CAN_NCQ_TRIM) != 0) {
+ softc->flags &= ~ADA_FLAG_CAN_NCQ_TRIM;
+ error = 0;
+ adasetdeletemethod(softc);
+ }
} else {
if ((done_ccb->ccb_h.status & CAM_DEV_QFRZN) != 0)
panic("REQ_CMP with QFRZN");
error = 0;
}
- bp = (struct bio *)done_ccb->ccb_h.ccb_bp;
bp->bio_error = error;
if (error != 0) {
bp->bio_resid = bp->bio_bcount;
@@ -1776,6 +2050,8 @@ adadone(struct cam_periph *periph, union ccb *done_ccb)
softc->outstanding_cmds--;
if (softc->outstanding_cmds == 0)
softc->flags |= ADA_FLAG_WAS_OTAG;
+
+ cam_iosched_bio_complete(softc->cam_iosched, bp, done_ccb);
xpt_release_ccb(done_ccb);
if (state == ADA_CCB_TRIM) {
TAILQ_HEAD(, bio) queue;
@@ -1793,7 +2069,7 @@ adadone(struct cam_periph *periph, union ccb *done_ccb)
* daschedule again so that we don't stall if there are
* no other I/Os pending apart from BIO_DELETEs.
*/
- softc->trim_running = 0;
+ cam_iosched_trim_done(softc->cam_iosched);
adaschedule(periph);
cam_periph_unlock(periph);
while ((bp1 = TAILQ_FIRST(&queue)) != NULL) {
@@ -1807,6 +2083,7 @@ adadone(struct cam_periph *periph, union ccb *done_ccb)
biodone(bp1);
}
} else {
+ adaschedule(periph);
cam_periph_unlock(periph);
biodone(bp);
}
@@ -1898,6 +2175,29 @@ out:
static int
adaerror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
{
+#ifdef CAM_IO_STATS
+ struct ada_softc *softc;
+ struct cam_periph *periph;
+
+ periph = xpt_path_periph(ccb->ccb_h.path);
+ softc = (struct ada_softc *)periph->softc;
+
+ switch (ccb->ccb_h.status & CAM_STATUS_MASK) {
+ case CAM_CMD_TIMEOUT:
+ softc->timeouts++;
+ break;
+ case CAM_REQ_ABORTED:
+ case CAM_REQ_CMP_ERR:
+ case CAM_REQ_TERMIO:
+ case CAM_UNREC_HBA_ERROR:
+ case CAM_DATA_RUN_ERR:
+ case CAM_ATA_STATUS_ERROR:
+ softc->errors++;
+ break;
+ default:
+ break;
+ }
+#endif
return(cam_periph_error(ccb, cam_flags, sense_flags, NULL));
}
diff --git a/sys/cam/cam.c b/sys/cam/cam.c
index 1f627ef..5061dd6 100644
--- a/sys/cam/cam.c
+++ b/sys/cam/cam.c
@@ -412,7 +412,8 @@ cam_error_string(struct cam_device *device, union ccb *ccb, char *str,
}
if (proto_flags & CAM_EAF_PRINT_RESULT) {
sbuf_cat(&sb, path_str);
- ata_res_sbuf(&ccb->ataio, &sb);
+ sbuf_printf(&sb, "RES: ");
+ ata_res_sbuf(&ccb->ataio.res, &sb);
sbuf_printf(&sb, "\n");
}
diff --git a/sys/cam/cam_ccb.h b/sys/cam/cam_ccb.h
index 28415ed..c739aa6 100644
--- a/sys/cam/cam_ccb.h
+++ b/sys/cam/cam_ccb.h
@@ -581,6 +581,7 @@ typedef enum {
} pi_tmflag;
typedef enum {
+ PIM_NCQ_KLUDGE = 0x200, /* Supports the sata ncq trim kludge */
PIM_EXTLUNS = 0x100,/* 64bit extended LUNs supported */
PIM_SCANHILO = 0x80, /* Bus scans from high ID to low ID */
PIM_NOREMOVE = 0x40, /* Removeable devices not included in scan */
diff --git a/sys/cam/cam_iosched.c b/sys/cam/cam_iosched.c
new file mode 100644
index 0000000..8e78663
--- /dev/null
+++ b/sys/cam/cam_iosched.c
@@ -0,0 +1,1603 @@
+/*-
+ * CAM IO Scheduler Interface
+ *
+ * Copyright (c) 2015 Netflix, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification, immediately at the beginning of the file.
+ * 2. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#include "opt_cam.h"
+#include "opt_ddb.h"
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bio.h>
+#include <sys/lock.h>
+#include <sys/malloc.h>
+#include <sys/mutex.h>
+#include <sys/sysctl.h>
+
+#include <cam/cam.h>
+#include <cam/cam_ccb.h>
+#include <cam/cam_periph.h>
+#include <cam/cam_xpt_periph.h>
+#include <cam/cam_iosched.h>
+
+#include <ddb/ddb.h>
+
+static MALLOC_DEFINE(M_CAMSCHED, "CAM I/O Scheduler",
+ "CAM I/O Scheduler buffers");
+
+/*
+ * Default I/O scheduler for FreeBSD. This implementation is just a thin-vineer
+ * over the bioq_* interface, with notions of separate calls for normal I/O and
+ * for trims.
+ */
+
+#ifdef CAM_NETFLIX_IOSCHED
+
+SYSCTL_DECL(_kern_cam);
+static int do_netflix_iosched = 1;
+TUNABLE_INT("kern.cam.do_netflix_iosched", &do_netflix_iosched);
+SYSCTL_INT(_kern_cam, OID_AUTO, do_netflix_iosched, CTLFLAG_RD,
+ &do_netflix_iosched, 1,
+ "Enable Netflix I/O scheduler optimizations.");
+
+static int alpha_bits = 9;
+TUNABLE_INT("kern.cam.iosched_alpha_bits", &alpha_bits);
+SYSCTL_INT(_kern_cam, OID_AUTO, iosched_alpha_bits, CTLFLAG_RW,
+ &alpha_bits, 1,
+ "Bits in EMA's alpha.");
+
+
+
+struct iop_stats;
+struct cam_iosched_softc;
+
+int iosched_debug = 0;
+
+typedef enum {
+ none = 0, /* No limits */
+ queue_depth, /* Limit how many ops we queue to SIM */
+ iops, /* Limit # of IOPS to the drive */
+ bandwidth, /* Limit bandwidth to the drive */
+ limiter_max
+} io_limiter;
+
+static const char *cam_iosched_limiter_names[] =
+ { "none", "queue_depth", "iops", "bandwidth" };
+
+/*
+ * Called to initialize the bits of the iop_stats structure relevant to the
+ * limiter. Called just after the limiter is set.
+ */
+typedef int l_init_t(struct iop_stats *);
+
+/*
+ * Called every tick.
+ */
+typedef int l_tick_t(struct iop_stats *);
+
+/*
+ * Called to see if the limiter thinks this IOP can be allowed to
+ * proceed. If so, the limiter assumes that the while IOP proceeded
+ * and makes any accounting of it that's needed.
+ */
+typedef int l_iop_t(struct iop_stats *, struct bio *);
+
+/*
+ * Called when an I/O completes so the limiter can updates its
+ * accounting. Pending I/Os may complete in any order (even when
+ * sent to the hardware at the same time), so the limiter may not
+ * make any assumptions other than this I/O has completed. If it
+ * returns 1, then xpt_schedule() needs to be called again.
+ */
+typedef int l_iodone_t(struct iop_stats *, struct bio *);
+
+static l_iop_t cam_iosched_qd_iop;
+static l_iop_t cam_iosched_qd_caniop;
+static l_iodone_t cam_iosched_qd_iodone;
+
+static l_init_t cam_iosched_iops_init;
+static l_tick_t cam_iosched_iops_tick;
+static l_iop_t cam_iosched_iops_caniop;
+static l_iop_t cam_iosched_iops_iop;
+
+static l_init_t cam_iosched_bw_init;
+static l_tick_t cam_iosched_bw_tick;
+static l_iop_t cam_iosched_bw_caniop;
+static l_iop_t cam_iosched_bw_iop;
+
+struct limswitch
+{
+ l_init_t *l_init;
+ l_tick_t *l_tick;
+ l_iop_t *l_iop;
+ l_iop_t *l_caniop;
+ l_iodone_t *l_iodone;
+} limsw[] =
+{
+ { /* none */
+ .l_init = NULL,
+ .l_tick = NULL,
+ .l_iop = NULL,
+ .l_iodone= NULL,
+ },
+ { /* queue_depth */
+ .l_init = NULL,
+ .l_tick = NULL,
+ .l_caniop = cam_iosched_qd_caniop,
+ .l_iop = cam_iosched_qd_iop,
+ .l_iodone= cam_iosched_qd_iodone,
+ },
+ { /* iops */
+ .l_init = cam_iosched_iops_init,
+ .l_tick = cam_iosched_iops_tick,
+ .l_caniop = cam_iosched_iops_caniop,
+ .l_iop = cam_iosched_iops_iop,
+ .l_iodone= NULL,
+ },
+ { /* bandwidth */
+ .l_init = cam_iosched_bw_init,
+ .l_tick = cam_iosched_bw_tick,
+ .l_caniop = cam_iosched_bw_caniop,
+ .l_iop = cam_iosched_bw_iop,
+ .l_iodone= NULL,
+ },
+};
+
+struct iop_stats
+{
+ /*
+ * sysctl state for this subnode.
+ */
+ struct sysctl_ctx_list sysctl_ctx;
+ struct sysctl_oid *sysctl_tree;
+
+ /*
+ * Information about the current rate limiters, if any
+ */
+ io_limiter limiter; /* How are I/Os being limited */
+ int min; /* Low range of limit */
+ int max; /* High range of limit */
+ int current; /* Current rate limiter */
+ int l_value1; /* per-limiter scratch value 1. */
+ int l_value2; /* per-limiter scratch value 2. */
+
+
+ /*
+ * Debug information about counts of I/Os that have gone through the
+ * scheduler.
+ */
+ int pending; /* I/Os pending in the hardware */
+ int queued; /* number currently in the queue */
+ int total; /* Total for all time -- wraps */
+ int in; /* number queued all time -- wraps */
+ int out; /* number completed all time -- wraps */
+
+ /*
+ * Statistics on different bits of the process.
+ */
+ /* Exp Moving Average, alpha = 1 / (1 << alpha_bits) */
+ sbintime_t ema;
+ sbintime_t emss; /* Exp Moving sum of the squares */
+ sbintime_t sd; /* Last computed sd */
+
+ struct cam_iosched_softc *softc;
+};
+
+
+typedef enum {
+ set_max = 0, /* current = max */
+ read_latency, /* Steer read latency by throttling writes */
+ cl_max /* Keep last */
+} control_type;
+
+static const char *cam_iosched_control_type_names[] =
+ { "set_max", "read_latency" };
+
+struct control_loop
+{
+ /*
+ * sysctl state for this subnode.
+ */
+ struct sysctl_ctx_list sysctl_ctx;
+ struct sysctl_oid *sysctl_tree;
+
+ sbintime_t next_steer; /* Time of next steer */
+ sbintime_t steer_interval; /* How often do we steer? */
+ sbintime_t lolat;
+ sbintime_t hilat;
+ int alpha;
+ control_type type; /* What type of control? */
+ int last_count; /* Last I/O count */
+
+ struct cam_iosched_softc *softc;
+};
+
+#endif
+
+struct cam_iosched_softc
+{
+ struct bio_queue_head bio_queue;
+ struct bio_queue_head trim_queue;
+ /* scheduler flags < 16, user flags >= 16 */
+ uint32_t flags;
+ int sort_io_queue;
+#ifdef CAM_NETFLIX_IOSCHED
+ int read_bias; /* Read bias setting */
+ int current_read_bias; /* Current read bias state */
+ int total_ticks;
+
+ struct bio_queue_head write_queue;
+ struct iop_stats read_stats, write_stats, trim_stats;
+ struct sysctl_ctx_list sysctl_ctx;
+ struct sysctl_oid *sysctl_tree;
+
+ int quanta; /* Number of quanta per second */
+ struct callout ticker; /* Callout for our quota system */
+ struct cam_periph *periph; /* cam periph associated with this device */
+ uint32_t this_frac; /* Fraction of a second (1024ths) for this tick */
+ sbintime_t last_time; /* Last time we ticked */
+ struct control_loop cl;
+#endif
+};
+
+#ifdef CAM_NETFLIX_IOSCHED
+/*
+ * helper functions to call the limsw functions.
+ */
+static int
+cam_iosched_limiter_init(struct iop_stats *ios)
+{
+ int lim = ios->limiter;
+
+ /* maybe this should be a kassert */
+ if (lim < none || lim >= limiter_max)
+ return EINVAL;
+
+ if (limsw[lim].l_init)
+ return limsw[lim].l_init(ios);
+
+ return 0;
+}
+
+static int
+cam_iosched_limiter_tick(struct iop_stats *ios)
+{
+ int lim = ios->limiter;
+
+ /* maybe this should be a kassert */
+ if (lim < none || lim >= limiter_max)
+ return EINVAL;
+
+ if (limsw[lim].l_tick)
+ return limsw[lim].l_tick(ios);
+
+ return 0;
+}
+
+static int
+cam_iosched_limiter_iop(struct iop_stats *ios, struct bio *bp)
+{
+ int lim = ios->limiter;
+
+ /* maybe this should be a kassert */
+ if (lim < none || lim >= limiter_max)
+ return EINVAL;
+
+ if (limsw[lim].l_iop)
+ return limsw[lim].l_iop(ios, bp);
+
+ return 0;
+}
+
+static int
+cam_iosched_limiter_caniop(struct iop_stats *ios, struct bio *bp)
+{
+ int lim = ios->limiter;
+
+ /* maybe this should be a kassert */
+ if (lim < none || lim >= limiter_max)
+ return EINVAL;
+
+ if (limsw[lim].l_caniop)
+ return limsw[lim].l_caniop(ios, bp);
+
+ return 0;
+}
+
+static int
+cam_iosched_limiter_iodone(struct iop_stats *ios, struct bio *bp)
+{
+ int lim = ios->limiter;
+
+ /* maybe this should be a kassert */
+ if (lim < none || lim >= limiter_max)
+ return 0;
+
+ if (limsw[lim].l_iodone)
+ return limsw[lim].l_iodone(ios, bp);
+
+ return 0;
+}
+
+/*
+ * Functions to implement the different kinds of limiters
+ */
+
+static int
+cam_iosched_qd_iop(struct iop_stats *ios, struct bio *bp)
+{
+
+ if (ios->current <= 0 || ios->pending < ios->current)
+ return 0;
+
+ return EAGAIN;
+}
+
+static int
+cam_iosched_qd_caniop(struct iop_stats *ios, struct bio *bp)
+{
+
+ if (ios->current <= 0 || ios->pending < ios->current)
+ return 0;
+
+ return EAGAIN;
+}
+
+static int
+cam_iosched_qd_iodone(struct iop_stats *ios, struct bio *bp)
+{
+
+ if (ios->current <= 0 || ios->pending != ios->current)
+ return 0;
+
+ return 1;
+}
+
+static int
+cam_iosched_iops_init(struct iop_stats *ios)
+{
+
+ ios->l_value1 = ios->current / ios->softc->quanta;
+ if (ios->l_value1 <= 0)
+ ios->l_value1 = 1;
+
+ return 0;
+}
+
+static int
+cam_iosched_iops_tick(struct iop_stats *ios)
+{
+
+ ios->l_value1 = (int)((ios->current * (uint64_t)ios->softc->this_frac) >> 16);
+ if (ios->l_value1 <= 0)
+ ios->l_value1 = 1;
+
+ return 0;
+}
+
+static int
+cam_iosched_iops_caniop(struct iop_stats *ios, struct bio *bp)
+{
+
+ /*
+ * So if we have any more IOPs left, allow it,
+ * otherwise wait.
+ */
+ if (ios->l_value1 <= 0)
+ return EAGAIN;
+ return 0;
+}
+
+static int
+cam_iosched_iops_iop(struct iop_stats *ios, struct bio *bp)
+{
+ int rv;
+
+ rv = cam_iosched_limiter_caniop(ios, bp);
+ if (rv == 0)
+ ios->l_value1--;
+
+ return rv;
+}
+
+static int
+cam_iosched_bw_init(struct iop_stats *ios)
+{
+
+ /* ios->current is in kB/s, so scale to bytes */
+ ios->l_value1 = ios->current * 1000 / ios->softc->quanta;
+
+ return 0;
+}
+
+static int
+cam_iosched_bw_tick(struct iop_stats *ios)
+{
+ int bw;
+
+ /*
+ * If we're in the hole for available quota from
+ * the last time, then add the quantum for this.
+ * If we have any left over from last quantum,
+ * then too bad, that's lost. Also, ios->current
+ * is in kB/s, so scale.
+ *
+ * We also allow up to 4 quanta of credits to
+ * accumulate to deal with burstiness. 4 is extremely
+ * arbitrary.
+ */
+ bw = (int)((ios->current * 1000ull * (uint64_t)ios->softc->this_frac) >> 16);
+ if (ios->l_value1 < bw * 4)
+ ios->l_value1 += bw;
+
+ return 0;
+}
+
+static int
+cam_iosched_bw_caniop(struct iop_stats *ios, struct bio *bp)
+{
+ /*
+ * So if we have any more bw quota left, allow it,
+ * otherwise wait. Not, we'll go negative and that's
+ * OK. We'll just get a lettle less next quota.
+ *
+ * Note on going negative: that allows us to process
+ * requests in order better, since we won't allow
+ * shorter reads to get around the long one that we
+ * don't have the quota to do just yet. It also prevents
+ * starvation by being a little more permissive about
+ * what we let through this quantum (to prevent the
+ * starvation), at the cost of getting a little less
+ * next quantum.
+ */
+ if (ios->l_value1 <= 0)
+ return EAGAIN;
+
+
+ return 0;
+}
+
+static int
+cam_iosched_bw_iop(struct iop_stats *ios, struct bio *bp)
+{
+ int rv;
+
+ rv = cam_iosched_limiter_caniop(ios, bp);
+ if (rv == 0)
+ ios->l_value1 -= bp->bio_length;
+
+ return rv;
+}
+
+static void cam_iosched_cl_maybe_steer(struct control_loop *clp);
+
+static void
+cam_iosched_ticker(void *arg)
+{
+ struct cam_iosched_softc *isc = arg;
+ sbintime_t now, delta;
+
+ callout_reset(&isc->ticker, hz / isc->quanta - 1, cam_iosched_ticker, isc);
+
+ now = sbinuptime();
+ delta = now - isc->last_time;
+ isc->this_frac = (uint32_t)delta >> 16; /* Note: discards seconds -- should be 0 harmless if not */
+ isc->last_time = now;
+
+ cam_iosched_cl_maybe_steer(&isc->cl);
+
+ cam_iosched_limiter_tick(&isc->read_stats);
+ cam_iosched_limiter_tick(&isc->write_stats);
+ cam_iosched_limiter_tick(&isc->trim_stats);
+
+ cam_iosched_schedule(isc, isc->periph);
+
+ isc->total_ticks++;
+}
+
+
+static void
+cam_iosched_cl_init(struct control_loop *clp, struct cam_iosched_softc *isc)
+{
+
+ clp->next_steer = sbinuptime();
+ clp->softc = isc;
+ clp->steer_interval = SBT_1S * 5; /* Let's start out steering every 5s */
+ clp->lolat = 5 * SBT_1MS;
+ clp->hilat = 15 * SBT_1MS;
+ clp->alpha = 20; /* Alpha == gain. 20 = .2 */
+ clp->type = set_max;
+}
+
+static void
+cam_iosched_cl_maybe_steer(struct control_loop *clp)
+{
+ struct cam_iosched_softc *isc;
+ sbintime_t now, lat;
+ int old;
+
+ isc = clp->softc;
+ now = isc->last_time;
+ if (now < clp->next_steer)
+ return;
+
+ clp->next_steer = now + clp->steer_interval;
+ switch (clp->type) {
+ case set_max:
+ if (isc->write_stats.current != isc->write_stats.max)
+ printf("Steering write from %d kBps to %d kBps\n",
+ isc->write_stats.current, isc->write_stats.max);
+ isc->read_stats.current = isc->read_stats.max;
+ isc->write_stats.current = isc->write_stats.max;
+ isc->trim_stats.current = isc->trim_stats.max;
+ break;
+ case read_latency:
+ old = isc->write_stats.current;
+ lat = isc->read_stats.ema;
+ /*
+ * Simple PLL-like engine. Since we're steering to a range for
+ * the SP (set point) that makes things a little more
+ * complicated. In addition, we're not directly controlling our
+ * PV (process variable), the read latency, but instead are
+ * manipulating the write bandwidth limit for our MV
+ * (manipulation variable), analysis of this code gets a bit
+ * messy. Also, the MV is a very noisy control surface for read
+ * latency since it is affected by many hidden processes inside
+ * the device which change how responsive read latency will be
+ * in reaction to changes in write bandwidth. Unlike the classic
+ * boiler control PLL. this may result in over-steering while
+ * the SSD takes its time to react to the new, lower load. This
+ * is why we use a relatively low alpha of between .1 and .25 to
+ * compensate for this effect. At .1, it takes ~22 steering
+ * intervals to back off by a factor of 10. At .2 it only takes
+ * ~10. At .25 it only takes ~8. However some preliminary data
+ * from the SSD drives suggests a reasponse time in 10's of
+ * seconds before latency drops regardless of the new write
+ * rate. Careful observation will be reqiured to tune this
+ * effectively.
+ *
+ * Also, when there's no read traffic, we jack up the write
+ * limit too regardless of the last read latency. 10 is
+ * somewhat arbitrary.
+ */
+ if (lat < clp->lolat || isc->read_stats.total - clp->last_count < 10)
+ isc->write_stats.current = isc->write_stats.current *
+ (100 + clp->alpha) / 100; /* Scale up */
+ else if (lat > clp->hilat)
+ isc->write_stats.current = isc->write_stats.current *
+ (100 - clp->alpha) / 100; /* Scale down */
+ clp->last_count = isc->read_stats.total;
+
+ /*
+ * Even if we don't steer, per se, enforce the min/max limits as
+ * those may have changed.
+ */
+ if (isc->write_stats.current < isc->write_stats.min)
+ isc->write_stats.current = isc->write_stats.min;
+ if (isc->write_stats.current > isc->write_stats.max)
+ isc->write_stats.current = isc->write_stats.max;
+ if (old != isc->write_stats.current)
+ printf("Steering write from %d kBps to %d kBps due to latency of %ldus\n",
+ old, isc->write_stats.current,
+ ((uint64_t)1000000 * (uint32_t)lat) >> 32);
+ break;
+ case cl_max:
+ break;
+ }
+}
+#endif
+
+ /* Trim or similar currently pending completion */
+#define CAM_IOSCHED_FLAG_TRIM_ACTIVE (1ul << 0)
+ /* Callout active, and needs to be torn down */
+#define CAM_IOSCHED_FLAG_CALLOUT_ACTIVE (1ul << 1)
+
+ /* Periph drivers set these flags to indicate work */
+#define CAM_IOSCHED_FLAG_WORK_FLAGS ((0xffffu) << 16)
+
+#ifdef CAM_NETFLIX_IOSCHED
+static void
+cam_iosched_io_metric_update(struct cam_iosched_softc *isc,
+ sbintime_t sim_latency, int cmd, size_t size);
+#endif
+
+static inline int
+cam_iosched_has_flagged_work(struct cam_iosched_softc *isc)
+{
+ return !!(isc->flags & CAM_IOSCHED_FLAG_WORK_FLAGS);
+}
+
+static inline int
+cam_iosched_has_io(struct cam_iosched_softc *isc)
+{
+#ifdef CAM_NETFLIX_IOSCHED
+ if (do_netflix_iosched) {
+ struct bio *rbp = bioq_first(&isc->bio_queue);
+ struct bio *wbp = bioq_first(&isc->write_queue);
+ int can_write = wbp != NULL &&
+ cam_iosched_limiter_caniop(&isc->write_stats, wbp) == 0;
+ int can_read = rbp != NULL &&
+ cam_iosched_limiter_caniop(&isc->read_stats, rbp) == 0;
+ if (iosched_debug > 2) {
+ printf("can write %d: pending_writes %d max_writes %d\n", can_write, isc->write_stats.pending, isc->write_stats.max);
+ printf("can read %d: read_stats.pending %d max_reads %d\n", can_read, isc->read_stats.pending, isc->read_stats.max);
+ printf("Queued reads %d writes %d\n", isc->read_stats.queued, isc->write_stats.queued);
+ }
+ return can_read || can_write;
+ }
+#endif
+ return bioq_first(&isc->bio_queue) != NULL;
+}
+
+static inline int
+cam_iosched_has_more_trim(struct cam_iosched_softc *isc)
+{
+ return !(isc->flags & CAM_IOSCHED_FLAG_TRIM_ACTIVE) &&
+ bioq_first(&isc->trim_queue);
+}
+
+#define cam_iosched_sort_queue(isc) ((isc)->sort_io_queue >= 0 ? \
+ (isc)->sort_io_queue : cam_sort_io_queues)
+
+
+static inline int
+cam_iosched_has_work(struct cam_iosched_softc *isc)
+{
+#ifdef CAM_NETFLIX_IOSCHED
+ if (iosched_debug > 2)
+ printf("has work: %d %d %d\n", cam_iosched_has_io(isc),
+ cam_iosched_has_more_trim(isc),
+ cam_iosched_has_flagged_work(isc));
+#endif
+
+ return cam_iosched_has_io(isc) ||
+ cam_iosched_has_more_trim(isc) ||
+ cam_iosched_has_flagged_work(isc);
+}
+
+#ifdef CAM_NETFLIX_IOSCHED
+static void
+cam_iosched_iop_stats_init(struct cam_iosched_softc *isc, struct iop_stats *ios)
+{
+
+ ios->limiter = none;
+ cam_iosched_limiter_init(ios);
+ ios->in = 0;
+ ios->max = 300000;
+ ios->min = 1;
+ ios->out = 0;
+ ios->pending = 0;
+ ios->queued = 0;
+ ios->total = 0;
+ ios->ema = 0;
+ ios->emss = 0;
+ ios->sd = 0;
+ ios->softc = isc;
+}
+
+static int
+cam_iosched_limiter_sysctl(SYSCTL_HANDLER_ARGS)
+{
+ char buf[16];
+ struct iop_stats *ios;
+ struct cam_iosched_softc *isc;
+ int value, i, error, cantick;
+ const char *p;
+
+ ios = arg1;
+ isc = ios->softc;
+ value = ios->limiter;
+ if (value < none || value >= limiter_max)
+ p = "UNKNOWN";
+ else
+ p = cam_iosched_limiter_names[value];
+
+ strlcpy(buf, p, sizeof(buf));
+ error = sysctl_handle_string(oidp, buf, sizeof(buf), req);
+ if (error != 0 || req->newptr == NULL)
+ return error;
+
+ cam_periph_lock(isc->periph);
+
+ for (i = none; i < limiter_max; i++) {
+ if (strcmp(buf, cam_iosched_limiter_names[i]) != 0)
+ continue;
+ ios->limiter = i;
+ error = cam_iosched_limiter_init(ios);
+ if (error != 0) {
+ ios->limiter = value;
+ cam_periph_unlock(isc->periph);
+ return error;
+ }
+ cantick = !!limsw[isc->read_stats.limiter].l_tick +
+ !!limsw[isc->write_stats.limiter].l_tick +
+ !!limsw[isc->trim_stats.limiter].l_tick +
+ 1; /* Control loop requires it */
+ if (isc->flags & CAM_IOSCHED_FLAG_CALLOUT_ACTIVE) {
+ if (cantick == 0) {
+ callout_stop(&isc->ticker);
+ isc->flags &= ~CAM_IOSCHED_FLAG_CALLOUT_ACTIVE;
+ }
+ } else {
+ if (cantick != 0) {
+ callout_reset(&isc->ticker, hz / isc->quanta - 1, cam_iosched_ticker, isc);
+ isc->flags |= CAM_IOSCHED_FLAG_CALLOUT_ACTIVE;
+ }
+ }
+
+ cam_periph_unlock(isc->periph);
+ return 0;
+ }
+
+ cam_periph_unlock(isc->periph);
+ return EINVAL;
+}
+
+static int
+cam_iosched_control_type_sysctl(SYSCTL_HANDLER_ARGS)
+{
+ char buf[16];
+ struct control_loop *clp;
+ struct cam_iosched_softc *isc;
+ int value, i, error;
+ const char *p;
+
+ clp = arg1;
+ isc = clp->softc;
+ value = clp->type;
+ if (value < none || value >= cl_max)
+ p = "UNKNOWN";
+ else
+ p = cam_iosched_control_type_names[value];
+
+ strlcpy(buf, p, sizeof(buf));
+ error = sysctl_handle_string(oidp, buf, sizeof(buf), req);
+ if (error != 0 || req->newptr == NULL)
+ return error;
+
+ for (i = set_max; i < cl_max; i++) {
+ if (strcmp(buf, cam_iosched_control_type_names[i]) != 0)
+ continue;
+ cam_periph_lock(isc->periph);
+ clp->type = i;
+ cam_periph_unlock(isc->periph);
+ return 0;
+ }
+
+ return EINVAL;
+}
+
+static int
+cam_iosched_sbintime_sysctl(SYSCTL_HANDLER_ARGS)
+{
+ char buf[16];
+ sbintime_t value;
+ int error;
+ uint64_t us;
+
+ value = *(sbintime_t *)arg1;
+ us = (uint64_t)value / SBT_1US;
+ snprintf(buf, sizeof(buf), "%ju", (intmax_t)us);
+ error = sysctl_handle_string(oidp, buf, sizeof(buf), req);
+ if (error != 0 || req->newptr == NULL)
+ return error;
+ us = strtoul(buf, NULL, 10);
+ if (us == 0)
+ return EINVAL;
+ *(sbintime_t *)arg1 = us * SBT_1US;
+ return 0;
+}
+
+static void
+cam_iosched_iop_stats_sysctl_init(struct cam_iosched_softc *isc, struct iop_stats *ios, char *name)
+{
+ struct sysctl_oid_list *n;
+ struct sysctl_ctx_list *ctx;
+
+ ios->sysctl_tree = SYSCTL_ADD_NODE(&isc->sysctl_ctx,
+ SYSCTL_CHILDREN(isc->sysctl_tree), OID_AUTO, name,
+ CTLFLAG_RD, 0, name);
+ n = SYSCTL_CHILDREN(ios->sysctl_tree);
+ ctx = &ios->sysctl_ctx;
+
+ SYSCTL_ADD_UQUAD(ctx, n,
+ OID_AUTO, "ema", CTLFLAG_RD,
+ &ios->ema,
+ "Fast Exponentially Weighted Moving Average");
+ SYSCTL_ADD_UQUAD(ctx, n,
+ OID_AUTO, "emss", CTLFLAG_RD,
+ &ios->emss,
+ "Fast Exponentially Weighted Moving Sum of Squares (maybe wrong)");
+ SYSCTL_ADD_UQUAD(ctx, n,
+ OID_AUTO, "sd", CTLFLAG_RD,
+ &ios->sd,
+ "Estimated SD for fast ema (may be wrong)");
+
+ SYSCTL_ADD_INT(ctx, n,
+ OID_AUTO, "pending", CTLFLAG_RD,
+ &ios->pending, 0,
+ "Instantaneous # of pending transactions");
+ SYSCTL_ADD_INT(ctx, n,
+ OID_AUTO, "count", CTLFLAG_RD,
+ &ios->total, 0,
+ "# of transactions submitted to hardware");
+ SYSCTL_ADD_INT(ctx, n,
+ OID_AUTO, "queued", CTLFLAG_RD,
+ &ios->queued, 0,
+ "# of transactions in the queue");
+ SYSCTL_ADD_INT(ctx, n,
+ OID_AUTO, "in", CTLFLAG_RD,
+ &ios->in, 0,
+ "# of transactions queued to driver");
+ SYSCTL_ADD_INT(ctx, n,
+ OID_AUTO, "out", CTLFLAG_RD,
+ &ios->out, 0,
+ "# of transactions completed");
+
+ SYSCTL_ADD_PROC(ctx, n,
+ OID_AUTO, "limiter", CTLTYPE_STRING | CTLFLAG_RW,
+ ios, 0, cam_iosched_limiter_sysctl, "A",
+ "Current limiting type.");
+ SYSCTL_ADD_INT(ctx, n,
+ OID_AUTO, "min", CTLFLAG_RW,
+ &ios->min, 0,
+ "min resource");
+ SYSCTL_ADD_INT(ctx, n,
+ OID_AUTO, "max", CTLFLAG_RW,
+ &ios->max, 0,
+ "max resource");
+ SYSCTL_ADD_INT(ctx, n,
+ OID_AUTO, "current", CTLFLAG_RW,
+ &ios->current, 0,
+ "current resource");
+
+}
+
+static void
+cam_iosched_iop_stats_fini(struct iop_stats *ios)
+{
+ if (ios->sysctl_tree)
+ if (sysctl_ctx_free(&ios->sysctl_ctx) != 0)
+ printf("can't remove iosched sysctl stats context\n");
+}
+
+static void
+cam_iosched_cl_sysctl_init(struct cam_iosched_softc *isc)
+{
+ struct sysctl_oid_list *n;
+ struct sysctl_ctx_list *ctx;
+ struct control_loop *clp;
+
+ clp = &isc->cl;
+ clp->sysctl_tree = SYSCTL_ADD_NODE(&isc->sysctl_ctx,
+ SYSCTL_CHILDREN(isc->sysctl_tree), OID_AUTO, "control",
+ CTLFLAG_RD, 0, "Control loop info");
+ n = SYSCTL_CHILDREN(clp->sysctl_tree);
+ ctx = &clp->sysctl_ctx;
+
+ SYSCTL_ADD_PROC(ctx, n,
+ OID_AUTO, "type", CTLTYPE_STRING | CTLFLAG_RW,
+ clp, 0, cam_iosched_control_type_sysctl, "A",
+ "Control loop algorithm");
+ SYSCTL_ADD_PROC(ctx, n,
+ OID_AUTO, "steer_interval", CTLTYPE_STRING | CTLFLAG_RW,
+ &clp->steer_interval, 0, cam_iosched_sbintime_sysctl, "A",
+ "How often to steer (in us)");
+ SYSCTL_ADD_PROC(ctx, n,
+ OID_AUTO, "lolat", CTLTYPE_STRING | CTLFLAG_RW,
+ &clp->lolat, 0, cam_iosched_sbintime_sysctl, "A",
+ "Low water mark for Latency (in us)");
+ SYSCTL_ADD_PROC(ctx, n,
+ OID_AUTO, "hilat", CTLTYPE_STRING | CTLFLAG_RW,
+ &clp->hilat, 0, cam_iosched_sbintime_sysctl, "A",
+ "Hi water mark for Latency (in us)");
+ SYSCTL_ADD_INT(ctx, n,
+ OID_AUTO, "alpha", CTLFLAG_RW,
+ &clp->alpha, 0,
+ "Alpha for PLL (x100) aka gain");
+}
+
+static void
+cam_iosched_cl_sysctl_fini(struct control_loop *clp)
+{
+ if (clp->sysctl_tree)
+ if (sysctl_ctx_free(&clp->sysctl_ctx) != 0)
+ printf("can't remove iosched sysctl control loop context\n");
+}
+#endif
+
+/*
+ * Allocate the iosched structure. This also insulates callers from knowing
+ * sizeof struct cam_iosched_softc.
+ */
+int
+cam_iosched_init(struct cam_iosched_softc **iscp, struct cam_periph *periph)
+{
+
+ *iscp = malloc(sizeof(**iscp), M_CAMSCHED, M_NOWAIT | M_ZERO);
+ if (*iscp == NULL)
+ return ENOMEM;
+#ifdef CAM_NETFLIX_IOSCHED
+ if (iosched_debug)
+ printf("CAM IOSCHEDULER Allocating entry at %p\n", *iscp);
+#endif
+ (*iscp)->sort_io_queue = -1;
+ bioq_init(&(*iscp)->bio_queue);
+ bioq_init(&(*iscp)->trim_queue);
+#ifdef CAM_NETFLIX_IOSCHED
+ if (do_netflix_iosched) {
+ bioq_init(&(*iscp)->write_queue);
+ (*iscp)->read_bias = 100;
+ (*iscp)->current_read_bias = 100;
+ (*iscp)->quanta = 200;
+ cam_iosched_iop_stats_init(*iscp, &(*iscp)->read_stats);
+ cam_iosched_iop_stats_init(*iscp, &(*iscp)->write_stats);
+ cam_iosched_iop_stats_init(*iscp, &(*iscp)->trim_stats);
+ (*iscp)->trim_stats.max = 1; /* Trims are special: one at a time for now */
+ (*iscp)->last_time = sbinuptime();
+ callout_init_mtx(&(*iscp)->ticker, cam_periph_mtx(periph), 0);
+ (*iscp)->periph = periph;
+ cam_iosched_cl_init(&(*iscp)->cl, *iscp);
+ callout_reset(&(*iscp)->ticker, hz / (*iscp)->quanta - 1, cam_iosched_ticker, *iscp);
+ (*iscp)->flags |= CAM_IOSCHED_FLAG_CALLOUT_ACTIVE;
+ }
+#endif
+
+ return 0;
+}
+
+/*
+ * Reclaim all used resources. This assumes that other folks have
+ * drained the requests in the hardware. Maybe an unwise assumption.
+ */
+void
+cam_iosched_fini(struct cam_iosched_softc *isc)
+{
+ if (isc) {
+ cam_iosched_flush(isc, NULL, ENXIO);
+#ifdef CAM_NETFLIX_IOSCHED
+ cam_iosched_iop_stats_fini(&isc->read_stats);
+ cam_iosched_iop_stats_fini(&isc->write_stats);
+ cam_iosched_iop_stats_fini(&isc->trim_stats);
+ cam_iosched_cl_sysctl_fini(&isc->cl);
+ if (isc->sysctl_tree)
+ if (sysctl_ctx_free(&isc->sysctl_ctx) != 0)
+ printf("can't remove iosched sysctl stats context\n");
+ if (isc->flags & CAM_IOSCHED_FLAG_CALLOUT_ACTIVE) {
+ callout_drain(&isc->ticker);
+ isc->flags &= ~ CAM_IOSCHED_FLAG_CALLOUT_ACTIVE;
+ }
+
+#endif
+ free(isc, M_CAMSCHED);
+ }
+}
+
+/*
+ * After we're sure we're attaching a device, go ahead and add
+ * hooks for any sysctl we may wish to honor.
+ */
+void cam_iosched_sysctl_init(struct cam_iosched_softc *isc,
+ struct sysctl_ctx_list *ctx, struct sysctl_oid *node)
+{
+#ifdef CAM_NETFLIX_IOSCHED
+ struct sysctl_oid_list *n;
+#endif
+
+ SYSCTL_ADD_INT(ctx, SYSCTL_CHILDREN(node),
+ OID_AUTO, "sort_io_queue", CTLFLAG_RW | CTLFLAG_MPSAFE,
+ &isc->sort_io_queue, 0,
+ "Sort IO queue to try and optimise disk access patterns");
+
+#ifdef CAM_NETFLIX_IOSCHED
+ if (!do_netflix_iosched)
+ return;
+
+ isc->sysctl_tree = SYSCTL_ADD_NODE(&isc->sysctl_ctx,
+ SYSCTL_CHILDREN(node), OID_AUTO, "iosched",
+ CTLFLAG_RD, 0, "I/O scheduler statistics");
+ n = SYSCTL_CHILDREN(isc->sysctl_tree);
+ ctx = &isc->sysctl_ctx;
+
+ cam_iosched_iop_stats_sysctl_init(isc, &isc->read_stats, "read");
+ cam_iosched_iop_stats_sysctl_init(isc, &isc->write_stats, "write");
+ cam_iosched_iop_stats_sysctl_init(isc, &isc->trim_stats, "trim");
+ cam_iosched_cl_sysctl_init(isc);
+
+ SYSCTL_ADD_INT(ctx, n,
+ OID_AUTO, "read_bias", CTLFLAG_RW,
+ &isc->read_bias, 100,
+ "How biased towards read should we be independent of limits");
+
+ SYSCTL_ADD_INT(ctx, n,
+ OID_AUTO, "quanta", CTLFLAG_RW,
+ &isc->quanta, 200,
+ "How many quanta per second do we slice the I/O up into");
+
+ SYSCTL_ADD_INT(ctx, n,
+ OID_AUTO, "total_ticks", CTLFLAG_RD,
+ &isc->total_ticks, 0,
+ "Total number of ticks we've done");
+#endif
+}
+
+/*
+ * Flush outstanding I/O. Consumers of this library don't know all the
+ * queues we may keep, so this allows all I/O to be flushed in one
+ * convenient call.
+ */
+void
+cam_iosched_flush(struct cam_iosched_softc *isc, struct devstat *stp, int err)
+{
+ bioq_flush(&isc->bio_queue, stp, err);
+ bioq_flush(&isc->trim_queue, stp, err);
+#ifdef CAM_NETFLIX_IOSCHED
+ if (do_netflix_iosched)
+ bioq_flush(&isc->write_queue, stp, err);
+#endif
+}
+
+#ifdef CAM_NETFLIX_IOSCHED
+static struct bio *
+cam_iosched_get_write(struct cam_iosched_softc *isc)
+{
+ struct bio *bp;
+
+ /*
+ * We control the write rate by controlling how many requests we send
+ * down to the drive at any one time. Fewer requests limits the
+ * effects of both starvation when the requests take a while and write
+ * amplification when each request is causing more than one write to
+ * the NAND media. Limiting the queue depth like this will also limit
+ * the write throughput and give and reads that want to compete to
+ * compete unfairly.
+ */
+ bp = bioq_first(&isc->write_queue);
+ if (bp == NULL) {
+ if (iosched_debug > 3)
+ printf("No writes present in write_queue\n");
+ return NULL;
+ }
+
+ /*
+ * If pending read, prefer that based on current read bias
+ * setting.
+ */
+ if (bioq_first(&isc->bio_queue) && isc->current_read_bias) {
+ if (iosched_debug)
+ printf("Reads present and current_read_bias is %d queued writes %d queued reads %d\n", isc->current_read_bias, isc->write_stats.queued, isc->read_stats.queued);
+ isc->current_read_bias--;
+ return NULL;
+ }
+
+ /*
+ * See if our current limiter allows this I/O.
+ */
+ if (cam_iosched_limiter_iop(&isc->write_stats, bp) != 0) {
+ if (iosched_debug)
+ printf("Can't write because limiter says no.\n");
+ return NULL;
+ }
+
+ /*
+ * Let's do this: We've passed all the gates and we're a go
+ * to schedule the I/O in the SIM.
+ */
+ isc->current_read_bias = isc->read_bias;
+ bioq_remove(&isc->write_queue, bp);
+ if (bp->bio_cmd == BIO_WRITE) {
+ isc->write_stats.queued--;
+ isc->write_stats.total++;
+ isc->write_stats.pending++;
+ }
+ if (iosched_debug > 9)
+ printf("HWQ : %p %#x\n", bp, bp->bio_cmd);
+ return bp;
+}
+#endif
+
+/*
+ * Put back a trim that you weren't able to actually schedule this time.
+ */
+void
+cam_iosched_put_back_trim(struct cam_iosched_softc *isc, struct bio *bp)
+{
+ bioq_insert_head(&isc->trim_queue, bp);
+#ifdef CAM_NETFLIX_IOSCHED
+ isc->trim_stats.queued++;
+ isc->trim_stats.total--; /* since we put it back, don't double count */
+ isc->trim_stats.pending--;
+#endif
+}
+
+/*
+ * gets the next trim from the trim queue.
+ *
+ * Assumes we're called with the periph lock held. It removes this
+ * trim from the queue and the device must explicitly reinstert it
+ * should the need arise.
+ */
+struct bio *
+cam_iosched_next_trim(struct cam_iosched_softc *isc)
+{
+ struct bio *bp;
+
+ bp = bioq_first(&isc->trim_queue);
+ if (bp == NULL)
+ return NULL;
+ bioq_remove(&isc->trim_queue, bp);
+#ifdef CAM_NETFLIX_IOSCHED
+ isc->trim_stats.queued--;
+ isc->trim_stats.total++;
+ isc->trim_stats.pending++;
+#endif
+ return bp;
+}
+
+/*
+ * gets the an available trim from the trim queue, if there's no trim
+ * already pending. It removes this trim from the queue and the device
+ * must explicitly reinstert it should the need arise.
+ *
+ * Assumes we're called with the periph lock held.
+ */
+struct bio *
+cam_iosched_get_trim(struct cam_iosched_softc *isc)
+{
+
+ if (!cam_iosched_has_more_trim(isc))
+ return NULL;
+
+ return cam_iosched_next_trim(isc);
+}
+
+/*
+ * Determine what the next bit of work to do is for the periph. The
+ * default implementation looks to see if we have trims to do, but no
+ * trims outstanding. If so, we do that. Otherwise we see if we have
+ * other work. If we do, then we do that. Otherwise why were we called?
+ */
+struct bio *
+cam_iosched_next_bio(struct cam_iosched_softc *isc)
+{
+ struct bio *bp;
+
+ /*
+ * See if we have a trim that can be scheduled. We can only send one
+ * at a time down, so this takes that into account.
+ *
+ * XXX newer TRIM commands are queueable. Revisit this when we
+ * implement them.
+ */
+ if ((bp = cam_iosched_get_trim(isc)) != NULL)
+ return bp;
+
+#ifdef CAM_NETFLIX_IOSCHED
+ /*
+ * See if we have any pending writes, and room in the queue for them,
+ * and if so, those are next.
+ */
+ if (do_netflix_iosched) {
+ if ((bp = cam_iosched_get_write(isc)) != NULL)
+ return bp;
+ }
+#endif
+
+ /*
+ * next, see if there's other, normal I/O waiting. If so return that.
+ */
+ if ((bp = bioq_first(&isc->bio_queue)) == NULL)
+ return NULL;
+
+#ifdef CAM_NETFLIX_IOSCHED
+ /*
+ * For the netflix scheduler, bio_queue is only for reads, so enforce
+ * the limits here. Enforce only for reads.
+ */
+ if (do_netflix_iosched) {
+ if (bp->bio_cmd == BIO_READ &&
+ cam_iosched_limiter_iop(&isc->read_stats, bp) != 0)
+ return NULL;
+ }
+#endif
+ bioq_remove(&isc->bio_queue, bp);
+#ifdef CAM_NETFLIX_IOSCHED
+ if (do_netflix_iosched) {
+ if (bp->bio_cmd == BIO_READ) {
+ isc->read_stats.queued--;
+ isc->read_stats.total++;
+ isc->read_stats.pending++;
+ } else
+ printf("Found bio_cmd = %#x\n", bp->bio_cmd);
+ }
+ if (iosched_debug > 9)
+ printf("HWQ : %p %#x\n", bp, bp->bio_cmd);
+#endif
+ return bp;
+}
+
+/*
+ * Driver has been given some work to do by the block layer. Tell the
+ * scheduler about it and have it queue the work up. The scheduler module
+ * will then return the currently most useful bit of work later, possibly
+ * deferring work for various reasons.
+ */
+void
+cam_iosched_queue_work(struct cam_iosched_softc *isc, struct bio *bp)
+{
+
+ /*
+ * Put all trims on the trim queue sorted, since we know
+ * that the collapsing code requires this. Otherwise put
+ * the work on the bio queue.
+ */
+ if (bp->bio_cmd == BIO_DELETE) {
+ bioq_disksort(&isc->trim_queue, bp);
+#ifdef CAM_NETFLIX_IOSCHED
+ isc->trim_stats.in++;
+ isc->trim_stats.queued++;
+#endif
+ }
+#ifdef CAM_NETFLIX_IOSCHED
+ else if (do_netflix_iosched &&
+ (bp->bio_cmd == BIO_WRITE || bp->bio_cmd == BIO_FLUSH)) {
+ if (cam_iosched_sort_queue(isc))
+ bioq_disksort(&isc->write_queue, bp);
+ else
+ bioq_insert_tail(&isc->write_queue, bp);
+ if (iosched_debug > 9)
+ printf("Qw : %p %#x\n", bp, bp->bio_cmd);
+ if (bp->bio_cmd == BIO_WRITE) {
+ isc->write_stats.in++;
+ isc->write_stats.queued++;
+ }
+ }
+#endif
+ else {
+ if (cam_iosched_sort_queue(isc))
+ bioq_disksort(&isc->bio_queue, bp);
+ else
+ bioq_insert_tail(&isc->bio_queue, bp);
+#ifdef CAM_NETFLIX_IOSCHED
+ if (iosched_debug > 9)
+ printf("Qr : %p %#x\n", bp, bp->bio_cmd);
+ if (bp->bio_cmd == BIO_READ) {
+ isc->read_stats.in++;
+ isc->read_stats.queued++;
+ } else if (bp->bio_cmd == BIO_WRITE) {
+ isc->write_stats.in++;
+ isc->write_stats.queued++;
+ }
+#endif
+ }
+}
+
+/*
+ * If we have work, get it scheduled. Called with the periph lock held.
+ */
+void
+cam_iosched_schedule(struct cam_iosched_softc *isc, struct cam_periph *periph)
+{
+
+ if (cam_iosched_has_work(isc))
+ xpt_schedule(periph, CAM_PRIORITY_NORMAL);
+}
+
+/*
+ * Complete a trim request
+ */
+void
+cam_iosched_trim_done(struct cam_iosched_softc *isc)
+{
+
+ isc->flags &= ~CAM_IOSCHED_FLAG_TRIM_ACTIVE;
+}
+
+/*
+ * Complete a bio. Called before we release the ccb with xpt_release_ccb so we
+ * might use notes in the ccb for statistics.
+ */
+int
+cam_iosched_bio_complete(struct cam_iosched_softc *isc, struct bio *bp,
+ union ccb *done_ccb)
+{
+ int retval = 0;
+#ifdef CAM_NETFLIX_IOSCHED
+ if (!do_netflix_iosched)
+ return retval;
+
+ if (iosched_debug > 10)
+ printf("done: %p %#x\n", bp, bp->bio_cmd);
+ if (bp->bio_cmd == BIO_WRITE) {
+ retval = cam_iosched_limiter_iodone(&isc->write_stats, bp);
+ isc->write_stats.out++;
+ isc->write_stats.pending--;
+ } else if (bp->bio_cmd == BIO_READ) {
+ retval = cam_iosched_limiter_iodone(&isc->read_stats, bp);
+ isc->read_stats.out++;
+ isc->read_stats.pending--;
+ } else if (bp->bio_cmd == BIO_DELETE) {
+ isc->trim_stats.out++;
+ isc->trim_stats.pending--;
+ } else if (bp->bio_cmd != BIO_FLUSH) {
+ if (iosched_debug)
+ printf("Completing command with bio_cmd == %#x\n", bp->bio_cmd);
+ }
+
+ if (!(bp->bio_flags & BIO_ERROR))
+ cam_iosched_io_metric_update(isc, done_ccb->ccb_h.qos.sim_data,
+ bp->bio_cmd, bp->bio_bcount);
+#endif
+ return retval;
+}
+
+/*
+ * Tell the io scheduler that you've pushed a trim down into the sim.
+ * xxx better place for this?
+ */
+void
+cam_iosched_submit_trim(struct cam_iosched_softc *isc)
+{
+
+ isc->flags |= CAM_IOSCHED_FLAG_TRIM_ACTIVE;
+}
+
+/*
+ * Change the sorting policy hint for I/O transactions for this device.
+ */
+void
+cam_iosched_set_sort_queue(struct cam_iosched_softc *isc, int val)
+{
+
+ isc->sort_io_queue = val;
+}
+
+int
+cam_iosched_has_work_flags(struct cam_iosched_softc *isc, uint32_t flags)
+{
+ return isc->flags & flags;
+}
+
+void
+cam_iosched_set_work_flags(struct cam_iosched_softc *isc, uint32_t flags)
+{
+ isc->flags |= flags;
+}
+
+void
+cam_iosched_clr_work_flags(struct cam_iosched_softc *isc, uint32_t flags)
+{
+ isc->flags &= ~flags;
+}
+
+#ifdef CAM_NETFLIX_IOSCHED
+/*
+ * After the method presented in Jack Crenshaw's 1998 article "Integer
+ * Suqare Roots," reprinted at
+ * http://www.embedded.com/electronics-blogs/programmer-s-toolbox/4219659/Integer-Square-Roots
+ * and well worth the read. Briefly, we find the power of 4 that's the
+ * largest smaller than val. We then check each smaller power of 4 to
+ * see if val is still bigger. The right shifts at each step divide
+ * the result by 2 which after successive application winds up
+ * accumulating the right answer. It could also have been accumulated
+ * using a separate root counter, but this code is smaller and faster
+ * than that method. This method is also integer size invariant.
+ * It returns floor(sqrt((float)val)), or the larget integer less than
+ * or equal to the square root.
+ */
+static uint64_t
+isqrt64(uint64_t val)
+{
+ uint64_t res = 0;
+ uint64_t bit = 1ULL << (sizeof(uint64_t) * NBBY - 2);
+
+ /*
+ * Find the largest power of 4 smaller than val.
+ */
+ while (bit > val)
+ bit >>= 2;
+
+ /*
+ * Accumulate the answer, one bit at a time (we keep moving
+ * them over since 2 is the square root of 4 and we test
+ * powers of 4). We accumulate where we find the bit, but
+ * the successive shifts land the bit in the right place
+ * by the end.
+ */
+ while (bit != 0) {
+ if (val >= res + bit) {
+ val -= res + bit;
+ res = (res >> 1) + bit;
+ } else
+ res >>= 1;
+ bit >>= 2;
+ }
+
+ return res;
+}
+
+/*
+ * a and b are 32.32 fixed point stored in a 64-bit word.
+ * Let al and bl be the .32 part of a and b.
+ * Let ah and bh be the 32 part of a and b.
+ * R is the radix and is 1 << 32
+ *
+ * a * b
+ * (ah + al / R) * (bh + bl / R)
+ * ah * bh + (al * bh + ah * bl) / R + al * bl / R^2
+ *
+ * After multiplicaiton, we have to renormalize by multiply by
+ * R, so we wind up with
+ * ah * bh * R + al * bh + ah * bl + al * bl / R
+ * which turns out to be a very nice way to compute this value
+ * so long as ah and bh are < 65536 there's no loss of high bits
+ * and the low order bits are below the threshold of caring for
+ * this application.
+ */
+static uint64_t
+mul(uint64_t a, uint64_t b)
+{
+ uint64_t al, ah, bl, bh;
+ al = a & 0xffffffff;
+ ah = a >> 32;
+ bl = b & 0xffffffff;
+ bh = b >> 32;
+ return ((ah * bh) << 32) + al * bh + ah * bl + ((al * bl) >> 32);
+}
+
+static void
+cam_iosched_update(struct iop_stats *iop, sbintime_t sim_latency)
+{
+ sbintime_t y, yy;
+ uint64_t var;
+
+ /*
+ * Classic expoentially decaying average with a tiny alpha
+ * (2 ^ -alpha_bits). For more info see the NIST statistical
+ * handbook.
+ *
+ * ema_t = y_t * alpha + ema_t-1 * (1 - alpha)
+ * alpha = 1 / (1 << alpha_bits)
+ *
+ * Since alpha is a power of two, we can compute this w/o any mult or
+ * division.
+ */
+ y = sim_latency;
+ iop->ema = (y + (iop->ema << alpha_bits) - iop->ema) >> alpha_bits;
+
+ yy = mul(y, y);
+ iop->emss = (yy + (iop->emss << alpha_bits) - iop->emss) >> alpha_bits;
+
+ /*
+ * s_1 = sum of data
+ * s_2 = sum of data * data
+ * ema ~ mean (or s_1 / N)
+ * emss ~ s_2 / N
+ *
+ * sd = sqrt((N * s_2 - s_1 ^ 2) / (N * (N - 1)))
+ * sd = sqrt((N * s_2 / N * (N - 1)) - (s_1 ^ 2 / (N * (N - 1))))
+ *
+ * N ~ 2 / alpha - 1
+ * alpha < 1 / 16 (typically much less)
+ * N > 31 --> N large so N * (N - 1) is approx N * N
+ *
+ * substituting and rearranging:
+ * sd ~ sqrt(s_2 / N - (s_1 / N) ^ 2)
+ * ~ sqrt(emss - ema ^ 2);
+ * which is the formula used here to get a decent estimate of sd which
+ * we use to detect outliers. Note that when first starting up, it
+ * takes a while for emss sum of squares estimator to converge on a
+ * good value. during this time, it can be less than ema^2. We
+ * compute a sd of 0 in that case, and ignore outliers.
+ */
+ var = iop->emss - mul(iop->ema, iop->ema);
+ iop->sd = (int64_t)var < 0 ? 0 : isqrt64(var);
+}
+
+#ifdef CAM_NETFLIX_IOSCHED
+static void
+cam_iosched_io_metric_update(struct cam_iosched_softc *isc,
+ sbintime_t sim_latency, int cmd, size_t size)
+{
+ /* xxx Do we need to scale based on the size of the I/O ? */
+ switch (cmd) {
+ case BIO_READ:
+ cam_iosched_update(&isc->read_stats, sim_latency);
+ break;
+ case BIO_WRITE:
+ cam_iosched_update(&isc->write_stats, sim_latency);
+ break;
+ case BIO_DELETE:
+ cam_iosched_update(&isc->trim_stats, sim_latency);
+ break;
+ default:
+ break;
+ }
+}
+#endif
+
+#ifdef DDB
+static int biolen(struct bio_queue_head *bq)
+{
+ int i = 0;
+ struct bio *bp;
+
+ TAILQ_FOREACH(bp, &bq->queue, bio_queue) {
+ i++;
+ }
+ return i;
+}
+
+/*
+ * Show the internal state of the I/O scheduler.
+ */
+DB_SHOW_COMMAND(iosched, cam_iosched_db_show)
+{
+ struct cam_iosched_softc *isc;
+
+ if (!have_addr) {
+ db_printf("Need addr\n");
+ return;
+ }
+ isc = (struct cam_iosched_softc *)addr;
+ db_printf("pending_reads: %d\n", isc->read_stats.pending);
+ db_printf("min_reads: %d\n", isc->read_stats.min);
+ db_printf("max_reads: %d\n", isc->read_stats.max);
+ db_printf("reads: %d\n", isc->read_stats.total);
+ db_printf("in_reads: %d\n", isc->read_stats.in);
+ db_printf("out_reads: %d\n", isc->read_stats.out);
+ db_printf("queued_reads: %d\n", isc->read_stats.queued);
+ db_printf("Current Q len %d\n", biolen(&isc->bio_queue));
+ db_printf("pending_writes: %d\n", isc->write_stats.pending);
+ db_printf("min_writes: %d\n", isc->write_stats.min);
+ db_printf("max_writes: %d\n", isc->write_stats.max);
+ db_printf("writes: %d\n", isc->write_stats.total);
+ db_printf("in_writes: %d\n", isc->write_stats.in);
+ db_printf("out_writes: %d\n", isc->write_stats.out);
+ db_printf("queued_writes: %d\n", isc->write_stats.queued);
+ db_printf("Current Q len %d\n", biolen(&isc->write_queue));
+ db_printf("pending_trims: %d\n", isc->trim_stats.pending);
+ db_printf("min_trims: %d\n", isc->trim_stats.min);
+ db_printf("max_trims: %d\n", isc->trim_stats.max);
+ db_printf("trims: %d\n", isc->trim_stats.total);
+ db_printf("in_trims: %d\n", isc->trim_stats.in);
+ db_printf("out_trims: %d\n", isc->trim_stats.out);
+ db_printf("queued_trims: %d\n", isc->trim_stats.queued);
+ db_printf("Current Q len %d\n", biolen(&isc->trim_queue));
+ db_printf("read_bias: %d\n", isc->read_bias);
+ db_printf("current_read_bias: %d\n", isc->current_read_bias);
+ db_printf("Trim active? %s\n",
+ (isc->flags & CAM_IOSCHED_FLAG_TRIM_ACTIVE) ? "yes" : "no");
+}
+#endif
+#endif
diff --git a/sys/cam/cam_iosched.h b/sys/cam/cam_iosched.h
new file mode 100644
index 0000000..34c926d
--- /dev/null
+++ b/sys/cam/cam_iosched.h
@@ -0,0 +1,64 @@
+/*-
+ * CAM IO Scheduler Interface
+ *
+ * Copyright (c) 2015 Netflix, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions, and the following disclaimer,
+ * without modification, immediately at the beginning of the file.
+ * 2. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef _CAM_CAM_IOSCHED_H
+#define _CAM_CAM_IOSCHED_H
+
+/* No user-servicable parts in here. */
+#ifdef _KERNEL
+
+/* Forward declare all structs to keep interface thin */
+struct cam_iosched_softc;
+struct sysctl_ctx_list;
+struct sysctl_oid;
+union ccb;
+struct bio;
+
+int cam_iosched_init(struct cam_iosched_softc **, struct cam_periph *periph);
+void cam_iosched_fini(struct cam_iosched_softc *);
+void cam_iosched_sysctl_init(struct cam_iosched_softc *, struct sysctl_ctx_list *, struct sysctl_oid *);
+struct bio *cam_iosched_next_trim(struct cam_iosched_softc *isc);
+struct bio *cam_iosched_get_trim(struct cam_iosched_softc *isc);
+struct bio *cam_iosched_next_bio(struct cam_iosched_softc *isc);
+void cam_iosched_queue_work(struct cam_iosched_softc *isc, struct bio *bp);
+void cam_iosched_flush(struct cam_iosched_softc *isc, struct devstat *stp, int err);
+void cam_iosched_schedule(struct cam_iosched_softc *isc, struct cam_periph *periph);
+void cam_iosched_finish_trim(struct cam_iosched_softc *isc);
+void cam_iosched_submit_trim(struct cam_iosched_softc *isc);
+void cam_iosched_put_back_trim(struct cam_iosched_softc *isc, struct bio *bp);
+void cam_iosched_set_sort_queue(struct cam_iosched_softc *isc, int val);
+int cam_iosched_has_work_flags(struct cam_iosched_softc *isc, uint32_t flags);
+void cam_iosched_set_work_flags(struct cam_iosched_softc *isc, uint32_t flags);
+void cam_iosched_clr_work_flags(struct cam_iosched_softc *isc, uint32_t flags);
+void cam_iosched_trim_done(struct cam_iosched_softc *isc);
+int cam_iosched_bio_complete(struct cam_iosched_softc *isc, struct bio *bp, union ccb *done_ccb);
+
+#endif
+#endif
diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c
index 91cb45d..299b4ec 100644
--- a/sys/cam/cam_periph.c
+++ b/sys/cam/cam_periph.c
@@ -86,6 +86,7 @@ static int camperiphscsisenseerror(union ccb *ccb,
u_int32_t *timeout,
u_int32_t *action,
const char **action_string);
+static void cam_periph_devctl_notify(union ccb *ccb);
static int nperiph_drivers;
static int initialized = 0;
@@ -1615,7 +1616,7 @@ cam_periph_error(union ccb *ccb, cam_flags camflags,
struct cam_periph *periph;
const char *action_string;
cam_status status;
- int frozen, error, openings;
+ int frozen, error, openings, devctl_err;
u_int32_t action, relsim_flags, timeout;
action = SSQ_PRINT_SENSE;
@@ -1624,9 +1625,26 @@ cam_periph_error(union ccb *ccb, cam_flags camflags,
status = ccb->ccb_h.status;
frozen = (status & CAM_DEV_QFRZN) != 0;
status &= CAM_STATUS_MASK;
- openings = relsim_flags = timeout = 0;
+ devctl_err = openings = relsim_flags = timeout = 0;
orig_ccb = ccb;
+ /* Filter the errors that should be reported via devctl */
+ switch (ccb->ccb_h.status & CAM_STATUS_MASK) {
+ case CAM_CMD_TIMEOUT:
+ case CAM_REQ_ABORTED:
+ case CAM_REQ_CMP_ERR:
+ case CAM_REQ_TERMIO:
+ case CAM_UNREC_HBA_ERROR:
+ case CAM_DATA_RUN_ERR:
+ case CAM_SCSI_STATUS_ERROR:
+ case CAM_ATA_STATUS_ERROR:
+ case CAM_SMP_STATUS_ERROR:
+ devctl_err++;
+ break;
+ default:
+ break;
+ }
+
switch (status) {
case CAM_REQ_CMP:
error = 0;
@@ -1754,6 +1772,9 @@ cam_periph_error(union ccb *ccb, cam_flags camflags,
xpt_print(ccb->ccb_h.path, "Retrying command\n");
}
+ if (devctl_err)
+ cam_periph_devctl_notify(orig_ccb);
+
if ((action & SSQ_LOST) != 0) {
lun_id_t lun_id;
@@ -1824,3 +1845,80 @@ cam_periph_error(union ccb *ccb, cam_flags camflags,
return (error);
}
+
+#define CAM_PERIPH_DEVD_MSG_SIZE 256
+
+static void
+cam_periph_devctl_notify(union ccb *ccb)
+{
+ struct cam_periph *periph;
+ struct ccb_getdev *cgd;
+ struct sbuf sb;
+ int serr, sk, asc, ascq;
+ char *sbmsg, *type;
+
+ sbmsg = malloc(CAM_PERIPH_DEVD_MSG_SIZE, M_CAMPERIPH, M_NOWAIT);
+ if (sbmsg == NULL)
+ return;
+
+ sbuf_new(&sb, sbmsg, CAM_PERIPH_DEVD_MSG_SIZE, SBUF_FIXEDLEN);
+
+ periph = xpt_path_periph(ccb->ccb_h.path);
+ sbuf_printf(&sb, "device=%s%d ", periph->periph_name,
+ periph->unit_number);
+
+ sbuf_printf(&sb, "serial=\"");
+ if ((cgd = (struct ccb_getdev *)xpt_alloc_ccb_nowait()) != NULL) {
+ xpt_setup_ccb(&cgd->ccb_h, ccb->ccb_h.path,
+ CAM_PRIORITY_NORMAL);
+ cgd->ccb_h.func_code = XPT_GDEV_TYPE;
+ xpt_action((union ccb *)cgd);
+
+ if (cgd->ccb_h.status == CAM_REQ_CMP)
+ sbuf_bcat(&sb, cgd->serial_num, cgd->serial_num_len);
+ }
+ sbuf_printf(&sb, "\" ");
+ sbuf_printf(&sb, "cam_status=\"0x%x\" ", ccb->ccb_h.status);
+
+ switch (ccb->ccb_h.status & CAM_STATUS_MASK) {
+ case CAM_CMD_TIMEOUT:
+ sbuf_printf(&sb, "timeout=%d ", ccb->ccb_h.timeout);
+ type = "timeout";
+ break;
+ case CAM_SCSI_STATUS_ERROR:
+ sbuf_printf(&sb, "scsi_status=%d ", ccb->csio.scsi_status);
+ if (scsi_extract_sense_ccb(ccb, &serr, &sk, &asc, &ascq))
+ sbuf_printf(&sb, "scsi_sense=\"%02x %02x %02x %02x\" ",
+ serr, sk, asc, ascq);
+ type = "error";
+ break;
+ case CAM_ATA_STATUS_ERROR:
+ sbuf_printf(&sb, "RES=\"");
+ ata_res_sbuf(&ccb->ataio.res, &sb);
+ sbuf_printf(&sb, "\" ");
+ type = "error";
+ break;
+ default:
+ type = "error";
+ break;
+ }
+
+ if (ccb->ccb_h.func_code == XPT_SCSI_IO) {
+ sbuf_printf(&sb, "CDB=\"");
+ if ((ccb->ccb_h.flags & CAM_CDB_POINTER) != 0)
+ scsi_cdb_sbuf(ccb->csio.cdb_io.cdb_ptr, &sb);
+ else
+ scsi_cdb_sbuf(ccb->csio.cdb_io.cdb_bytes, &sb);
+ sbuf_printf(&sb, "\" ");
+ } else if (ccb->ccb_h.func_code == XPT_ATA_IO) {
+ sbuf_printf(&sb, "ACB=\"");
+ ata_cmd_sbuf(&ccb->ataio.cmd, &sb);
+ sbuf_printf(&sb, "\" ");
+ }
+
+ if (sbuf_finish(&sb) == 0)
+ devctl_notify("CAM", "periph", type, sbuf_data(&sb));
+ sbuf_delete(&sb);
+ free(sbmsg, M_CAMPERIPH);
+}
+
diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c
index e811fe6..b426857 100644
--- a/sys/cam/cam_xpt.c
+++ b/sys/cam/cam_xpt.c
@@ -3311,6 +3311,7 @@ xpt_run_devq(struct cam_devq *devq)
lock = (mtx_owned(sim->mtx) == 0);
if (lock)
CAM_SIM_LOCK(sim);
+ work_ccb->ccb_h.qos.sim_data = sbinuptime(); // xxx uintprt_t too small 32bit platforms
(*(sim->sim_action))(sim, work_ccb);
if (lock)
CAM_SIM_UNLOCK(sim);
@@ -4439,6 +4440,8 @@ xpt_done(union ccb *done_ccb)
if ((done_ccb->ccb_h.func_code & XPT_FC_QUEUED) == 0)
return;
+ /* Store the time the ccb was in the sim */
+ done_ccb->ccb_h.qos.sim_data = sbinuptime() - done_ccb->ccb_h.qos.sim_data;
hash = (done_ccb->ccb_h.path_id + done_ccb->ccb_h.target_id +
done_ccb->ccb_h.target_lun) % cam_num_doneqs;
queue = &cam_doneqs[hash];
@@ -4459,6 +4462,8 @@ xpt_done_direct(union ccb *done_ccb)
if ((done_ccb->ccb_h.func_code & XPT_FC_QUEUED) == 0)
return;
+ /* Store the time the ccb was in the sim */
+ done_ccb->ccb_h.qos.sim_data = sbinuptime() - done_ccb->ccb_h.qos.sim_data;
xpt_done_process(&done_ccb->ccb_h);
}
diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c
index 07a6435..d97e99d 100644
--- a/sys/cam/scsi/scsi_da.c
+++ b/sys/cam/scsi/scsi_da.c
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#include <cam/cam_periph.h>
#include <cam/cam_xpt_periph.h>
#include <cam/cam_sim.h>
+#include <cam/cam_iosched.h>
#include <cam/scsi/scsi_message.h>
@@ -199,21 +200,19 @@ struct disk_params {
#define ATA_TRIM_MAX_RANGES ((UNMAP_BUF_SIZE / \
(ATA_DSM_RANGE_SIZE * ATA_DSM_BLK_SIZE)) * ATA_DSM_BLK_SIZE)
+#define DA_WORK_TUR (1 << 16)
+
struct da_softc {
- struct bio_queue_head bio_queue;
- struct bio_queue_head delete_queue;
+ struct cam_iosched_softc *cam_iosched;
struct bio_queue_head delete_run_queue;
LIST_HEAD(, ccb_hdr) pending_ccbs;
- int tur; /* TEST UNIT READY should be sent */
int refcount; /* Active xpt_action() calls */
da_state state;
da_flags flags;
da_quirks quirks;
- int sort_io_queue;
int minimum_cmd_size;
int error_inject;
int trim_max_ranges;
- int delete_running;
int delete_available; /* Delete methods possibly available */
u_int maxio;
uint32_t unmap_max_ranges;
@@ -222,6 +221,8 @@ struct da_softc {
da_delete_methods delete_method_pref;
da_delete_methods delete_method;
da_delete_func_t *delete_func;
+ int unmappedio;
+ int rotating;
struct disk_params params;
struct disk *disk;
union ccb saved_ccb;
@@ -233,6 +234,13 @@ struct da_softc {
uint8_t unmap_buf[UNMAP_BUF_SIZE];
struct scsi_read_capacity_data_long rcaplong;
struct callout mediapoll_c;
+#ifdef CAM_IO_STATS
+ struct sysctl_ctx_list sysctl_stats_ctx;
+ struct sysctl_oid *sysctl_stats_tree;
+ u_int errors;
+ u_int timeouts;
+ u_int invalidations;
+#endif
};
#define dadeleteflag(softc, delete_method, enable) \
@@ -1193,6 +1201,7 @@ static periph_init_t dainit;
static void daasync(void *callback_arg, u_int32_t code,
struct cam_path *path, void *arg);
static void dasysctlinit(void *context, int pending);
+static int dasysctlsofttimeout(SYSCTL_HANDLER_ARGS);
static int dacmdsizesysctl(SYSCTL_HANDLER_ARGS);
static int dadeletemethodsysctl(SYSCTL_HANDLER_ARGS);
static int dadeletemaxsysctl(SYSCTL_HANDLER_ARGS);
@@ -1230,6 +1239,10 @@ static timeout_t damediapoll;
#define DA_DEFAULT_TIMEOUT 60 /* Timeout in seconds */
#endif
+#ifndef DA_DEFAULT_SOFTTIMEOUT
+#define DA_DEFAULT_SOFTTIMEOUT 0
+#endif
+
#ifndef DA_DEFAULT_RETRY
#define DA_DEFAULT_RETRY 4
#endif
@@ -1238,12 +1251,10 @@ static timeout_t damediapoll;
#define DA_DEFAULT_SEND_ORDERED 1
#endif
-#define DA_SIO (softc->sort_io_queue >= 0 ? \
- softc->sort_io_queue : cam_sort_io_queues)
-
static int da_poll_period = DA_DEFAULT_POLL_PERIOD;
static int da_retry_count = DA_DEFAULT_RETRY;
static int da_default_timeout = DA_DEFAULT_TIMEOUT;
+static sbintime_t da_default_softtimeout = DA_DEFAULT_SOFTTIMEOUT;
static int da_send_ordered = DA_DEFAULT_SEND_ORDERED;
static SYSCTL_NODE(_kern_cam, OID_AUTO, da, CTLFLAG_RD, 0,
@@ -1257,6 +1268,11 @@ SYSCTL_INT(_kern_cam_da, OID_AUTO, default_timeout, CTLFLAG_RWTUN,
SYSCTL_INT(_kern_cam_da, OID_AUTO, send_ordered, CTLFLAG_RWTUN,
&da_send_ordered, 0, "Send Ordered Tags");
+SYSCTL_PROC(_kern_cam_da, OID_AUTO, default_softtimeout,
+ CTLTYPE_UINT | CTLFLAG_RW, NULL, 0, dasysctlsofttimeout, "I",
+ "Soft I/O timeout (ms)");
+TUNABLE_INT64("kern.cam.da.default_softtimeout", &da_default_softtimeout);
+
/*
* DA_ORDEREDTAG_INTERVAL determines how often, relative
* to the default timeout, we check to see whether an ordered
@@ -1400,12 +1416,7 @@ daschedule(struct cam_periph *periph)
if (softc->state != DA_STATE_NORMAL)
return;
- /* Check if we have more work to do. */
- if (bioq_first(&softc->bio_queue) ||
- (!softc->delete_running && bioq_first(&softc->delete_queue)) ||
- softc->tur) {
- xpt_schedule(periph, CAM_PRIORITY_NORMAL);
- }
+ cam_iosched_schedule(softc->cam_iosched, periph);
}
/*
@@ -1438,13 +1449,7 @@ dastrategy(struct bio *bp)
/*
* Place it in the queue of disk activities for this disk
*/
- if (bp->bio_cmd == BIO_DELETE) {
- bioq_disksort(&softc->delete_queue, bp);
- } else if (DA_SIO) {
- bioq_disksort(&softc->bio_queue, bp);
- } else {
- bioq_insert_tail(&softc->bio_queue, bp);
- }
+ cam_iosched_queue_work(softc->cam_iosched, bp);
/*
* Schedule ourselves for performing the work.
@@ -1519,7 +1524,7 @@ dadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t leng
/*begin_lba*/0,/* Cover the whole disk */
/*lb_count*/0,
SSD_FULL_SIZE,
- 5 * 60 * 1000);
+ 5 * 1000);
xpt_polled_action((union ccb *)&csio);
error = cam_periph_error((union ccb *)&csio,
@@ -1599,14 +1604,16 @@ daoninvalidate(struct cam_periph *periph)
xpt_register_async(0, daasync, periph, periph->path);
softc->flags |= DA_FLAG_PACK_INVALID;
+#ifdef CAM_IO_STATS
+ softc->invalidations++;
+#endif
/*
* Return all queued I/O with ENXIO.
* XXX Handle any transactions queued to the card
* with XPT_ABORT_CCB.
*/
- bioq_flush(&softc->bio_queue, NULL, ENXIO);
- bioq_flush(&softc->delete_queue, NULL, ENXIO);
+ cam_iosched_flush(softc->cam_iosched, NULL, ENXIO);
/*
* Tell GEOM that we've gone away, we'll get a callback when it is
@@ -1624,12 +1631,20 @@ dacleanup(struct cam_periph *periph)
cam_periph_unlock(periph);
+ cam_iosched_fini(softc->cam_iosched);
+
/*
* If we can't free the sysctl tree, oh well...
*/
- if ((softc->flags & DA_FLAG_SCTX_INIT) != 0
- && sysctl_ctx_free(&softc->sysctl_ctx) != 0) {
- xpt_print(periph->path, "can't remove sysctl context\n");
+ if ((softc->flags & DA_FLAG_SCTX_INIT) != 0) {
+#ifdef CAM_IO_STATS
+ if (sysctl_ctx_free(&softc->sysctl_stats_ctx) != 0)
+ xpt_print(periph->path,
+ "can't remove sysctl stats context\n");
+#endif
+ if (sysctl_ctx_free(&softc->sysctl_ctx) != 0)
+ xpt_print(periph->path,
+ "can't remove sysctl context\n");
}
callout_drain(&softc->mediapoll_c);
@@ -1732,9 +1747,9 @@ daasync(void *callback_arg, u_int32_t code,
}
case AC_SCSI_AEN:
softc = (struct da_softc *)periph->softc;
- if (!softc->tur) {
+ if (!cam_iosched_has_work_flags(softc->cam_iosched, DA_WORK_TUR)) {
if (cam_periph_acquire(periph) == CAM_REQ_CMP) {
- softc->tur = 1;
+ cam_iosched_set_work_flags(softc->cam_iosched, DA_WORK_TUR);
daschedule(periph);
}
}
@@ -1808,9 +1823,6 @@ dasysctlinit(void *context, int pending)
OID_AUTO, "minimum_cmd_size", CTLTYPE_INT | CTLFLAG_RW,
&softc->minimum_cmd_size, 0, dacmdsizesysctl, "I",
"Minimum CDB size");
- SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree),
- OID_AUTO, "sort_io_queue", CTLFLAG_RW, &softc->sort_io_queue, 0,
- "Sort IO queue to try and optimise disk access patterns");
SYSCTL_ADD_INT(&softc->sysctl_ctx,
SYSCTL_CHILDREN(softc->sysctl_tree),
@@ -1821,6 +1833,23 @@ dasysctlinit(void *context, int pending)
0,
"error_inject leaf");
+ SYSCTL_ADD_INT(&softc->sysctl_ctx,
+ SYSCTL_CHILDREN(softc->sysctl_tree),
+ OID_AUTO,
+ "unmapped_io",
+ CTLFLAG_RD,
+ &softc->unmappedio,
+ 0,
+ "Unmapped I/O leaf");
+
+ SYSCTL_ADD_INT(&softc->sysctl_ctx,
+ SYSCTL_CHILDREN(softc->sysctl_tree),
+ OID_AUTO,
+ "rotating",
+ CTLFLAG_RD,
+ &softc->rotating,
+ 0,
+ "Rotating media");
/*
* Add some addressing info.
@@ -1846,6 +1875,44 @@ dasysctlinit(void *context, int pending)
&softc->wwpn, "World Wide Port Name");
}
}
+
+#ifdef CAM_IO_STATS
+ /*
+ * Now add some useful stats.
+ * XXX These should live in cam_periph and be common to all periphs
+ */
+ softc->sysctl_stats_tree = SYSCTL_ADD_NODE(&softc->sysctl_stats_ctx,
+ SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "stats",
+ CTLFLAG_RD, 0, "Statistics");
+ SYSCTL_ADD_INT(&softc->sysctl_stats_ctx,
+ SYSCTL_CHILDREN(softc->sysctl_stats_tree),
+ OID_AUTO,
+ "errors",
+ CTLFLAG_RD,
+ &softc->errors,
+ 0,
+ "Transport errors reported by the SIM");
+ SYSCTL_ADD_INT(&softc->sysctl_stats_ctx,
+ SYSCTL_CHILDREN(softc->sysctl_stats_tree),
+ OID_AUTO,
+ "timeouts",
+ CTLFLAG_RD,
+ &softc->timeouts,
+ 0,
+ "Device timeouts reported by the SIM");
+ SYSCTL_ADD_INT(&softc->sysctl_stats_ctx,
+ SYSCTL_CHILDREN(softc->sysctl_stats_tree),
+ OID_AUTO,
+ "pack_invalidations",
+ CTLFLAG_RD,
+ &softc->invalidations,
+ 0,
+ "Device pack invalidations");
+#endif
+
+ cam_iosched_sysctl_init(softc->cam_iosched, &softc->sysctl_ctx,
+ softc->sysctl_tree);
+
cam_periph_release(periph);
}
@@ -1904,6 +1971,26 @@ dacmdsizesysctl(SYSCTL_HANDLER_ARGS)
return (0);
}
+static int
+dasysctlsofttimeout(SYSCTL_HANDLER_ARGS)
+{
+ sbintime_t value;
+ int error;
+
+ value = da_default_softtimeout / SBT_1MS;
+
+ error = sysctl_handle_int(oidp, (int *)&value, 0, req);
+ if ((error != 0) || (req->newptr == NULL))
+ return (error);
+
+ /* XXX Should clip this to a reasonable level */
+ if (value > da_default_timeout * 1000)
+ return (EINVAL);
+
+ da_default_softtimeout = value * SBT_1MS;
+ return (0);
+}
+
static void
dadeletemethodset(struct da_softc *softc, da_delete_methods delete_method)
{
@@ -2075,14 +2162,18 @@ daregister(struct cam_periph *periph, void *arg)
if (softc == NULL) {
printf("daregister: Unable to probe new device. "
- "Unable to allocate softc\n");
+ "Unable to allocate softc\n");
return(CAM_REQ_CMP_ERR);
}
+ if (cam_iosched_init(&softc->cam_iosched, periph) != 0) {
+ printf("daregister: Unable to probe new device. "
+ "Unable to allocate iosched memory\n");
+ return(CAM_REQ_CMP_ERR);
+ }
+
LIST_INIT(&softc->pending_ccbs);
softc->state = DA_STATE_PROBE_RC;
- bioq_init(&softc->bio_queue);
- bioq_init(&softc->delete_queue);
bioq_init(&softc->delete_run_queue);
if (SID_IS_REMOVABLE(&cgd->inq_data))
softc->flags |= DA_FLAG_PACK_REMOVABLE;
@@ -2090,7 +2181,7 @@ daregister(struct cam_periph *periph, void *arg)
softc->unmap_max_lba = UNMAP_RANGE_MAX;
softc->ws_max_blks = WS16_MAX_BLKS;
softc->trim_max_ranges = ATA_TRIM_MAX_RANGES;
- softc->sort_io_queue = -1;
+ softc->rotating = 1;
periph->softc = softc;
@@ -2199,8 +2290,11 @@ daregister(struct cam_periph *periph, void *arg)
softc->disk->d_flags = DISKFLAG_DIRECT_COMPLETION;
if ((softc->quirks & DA_Q_NO_SYNC_CACHE) == 0)
softc->disk->d_flags |= DISKFLAG_CANFLUSHCACHE;
- if ((cpi.hba_misc & PIM_UNMAPPED) != 0)
+ if ((cpi.hba_misc & PIM_UNMAPPED) != 0) {
+ softc->unmappedio = 1;
softc->disk->d_flags |= DISKFLAG_UNMAPPED_BIO;
+ xpt_print(periph->path, "UNMAPPED\n");
+ }
cam_strvis(softc->disk->d_descr, cgd->inq_data.vendor,
sizeof(cgd->inq_data.vendor), sizeof(softc->disk->d_descr));
strlcat(softc->disk->d_descr, " ", sizeof(softc->disk->d_descr));
@@ -2277,23 +2371,11 @@ skipstate:
struct bio *bp;
uint8_t tag_code;
- /* Run BIO_DELETE if not running yet. */
- if (!softc->delete_running &&
- (bp = bioq_first(&softc->delete_queue)) != NULL) {
- if (softc->delete_func != NULL) {
- softc->delete_func(periph, start_ccb, bp);
- goto out;
- } else {
- bioq_flush(&softc->delete_queue, NULL, 0);
- /* FALLTHROUGH */
- }
- }
-
- /* Run regular command. */
- bp = bioq_takefirst(&softc->bio_queue);
+more:
+ bp = cam_iosched_next_bio(softc->cam_iosched);
if (bp == NULL) {
- if (softc->tur) {
- softc->tur = 0;
+ if (cam_iosched_has_work_flags(softc->cam_iosched, DA_WORK_TUR)) {
+ cam_iosched_clr_work_flags(softc->cam_iosched, DA_WORK_TUR);
scsi_test_unit_ready(&start_ccb->csio,
/*retries*/ da_retry_count,
dadone,
@@ -2307,9 +2389,21 @@ skipstate:
xpt_release_ccb(start_ccb);
break;
}
- if (softc->tur) {
- softc->tur = 0;
- cam_periph_release_locked(periph);
+
+ if (bp->bio_cmd == BIO_DELETE) {
+ if (softc->delete_func != NULL) {
+ softc->delete_func(periph, start_ccb, bp);
+ goto out;
+ } else {
+ /* Not sure this is possible, but failsafe by lying and saying "sure, done." */
+ biofinish(bp, NULL, 0);
+ goto more;
+ }
+ }
+
+ if (cam_iosched_has_work_flags(softc->cam_iosched, DA_WORK_TUR)) {
+ cam_iosched_clr_work_flags(softc->cam_iosched, DA_WORK_TUR);
+ cam_periph_release_locked(periph); /* XXX is this still valid? I think so but unverified */
}
if ((bp->bio_flags & BIO_ORDERED) != 0 ||
@@ -2377,6 +2471,7 @@ skipstate:
}
start_ccb->ccb_h.ccb_state = DA_CCB_BUFFER_IO;
start_ccb->ccb_h.flags |= CAM_UNLOCKED;
+ start_ccb->ccb_h.softtimeout = sbttotv(da_default_softtimeout);
out:
LIST_INSERT_HEAD(&softc->pending_ccbs,
@@ -2625,11 +2720,19 @@ da_delete_unmap(struct cam_periph *periph, union ccb *ccb, struct bio *bp)
* fewer LBA's than requested.
*/
- softc->delete_running = 1;
bzero(softc->unmap_buf, sizeof(softc->unmap_buf));
bp1 = bp;
do {
- bioq_remove(&softc->delete_queue, bp1);
+ /*
+ * Note: ada and da are different in how they store the
+ * pending bp's in a trim. ada stores all of them in the
+ * trim_req.bps. da stores all but the first one in the
+ * delete_run_queue. ada then completes all the bps in
+ * its adadone() loop. da completes all the bps in the
+ * delete_run_queue in dadone, and relies on the biodone
+ * after to complete. This should be reconciled since there's
+ * no real reason to do it differently. XXX
+ */
if (bp1 != bp)
bioq_insert_tail(&softc->delete_run_queue, bp1);
lba = bp1->bio_pblkno;
@@ -2669,11 +2772,15 @@ da_delete_unmap(struct cam_periph *periph, union ccb *ccb, struct bio *bp)
lastcount = c;
}
lastlba = lba;
- bp1 = bioq_first(&softc->delete_queue);
- if (bp1 == NULL || ranges >= softc->unmap_max_ranges ||
+ bp1 = cam_iosched_next_trim(softc->cam_iosched);
+ if (bp1 == NULL)
+ break;
+ if (ranges >= softc->unmap_max_ranges ||
totalcount + bp1->bio_bcount /
- softc->params.secsize > softc->unmap_max_lba)
+ softc->params.secsize > softc->unmap_max_lba) {
+ cam_iosched_put_back_trim(softc->cam_iosched, bp1);
break;
+ }
} while (1);
scsi_ulto2b(ranges * 16 + 6, &buf[0]);
scsi_ulto2b(ranges * 16, &buf[2]);
@@ -2689,6 +2796,7 @@ da_delete_unmap(struct cam_periph *periph, union ccb *ccb, struct bio *bp)
da_default_timeout * 1000);
ccb->ccb_h.ccb_state = DA_CCB_DELETE;
ccb->ccb_h.flags |= CAM_UNLOCKED;
+ cam_iosched_submit_trim(softc->cam_iosched);
}
static void
@@ -2703,12 +2811,10 @@ da_delete_trim(struct cam_periph *periph, union ccb *ccb, struct bio *bp)
uint32_t lastcount = 0, c, requestcount;
int ranges = 0, off, block_count;
- softc->delete_running = 1;
bzero(softc->unmap_buf, sizeof(softc->unmap_buf));
bp1 = bp;
do {
- bioq_remove(&softc->delete_queue, bp1);
- if (bp1 != bp)
+ if (bp1 != bp)//XXX imp XXX
bioq_insert_tail(&softc->delete_run_queue, bp1);
lba = bp1->bio_pblkno;
count = bp1->bio_bcount / softc->params.secsize;
@@ -2752,10 +2858,14 @@ da_delete_trim(struct cam_periph *periph, union ccb *ccb, struct bio *bp)
}
}
lastlba = lba;
- bp1 = bioq_first(&softc->delete_queue);
- if (bp1 == NULL || bp1->bio_bcount / softc->params.secsize >
- (softc->trim_max_ranges - ranges) * ATA_DSM_RANGE_MAX)
+ bp1 = cam_iosched_next_trim(softc->cam_iosched);
+ if (bp1 == NULL)
+ break;
+ if (bp1->bio_bcount / softc->params.secsize >
+ (softc->trim_max_ranges - ranges) * ATA_DSM_RANGE_MAX) {
+ cam_iosched_put_back_trim(softc->cam_iosched, bp1);
break;
+ }
} while (1);
block_count = (ranges + ATA_DSM_BLK_RANGES - 1) / ATA_DSM_BLK_RANGES;
@@ -2770,6 +2880,7 @@ da_delete_trim(struct cam_periph *periph, union ccb *ccb, struct bio *bp)
da_default_timeout * 1000);
ccb->ccb_h.ccb_state = DA_CCB_DELETE;
ccb->ccb_h.flags |= CAM_UNLOCKED;
+ cam_iosched_submit_trim(softc->cam_iosched);
}
/*
@@ -2788,13 +2899,11 @@ da_delete_ws(struct cam_periph *periph, union ccb *ccb, struct bio *bp)
softc = (struct da_softc *)periph->softc;
ws_max_blks = softc->disk->d_delmaxsize / softc->params.secsize;
- softc->delete_running = 1;
lba = bp->bio_pblkno;
count = 0;
bp1 = bp;
do {
- bioq_remove(&softc->delete_queue, bp1);
- if (bp1 != bp)
+ if (bp1 != bp)//XXX imp XXX
bioq_insert_tail(&softc->delete_run_queue, bp1);
count += bp1->bio_bcount / softc->params.secsize;
if (count > ws_max_blks) {
@@ -2805,11 +2914,15 @@ da_delete_ws(struct cam_periph *periph, union ccb *ccb, struct bio *bp)
count = omin(count, ws_max_blks);
break;
}
- bp1 = bioq_first(&softc->delete_queue);
- if (bp1 == NULL || lba + count != bp1->bio_pblkno ||
+ bp1 = cam_iosched_next_trim(softc->cam_iosched);
+ if (bp1 == NULL)
+ break;
+ if (lba + count != bp1->bio_pblkno ||
count + bp1->bio_bcount /
- softc->params.secsize > ws_max_blks)
+ softc->params.secsize > ws_max_blks) {
+ cam_iosched_put_back_trim(softc->cam_iosched, bp1);
break;
+ }
} while (1);
scsi_write_same(&ccb->csio,
@@ -2827,6 +2940,7 @@ da_delete_ws(struct cam_periph *periph, union ccb *ccb, struct bio *bp)
da_default_timeout * 1000);
ccb->ccb_h.ccb_state = DA_CCB_DELETE;
ccb->ccb_h.flags |= CAM_UNLOCKED;
+ cam_iosched_submit_trim(softc->cam_iosched);
}
static int
@@ -2870,8 +2984,8 @@ cmd6workaround(union ccb *ccb)
da_delete_method_desc[softc->delete_method]);
while ((bp = bioq_takefirst(&softc->delete_run_queue)) != NULL)
- bioq_disksort(&softc->delete_queue, bp);
- bioq_disksort(&softc->delete_queue,
+ cam_iosched_queue_work(softc->cam_iosched, bp);
+ cam_iosched_queue_work(softc->cam_iosched,
(struct bio *)ccb->ccb_h.ccb_bp);
ccb->ccb_h.ccb_bp = NULL;
return (0);
@@ -2998,9 +3112,12 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
xpt_print(periph->path,
"Invalidating pack\n");
softc->flags |= DA_FLAG_PACK_INVALID;
+#ifdef CAM_IO_STATS
+ softc->invalidations++;
+#endif
queued_error = ENXIO;
}
- bioq_flush(&softc->bio_queue, NULL,
+ cam_iosched_flush(softc->cam_iosched, NULL,
queued_error);
if (bp != NULL) {
bp->bio_error = error;
@@ -3043,6 +3160,7 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
if (LIST_EMPTY(&softc->pending_ccbs))
softc->flags |= DA_FLAG_WAS_OTAG;
+ cam_iosched_bio_complete(softc->cam_iosched, bp, done_ccb);
xpt_release_ccb(done_ccb);
if (state == DA_CCB_DELETE) {
TAILQ_HEAD(, bio) queue;
@@ -3060,7 +3178,7 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
* and call daschedule again so that we don't stall if
* there are no other I/Os pending apart from BIO_DELETEs.
*/
- softc->delete_running = 0;
+ cam_iosched_trim_done(softc->cam_iosched);
daschedule(periph);
cam_periph_unlock(periph);
while ((bp1 = TAILQ_FIRST(&queue)) != NULL) {
@@ -3073,8 +3191,10 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
bp1->bio_resid = 0;
biodone(bp1);
}
- } else
+ } else {
+ daschedule(periph);
cam_periph_unlock(periph);
+ }
if (bp != NULL)
biodone(bp);
return;
@@ -3459,7 +3579,8 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
scsi_2btoul(bdc->medium_rotation_rate);
if (softc->disk->d_rotation_rate ==
SVPD_BDC_RATE_NON_ROTATING) {
- softc->sort_io_queue = 0;
+ cam_iosched_set_sort_queue(softc->cam_iosched, 0);
+ softc->rotating = 0;
}
if (softc->disk->d_rotation_rate != old_rate) {
disk_attr_changed(softc->disk,
@@ -3521,9 +3642,9 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
ata_params->media_rotation_rate;
if (softc->disk->d_rotation_rate ==
ATA_RATE_NON_ROTATING) {
- softc->sort_io_queue = 0;
+ cam_iosched_set_sort_queue(softc->cam_iosched, 0);
+ softc->rotating = 0;
}
-
if (softc->disk->d_rotation_rate != old_rate) {
disk_attr_changed(softc->disk,
"GEOM::rotation_rate", M_NOWAIT);
@@ -3652,6 +3773,23 @@ daerror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
if (error == ERESTART)
return (ERESTART);
+#ifdef CAM_IO_STATS
+ switch (ccb->ccb_h.status & CAM_STATUS_MASK) {
+ case CAM_CMD_TIMEOUT:
+ softc->timeouts++;
+ break;
+ case CAM_REQ_ABORTED:
+ case CAM_REQ_CMP_ERR:
+ case CAM_REQ_TERMIO:
+ case CAM_UNREC_HBA_ERROR:
+ case CAM_DATA_RUN_ERR:
+ softc->errors++;
+ break;
+ default:
+ break;
+ }
+#endif
+
/*
* XXX
* Until we have a better way of doing pack validation,
@@ -3671,9 +3809,10 @@ damediapoll(void *arg)
struct cam_periph *periph = arg;
struct da_softc *softc = periph->softc;
- if (!softc->tur && LIST_EMPTY(&softc->pending_ccbs)) {
+ if (!cam_iosched_has_work_flags(softc->cam_iosched, DA_WORK_TUR) &&
+ LIST_EMPTY(&softc->pending_ccbs)) {
if (cam_periph_acquire(periph) == CAM_REQ_CMP) {
- softc->tur = 1;
+ cam_iosched_set_work_flags(softc->cam_iosched, DA_WORK_TUR);
daschedule(periph);
}
}
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 1777fba..a92a54b 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
@@ -163,6 +163,7 @@ vdev_geom_attach(struct g_provider *pp, vdev_t *vd)
{
struct g_geom *gp;
struct g_consumer *cp;
+ int error;
g_topology_assert();
@@ -180,11 +181,17 @@ vdev_geom_attach(struct g_provider *pp, vdev_t *vd)
gp->orphan = vdev_geom_orphan;
gp->attrchanged = vdev_geom_attrchanged;
cp = g_new_consumer(gp);
- if (g_attach(cp, pp) != 0) {
+ error = g_attach(cp, pp);
+ if (error != 0) {
+ ZFS_LOG(1, "%s(%d): g_attach failed: %d\n", __func__,
+ __LINE__, error);
g_wither_geom(gp, ENXIO);
return (NULL);
}
- if (g_access(cp, 1, 0, 1) != 0) {
+ error = g_access(cp, 1, 0, 1);
+ if (error != 0) {
+ ZFS_LOG(1, "%s(%d): g_access failed: %d\n", __func__,
+ __LINE__, error);
g_wither_geom(gp, ENXIO);
return (NULL);
}
@@ -199,19 +206,29 @@ vdev_geom_attach(struct g_provider *pp, vdev_t *vd)
}
if (cp == NULL) {
cp = g_new_consumer(gp);
- if (g_attach(cp, pp) != 0) {
+ error = g_attach(cp, pp);
+ if (error != 0) {
+ ZFS_LOG(1, "%s(%d): g_attach failed: %d\n",
+ __func__, __LINE__, error);
g_destroy_consumer(cp);
return (NULL);
}
- if (g_access(cp, 1, 0, 1) != 0) {
+ error = g_access(cp, 1, 0, 1);
+ if (error != 0) {
+ ZFS_LOG(1, "%s(%d): g_access failed: %d\n",
+ __func__, __LINE__, error);
g_detach(cp);
g_destroy_consumer(cp);
return (NULL);
}
ZFS_LOG(1, "Created consumer for %s.", pp->name);
} else {
- if (g_access(cp, 1, 0, 1) != 0)
+ error = g_access(cp, 1, 0, 1);
+ if (error != 0) {
+ ZFS_LOG(1, "%s(%d): g_access failed: %d\n",
+ __func__, __LINE__, error);
return (NULL);
+ }
ZFS_LOG(1, "Used existing consumer for %s.", pp->name);
}
}
@@ -229,9 +246,6 @@ vdev_geom_attach(struct g_provider *pp, vdev_t *vd)
cp->private = vd;
vd->vdev_tsd = cp;
- /* Fetch initial physical path information for this device. */
- vdev_geom_attrchanged(cp, "GEOM::physpath");
-
cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE;
return (cp);
}
@@ -625,7 +639,8 @@ vdev_geom_open_by_guids(vdev_t *vd)
g_topology_assert();
- ZFS_LOG(1, "Searching by guid [%ju].", (uintmax_t)vd->vdev_guid);
+ ZFS_LOG(1, "Searching by guids [%ju:%ju].",
+ (uintmax_t)spa_guid(vd->vdev_spa), (uintmax_t)vd->vdev_guid);
cp = vdev_geom_attach_by_guids(vd);
if (cp != NULL) {
len = strlen(cp->provider->name) + strlen("/dev/") + 1;
@@ -787,6 +802,10 @@ vdev_geom_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,
}
}
+ /* Fetch initial physical path information for this device. */
+ if (cp != NULL)
+ vdev_geom_attrchanged(cp, "GEOM::physpath");
+
g_topology_unlock();
PICKUP_GIANT();
if (cp == NULL) {
diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c
index 572060e..bb5a475 100644
--- a/sys/compat/linux/linux_ioctl.c
+++ b/sys/compat/linux/linux_ioctl.c
@@ -2902,7 +2902,7 @@ linux_v4l_cliplist_copy(struct l_video_window *lvw, struct video_window *vw)
vw->clips = NULL;
ppvc = &(vw->clips);
while (clipcount-- > 0) {
- if (plvc == 0) {
+ if (plvc == NULL) {
error = EFAULT;
break;
} else {
diff --git a/sys/conf/NOTES b/sys/conf/NOTES
index ec5618c..406373f 100644
--- a/sys/conf/NOTES
+++ b/sys/conf/NOTES
@@ -719,7 +719,7 @@ options ALTQ_CBQ # Class Based Queueing
options ALTQ_RED # Random Early Detection
options ALTQ_RIO # RED In/Out
options ALTQ_HFSC # Hierarchical Packet Scheduler
-options ALTQ_FAIRQ # Fair Packet Scheduler
+options ALTQ_FAIRQ # Fair Packet Scheduler
options ALTQ_CDNR # Traffic conditioner
options ALTQ_PRIQ # Priority Queueing
options ALTQ_NOPCC # Required if the TSC is unusable
diff --git a/sys/conf/files b/sys/conf/files
index 46e9768..6e57021 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -68,6 +68,7 @@ usbdevs_data.h optional usb \
clean "usbdevs_data.h"
cam/cam.c optional scbus
cam/cam_compat.c optional scbus
+cam/cam_iosched.c optional scbus
cam/cam_periph.c optional scbus
cam/cam_queue.c optional scbus
cam/cam_sim.c optional scbus
@@ -1442,7 +1443,7 @@ dev/fdt/fdt_pinctrl.c optional fdt fdt_pinctrl
dev/fdt/fdt_pinctrl_if.m optional fdt fdt_pinctrl
dev/fdt/fdt_slicer.c optional fdt cfi | fdt nand | fdt mx25l
dev/fdt/fdt_static_dtb.S optional fdt fdt_dtb_static \
- dependency "$S/boot/fdt/dts/${MACHINE}/${FDT_DTS_FILE}"
+ dependency "fdt_dtb_file"
dev/fdt/simplebus.c optional fdt
dev/fe/if_fe.c optional fe
dev/fe/if_fe_pccard.c optional fe pccard
@@ -3748,6 +3749,7 @@ netpfil/ipfw/ip_dn_io.c optional inet dummynet
netpfil/ipfw/ip_dn_glue.c optional inet dummynet
netpfil/ipfw/ip_fw2.c optional inet ipfirewall
netpfil/ipfw/ip_fw_dynamic.c optional inet ipfirewall
+netpfil/ipfw/ip_fw_eaction.c optional inet ipfirewall
netpfil/ipfw/ip_fw_log.c optional inet ipfirewall
netpfil/ipfw/ip_fw_pfil.c optional inet ipfirewall
netpfil/ipfw/ip_fw_sockopt.c optional inet ipfirewall
diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64
index 85366fa..ca31558 100644
--- a/sys/conf/files.amd64
+++ b/sys/conf/files.amd64
@@ -277,6 +277,7 @@ dev/hyperv/vmbus/hv_hv.c optional hyperv
dev/hyperv/vmbus/hv_et.c optional hyperv
dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv
dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c optional hyperv
+dev/hyperv/vmbus/amd64/hv_vector.S optional hyperv
dev/nfe/if_nfe.c optional nfe pci
dev/ntb/if_ntb/if_ntb.c optional if_ntb
dev/ntb/ntb_hw/ntb_hw.c optional if_ntb | ntb_hw
diff --git a/sys/conf/files.arm b/sys/conf/files.arm
index a9da11c..b77d1fc 100644
--- a/sys/conf/files.arm
+++ b/sys/conf/files.arm
@@ -45,8 +45,8 @@ arm/arm/hdmi_if.m optional hdmi
arm/arm/identcpu.c standard
arm/arm/in_cksum.c optional inet | inet6
arm/arm/in_cksum_arm.S optional inet | inet6
-arm/arm/intr.c optional !arm_intrng
-kern/subr_intr.c optional arm_intrng
+arm/arm/intr.c optional !intrng
+kern/subr_intr.c optional intrng
arm/arm/locore.S standard no-obj
arm/arm/machdep.c standard
arm/arm/machdep_intr.c standard
@@ -57,7 +57,6 @@ arm/arm/mpcore_timer.c optional mpcore_timer
arm/arm/nexus.c standard
arm/arm/ofw_machdep.c optional fdt
arm/arm/physmem.c standard
-kern/pic_if.m optional arm_intrng
arm/arm/pl190.c optional pl190
arm/arm/pl310.c optional pl310
arm/arm/platform.c optional platform
@@ -116,6 +115,7 @@ font.h optional sc \
compile-with "uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x16.fnt && file2c 'u_char dflt_font_16[16*256] = {' '};' < ${SC_DFLT_FONT}-8x16 > font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x14.fnt && file2c 'u_char dflt_font_14[14*256] = {' '};' < ${SC_DFLT_FONT}-8x14 >> font.h && uudecode < /usr/share/syscons/fonts/${SC_DFLT_FONT}-8x8.fnt && file2c 'u_char dflt_font_8[8*256] = {' '};' < ${SC_DFLT_FONT}-8x8 >> font.h" \
no-obj no-implicit-rule before-depend \
clean "font.h ${SC_DFLT_FONT}-8x14 ${SC_DFLT_FONT}-8x16 ${SC_DFLT_FONT}-8x8"
+kern/pic_if.m optional intrng
kern/subr_busdma_bufalloc.c standard
kern/subr_sfbuf.c standard
libkern/arm/aeabi_unwind.c standard
diff --git a/sys/conf/files.i386 b/sys/conf/files.i386
index 4b6f158..eb8585f 100644
--- a/sys/conf/files.i386
+++ b/sys/conf/files.i386
@@ -252,6 +252,7 @@ dev/hyperv/vmbus/hv_hv.c optional hyperv
dev/hyperv/vmbus/hv_et.c optional hyperv
dev/hyperv/vmbus/hv_ring_buffer.c optional hyperv
dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c optional hyperv
+dev/hyperv/vmbus/i386/hv_vector.S optional hyperv
dev/ichwd/ichwd.c optional ichwd
dev/if_ndis/if_ndis.c optional ndis
dev/if_ndis/if_ndis_pccard.c optional ndis pccard
diff --git a/sys/conf/kern.post.mk b/sys/conf/kern.post.mk
index d28e87b..3286c66 100644
--- a/sys/conf/kern.post.mk
+++ b/sys/conf/kern.post.mk
@@ -215,7 +215,7 @@ DEPEND_CFLAGS+= -MT${.TARGET}
.if defined(.PARSEDIR)
# Only add in DEPEND_CFLAGS for CFLAGS on files we expect from DEPENDOBJS
# as those are the only ones we will include.
-DEPEND_CFLAGS_CONDITION= !empty(DEPENDOBJS:M${.TARGET})
+DEPEND_CFLAGS_CONDITION= "${DEPENDOBJS:M${.TARGET}}" != ""
CFLAGS+= ${${DEPEND_CFLAGS_CONDITION}:?${DEPEND_CFLAGS}:}
.else
CFLAGS+= ${DEPEND_CFLAGS}
diff --git a/sys/conf/options b/sys/conf/options
index 2283705..11e778f 100644
--- a/sys/conf/options
+++ b/sys/conf/options
@@ -329,6 +329,7 @@ CAM_DEBUG_TARGET opt_cam.h
CAM_DEBUG_LUN opt_cam.h
CAM_DEBUG_FLAGS opt_cam.h
CAM_BOOT_DELAY opt_cam.h
+CAM_NETFLIX_IOSCHED opt_cam.h
SCSI_DELAY opt_scsi.h
SCSI_NO_SENSE_STRINGS opt_scsi.h
SCSI_NO_OP_STRINGS opt_scsi.h
diff --git a/sys/conf/options.amd64 b/sys/conf/options.amd64
index 0e59187..f1d4b4a 100644
--- a/sys/conf/options.amd64
+++ b/sys/conf/options.amd64
@@ -63,7 +63,5 @@ BPF_JITTER opt_bpf.h
XENHVM opt_global.h
-HYPERV opt_global.h
-
# options for the Intel C600 SAS driver (isci)
ISCI_LOGGING opt_isci.h
diff --git a/sys/conf/options.arm b/sys/conf/options.arm
index d6d7a37..4737b80 100644
--- a/sys/conf/options.arm
+++ b/sys/conf/options.arm
@@ -1,7 +1,6 @@
#$FreeBSD$
ARMV6 opt_global.h
ARM_CACHE_LOCK_ENABLE opt_global.h
-ARM_INTRNG opt_global.h
ARM_KERN_DIRECTMAP opt_vm.h
ARM_L2_PIPT opt_global.h
ARM_MANY_BOARD opt_global.h
@@ -24,6 +23,7 @@ DEV_PMU opt_global.h
EFI opt_platform.h
FLASHADDR opt_global.h
GIC_DEFAULT_ICFGR_INIT opt_global.h
+INTRNG opt_global.h
IPI_IRQ_START opt_smp.h
IPI_IRQ_END opt_smp.h
FREEBSD_BOOT_LOADER opt_global.h
diff --git a/sys/conf/options.i386 b/sys/conf/options.i386
index 69eb7e3..e51f82c 100644
--- a/sys/conf/options.i386
+++ b/sys/conf/options.i386
@@ -123,7 +123,5 @@ BPF_JITTER opt_bpf.h
XENHVM opt_global.h
-HYPERV opt_global.h
-
# options for the Intel C600 SAS driver (isci)
ISCI_LOGGING opt_isci.h
diff --git a/sys/conf/options.mips b/sys/conf/options.mips
index 69708cc..daae01f 100644
--- a/sys/conf/options.mips
+++ b/sys/conf/options.mips
@@ -144,4 +144,5 @@ PV_STATS opt_pmap.h
#
# Options to use INTRNG code
#
-MIPS_INTRNG opt_global.h
+INTRNG opt_global.h
+MIPS_NIRQ opt_global.h
diff --git a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
index 3b74f8c..2796055 100644
--- a/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
+++ b/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
@@ -738,7 +738,7 @@ ipf_fastroute(m0, mpp, fin, fdp)
*/
if (M_WRITABLE(m) == 0) {
m0 = m_dup(m, M_NOWAIT);
- if (m0 != 0) {
+ if (m0 != NULL) {
FREE_MB_T(m);
m = m0;
*mpp = m;
@@ -885,7 +885,7 @@ ipf_fastroute(m0, mpp, fin, fdp)
#else
MGET(m, M_NOWAIT, MT_HEADER);
#endif
- if (m == 0) {
+ if (m == NULL) {
m = m0;
error = ENOBUFS;
goto bad;
diff --git a/sys/contrib/rdma/krping/krping.c b/sys/contrib/rdma/krping/krping.c
index 931f760..8e91e2a 100644
--- a/sys/contrib/rdma/krping/krping.c
+++ b/sys/contrib/rdma/krping/krping.c
@@ -54,8 +54,8 @@ __FBSDID("$FreeBSD$");
#include "getopt.h"
extern int krping_debug;
-#define DEBUG_LOG(cb, x...) if (krping_debug) krping_printf((cb)->cookie, x)
-#define PRINTF(cb, x...) krping_printf((cb)->cookie, x)
+#define DEBUG_LOG(cb, x...) if (krping_debug) log(LOG_INFO, x)
+#define PRINTF(cb, x...) log(LOG_INFO, x)
#define BIND_INFO 1
MODULE_AUTHOR("Steve Wise");
@@ -376,8 +376,8 @@ static void krping_cq_event_handler(struct ib_cq *cq, void *ctx)
continue;
} else {
PRINTF(cb, "cq completion failed with "
- "wr_id %Lx status %d opcode %d vender_err %x\n",
- wc.wr_id, wc.status, wc.opcode, wc.vendor_err);
+ "wr_id %jx status %d opcode %d vender_err %x\n",
+ (uintmax_t)wc.wr_id, wc.status, wc.opcode, wc.vendor_err);
goto error;
}
}
@@ -570,8 +570,8 @@ static int krping_setup_buffers(struct krping_cb *cb)
if (!cb->local_dma_lkey) {
buf.addr = cb->recv_dma_addr;
buf.size = sizeof cb->recv_buf;
- DEBUG_LOG(cb, "recv buf dma_addr %llx size %d\n", buf.addr,
- (int)buf.size);
+ DEBUG_LOG(cb, "recv buf dma_addr %jx size %d\n",
+ (uintmax_t)buf.addr, (int)buf.size);
iovbase = cb->recv_dma_addr;
cb->recv_mr = ib_reg_phys_mr(cb->pd, &buf, 1,
IB_ACCESS_LOCAL_WRITE,
@@ -585,8 +585,8 @@ static int krping_setup_buffers(struct krping_cb *cb)
buf.addr = cb->send_dma_addr;
buf.size = sizeof cb->send_buf;
- DEBUG_LOG(cb, "send buf dma_addr %llx size %d\n", buf.addr,
- (int)buf.size);
+ DEBUG_LOG(cb, "send buf dma_addr %jx size %d\n",
+ (uintmax_t)buf.addr, (int)buf.size);
iovbase = cb->send_dma_addr;
cb->send_mr = ib_reg_phys_mr(cb->pd, &buf, 1,
0, &iovbase);
@@ -657,8 +657,8 @@ static int krping_setup_buffers(struct krping_cb *cb)
ret = PTR_ERR(cb->rdma_mr);
goto bail;
}
- DEBUG_LOG(cb, "rdma buf dma_addr %llx size %d mr rkey 0x%x\n",
- buf.addr, (int)buf.size, cb->rdma_mr->rkey);
+ DEBUG_LOG(cb, "rdma buf dma_addr %jx size %d mr rkey 0x%x\n",
+ (uintmax_t)buf.addr, (int)buf.size, cb->rdma_mr->rkey);
break;
default:
ret = -EINVAL;
@@ -691,8 +691,8 @@ static int krping_setup_buffers(struct krping_cb *cb)
buf.addr = cb->start_dma_addr;
buf.size = cb->size;
- DEBUG_LOG(cb, "start buf dma_addr %llx size %d\n",
- buf.addr, (int)buf.size);
+ DEBUG_LOG(cb, "start buf dma_addr %jx size %d\n",
+ (uintmax_t)buf.addr, (int)buf.size);
iovbase = cb->start_dma_addr;
cb->start_mr = ib_reg_phys_mr(cb->pd, &buf, 1,
flags,
@@ -882,16 +882,16 @@ static u32 krping_rdma_rkey(struct krping_cb *cb, u64 buf, int post_inv)
for (i=0; i < cb->fastreg_wr.wr.fast_reg.page_list_len;
i++, p += PAGE_SIZE) {
cb->page_list->page_list[i] = p;
- DEBUG_LOG(cb, "page_list[%d] 0x%llx\n", i, p);
+ DEBUG_LOG(cb, "page_list[%d] 0x%jx\n", i, (uintmax_t)p);
}
DEBUG_LOG(cb, "post_inv = %d, fastreg new rkey 0x%x shift %u len %u"
- " iova_start %llx page_list_len %u\n",
+ " iova_start %jx page_list_len %u\n",
post_inv,
cb->fastreg_wr.wr.fast_reg.rkey,
cb->fastreg_wr.wr.fast_reg.page_shift,
cb->fastreg_wr.wr.fast_reg.length,
- cb->fastreg_wr.wr.fast_reg.iova_start,
+ (uintmax_t)cb->fastreg_wr.wr.fast_reg.iova_start,
cb->fastreg_wr.wr.fast_reg.page_list_len);
if (post_inv)
@@ -930,9 +930,9 @@ static u32 krping_rdma_rkey(struct krping_cb *cb, u64 buf, int post_inv)
#else
cb->bind_attr.addr = buf;
#endif
- DEBUG_LOG(cb, "binding mw rkey 0x%x to buf %llx mr rkey 0x%x\n",
+ DEBUG_LOG(cb, "binding mw rkey 0x%x to buf %jx mr rkey 0x%x\n",
#ifdef BIND_INFO
- cb->mw->rkey, buf, cb->bind_attr.bind_info.mr->rkey);
+ cb->mw->rkey, (uintmax_t)buf, cb->bind_attr.bind_info.mr->rkey);
#else
cb->mw->rkey, buf, cb->bind_attr.mr->rkey);
#endif
@@ -1199,8 +1199,8 @@ static void rlat_test(struct krping_cb *cb)
}
PRINTF(cb, "delta sec %lu delta usec %lu iter %d size %d\n",
- stop_tv.tv_sec - start_tv.tv_sec,
- stop_tv.tv_usec - start_tv.tv_usec,
+ (unsigned long)(stop_tv.tv_sec - start_tv.tv_sec),
+ (unsigned long)(stop_tv.tv_usec - start_tv.tv_usec),
scnt, cb->size);
}
@@ -1333,12 +1333,12 @@ static void wlat_test(struct krping_cb *cb)
sum_poll += poll_cycles_stop[i] - poll_cycles_start[i];
sum_last_poll += poll_cycles_stop[i]-last_poll_cycles_start[i];
}
- PRINTF(cb,
+ PRINTF(cb,
"delta sec %lu delta usec %lu iter %d size %d cycle_iters %d"
" sum_post %llu sum_poll %llu sum_last_poll %llu\n",
- stop_tv.tv_sec - start_tv.tv_sec,
- stop_tv.tv_usec - start_tv.tv_usec,
- scnt, cb->size, cycle_iters,
+ (unsigned long)(stop_tv.tv_sec - start_tv.tv_sec),
+ (unsigned long)(stop_tv.tv_usec - start_tv.tv_usec),
+ scnt, cb->size, cycle_iters,
(unsigned long long)sum_post, (unsigned long long)sum_poll,
(unsigned long long)sum_last_poll);
kfree(post_cycles_start);
@@ -1459,11 +1459,11 @@ static void bw_test(struct krping_cb *cb)
sum_poll += poll_cycles_stop[i] - poll_cycles_start[i];
sum_last_poll += poll_cycles_stop[i]-last_poll_cycles_start[i];
}
- PRINTF(cb,
+ PRINTF(cb,
"delta sec %lu delta usec %lu iter %d size %d cycle_iters %d"
" sum_post %llu sum_poll %llu sum_last_poll %llu\n",
- stop_tv.tv_sec - start_tv.tv_sec,
- stop_tv.tv_usec - start_tv.tv_usec,
+ (unsigned long)(stop_tv.tv_sec - start_tv.tv_sec),
+ (unsigned long)(stop_tv.tv_usec - start_tv.tv_usec),
scnt, cb->size, cycle_iters,
(unsigned long long)sum_post, (unsigned long long)sum_poll,
(unsigned long long)sum_last_poll);
@@ -1588,12 +1588,12 @@ static int fastreg_supported(struct krping_cb *cb, int server)
return 0;
}
if (!(attr.device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS)) {
- PRINTF(cb, "Fastreg not supported - device_cap_flags 0x%x\n",
- attr.device_cap_flags);
+ PRINTF(cb, "Fastreg not supported - device_cap_flags 0x%llx\n",
+ (unsigned long long)attr.device_cap_flags);
return 0;
}
- DEBUG_LOG(cb, "Fastreg supported - device_cap_flags 0x%x\n",
- attr.device_cap_flags);
+ DEBUG_LOG(cb, "Fastreg supported - device_cap_flags 0x%jx\n",
+ (uintmax_t)attr.device_cap_flags);
return 1;
}
@@ -1664,19 +1664,19 @@ static void krping_fr_test5(struct krping_cb *cb)
}
pl = kzalloc(sizeof *pl * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s pl %p size %lu\n", __func__, pl, sizeof *pl * depth);
+ DEBUG_LOG(cb, "%s pl %p size %zu\n", __func__, pl, sizeof *pl * depth);
mr = kzalloc(sizeof *mr * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s mr %p size %lu\n", __func__, mr, sizeof *mr * depth);
+ DEBUG_LOG(cb, "%s mr %p size %zu\n", __func__, mr, sizeof *mr * depth);
fr = kzalloc(sizeof *fr * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s fr %p size %lu\n", __func__, fr, sizeof *fr * depth);
+ DEBUG_LOG(cb, "%s fr %p size %zu\n", __func__, fr, sizeof *fr * depth);
sgl = kzalloc(sizeof *sgl * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s sgl %p size %lu\n", __func__, sgl, sizeof *sgl * depth);
+ DEBUG_LOG(cb, "%s sgl %p size %zu\n", __func__, sgl, sizeof *sgl * depth);
read = kzalloc(sizeof *read * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s read %p size %lu\n", __func__, read, sizeof *read * depth);
+ DEBUG_LOG(cb, "%s read %p size %zu\n", __func__, read, sizeof *read * depth);
buf = kzalloc(sizeof *buf * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s buf %p size %lu\n", __func__, buf, sizeof *buf * depth);
+ DEBUG_LOG(cb, "%s buf %p size %zu\n", __func__, buf, sizeof *buf * depth);
dma_addr = kzalloc(sizeof *dma_addr * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s dma_addr %p size %lu\n", __func__, dma_addr, sizeof *dma_addr * depth);
+ DEBUG_LOG(cb, "%s dma_addr %p size %zu\n", __func__, dma_addr, sizeof *dma_addr * depth);
if (!pl || !mr || !fr || !read || !sgl || !buf || !dma_addr) {
PRINTF(cb, "kzalloc failed\n");
goto err1;
@@ -1719,16 +1719,16 @@ static void krping_fr_test5(struct krping_cb *cb)
DEBUG_LOG(cb, "%s dma_addr[%u] %p\n", __func__, scnt, (void *)dma_addr[scnt]);
for (i=0; i<plen; i++) {
pl[scnt]->page_list[i] = ((unsigned long)dma_addr[scnt] & PAGE_MASK) + (i * PAGE_SIZE);
- DEBUG_LOG(cb, "%s pl[%u]->page_list[%u] 0x%llx\n",
- __func__, scnt, i, pl[scnt]->page_list[i]);
+ DEBUG_LOG(cb, "%s pl[%u]->page_list[%u] 0x%jx\n",
+ __func__, scnt, i, (uintmax_t)pl[scnt]->page_list[i]);
}
sgl[scnt].lkey = mr[scnt]->rkey;
sgl[scnt].length = cb->size;
sgl[scnt].addr = (u64)buf[scnt];
- DEBUG_LOG(cb, "%s sgl[%u].lkey 0x%x length %u addr 0x%llx\n",
+ DEBUG_LOG(cb, "%s sgl[%u].lkey 0x%x length %u addr 0x%jx\n",
__func__, scnt, sgl[scnt].lkey, sgl[scnt].length,
- sgl[scnt].addr);
+ (uintmax_t)sgl[scnt].addr);
fr[scnt].opcode = IB_WR_FAST_REG_MR;
fr[scnt].wr_id = scnt;
@@ -1778,9 +1778,9 @@ static void krping_fr_test5(struct krping_cb *cb)
if (ret == 1) {
if (wc.status) {
PRINTF(cb,
- "completion error %u wr_id %lld "
+ "completion error %u wr_id %ju "
"opcode %d\n", wc.status,
- wc.wr_id, wc.opcode);
+ (uintmax_t)wc.wr_id, wc.opcode);
goto err2;
}
count++;
@@ -1877,8 +1877,8 @@ static void krping_fr_test5_server(struct krping_cb *cb)
while (cb->state < RDMA_READ_ADV) {
krping_cq_event_handler(cb->cq, cb);
}
- DEBUG_LOG(cb, "%s client STAG %x TO 0x%llx\n", __func__,
- cb->remote_rkey, cb->remote_addr);
+ DEBUG_LOG(cb, "%s client STAG %x TO 0x%jx\n", __func__,
+ cb->remote_rkey, (uintmax_t)cb->remote_addr);
/* Send STAG/TO/Len to client */
krping_format_send(cb, cb->start_dma_addr);
@@ -1940,7 +1940,8 @@ static void krping_fr_test5_client(struct krping_cb *cb)
while (cb->state < RDMA_WRITE_ADV) {
krping_cq_event_handler(cb->cq, cb);
}
- DEBUG_LOG(cb, "%s server STAG %x TO 0x%llx\n", __func__, cb->remote_rkey, cb->remote_addr);
+ DEBUG_LOG(cb, "%s server STAG %x TO 0x%jx\n", __func__, cb->remote_rkey,
+ (uintmax_t)cb->remote_addr);
return krping_fr_test5(cb);
}
@@ -1978,28 +1979,28 @@ static void krping_fr_test6(struct krping_cb *cb)
}
pl = kzalloc(sizeof *pl * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s pl %p size %lu\n", __func__, pl, sizeof *pl * depth);
+ DEBUG_LOG(cb, "%s pl %p size %zu\n", __func__, pl, sizeof *pl * depth);
mr = kzalloc(sizeof *mr * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s mr %p size %lu\n", __func__, mr, sizeof *mr * depth);
+ DEBUG_LOG(cb, "%s mr %p size %zu\n", __func__, mr, sizeof *mr * depth);
fr = kzalloc(sizeof *fr * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s fr %p size %lu\n", __func__, fr, sizeof *fr * depth);
+ DEBUG_LOG(cb, "%s fr %p size %zu\n", __func__, fr, sizeof *fr * depth);
sgl = kzalloc(sizeof *sgl * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s sgl %p size %lu\n", __func__, sgl, sizeof *sgl * depth);
+ DEBUG_LOG(cb, "%s sgl %p size %zu\n", __func__, sgl, sizeof *sgl * depth);
write = kzalloc(sizeof *write * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s read %p size %lu\n", __func__, write, sizeof *write * depth);
+ DEBUG_LOG(cb, "%s read %p size %zu\n", __func__, write, sizeof *write * depth);
inv = kzalloc(sizeof *inv * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s inv %p size %lu\n", __func__, inv, sizeof *inv * depth);
+ DEBUG_LOG(cb, "%s inv %p size %zu\n", __func__, inv, sizeof *inv * depth);
buf = kzalloc(sizeof *buf * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s buf %p size %lu\n", __func__, buf, sizeof *buf * depth);
+ DEBUG_LOG(cb, "%s buf %p size %zu\n", __func__, buf, sizeof *buf * depth);
dma_addr = kzalloc(sizeof *dma_addr * depth, GFP_KERNEL);
- DEBUG_LOG(cb, "%s dma_addr %p size %lu\n", __func__, dma_addr, sizeof *dma_addr * depth);
+ DEBUG_LOG(cb, "%s dma_addr %p size %zu\n", __func__, dma_addr, sizeof *dma_addr * depth);
if (!pl || !mr || !fr || !write || !sgl || !buf || !dma_addr) {
PRINTF(cb, "kzalloc failed\n");
@@ -2043,8 +2044,8 @@ static void krping_fr_test6(struct krping_cb *cb)
DEBUG_LOG(cb, "%s dma_addr[%u] %p\n", __func__, scnt, (void *)dma_addr[scnt]);
for (i=0; i<plen; i++) {
pl[scnt]->page_list[i] = ((unsigned long)dma_addr[scnt] & PAGE_MASK) + (i * PAGE_SIZE);
- DEBUG_LOG(cb, "%s pl[%u]->page_list[%u] 0x%llx\n",
- __func__, scnt, i, pl[scnt]->page_list[i]);
+ DEBUG_LOG(cb, "%s pl[%u]->page_list[%u] 0x%jx\n",
+ __func__, scnt, i, (uintmax_t)pl[scnt]->page_list[i]);
}
write[scnt].opcode = IB_WR_RDMA_WRITE;
@@ -2101,9 +2102,9 @@ static void krping_fr_test6(struct krping_cb *cb)
if (ret == 1) {
if (wc.status) {
PRINTF(cb,
- "completion error %u wr_id %lld "
+ "completion error %u wr_id %ju "
"opcode %d\n", wc.status,
- wc.wr_id, wc.opcode);
+ (uintmax_t)wc.wr_id, wc.opcode);
goto err2;
}
count++;
@@ -2200,8 +2201,8 @@ static void krping_fr_test6_server(struct krping_cb *cb)
while (cb->state < RDMA_READ_ADV) {
krping_cq_event_handler(cb->cq, cb);
}
- DEBUG_LOG(cb, "%s client STAG %x TO 0x%llx\n", __func__,
- cb->remote_rkey, cb->remote_addr);
+ DEBUG_LOG(cb, "%s client STAG %x TO 0x%jx\n", __func__,
+ cb->remote_rkey, (uintmax_t)cb->remote_addr);
/* Send STAG/TO/Len to client */
krping_format_send(cb, cb->start_dma_addr);
@@ -2263,7 +2264,8 @@ static void krping_fr_test6_client(struct krping_cb *cb)
while (cb->state < RDMA_WRITE_ADV) {
krping_cq_event_handler(cb->cq, cb);
}
- DEBUG_LOG(cb, "%s server STAG %x TO 0x%llx\n", __func__, cb->remote_rkey, cb->remote_addr);
+ DEBUG_LOG(cb, "%s server STAG %x TO 0x%jx\n", __func__, cb->remote_rkey,
+ (uintmax_t)cb->remote_addr);
return krping_fr_test6(cb);
}
diff --git a/sys/contrib/rdma/krping/krping.h b/sys/contrib/rdma/krping/krping.h
index 04be531..f201d10 100644
--- a/sys/contrib/rdma/krping/krping.h
+++ b/sys/contrib/rdma/krping/krping.h
@@ -17,5 +17,4 @@ struct krping_stats {
int krping_doit(char *, void *);
void krping_walk_cb_list(void (*)(struct krping_stats *, void *), void *);
void krping_init(void);
-void krping_printf(void *, const char *, ...);
int krping_sigpending(void);
diff --git a/sys/contrib/rdma/krping/krping_dev.c b/sys/contrib/rdma/krping/krping_dev.c
index 2244d72..7902ebf 100644
--- a/sys/contrib/rdma/krping/krping_dev.c
+++ b/sys/contrib/rdma/krping/krping_dev.c
@@ -209,16 +209,6 @@ krping_write(struct cdev *dev, struct uio *uio, int ioflag)
return(err);
}
-void
-krping_printf(void *cookie, const char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- vtprintf(cookie, -1, fmt, ap);
- va_end(ap);
-}
-
int
krping_sigpending(void)
{
diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c
index 0d4f28f..4f66498 100644
--- a/sys/ddb/db_command.c
+++ b/sys/ddb/db_command.c
@@ -144,7 +144,7 @@ static struct command db_cmds[] = {
};
struct command_table db_cmd_table = LIST_HEAD_INITIALIZER(db_cmd_table);
-static struct command *db_last_command = 0;
+static struct command *db_last_command = NULL;
/*
* if 'ed' style: 'dot' is set at start of last item printed,
@@ -429,7 +429,7 @@ db_command(struct command **last_cmdp, struct command_table *cmd_table,
}
}
*last_cmdp = cmd;
- if (cmd != 0) {
+ if (cmd != NULL) {
/*
* Execute the command.
*/
diff --git a/sys/ddb/db_ps.c b/sys/ddb/db_ps.c
index 76ab2c5..e20b363 100644
--- a/sys/ddb/db_ps.c
+++ b/sys/ddb/db_ps.c
@@ -184,7 +184,8 @@ db_ps(db_expr_t addr, bool hasaddr, db_expr_t count, char *modif)
strlcat(state, "V", sizeof(state));
if (p->p_flag & P_SYSTEM || p->p_lock > 0)
strlcat(state, "L", sizeof(state));
- if (p->p_session != NULL && SESS_LEADER(p))
+ if (p->p_pgrp != NULL && p->p_session != NULL &&
+ SESS_LEADER(p))
strlcat(state, "s", sizeof(state));
/* Cheated here and didn't compare pgid's. */
if (p->p_flag & P_CONTROLT)
diff --git a/sys/ddb/db_sym.c b/sys/ddb/db_sym.c
index ffcba79..25ae4bc 100644
--- a/sys/ddb/db_sym.c
+++ b/sys/ddb/db_sym.c
@@ -395,7 +395,7 @@ db_symbol_values(c_db_sym_t sym, const char **namep, db_expr_t *valuep)
db_expr_t value;
if (sym == DB_SYM_NULL) {
- *namep = 0;
+ *namep = NULL;
return;
}
@@ -438,13 +438,13 @@ db_printsym(db_expr_t off, db_strategy_t strategy)
cursym = db_search_symbol(off, strategy, &d);
db_symbol_values(cursym, &name, &value);
- if (name == 0)
+ if (name == NULL)
value = off;
if (value >= DB_SMALL_VALUE_MIN && value <= DB_SMALL_VALUE_MAX) {
db_printf("%+#lr", (long)off);
return;
}
- if (name == 0 || d >= (unsigned long)db_maxoff) {
+ if (name == NULL || d >= (unsigned long)db_maxoff) {
db_printf("%#lr", (unsigned long)off);
return;
}
diff --git a/sys/dev/acpica/acpi_pci.c b/sys/dev/acpica/acpi_pci.c
index 1dee131..44b5804 100644
--- a/sys/dev/acpica/acpi_pci.c
+++ b/sys/dev/acpica/acpi_pci.c
@@ -70,7 +70,7 @@ CTASSERT(ACPI_STATE_D1 == PCI_POWERSTATE_D1);
CTASSERT(ACPI_STATE_D2 == PCI_POWERSTATE_D2);
CTASSERT(ACPI_STATE_D3 == PCI_POWERSTATE_D3);
-static int acpi_pci_attach(device_t dev);
+static struct pci_devinfo *acpi_pci_alloc_devinfo(device_t dev);
static void acpi_pci_child_deleted(device_t dev, device_t child);
static int acpi_pci_child_location_str_method(device_t cbdev,
device_t child, char *buf, size_t buflen);
@@ -86,15 +86,9 @@ static int acpi_pci_set_powerstate_method(device_t dev, device_t child,
static void acpi_pci_update_device(ACPI_HANDLE handle, device_t pci_child);
static bus_dma_tag_t acpi_pci_get_dma_tag(device_t bus, device_t child);
-#ifdef PCI_IOV
-static device_t acpi_pci_create_iov_child(device_t bus, device_t pf,
- uint16_t rid, uint16_t vid, uint16_t did);
-#endif
-
static device_method_t acpi_pci_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, acpi_pci_probe),
- DEVMETHOD(device_attach, acpi_pci_attach),
/* Bus interface */
DEVMETHOD(bus_read_ivar, acpi_pci_read_ivar),
@@ -105,11 +99,9 @@ static device_method_t acpi_pci_methods[] = {
DEVMETHOD(bus_get_domain, acpi_get_domain),
/* PCI interface */
+ DEVMETHOD(pci_alloc_devinfo, acpi_pci_alloc_devinfo),
DEVMETHOD(pci_child_added, acpi_pci_child_added),
DEVMETHOD(pci_set_powerstate, acpi_pci_set_powerstate_method),
-#ifdef PCI_IOV
- DEVMETHOD(pci_create_iov_child, acpi_pci_create_iov_child),
-#endif
DEVMETHOD_END
};
@@ -123,6 +115,15 @@ MODULE_DEPEND(acpi_pci, acpi, 1, 1, 1);
MODULE_DEPEND(acpi_pci, pci, 1, 1, 1);
MODULE_VERSION(acpi_pci, 1);
+static struct pci_devinfo *
+acpi_pci_alloc_devinfo(device_t dev)
+{
+ struct acpi_pci_devinfo *dinfo;
+
+ dinfo = malloc(sizeof(*dinfo), M_DEVBUF, M_WAITOK | M_ZERO);
+ return (&dinfo->ap_dinfo);
+}
+
static int
acpi_pci_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
{
@@ -298,38 +299,6 @@ void
acpi_pci_child_added(device_t dev, device_t child)
{
- AcpiWalkNamespace(ACPI_TYPE_DEVICE, acpi_get_handle(dev), 1,
- acpi_pci_save_handle, NULL, child, NULL);
-}
-
-static int
-acpi_pci_probe(device_t dev)
-{
-
- if (acpi_get_handle(dev) == NULL)
- return (ENXIO);
- device_set_desc(dev, "ACPI PCI bus");
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-acpi_pci_attach(device_t dev)
-{
- int busno, domain, error;
-
- error = pci_attach_common(dev);
- if (error)
- return (error);
-
- /*
- * Since there can be multiple independantly numbered PCI
- * busses on systems with multiple PCI domains, we can't use
- * the unit number to decide which bus we are probing. We ask
- * the parent pcib what our domain and bus numbers are.
- */
- domain = pcib_get_domain(dev);
- busno = pcib_get_bus(dev);
-
/*
* PCI devices are added via the bus scan in the normal PCI
* bus driver. As each device is added, the
@@ -342,9 +311,18 @@ acpi_pci_attach(device_t dev)
* pci_add_children() doesn't find. We currently just ignore
* these devices.
*/
- pci_add_children(dev, domain, busno, sizeof(struct acpi_pci_devinfo));
+ AcpiWalkNamespace(ACPI_TYPE_DEVICE, acpi_get_handle(dev), 1,
+ acpi_pci_save_handle, NULL, child, NULL);
+}
+
+static int
+acpi_pci_probe(device_t dev)
+{
- return (bus_generic_attach(dev));
+ if (acpi_get_handle(dev) == NULL)
+ return (ENXIO);
+ device_set_desc(dev, "ACPI PCI bus");
+ return (BUS_PROBE_DEFAULT);
}
#ifdef ACPI_DMAR
@@ -372,14 +350,3 @@ acpi_pci_get_dma_tag(device_t bus, device_t child)
}
#endif
-#ifdef PCI_IOV
-static device_t
-acpi_pci_create_iov_child(device_t bus, device_t pf, uint16_t rid, uint16_t vid,
- uint16_t did)
-{
-
- return (pci_add_iov_child(bus, pf, sizeof(struct acpi_pci_devinfo), rid,
- vid, did));
-}
-#endif
-
diff --git a/sys/dev/ahci/ahci.c b/sys/dev/ahci/ahci.c
index 8341f66..b27e30d 100644
--- a/sys/dev/ahci/ahci.c
+++ b/sys/dev/ahci/ahci.c
@@ -2417,6 +2417,9 @@ ahci_setup_fis(struct ahci_channel *ch, struct ahci_cmd_tab *ctp, union ccb *ccb
fis[13] = ccb->ataio.cmd.sector_count_exp;
}
fis[15] = ATA_A_4BIT;
+ /* Gross and vile hack -- makes ncq trim work w/o changing ataio size */
+ if (ccb->ataio.cmd.flags & CAM_ATAIO_AUX_HACK)
+ fis[16] = 1;
} else {
fis[15] = ccb->ataio.cmd.control;
}
@@ -2674,7 +2677,7 @@ ahciaction(struct cam_sim *sim, union ccb *ccb)
if (ch->caps & AHCI_CAP_SPM)
cpi->hba_inquiry |= PI_SATAPM;
cpi->target_sprt = 0;
- cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED;
+ cpi->hba_misc = PIM_SEQSCAN | PIM_UNMAPPED | PIM_NCQ_KLUDGE;
cpi->hba_eng_cnt = 0;
if (ch->caps & AHCI_CAP_SPM)
cpi->max_target = 15;
diff --git a/sys/dev/cardbus/cardbus.c b/sys/dev/cardbus/cardbus.c
index e785b0f..a6037e1 100644
--- a/sys/dev/cardbus/cardbus.c
+++ b/sys/dev/cardbus/cardbus.c
@@ -169,6 +169,15 @@ cardbus_device_setup_regs(pcicfgregs *cfg)
pci_write_config(dev, PCIR_MAXLAT, 0x14, 1);
}
+static struct pci_devinfo *
+cardbus_alloc_devinfo(device_t dev)
+{
+ struct cardbus_devinfo *dinfo;
+
+ dinfo = malloc(sizeof(*dinfo), M_DEVBUF, M_WAITOK | M_ZERO);
+ return (&dinfo->pci);
+}
+
static int
cardbus_attach_card(device_t cbdev)
{
@@ -191,8 +200,7 @@ cardbus_attach_card(device_t cbdev)
struct cardbus_devinfo *dinfo;
dinfo = (struct cardbus_devinfo *)
- pci_read_device(brdev, domain, bus, slot, func,
- sizeof(struct cardbus_devinfo));
+ pci_read_device(brdev, cbdev, domain, bus, slot, func);
if (dinfo == NULL)
continue;
if (dinfo->pci.cfg.mfdev)
@@ -343,6 +351,9 @@ static device_method_t cardbus_methods[] = {
DEVMETHOD(card_attach_card, cardbus_attach_card),
DEVMETHOD(card_detach_card, cardbus_detach_card),
+ /* PCI interface */
+ DEVMETHOD(pci_alloc_devinfo, cardbus_alloc_devinfo),
+
{0,0}
};
diff --git a/sys/dev/fdt/fdt_common.h b/sys/dev/fdt/fdt_common.h
index 17af344..94f84ff 100644
--- a/sys/dev/fdt/fdt_common.h
+++ b/sys/dev/fdt/fdt_common.h
@@ -45,7 +45,7 @@ struct fdt_sense_level {
enum intr_polarity pol;
};
-#if defined(__arm__) && !defined(ARM_INTRNG)
+#if defined(__arm__) && !defined(INTRNG)
typedef int (*fdt_pic_decode_t)(phandle_t, pcell_t *, int *, int *, int *);
extern fdt_pic_decode_t fdt_pic_table[];
#endif
diff --git a/sys/dev/fdt/fdt_powerpc.c b/sys/dev/fdt/fdt_powerpc.c
index f408d0a..80cfa4b 100644
--- a/sys/dev/fdt/fdt_powerpc.c
+++ b/sys/dev/fdt/fdt_powerpc.c
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
#include "fdt_common.h"
static void
-fdt_fixup_busfreq(phandle_t root)
+fdt_fixup_busfreq(phandle_t root, uint32_t div)
{
phandle_t sb, cpus, child;
pcell_t freq;
@@ -72,12 +72,71 @@ fdt_fixup_busfreq(phandle_t root)
sizeof(freq)) <= 0)
return;
+ if (div == 0)
+ return;
+
+ freq /= div;
+
OF_setprop(sb, "bus-frequency", (void *)&freq, sizeof(freq));
}
+static void
+fdt_fixup_busfreq_mpc85xx(phandle_t root)
+{
+
+ fdt_fixup_busfreq(root, 1);
+}
+
+static void
+fdt_fixup_busfreq_dpaa(phandle_t root)
+{
+
+ fdt_fixup_busfreq(root, 2);
+}
+
+static void
+fdt_fixup_fman(phandle_t root)
+{
+ phandle_t node;
+ pcell_t freq;
+
+ if ((node = fdt_find_compatible(root, "simple-bus", 1)) == 0)
+ return;
+
+ if (OF_getprop(node, "bus-frequency", (void *)&freq,
+ sizeof(freq)) <= 0)
+ return;
+
+ /*
+ * Set clock-frequency for FMan nodes (only on QorIQ DPAA targets).
+ * That frequency is equal to /soc node bus-frequency.
+ */
+ for (node = OF_child(node); node != 0; node = OF_peer(node)) {
+ if (fdt_is_compatible(node, "fsl,fman") == 0)
+ continue;
+
+ if (OF_setprop(node, "clock-frequency", (void *)&freq,
+ sizeof(freq)) == -1) {
+ /*
+ * XXX Shall we take some actions if no clock-frequency
+ * property was found?
+ */
+ }
+ }
+}
+
struct fdt_fixup_entry fdt_fixup_table[] = {
- { "fsl,MPC8572DS", &fdt_fixup_busfreq },
- { "MPC8555CDS", &fdt_fixup_busfreq },
+ { "fsl,MPC8572DS", &fdt_fixup_busfreq_mpc85xx },
+ { "MPC8555CDS", &fdt_fixup_busfreq_mpc85xx },
+ { "fsl,P2020", &fdt_fixup_busfreq_mpc85xx },
+ { "fsl,P2041RDB", &fdt_fixup_busfreq_dpaa },
+ { "fsl,P2041RDB", &fdt_fixup_fman },
+ { "fsl,P3041DS", &fdt_fixup_busfreq_dpaa },
+ { "fsl,P3041DS", &fdt_fixup_fman },
+ { "fsl,P5020DS", &fdt_fixup_busfreq_dpaa },
+ { "fsl,P5020DS", &fdt_fixup_fman },
+ { "varisys,CYRUS", &fdt_fixup_busfreq_dpaa },
+ { "varisys,CYRUS", &fdt_fixup_fman },
{ NULL, NULL }
};
diff --git a/sys/dev/flash/mx25l.c b/sys/dev/flash/mx25l.c
index 6b71340..96fb4a4 100644
--- a/sys/dev/flash/mx25l.c
+++ b/sys/dev/flash/mx25l.c
@@ -432,6 +432,12 @@ mx25l_set_4b_mode(device_t dev, uint8_t command)
return (err);
}
+static struct ofw_compat_data compat_data[] = {
+ { "st,m25p", 1 },
+ { "jedec,spi-nor", 1 },
+ { NULL, 0 },
+};
+
static int
mx25l_probe(device_t dev)
{
@@ -439,7 +445,7 @@ mx25l_probe(device_t dev)
#ifdef FDT
if (!ofw_bus_status_okay(dev))
return (ENXIO);
- if (!ofw_bus_is_compatible(dev, "st,m25p"))
+ if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
return (ENXIO);
#endif
device_set_desc(dev, "M25Pxx Flash Family");
diff --git a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
index 933f454..153f9c3 100644
--- a/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
+++ b/sys/dev/hyperv/netvsc/hv_netvsc_drv_freebsd.c
@@ -419,7 +419,6 @@ netvsc_attach(device_t dev)
sc = device_get_softc(dev);
- bzero(sc, sizeof(hn_softc_t));
sc->hn_unit = unit;
sc->hn_dev = dev;
@@ -2809,8 +2808,10 @@ hn_channel_attach(struct hn_softc *sc, struct hv_vmbus_channel *chan)
rxr->hn_rx_flags |= HN_RX_FLAG_ATTACHED;
chan->hv_chan_rxr = rxr;
- if_printf(sc->hn_ifp, "link RX ring %d to channel%u\n",
- idx, chan->offer_msg.child_rel_id);
+ if (bootverbose) {
+ if_printf(sc->hn_ifp, "link RX ring %d to channel%u\n",
+ idx, chan->offer_msg.child_rel_id);
+ }
if (idx < sc->hn_tx_ring_inuse) {
struct hn_tx_ring *txr = &sc->hn_tx_ring[idx];
@@ -2821,8 +2822,10 @@ hn_channel_attach(struct hn_softc *sc, struct hv_vmbus_channel *chan)
chan->hv_chan_txr = txr;
txr->hn_chan = chan;
- if_printf(sc->hn_ifp, "link TX ring %d to channel%u\n",
- idx, chan->offer_msg.child_rel_id);
+ if (bootverbose) {
+ if_printf(sc->hn_ifp, "link TX ring %d to channel%u\n",
+ idx, chan->offer_msg.child_rel_id);
+ }
}
/* Bind channel to a proper CPU */
diff --git a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
index 38f2f28..10d513c 100644
--- a/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
+++ b/sys/dev/hyperv/storvsc/hv_storvsc_drv_freebsd.c
@@ -981,8 +981,6 @@ storvsc_attach(device_t dev)
goto cleanup;
}
- bzero(sc, sizeof(struct storvsc_softc));
-
/* fill in driver specific properties */
sc->hs_drv_props = &g_drv_props_table[stor_type];
@@ -1259,6 +1257,7 @@ storvsc_timeout_test(struct hv_storvsc_request *reqp,
}
#endif /* HVS_TIMEOUT_TEST */
+#ifdef notyet
/**
* @brief timeout handler for requests
*
@@ -1306,6 +1305,7 @@ storvsc_timeout(void *arg)
storvsc_timeout_test(reqp, MODE_SELECT_10, 1);
#endif
}
+#endif
/**
* @brief StorVSC device poll function
@@ -1458,6 +1458,7 @@ storvsc_action(struct cam_sim *sim, union ccb *ccb)
return;
}
+#ifdef notyet
if (ccb->ccb_h.timeout != CAM_TIME_INFINITY) {
callout_init(&reqp->callout, 1);
callout_reset_sbt(&reqp->callout,
@@ -1477,6 +1478,7 @@ storvsc_action(struct cam_sim *sim, union ccb *ccb)
}
#endif /* HVS_TIMEOUT_TEST */
}
+#endif
if ((res = hv_storvsc_io_request(sc->hs_dev, reqp)) != 0) {
xpt_print(ccb->ccb_h.path,
@@ -2024,6 +2026,7 @@ storvsc_io_done(struct hv_storvsc_request *reqp)
mtx_unlock(&sc->hs_lock);
}
+#ifdef notyet
/*
* callout_drain() will wait for the timer handler to finish
* if it is running. So we don't need any lock to synchronize
@@ -2034,6 +2037,7 @@ storvsc_io_done(struct hv_storvsc_request *reqp)
if (ccb->ccb_h.timeout != CAM_TIME_INFINITY) {
callout_drain(&reqp->callout);
}
+#endif
ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
ccb->ccb_h.status &= ~CAM_STATUS_MASK;
@@ -2087,8 +2091,9 @@ storvsc_io_done(struct hv_storvsc_request *reqp)
reqp->softc->hs_frozen = 0;
}
storvsc_free_request(sc, reqp);
- xpt_done(ccb);
mtx_unlock(&sc->hs_lock);
+
+ xpt_done_direct(ccb);
}
/**
diff --git a/sys/dev/hyperv/vmbus/amd64/hv_vector.S b/sys/dev/hyperv/vmbus/amd64/hv_vector.S
new file mode 100644
index 0000000..2594483
--- /dev/null
+++ b/sys/dev/hyperv/vmbus/amd64/hv_vector.S
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 2016 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <machine/asmacros.h>
+#include <machine/specialreg.h>
+
+#include "assym.s"
+
+/*
+ * This is the Hyper-V vmbus channel direct callback interrupt.
+ * Only used when it is running on Hyper-V.
+ */
+ .text
+ SUPERALIGN_TEXT
+IDTVEC(hv_vmbus_callback)
+ PUSH_FRAME
+ FAKE_MCOUNT(TF_RIP(%rsp))
+ movq %rsp, %rdi
+ call hv_vector_handler
+ MEXITCOUNT
+ jmp doreti
diff --git a/sys/dev/hyperv/vmbus/hv_channel_mgmt.c b/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
index 42d3750..0094187 100644
--- a/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
+++ b/sys/dev/hyperv/vmbus/hv_channel_mgmt.c
@@ -219,10 +219,14 @@ vmbus_channel_process_offer(hv_vmbus_channel *new_channel)
sc_list_entry);
mtx_unlock(&channel->sc_lock);
+ if (bootverbose) {
+ printf("VMBUS get multi-channel offer, "
+ "rel=%u, sub=%u\n",
+ new_channel->offer_msg.child_rel_id,
+ new_channel->offer_msg.offer.sub_channel_index);
+ }
+
/* Insert new channel into channel_anchor. */
- printf("VMBUS get multi-channel offer, rel=%u,sub=%u\n",
- new_channel->offer_msg.child_rel_id,
- new_channel->offer_msg.offer.sub_channel_index);
mtx_lock(&hv_vmbus_g_connection.channel_lock);
TAILQ_INSERT_TAIL(&hv_vmbus_g_connection.channel_anchor,
new_channel, list_entry);
diff --git a/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c b/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
index 44e19d2..ec4b26f 100644
--- a/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
+++ b/sys/dev/hyperv/vmbus/hv_vmbus_drv_freebsd.c
@@ -370,9 +370,7 @@ vmbus_probe(device_t dev) {
return (BUS_PROBE_DEFAULT);
}
-#ifdef HYPERV
extern inthand_t IDTVEC(hv_vmbus_callback);
-#endif
/**
* @brief Main vmbus driver initialization routine.
@@ -406,14 +404,10 @@ vmbus_bus_init(void)
return (ret);
}
-#ifdef HYPERV
/*
* Find a free IDT slot for vmbus callback.
*/
hv_vmbus_g_context.hv_cb_vector = lapic_ipi_alloc(IDTVEC(hv_vmbus_callback));
-#else
- hv_vmbus_g_context.hv_cb_vector = -1;
-#endif
if (hv_vmbus_g_context.hv_cb_vector < 0) {
if(bootverbose)
printf("Error VMBUS: Cannot find free IDT slot for "
diff --git a/sys/dev/hyperv/vmbus/i386/hv_vector.S b/sys/dev/hyperv/vmbus/i386/hv_vector.S
new file mode 100644
index 0000000..55a2613
--- /dev/null
+++ b/sys/dev/hyperv/vmbus/i386/hv_vector.S
@@ -0,0 +1,49 @@
+/*-
+ * Copyright (c) 2016 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.
+ *
+ * $FreeBSD$
+ */
+
+#include <machine/asmacros.h>
+#include <machine/specialreg.h>
+
+#include "assym.s"
+
+/*
+ * This is the Hyper-V vmbus channel direct callback interrupt.
+ * Only used when it is running on Hyper-V.
+ */
+ .text
+ SUPERALIGN_TEXT
+IDTVEC(hv_vmbus_callback)
+ PUSH_FRAME
+ SET_KERNEL_SREGS
+ cld
+ FAKE_MCOUNT(TF_EIP(%esp))
+ pushl %esp
+ call hv_vector_handler
+ add $4, %esp
+ MEXITCOUNT
+ jmp doreti
diff --git a/sys/dev/isp/isp.c b/sys/dev/isp/isp.c
index dd8112f..01d7cbb 100644
--- a/sys/dev/isp/isp.c
+++ b/sys/dev/isp/isp.c
@@ -3011,7 +3011,6 @@ isp_fclink_test(ispsoftc_t *isp, int chan, int usdelay)
return (0);
isp_prt(isp, ISP_LOG_SANCFG, "Chan %d FC link test", chan);
- fcp->isp_loopstate = LOOP_TESTING_LINK;
/*
* Wait up to N microseconds for F/W to go to a ready state.
@@ -3022,7 +3021,7 @@ isp_fclink_test(ispsoftc_t *isp, int chan, int usdelay)
if (fcp->isp_fwstate == FW_READY) {
break;
}
- if (fcp->isp_loopstate < LOOP_TESTING_LINK)
+ if (fcp->isp_loopstate < LOOP_HAVE_LINK)
goto abort;
GET_NANOTIME(&hrb);
if ((NANOTIME_SUB(&hrb, &hra) / 1000 + 1000 >= usdelay))
@@ -3077,6 +3076,11 @@ isp_fclink_test(ispsoftc_t *isp, int chan, int usdelay)
fcp->isp_loopid = i;
}
+#if 0
+ fcp->isp_loopstate = LOOP_HAVE_ADDR;
+#endif
+ fcp->isp_loopstate = LOOP_TESTING_LINK;
+
if (fcp->isp_topo == TOPO_F_PORT || fcp->isp_topo == TOPO_FL_PORT) {
nphdl = IS_24XX(isp) ? NPH_FL_ID : FL_ID;
r = isp_getpdb(isp, chan, nphdl, &pdb);
@@ -6138,7 +6142,7 @@ isp_handle_other_response(ispsoftc_t *isp, int type, isphdr_t *hp, uint32_t *opt
{
isp_ridacq_t rid;
int chan, c;
- uint32_t hdl;
+ uint32_t hdl, portid;
void *ptr;
switch (type) {
@@ -6150,6 +6154,8 @@ isp_handle_other_response(ispsoftc_t *isp, int type, isphdr_t *hp, uint32_t *opt
return (1);
case RQSTYPE_RPT_ID_ACQ:
isp_get_ridacq(isp, (isp_ridacq_t *)hp, &rid);
+ portid = (uint32_t)rid.ridacq_vp_port_hi << 16 |
+ rid.ridacq_vp_port_lo;
if (rid.ridacq_format == 0) {
for (chan = 0; chan < isp->isp_nchan; chan++) {
fcparam *fcp = FCPARAM(isp, chan);
@@ -6171,7 +6177,9 @@ isp_handle_other_response(ispsoftc_t *isp, int type, isphdr_t *hp, uint32_t *opt
fcparam *fcp = FCPARAM(isp, rid.ridacq_vp_index);
if (rid.ridacq_vp_status == RIDACQ_STS_COMPLETE ||
rid.ridacq_vp_status == RIDACQ_STS_CHANGED) {
- fcp->isp_loopstate = LOOP_HAVE_LINK;
+ fcp->isp_topo = (rid.ridacq_map[0] >> 9) & 0x7;
+ fcp->isp_portid = portid;
+ fcp->isp_loopstate = LOOP_HAVE_ADDR;
isp_async(isp, ISPASYNC_CHANGE_NOTIFY,
rid.ridacq_vp_index, ISPASYNC_CHANGE_OTHER);
} else {
diff --git a/sys/dev/isp/isp_library.c b/sys/dev/isp/isp_library.c
index c7bce2d..48e0535 100644
--- a/sys/dev/isp/isp_library.c
+++ b/sys/dev/isp/isp_library.c
@@ -532,6 +532,7 @@ isp_fc_loop_statename(int state)
switch (state) {
case LOOP_NIL: return "NIL";
case LOOP_HAVE_LINK: return "Have Link";
+ case LOOP_HAVE_ADDR: return "Have Address";
case LOOP_TESTING_LINK: return "Testing Link";
case LOOP_LTEST_DONE: return "Link Test Done";
case LOOP_SCANNING_LOOP: return "Scanning Loop";
@@ -548,7 +549,7 @@ const char *
isp_fc_toponame(fcparam *fcp)
{
- if (fcp->isp_loopstate < LOOP_LTEST_DONE) {
+ if (fcp->isp_loopstate < LOOP_HAVE_ADDR) {
return "Unavailable";
}
switch (fcp->isp_topo) {
@@ -2329,7 +2330,7 @@ isp_find_chan_by_did(ispsoftc_t *isp, uint32_t did, uint16_t *cp)
for (chan = 0; chan < isp->isp_nchan; chan++) {
fcparam *fcp = FCPARAM(isp, chan);
if ((fcp->role & ISP_ROLE_TARGET) == 0 ||
- fcp->isp_loopstate < LOOP_LTEST_DONE) {
+ fcp->isp_loopstate < LOOP_HAVE_ADDR) {
continue;
}
if (fcp->isp_portid == did) {
diff --git a/sys/dev/isp/ispvar.h b/sys/dev/isp/ispvar.h
index 104782b..a97a04f 100644
--- a/sys/dev/isp/ispvar.h
+++ b/sys/dev/isp/ispvar.h
@@ -490,14 +490,15 @@ typedef struct {
#define LOOP_NIL 0
#define LOOP_HAVE_LINK 1
-#define LOOP_TESTING_LINK 2
-#define LOOP_LTEST_DONE 3
-#define LOOP_SCANNING_LOOP 4
-#define LOOP_LSCAN_DONE 5
-#define LOOP_SCANNING_FABRIC 6
-#define LOOP_FSCAN_DONE 7
-#define LOOP_SYNCING_PDB 8
-#define LOOP_READY 9
+#define LOOP_HAVE_ADDR 2
+#define LOOP_TESTING_LINK 3
+#define LOOP_LTEST_DONE 4
+#define LOOP_SCANNING_LOOP 5
+#define LOOP_LSCAN_DONE 6
+#define LOOP_SCANNING_FABRIC 7
+#define LOOP_FSCAN_DONE 8
+#define LOOP_SYNCING_PDB 9
+#define LOOP_READY 10
#define TOPO_NL_PORT 0
#define TOPO_FL_PORT 1
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index fbe9abd..273ab4b 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -126,8 +126,8 @@ static int pci_remap_intr_method(device_t bus, device_t dev,
static uint16_t pci_get_rid_method(device_t dev, device_t child);
-static struct pci_devinfo * pci_fill_devinfo(device_t pcib, int d, int b, int s,
- int f, uint16_t vid, uint16_t did, size_t size);
+static struct pci_devinfo * pci_fill_devinfo(device_t pcib, device_t bus, int d,
+ int b, int s, int f, uint16_t vid, uint16_t did);
static device_method_t pci_methods[] = {
/* Device interface */
@@ -196,6 +196,7 @@ static device_method_t pci_methods[] = {
DEVMETHOD(pci_msix_pba_bar, pci_msix_pba_bar_method),
DEVMETHOD(pci_msix_table_bar, pci_msix_table_bar_method),
DEVMETHOD(pci_get_rid, pci_get_rid_method),
+ DEVMETHOD(pci_alloc_devinfo, pci_alloc_devinfo_method),
DEVMETHOD(pci_child_added, pci_child_added_method),
#ifdef PCI_IOV
DEVMETHOD(pci_iov_attach, pci_iov_attach_method),
@@ -619,7 +620,7 @@ pci_hdrtypedata(device_t pcib, int b, int s, int f, pcicfgregs *cfg)
/* read configuration header into pcicfgregs structure */
struct pci_devinfo *
-pci_read_device(device_t pcib, int d, int b, int s, int f, size_t size)
+pci_read_device(device_t pcib, device_t bus, int d, int b, int s, int f)
{
#define REG(n, w) PCIB_READ_CONFIG(pcib, b, s, f, n, w)
uint16_t vid, did;
@@ -627,19 +628,27 @@ pci_read_device(device_t pcib, int d, int b, int s, int f, size_t size)
vid = REG(PCIR_VENDOR, 2);
did = REG(PCIR_DEVICE, 2);
if (vid != 0xffff)
- return (pci_fill_devinfo(pcib, d, b, s, f, vid, did, size));
+ return (pci_fill_devinfo(pcib, bus, d, b, s, f, vid, did));
return (NULL);
}
+struct pci_devinfo *
+pci_alloc_devinfo_method(device_t dev)
+{
+
+ return (malloc(sizeof(struct pci_devinfo), M_DEVBUF,
+ M_WAITOK | M_ZERO));
+}
+
static struct pci_devinfo *
-pci_fill_devinfo(device_t pcib, int d, int b, int s, int f, uint16_t vid,
- uint16_t did, size_t size)
+pci_fill_devinfo(device_t pcib, device_t bus, int d, int b, int s, int f,
+ uint16_t vid, uint16_t did)
{
struct pci_devinfo *devlist_entry;
pcicfgregs *cfg;
- devlist_entry = malloc(size, M_DEVBUF, M_WAITOK | M_ZERO);
+ devlist_entry = PCI_ALLOC_DEVINFO(bus);
cfg = &devlist_entry->cfg;
@@ -665,7 +674,6 @@ pci_fill_devinfo(device_t pcib, int d, int b, int s, int f, uint16_t vid,
cfg->hdrtype &= ~PCIM_MFDEV;
STAILQ_INIT(&cfg->maps);
- cfg->devinfo_size = size;
cfg->iov = NULL;
pci_fixancient(cfg);
@@ -3854,11 +3862,11 @@ pci_add_resources(device_t bus, device_t dev, int force, uint32_t prefetchmask)
static struct pci_devinfo *
pci_identify_function(device_t pcib, device_t dev, int domain, int busno,
- int slot, int func, size_t dinfo_size)
+ int slot, int func)
{
struct pci_devinfo *dinfo;
- dinfo = pci_read_device(pcib, domain, busno, slot, func, dinfo_size);
+ dinfo = pci_read_device(pcib, dev, domain, busno, slot, func);
if (dinfo != NULL)
pci_add_child(dev, dinfo);
@@ -3866,7 +3874,7 @@ pci_identify_function(device_t pcib, device_t dev, int domain, int busno,
}
void
-pci_add_children(device_t dev, int domain, int busno, size_t dinfo_size)
+pci_add_children(device_t dev, int domain, int busno)
{
#define REG(n, w) PCIB_READ_CONFIG(pcib, busno, s, f, n, w)
device_t pcib = device_get_parent(dev);
@@ -3882,8 +3890,7 @@ pci_add_children(device_t dev, int domain, int busno, size_t dinfo_size)
* functions on this bus as ARI changes the set of slots and functions
* that are legal on this bus.
*/
- dinfo = pci_identify_function(pcib, dev, domain, busno, 0, 0,
- dinfo_size);
+ dinfo = pci_identify_function(pcib, dev, domain, busno, 0, 0);
if (dinfo != NULL && pci_enable_ari)
PCIB_TRY_ENABLE_ARI(pcib, dinfo->cfg.dev);
@@ -3893,8 +3900,6 @@ pci_add_children(device_t dev, int domain, int busno, size_t dinfo_size)
*/
first_func = 1;
- KASSERT(dinfo_size >= sizeof(struct pci_devinfo),
- ("dinfo_size too small"));
maxslots = PCIB_MAXSLOTS(pcib);
for (s = 0; s <= maxslots; s++, first_func = 0) {
pcifunchigh = 0;
@@ -3906,16 +3911,15 @@ pci_add_children(device_t dev, int domain, int busno, size_t dinfo_size)
if (hdrtype & PCIM_MFDEV)
pcifunchigh = PCIB_MAXFUNCS(pcib);
for (f = first_func; f <= pcifunchigh; f++)
- pci_identify_function(pcib, dev, domain, busno, s, f,
- dinfo_size);
+ pci_identify_function(pcib, dev, domain, busno, s, f);
}
#undef REG
}
#ifdef PCI_IOV
device_t
-pci_add_iov_child(device_t bus, device_t pf, size_t size, uint16_t rid,
- uint16_t vid, uint16_t did)
+pci_add_iov_child(device_t bus, device_t pf, uint16_t rid, uint16_t vid,
+ uint16_t did)
{
struct pci_devinfo *pf_dinfo, *vf_dinfo;
device_t pcib;
@@ -3923,23 +3927,12 @@ pci_add_iov_child(device_t bus, device_t pf, size_t size, uint16_t rid,
pf_dinfo = device_get_ivars(pf);
- /*
- * Do a sanity check that we have been passed the correct size. If this
- * test fails then likely the pci subclass hasn't implemented the
- * pci_create_iov_child method like it's supposed it.
- */
- if (size != pf_dinfo->cfg.devinfo_size) {
- device_printf(pf,
- "PCI subclass does not properly implement PCI_IOV\n");
- return (NULL);
- }
-
pcib = device_get_parent(bus);
PCIB_DECODE_RID(pcib, rid, &busno, &slot, &func);
- vf_dinfo = pci_fill_devinfo(pcib, pci_get_domain(pcib), busno, slot, func,
- vid, did, size);
+ vf_dinfo = pci_fill_devinfo(pcib, bus, pci_get_domain(pcib), busno,
+ slot, func, vid, did);
vf_dinfo->cfg.flags |= PCICFG_VF;
pci_add_child(bus, vf_dinfo);
@@ -3952,8 +3945,7 @@ pci_create_iov_child_method(device_t bus, device_t pf, uint16_t rid,
uint16_t vid, uint16_t did)
{
- return (pci_add_iov_child(bus, pf, sizeof(struct pci_devinfo), rid, vid,
- did));
+ return (pci_add_iov_child(bus, pf, rid, vid, did));
}
#endif
@@ -4050,7 +4042,7 @@ pci_attach(device_t dev)
*/
domain = pcib_get_domain(dev);
busno = pcib_get_bus(dev);
- pci_add_children(dev, domain, busno, sizeof(struct pci_devinfo));
+ pci_add_children(dev, domain, busno);
return (bus_generic_attach(dev));
}
diff --git a/sys/dev/pci/pci_if.m b/sys/dev/pci/pci_if.m
index 7049b9f..da80305 100644
--- a/sys/dev/pci/pci_if.m
+++ b/sys/dev/pci/pci_if.m
@@ -213,6 +213,10 @@ METHOD uint16_t get_rid {
device_t child;
};
+METHOD struct pci_devinfo * alloc_devinfo {
+ device_t dev;
+};
+
METHOD void child_added {
device_t dev;
device_t child;
diff --git a/sys/dev/pci/pci_iov.c b/sys/dev/pci/pci_iov.c
index d216557..287f5a2 100644
--- a/sys/dev/pci/pci_iov.c
+++ b/sys/dev/pci/pci_iov.c
@@ -600,14 +600,12 @@ pci_iov_enumerate_vfs(struct pci_devinfo *dinfo, const nvlist_t *config,
device_t bus, dev, vf;
struct pcicfg_iov *iov;
struct pci_devinfo *vfinfo;
- size_t size;
int i, error;
uint16_t vid, did, next_rid;
iov = dinfo->cfg.iov;
dev = dinfo->cfg.dev;
bus = device_get_parent(dev);
- size = dinfo->cfg.devinfo_size;
next_rid = first_rid;
vid = pci_get_vendor(dev);
did = IOV_READ(dinfo, PCIR_SRIOV_VF_DID, 2);
diff --git a/sys/dev/pci/pci_private.h b/sys/dev/pci/pci_private.h
index e11dcfa..222ffb8 100644
--- a/sys/dev/pci/pci_private.h
+++ b/sys/dev/pci/pci_private.h
@@ -48,14 +48,14 @@ struct pci_softc {
extern int pci_do_power_resume;
extern int pci_do_power_suspend;
-void pci_add_children(device_t dev, int domain, int busno,
- size_t dinfo_size);
+void pci_add_children(device_t dev, int domain, int busno);
void pci_add_child(device_t bus, struct pci_devinfo *dinfo);
-device_t pci_add_iov_child(device_t bus, device_t pf, size_t dinfo_size,
- uint16_t rid, uint16_t vid, uint16_t did);
+device_t pci_add_iov_child(device_t bus, device_t pf, uint16_t rid,
+ uint16_t vid, uint16_t did);
void pci_add_resources(device_t bus, device_t dev, int force,
uint32_t prefetchmask);
void pci_add_resources_ea(device_t bus, device_t dev, int alloc_iov);
+struct pci_devinfo *pci_alloc_devinfo_method(device_t dev);
int pci_attach_common(device_t dev);
void pci_driver_added(device_t dev, driver_t *driver);
int pci_ea_is_enabled(device_t dev, int rid);
@@ -117,8 +117,8 @@ int pci_deactivate_resource(device_t dev, device_t child, int type,
void pci_delete_resource(device_t dev, device_t child,
int type, int rid);
struct resource_list *pci_get_resource_list (device_t dev, device_t child);
-struct pci_devinfo *pci_read_device(device_t pcib, int d, int b, int s, int f,
- size_t size);
+struct pci_devinfo *pci_read_device(device_t pcib, device_t bus, int d, int b,
+ int s, int f);
void pci_print_verbose(struct pci_devinfo *dinfo);
int pci_freecfg(struct pci_devinfo *dinfo);
void pci_child_deleted(device_t dev, device_t child);
diff --git a/sys/dev/pci/pcivar.h b/sys/dev/pci/pcivar.h
index c829292..8d9ea7e 100644
--- a/sys/dev/pci/pcivar.h
+++ b/sys/dev/pci/pcivar.h
@@ -209,7 +209,6 @@ typedef struct pcicfg {
uint8_t func; /* config space function number */
uint32_t flags; /* flags defined above */
- size_t devinfo_size; /* Size of devinfo for this bus type. */
struct pcicfg_bridge bridge; /* Bridges */
struct pcicfg_pp pp; /* Power management */
diff --git a/sys/dev/rt/if_rt.c b/sys/dev/rt/if_rt.c
index fd042fe..5b4dc85 100644
--- a/sys/dev/rt/if_rt.c
+++ b/sys/dev/rt/if_rt.c
@@ -99,13 +99,14 @@ __FBSDID("$FreeBSD$");
#ifdef FDT
/* more specific and new models should go first */
static const struct ofw_compat_data rt_compat_data[] = {
- { "ralink,rt3050-eth", RT_CHIPID_RT3050 },
- { "ralink,rt3352-eth", RT_CHIPID_RT3050 },
- { "ralink,rt3883-eth", RT_CHIPID_RT3050 },
- { "ralink,rt5350-eth", RT_CHIPID_RT5350 },
- { "ralink,mt7620a-eth", RT_CHIPID_MT7620 },
- { "ralink,mt7621-eth", RT_CHIPID_MT7621 },
- { NULL, 0 }
+ { "ralink,rt3050-eth", RT_CHIPID_RT3050 },
+ { "ralink,rt3352-eth", RT_CHIPID_RT3050 },
+ { "ralink,rt3883-eth", RT_CHIPID_RT3050 },
+ { "ralink,rt5350-eth", RT_CHIPID_RT5350 },
+ { "ralink,mt7620a-eth", RT_CHIPID_MT7620 },
+ { "ralink,mt7621-eth", RT_CHIPID_MT7621 },
+ { "mediatek,mt7621-eth", RT_CHIPID_MT7621 },
+ { NULL, 0 }
};
#endif
diff --git a/sys/dev/wbwd/wbwd.c b/sys/dev/wbwd/wbwd.c
index 53e9084..75fbea4 100644
--- a/sys/dev/wbwd/wbwd.c
+++ b/sys/dev/wbwd/wbwd.c
@@ -505,19 +505,10 @@ wb_set_watchdog(struct wb_softc *sc, unsigned int timeout)
/* Watchdog is configured as part of LDN 8 (GPIO Port2, Watchdog) */
write_reg(sc, WB_LDN_REG, WB_LDN_REG_LDN8);
- /* Disable and validate or arm/reset watchdog. */
if (timeout == 0) {
/* Disable watchdog. */
- write_reg(sc, sc->time_reg, 0x00);
- sc->reg_timeout = read_reg(sc, sc->time_reg);
- (*sc->ext_cfg_exit_f)(sc, 0);
-
- /* Re-check. */
- if (sc->reg_timeout != 0x00) {
- device_printf(sc->dev, "Failed to disable watchdog: "
- "0x%02x.\n", sc->reg_timeout);
- return (EIO);
- }
+ sc->reg_timeout = 0;
+ write_reg(sc, sc->time_reg, sc->reg_timeout);
} else {
/* Read current scaling factor. */
@@ -547,12 +538,12 @@ wb_set_watchdog(struct wb_softc *sc, unsigned int timeout)
/* Set timer and arm/reset the watchdog. */
write_reg(sc, sc->time_reg, sc->reg_timeout);
- (*sc->ext_cfg_exit_f)(sc, 0);
}
+ (*sc->ext_cfg_exit_f)(sc, 0);
+
if (sc->debug_verbose)
wb_print_state(sc, "After watchdog counter (re)load");
-
return (0);
}
diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c
index bf18094..649b01a 100644
--- a/sys/fs/cd9660/cd9660_vfsops.c
+++ b/sys/fs/cd9660/cd9660_vfsops.c
@@ -709,7 +709,7 @@ cd9660_vget_internal(mp, ino, flags, vpp, relocated, isodir)
if (error || *vpp != NULL)
return (error);
- if (isodir == 0) {
+ if (isodir == NULL) {
int lbn, off;
lbn = lblkno(imp, ino);
@@ -759,7 +759,7 @@ cd9660_vget_internal(mp, ino, flags, vpp, relocated, isodir)
}
#endif
} else
- bp = 0;
+ bp = NULL;
ip->i_mnt = imp;
diff --git a/sys/fs/msdosfs/msdosfs_conv.c b/sys/fs/msdosfs/msdosfs_conv.c
index fc9b4d4..efed30c 100644
--- a/sys/fs/msdosfs/msdosfs_conv.c
+++ b/sys/fs/msdosfs/msdosfs_conv.c
@@ -353,7 +353,7 @@ unix2dosfn(const u_char *un, u_char dn[12], size_t unlen, u_int gen,
* ignores all dots before extension, and use all
* chars as filename except for dots.
*/
- dp = dp1 = 0;
+ dp = dp1 = NULL;
for (cp = un + 1, i = unlen - 1; --i >= 0;) {
switch (*cp++) {
case '.':
@@ -365,7 +365,7 @@ unix2dosfn(const u_char *un, u_char dn[12], size_t unlen, u_int gen,
default:
if (dp1)
dp = dp1;
- dp1 = 0;
+ dp1 = NULL;
break;
}
}
diff --git a/sys/fs/msdosfs/msdosfs_fat.c b/sys/fs/msdosfs/msdosfs_fat.c
index cf03e00..5df053c 100644
--- a/sys/fs/msdosfs/msdosfs_fat.c
+++ b/sys/fs/msdosfs/msdosfs_fat.c
@@ -256,14 +256,14 @@ fc_lookup(struct denode *dep, u_long findcn, u_long *frcnp, u_long *fsrcnp)
{
int i;
u_long cn;
- struct fatcache *closest = 0;
+ struct fatcache *closest = NULL;
ASSERT_VOP_LOCKED(DETOV(dep), "fc_lookup");
for (i = 0; i < FC_SIZE; i++) {
cn = dep->de_fc[i].fc_frcn;
if (cn != FCE_EMPTY && cn <= findcn) {
- if (closest == 0 || cn > closest->fc_frcn)
+ if (closest == NULL || cn > closest->fc_frcn)
closest = &dep->de_fc[i];
}
}
diff --git a/sys/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c
index 0d03831..f7955f2 100644
--- a/sys/fs/msdosfs/msdosfs_lookup.c
+++ b/sys/fs/msdosfs/msdosfs_lookup.c
@@ -454,7 +454,7 @@ found:
* in a deadlock.
*/
brelse(bp);
- bp = 0;
+ bp = NULL;
foundroot:
/*
diff --git a/sys/geom/gate/g_gate.c b/sys/geom/gate/g_gate.c
index 3453eef..8cfe9d4 100644
--- a/sys/geom/gate/g_gate.c
+++ b/sys/geom/gate/g_gate.c
@@ -945,7 +945,7 @@ g_gate_modevent(module_t mod, int type, void *data)
}
mtx_unlock(&g_gate_units_lock);
mtx_destroy(&g_gate_units_lock);
- if (status_dev != 0)
+ if (status_dev != NULL)
destroy_dev(status_dev);
free(g_gate_units, M_GATE);
break;
diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c
index 61f70c1..8270274 100644
--- a/sys/geom/geom_io.c
+++ b/sys/geom/geom_io.c
@@ -504,11 +504,11 @@ g_io_request(struct bio *bp, struct g_consumer *cp)
cmd = bp->bio_cmd;
if (cmd == BIO_READ || cmd == BIO_WRITE || cmd == BIO_GETATTR) {
KASSERT(bp->bio_data != NULL,
- ("NULL bp->data in g_io_request(cmd=%hhu)", bp->bio_cmd));
+ ("NULL bp->data in g_io_request(cmd=%hu)", bp->bio_cmd));
}
if (cmd == BIO_DELETE || cmd == BIO_FLUSH) {
KASSERT(bp->bio_data == NULL,
- ("non-NULL bp->data in g_io_request(cmd=%hhu)",
+ ("non-NULL bp->data in g_io_request(cmd=%hu)",
bp->bio_cmd));
}
if (cmd == BIO_READ || cmd == BIO_WRITE || cmd == BIO_DELETE) {
diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c
index bf14a86..54a99bf 100644
--- a/sys/geom/geom_subr.c
+++ b/sys/geom/geom_subr.c
@@ -1508,8 +1508,8 @@ DB_SHOW_COMMAND(bio, db_show_bio)
db_printf("BIO %p\n", bp);
db_print_bio_cmd(bp);
db_print_bio_flags(bp);
- db_printf(" cflags: 0x%hhx\n", bp->bio_cflags);
- db_printf(" pflags: 0x%hhx\n", bp->bio_pflags);
+ db_printf(" cflags: 0x%hx\n", bp->bio_cflags);
+ db_printf(" pflags: 0x%hx\n", bp->bio_pflags);
db_printf(" offset: %jd\n", (intmax_t)bp->bio_offset);
db_printf(" length: %jd\n", (intmax_t)bp->bio_length);
db_printf(" bcount: %ld\n", bp->bio_bcount);
diff --git a/sys/geom/mirror/g_mirror.c b/sys/geom/mirror/g_mirror.c
index 70f5eb1..59da980 100644
--- a/sys/geom/mirror/g_mirror.c
+++ b/sys/geom/mirror/g_mirror.c
@@ -1905,7 +1905,7 @@ g_mirror_worker(void *arg)
g_mirror_sync_request(bp); /* WRITE */
else {
KASSERT(0,
- ("Invalid request cflags=0x%hhx to=%s.",
+ ("Invalid request cflags=0x%hx to=%s.",
bp->bio_cflags, bp->bio_to->name));
}
} else {
diff --git a/sys/geom/raid3/g_raid3.c b/sys/geom/raid3/g_raid3.c
index 584076f..617f72e 100644
--- a/sys/geom/raid3/g_raid3.c
+++ b/sys/geom/raid3/g_raid3.c
@@ -2127,7 +2127,7 @@ process:
g_raid3_sync_request(bp); /* WRITE */
else {
KASSERT(0,
- ("Invalid request cflags=0x%hhx to=%s.",
+ ("Invalid request cflags=0x%hx to=%s.",
bp->bio_cflags, bp->bio_to->name));
}
} else if (g_raid3_register_request(bp) != 0) {
diff --git a/sys/i386/conf/GENERIC b/sys/i386/conf/GENERIC
index e23906d..ee2df93 100644
--- a/sys/i386/conf/GENERIC
+++ b/sys/i386/conf/GENERIC
@@ -367,8 +367,6 @@ device virtio_scsi # VirtIO SCSI device
device virtio_balloon # VirtIO Memory Balloon device
# HyperV drivers and enchancement support
-# NOTE: HYPERV depends on hyperv. They must be added or removed together.
-options HYPERV # Hyper-V kernel infrastructure
device hyperv # HyperV drivers
# Xen HVM Guest Optimizations
diff --git a/sys/i386/i386/apic_vector.s b/sys/i386/i386/apic_vector.s
index 18b3c5d..9d56b93 100644
--- a/sys/i386/i386/apic_vector.s
+++ b/sys/i386/i386/apic_vector.s
@@ -181,25 +181,6 @@ IDTVEC(xen_intr_upcall)
jmp doreti
#endif
-#ifdef HYPERV
-/*
- * This is the Hyper-V vmbus channel direct callback interrupt.
- * Only used when it is running on Hyper-V.
- */
- .text
- SUPERALIGN_TEXT
-IDTVEC(hv_vmbus_callback)
- PUSH_FRAME
- SET_KERNEL_SREGS
- cld
- FAKE_MCOUNT(TF_EIP(%esp))
- pushl %esp
- call hv_vector_handler
- add $4, %esp
- MEXITCOUNT
- jmp doreti
-#endif
-
#ifdef SMP
/*
* Global address space TLB shootdown.
diff --git a/sys/i386/i386/db_disasm.c b/sys/i386/i386/db_disasm.c
index 4f771dc..2b398da 100644
--- a/sys/i386/i386/db_disasm.c
+++ b/sys/i386/i386/db_disasm.c
@@ -953,17 +953,17 @@ db_read_address(loc, short_addr, regmodrm, addrp)
return (loc);
}
addrp->is_reg = FALSE;
- addrp->index = 0;
+ addrp->index = NULL;
if (short_addr) {
- addrp->index = 0;
+ addrp->index = NULL;
addrp->ss = 0;
switch (mod) {
case 0:
if (rm == 6) {
get_value_inc(disp, loc, 2, FALSE);
addrp->disp = disp;
- addrp->base = 0;
+ addrp->base = NULL;
}
else {
addrp->disp = 0;
@@ -997,7 +997,7 @@ db_read_address(loc, short_addr, regmodrm, addrp)
case 0:
if (rm == 5) {
get_value_inc(addrp->disp, loc, 4, FALSE);
- addrp->base = 0;
+ addrp->base = NULL;
}
else {
addrp->disp = 0;
@@ -1037,7 +1037,7 @@ db_print_address(seg, size, addrp)
}
db_printsym((db_addr_t)addrp->disp, DB_STGY_ANY);
- if (addrp->base != 0 || addrp->index != 0) {
+ if (addrp->base != NULL || addrp->index != NULL) {
db_printf("(");
if (addrp->base)
db_printf("%s", addrp->base);
@@ -1171,7 +1171,7 @@ db_disasm(db_addr_t loc, bool altfmt)
get_value_inc(inst, loc, 1, FALSE);
short_addr = FALSE;
size = LONG;
- seg = 0;
+ seg = NULL;
/*
* Get prefixes
@@ -1239,7 +1239,7 @@ db_disasm(db_addr_t loc, bool altfmt)
if (inst == 0x0f) {
get_value_inc(inst, loc, 1, FALSE);
ip = db_inst_0f[inst>>4];
- if (ip == 0) {
+ if (ip == NULL) {
ip = &db_bad_inst;
}
else {
diff --git a/sys/i386/i386/exception.s b/sys/i386/i386/exception.s
index f91f516..c03cbce 100644
--- a/sys/i386/i386/exception.s
+++ b/sys/i386/i386/exception.s
@@ -343,6 +343,7 @@ MCOUNT_LABEL(eintr)
.text
SUPERALIGN_TEXT
.type doreti,@function
+ .globl doreti
doreti:
FAKE_MCOUNT($bintr) /* init "from" bintr -> doreti */
doreti_next:
diff --git a/sys/i386/i386/pmap.c b/sys/i386/i386/pmap.c
index 5bdc988..575e42f 100644
--- a/sys/i386/i386/pmap.c
+++ b/sys/i386/i386/pmap.c
@@ -269,15 +269,15 @@ pt_entry_t *CMAP3;
static pd_entry_t *KPTD;
caddr_t ptvmmap = 0;
caddr_t CADDR3;
-struct msgbuf *msgbufp = 0;
+struct msgbuf *msgbufp = NULL;
/*
* Crashdump maps.
*/
static caddr_t crashdumpmap;
-static pt_entry_t *PMAP1 = 0, *PMAP2;
-static pt_entry_t *PADDR1 = 0, *PADDR2;
+static pt_entry_t *PMAP1 = NULL, *PMAP2;
+static pt_entry_t *PADDR1 = NULL, *PADDR2;
#ifdef SMP
static int PMAP1cpu;
static int PMAP1changedcpu;
diff --git a/sys/i386/ibcs2/imgact_coff.c b/sys/i386/ibcs2/imgact_coff.c
index a7543d7..3a5611d 100644
--- a/sys/i386/ibcs2/imgact_coff.c
+++ b/sys/i386/ibcs2/imgact_coff.c
@@ -69,7 +69,7 @@ load_coff_section(struct vmspace *vmspace, struct vnode *vp, vm_offset_t offset,
vm_offset_t map_offset;
vm_offset_t map_addr;
int error;
- unsigned char *data_buf = 0;
+ unsigned char *data_buf = NULL;
size_t copy_len;
map_offset = trunc_page(offset);
@@ -163,7 +163,7 @@ coff_load_file(struct thread *td, char *name)
struct filehdr *fhdr;
struct aouthdr *ahdr;
struct scnhdr *scns;
- char *ptr = 0;
+ char *ptr = NULL;
int nscns;
unsigned long text_offset = 0, text_address = 0, text_size = 0;
unsigned long data_offset = 0, data_address = 0, data_size = 0;
@@ -363,7 +363,7 @@ exec_coff_imgact(imgp)
/* .bss section */
bss_size = scns[i].s_size;
} else if (scns[i].s_flags & STYP_LIB) {
- char *buf = 0;
+ char *buf = NULL;
int foff = trunc_page(scns[i].s_scnptr);
int off = scns[i].s_scnptr - foff;
int len = round_page(scns[i].s_size + PAGE_SIZE);
diff --git a/sys/isa/pnp.c b/sys/isa/pnp.c
index f2e5dfc..599af84 100644
--- a/sys/isa/pnp.c
+++ b/sys/isa/pnp.c
@@ -416,14 +416,14 @@ static int
pnp_create_devices(device_t parent, pnp_id *p, int csn,
u_char *resources, int len)
{
- u_char tag, *resp, *resinfo, *startres = 0;
+ u_char tag, *resp, *resinfo, *startres = NULL;
int large_len, scanning = len, retval = FALSE;
uint32_t logical_id;
device_t dev = 0;
int ldn = 0;
struct pnp_set_config_arg *csnldn;
char buf[100];
- char *desc = 0;
+ char *desc = NULL;
resp = resources;
while (scanning > 0) {
@@ -492,7 +492,7 @@ pnp_create_devices(device_t parent, pnp_id *p, int csn,
pnp_parse_resources(dev, startres,
resinfo - startres - 1, ldn);
dev = 0;
- startres = 0;
+ startres = NULL;
}
/*
@@ -537,7 +537,7 @@ pnp_create_devices(device_t parent, pnp_id *p, int csn,
pnp_parse_resources(dev, startres,
resinfo - startres - 1, ldn);
dev = 0;
- startres = 0;
+ startres = NULL;
scanning = 0;
break;
@@ -674,7 +674,7 @@ pnp_isolation_protocol(device_t parent)
int csn;
pnp_id id;
int found = 0, len;
- u_char *resources = 0;
+ u_char *resources = NULL;
int space = 0;
int error;
#ifdef PC98
diff --git a/sys/kern/kern_dump.c b/sys/kern/kern_dump.c
index 1fd2fdd..e3d338f 100644
--- a/sys/kern/kern_dump.c
+++ b/sys/kern/kern_dump.c
@@ -55,13 +55,11 @@ CTASSERT(sizeof(struct kerneldumpheader) == 512);
*/
#define SIZEOF_METADATA (64*1024)
-#define MD_ALIGN(x) (((off_t)(x) + PAGE_MASK) & ~PAGE_MASK)
-#define DEV_ALIGN(x) (((off_t)(x) + (DEV_BSIZE-1)) & ~(DEV_BSIZE-1))
+#define MD_ALIGN(x) roundup2((off_t)(x), PAGE_SIZE)
off_t dumplo;
/* Handle buffered writes. */
-static char buffer[DEV_BSIZE];
static size_t fragsz;
struct dump_pa dump_map[DUMPSYS_MD_PA_NPAIRS];
@@ -125,19 +123,19 @@ dumpsys_buf_write(struct dumperinfo *di, char *ptr, size_t sz)
int error;
while (sz) {
- len = DEV_BSIZE - fragsz;
+ len = di->blocksize - fragsz;
if (len > sz)
len = sz;
- bcopy(ptr, buffer + fragsz, len);
+ memcpy((char *)di->blockbuf + fragsz, ptr, len);
fragsz += len;
ptr += len;
sz -= len;
- if (fragsz == DEV_BSIZE) {
- error = dump_write(di, buffer, 0, dumplo,
- DEV_BSIZE);
+ if (fragsz == di->blocksize) {
+ error = dump_write(di, di->blockbuf, 0, dumplo,
+ di->blocksize);
if (error)
return (error);
- dumplo += DEV_BSIZE;
+ dumplo += di->blocksize;
fragsz = 0;
}
}
@@ -152,8 +150,8 @@ dumpsys_buf_flush(struct dumperinfo *di)
if (fragsz == 0)
return (0);
- error = dump_write(di, buffer, 0, dumplo, DEV_BSIZE);
- dumplo += DEV_BSIZE;
+ error = dump_write(di, di->blockbuf, 0, dumplo, di->blocksize);
+ dumplo += di->blocksize;
fragsz = 0;
return (error);
}
@@ -174,7 +172,7 @@ dumpsys_cb_dumpdata(struct dump_pa *mdp, int seqnr, void *arg)
error = 0; /* catch case in which chunk size is 0 */
counter = 0; /* Update twiddle every 16MB */
- va = 0;
+ va = NULL;
pgs = mdp->pa_size / PAGE_SIZE;
pa = mdp->pa_start;
maxdumppgs = min(di->maxiosize / PAGE_SIZE, MAXDUMPPGS);
@@ -286,7 +284,7 @@ dumpsys_generic(struct dumperinfo *di)
Elf_Ehdr ehdr;
uint64_t dumpsize;
off_t hdrgap;
- size_t hdrsz;
+ size_t hdrsz, size;
int error;
#ifndef __powerpc__
@@ -324,15 +322,15 @@ dumpsys_generic(struct dumperinfo *di)
hdrsz = ehdr.e_phoff + ehdr.e_phnum * ehdr.e_phentsize;
fileofs = MD_ALIGN(hdrsz);
dumpsize += fileofs;
- hdrgap = fileofs - DEV_ALIGN(hdrsz);
+ hdrgap = fileofs - roundup2((off_t)hdrsz, di->blocksize);
/* Determine dump offset on device. */
- if (di->mediasize < SIZEOF_METADATA + dumpsize + sizeof(kdh) * 2) {
+ if (di->mediasize < SIZEOF_METADATA + dumpsize + di->blocksize * 2) {
error = ENOSPC;
goto fail;
}
dumplo = di->mediaoffset + di->mediasize - dumpsize;
- dumplo -= sizeof(kdh) * 2;
+ dumplo -= di->blocksize * 2;
mkdumpheader(&kdh, KERNELDUMPMAGIC, KERNELDUMP_ARCH_VERSION, dumpsize,
di->blocksize);
@@ -341,10 +339,10 @@ dumpsys_generic(struct dumperinfo *di)
ehdr.e_phnum - DUMPSYS_NUM_AUX_HDRS);
/* Dump leader */
- error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh));
+ error = dump_write_pad(di, &kdh, 0, dumplo, sizeof(kdh), &size);
if (error)
goto fail;
- dumplo += sizeof(kdh);
+ dumplo += size;
/* Dump ELF header */
error = dumpsys_buf_write(di, (char*)&ehdr, sizeof(ehdr));
@@ -375,7 +373,7 @@ dumpsys_generic(struct dumperinfo *di)
goto fail;
/* Dump trailer */
- error = dump_write(di, &kdh, 0, dumplo, sizeof(kdh));
+ error = dump_write_pad(di, &kdh, 0, dumplo, sizeof(kdh), &size);
if (error)
goto fail;
diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c
index 511ab69..c05c063 100644
--- a/sys/kern/kern_environment.c
+++ b/sys/kern/kern_environment.c
@@ -545,6 +545,36 @@ getenv_uint(const char *name, unsigned int *data)
}
/*
+ * Return an int64_t value from an environment variable.
+ */
+int
+getenv_int64(const char *name, int64_t *data)
+{
+ quad_t tmp;
+ int64_t rval;
+
+ rval = getenv_quad(name, &tmp);
+ if (rval)
+ *data = (int64_t) tmp;
+ return (rval);
+}
+
+/*
+ * Return an uint64_t value from an environment variable.
+ */
+int
+getenv_uint64(const char *name, uint64_t *data)
+{
+ quad_t tmp;
+ uint64_t rval;
+
+ rval = getenv_quad(name, &tmp);
+ if (rval)
+ *data = (uint64_t) tmp;
+ return (rval);
+}
+
+/*
* Return a long value from an environment variable.
*/
int
@@ -650,6 +680,22 @@ tunable_ulong_init(void *data)
}
void
+tunable_int64_init(void *data)
+{
+ struct tunable_int64 *d = (struct tunable_int64 *)data;
+
+ TUNABLE_INT64_FETCH(d->path, d->var);
+}
+
+void
+tunable_uint64_init(void *data)
+{
+ struct tunable_uint64 *d = (struct tunable_uint64 *)data;
+
+ TUNABLE_UINT64_FETCH(d->path, d->var);
+}
+
+void
tunable_quad_init(void *data)
{
struct tunable_quad *d = (struct tunable_quad *)data;
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c
index 134e9a2..7c0d6b5 100644
--- a/sys/kern/kern_kthread.c
+++ b/sys/kern/kern_kthread.c
@@ -445,7 +445,7 @@ kproc_kthread_add(void (*func)(void *), void *arg,
char buf[100];
struct thread *td;
- if (*procptr == 0) {
+ if (*procptr == NULL) {
error = kproc_create(func, arg,
procptr, flags, pages, "%s", procname);
if (error)
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index e980176..9a41165 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1444,7 +1444,7 @@ sysctl_kern_proc(SYSCTL_HANDLER_ARGS)
p = LIST_FIRST(&allproc);
else
p = LIST_FIRST(&zombproc);
- for (; p != 0; p = LIST_NEXT(p, p_list)) {
+ for (; p != NULL; p = LIST_NEXT(p, p_list)) {
/*
* Skip embryonic processes.
*/
diff --git a/sys/kern/kern_racct.c b/sys/kern/kern_racct.c
index 438a249..d6f7510 100644
--- a/sys/kern/kern_racct.c
+++ b/sys/kern/kern_racct.c
@@ -472,8 +472,8 @@ racct_create(struct racct **racctp)
static void
racct_destroy_locked(struct racct **racctp)
{
- int i;
struct racct *racct;
+ int i;
ASSERT_RACCT_ENABLED();
@@ -668,8 +668,7 @@ racct_add_buf(struct proc *p, const struct buf *bp, int is_write)
static int
racct_set_locked(struct proc *p, int resource, uint64_t amount, int force)
{
- int64_t old_amount, decayed_amount;
- int64_t diff_proc, diff_cred;
+ int64_t old_amount, decayed_amount, diff_proc, diff_cred;
#ifdef RCTL
int error;
#endif
@@ -964,10 +963,9 @@ racct_proc_fork_done(struct proc *child)
void
racct_proc_exit(struct proc *p)
{
- int i;
- uint64_t runtime;
struct timeval wallclock;
- uint64_t pct_estimate, pct;
+ uint64_t pct_estimate, pct, runtime;
+ int i;
if (!racct_enable)
return;
@@ -1206,8 +1204,7 @@ racctd(void)
struct thread *td;
struct proc *p;
struct timeval wallclock;
- uint64_t runtime;
- uint64_t pct, pct_estimate;
+ uint64_t pct, pct_estimate, runtime;
ASSERT_RACCT_ENABLED();
@@ -1317,7 +1314,7 @@ racct_init(void)
return;
racct_zone = uma_zcreate("racct", sizeof(struct racct),
- NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
+ NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
/*
* XXX: Move this somewhere.
*/
diff --git a/sys/kern/kern_rctl.c b/sys/kern/kern_rctl.c
index 98b5055..9647090 100644
--- a/sys/kern/kern_rctl.c
+++ b/sys/kern/kern_rctl.c
@@ -210,8 +210,8 @@ static struct dict actionnames[] = {
static void rctl_init(void);
SYSINIT(rctl, SI_SUB_RACCT, SI_ORDER_FIRST, rctl_init, NULL);
-static uma_zone_t rctl_rule_link_zone;
static uma_zone_t rctl_rule_zone;
+static uma_zone_t rctl_rule_link_zone;
static struct rwlock rctl_lock;
RW_SYSINIT(rctl_lock, &rctl_lock, "RCTL lock");
@@ -229,8 +229,7 @@ static MALLOC_DEFINE(M_RCTL, "rctl", "Resource Limits");
static int rctl_throttle_min_sysctl(SYSCTL_HANDLER_ARGS)
{
- int val = rctl_throttle_min;
- int error;
+ int error, val = rctl_throttle_min;
error = sysctl_handle_int(oidp, &val, 0, req);
if (error || !req->newptr)
@@ -247,8 +246,7 @@ static int rctl_throttle_min_sysctl(SYSCTL_HANDLER_ARGS)
static int rctl_throttle_max_sysctl(SYSCTL_HANDLER_ARGS)
{
- int val = rctl_throttle_max;
- int error;
+ int error, val = rctl_throttle_max;
error = sysctl_handle_int(oidp, &val, 0, req);
if (error || !req->newptr)
@@ -265,8 +263,7 @@ static int rctl_throttle_max_sysctl(SYSCTL_HANDLER_ARGS)
static int rctl_throttle_pct_sysctl(SYSCTL_HANDLER_ARGS)
{
- int val = rctl_throttle_pct;
- int error;
+ int error, val = rctl_throttle_pct;
error = sysctl_handle_int(oidp, &val, 0, req);
if (error || !req->newptr)
@@ -283,8 +280,7 @@ static int rctl_throttle_pct_sysctl(SYSCTL_HANDLER_ARGS)
static int rctl_throttle_pct2_sysctl(SYSCTL_HANDLER_ARGS)
{
- int val = rctl_throttle_pct2;
- int error;
+ int error, val = rctl_throttle_pct2;
error = sysctl_handle_int(oidp, &val, 0, req);
if (error || !req->newptr)
@@ -367,8 +363,8 @@ rctl_proc_rule_to_racct(const struct proc *p, const struct rctl_rule *rule)
static int64_t
rctl_available_resource(const struct proc *p, const struct rctl_rule *rule)
{
- int64_t available;
const struct racct *racct;
+ int64_t available;
ASSERT_RACCT_ENABLED();
RCTL_LOCK_ASSERT();
@@ -515,10 +511,10 @@ rctl_enforce(struct proc *p, int resource, uint64_t amount)
struct rctl_rule *rule;
struct rctl_rule_link *link;
struct sbuf sb;
+ char *buf;
int64_t available;
uint64_t sleep_ms, sleep_ratio;
int should_deny = 0;
- char *buf;
ASSERT_RACCT_ENABLED();
@@ -945,8 +941,8 @@ static int
rctl_racct_remove_rules(struct racct *racct,
const struct rctl_rule *filter)
{
- int removed = 0;
struct rctl_rule_link *link, *linktmp;
+ int removed = 0;
ASSERT_RACCT_ENABLED();
RCTL_WLOCK_ASSERT();
@@ -1160,11 +1156,11 @@ rctl_rule_fully_specified(const struct rctl_rule *rule)
static int
rctl_string_to_rule(char *rulestr, struct rctl_rule **rulep)
{
- int error = 0;
+ struct rctl_rule *rule;
char *subjectstr, *subject_idstr, *resourcestr, *actionstr,
*amountstr, *perstr;
- struct rctl_rule *rule;
id_t id;
+ int error = 0;
ASSERT_RACCT_ENABLED();
@@ -1450,8 +1446,8 @@ rctl_rule_remove_callback(struct racct *racct, void *arg2, void *arg3)
int
rctl_rule_remove(struct rctl_rule *filter)
{
- int found = 0;
struct proc *p;
+ int found = 0;
ASSERT_RACCT_ENABLED();
@@ -1554,8 +1550,8 @@ rctl_rule_to_sbuf(struct sbuf *sb, const struct rctl_rule *rule)
static int
rctl_read_inbuf(char **inputstr, const char *inbufp, size_t inbuflen)
{
- int error;
char *str;
+ int error;
ASSERT_RACCT_ENABLED();
@@ -1603,9 +1599,9 @@ rctl_write_outbuf(struct sbuf *outputsbuf, char *outbufp, size_t outbuflen)
static struct sbuf *
rctl_racct_to_sbuf(struct racct *racct, int sloppy)
{
- int i;
- int64_t amount;
struct sbuf *sb;
+ int64_t amount;
+ int i;
ASSERT_RACCT_ENABLED();
@@ -1625,14 +1621,14 @@ rctl_racct_to_sbuf(struct racct *racct, int sloppy)
int
sys_rctl_get_racct(struct thread *td, struct rctl_get_racct_args *uap)
{
- int error;
- char *inputstr;
struct rctl_rule *filter;
struct sbuf *outputsbuf = NULL;
struct proc *p;
struct uidinfo *uip;
struct loginclass *lc;
struct prison_racct *prr;
+ char *inputstr;
+ int error;
if (!racct_enable)
return (ENOSYS);
@@ -1721,13 +1717,13 @@ rctl_get_rules_callback(struct racct *racct, void *arg2, void *arg3)
int
sys_rctl_get_rules(struct thread *td, struct rctl_get_rules_args *uap)
{
- int error;
- size_t bufsize;
- char *inputstr, *buf;
struct sbuf *sb;
struct rctl_rule *filter;
struct rctl_rule_link *link;
struct proc *p;
+ char *inputstr, *buf;
+ size_t bufsize;
+ int error;
if (!racct_enable)
return (ENOSYS);
@@ -1807,12 +1803,12 @@ out:
int
sys_rctl_get_limits(struct thread *td, struct rctl_get_limits_args *uap)
{
- int error;
- size_t bufsize;
- char *inputstr, *buf;
struct sbuf *sb;
struct rctl_rule *filter;
struct rctl_rule_link *link;
+ char *inputstr, *buf;
+ size_t bufsize;
+ int error;
if (!racct_enable)
return (ENOSYS);
@@ -1889,9 +1885,9 @@ out:
int
sys_rctl_add_rule(struct thread *td, struct rctl_add_rule_args *uap)
{
- int error;
struct rctl_rule *rule;
char *inputstr;
+ int error;
if (!racct_enable)
return (ENOSYS);
@@ -1934,9 +1930,9 @@ out:
int
sys_rctl_remove_rule(struct thread *td, struct rctl_remove_rule_args *uap)
{
- int error;
struct rctl_rule *filter;
char *inputstr;
+ int error;
if (!racct_enable)
return (ENOSYS);
@@ -1970,12 +1966,12 @@ sys_rctl_remove_rule(struct thread *td, struct rctl_remove_rule_args *uap)
void
rctl_proc_ucred_changed(struct proc *p, struct ucred *newcred)
{
- int rulecnt, i;
+ LIST_HEAD(, rctl_rule_link) newrules;
struct rctl_rule_link *link, *newlink;
struct uidinfo *newuip;
struct loginclass *newlc;
struct prison_racct *newprr;
- LIST_HEAD(, rctl_rule_link) newrules;
+ int rulecnt, i;
ASSERT_RACCT_ENABLED();
@@ -2118,9 +2114,9 @@ goaround:
int
rctl_proc_fork(struct proc *parent, struct proc *child)
{
- int error;
- struct rctl_rule_link *link;
struct rctl_rule *rule;
+ struct rctl_rule_link *link;
+ int error;
LIST_INIT(&child->p_racct->r_rule_links);
@@ -2197,11 +2193,11 @@ rctl_init(void)
if (!racct_enable)
return;
+ rctl_rule_zone = uma_zcreate("rctl_rule", sizeof(struct rctl_rule),
+ NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
rctl_rule_link_zone = uma_zcreate("rctl_rule_link",
sizeof(struct rctl_rule_link), NULL, NULL, NULL, NULL,
- UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
- rctl_rule_zone = uma_zcreate("rctl_rule", sizeof(struct rctl_rule),
- NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE);
+ UMA_ALIGN_PTR, 0);
/*
* Set default values, making sure not to overwrite the ones
diff --git a/sys/kern/kern_shutdown.c b/sys/kern/kern_shutdown.c
index 87e7d63..7588d4c 100644
--- a/sys/kern/kern_shutdown.c
+++ b/sys/kern/kern_shutdown.c
@@ -88,6 +88,8 @@ __FBSDID("$FreeBSD$");
#include <sys/signalvar.h>
+static MALLOC_DEFINE(M_DUMPER, "dumper", "dumper block buffer");
+
#ifndef PANIC_REBOOT_WAIT_TIME
#define PANIC_REBOOT_WAIT_TIME 15 /* default to 15 seconds */
#endif
@@ -848,7 +850,9 @@ set_dumper(struct dumperinfo *di, const char *devname, struct thread *td)
return (error);
if (di == NULL) {
- bzero(&dumper, sizeof dumper);
+ if (dumper.blockbuf != NULL)
+ free(dumper.blockbuf, M_DUMPER);
+ bzero(&dumper, sizeof(dumper));
dumpdevname[0] = '\0';
return (0);
}
@@ -860,6 +864,7 @@ set_dumper(struct dumperinfo *di, const char *devname, struct thread *td)
printf("set_dumper: device name truncated from '%s' -> '%s'\n",
devname, dumpdevname);
}
+ dumper.blockbuf = malloc(di->blocksize, M_DUMPER, M_WAITOK | M_ZERO);
return (0);
}
@@ -880,6 +885,31 @@ dump_write(struct dumperinfo *di, void *virtual, vm_offset_t physical,
return (di->dumper(di->priv, virtual, physical, offset, length));
}
+/* Call dumper with bounds checking. */
+int
+dump_write_pad(struct dumperinfo *di, void *virtual, vm_offset_t physical,
+ off_t offset, size_t length, size_t *size)
+{
+ char *temp;
+ int ret;
+
+ if (length > di->blocksize)
+ return (ENOMEM);
+
+ *size = di->blocksize;
+ if (length == di->blocksize)
+ temp = virtual;
+ else {
+ temp = di->blockbuf;
+ memset(temp + length, 0, di->blocksize - length);
+ memcpy(temp, virtual, length);
+ }
+ ret = dump_write(di, temp, physical, offset, *size);
+
+ return (ret);
+}
+
+
void
mkdumpheader(struct kerneldumpheader *kdh, char *magic, uint32_t archver,
uint64_t dumplen, uint32_t blksz)
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index f57cd58..aae705e 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -912,7 +912,7 @@ sysctl_sysctl_name(SYSCTL_HANDLER_ARGS)
name++;
continue;
}
- lsp2 = 0;
+ lsp2 = NULL;
SLIST_FOREACH(oid, lsp, oid_link) {
if (oid->oid_number != *name)
continue;
@@ -1083,7 +1083,7 @@ sysctl_sysctl_name2oid(SYSCTL_HANDLER_ARGS)
{
char *p;
int error, oid[CTL_MAXNAME], len = 0;
- struct sysctl_oid *op = 0;
+ struct sysctl_oid *op = NULL;
struct rm_priotracker tracker;
if (!req->newlen)
diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c
index 1579c28..349a95e 100644
--- a/sys/kern/link_elf.c
+++ b/sys/kern/link_elf.c
@@ -1382,7 +1382,7 @@ link_elf_search_symbol(linker_file_t lf, caddr_t value,
u_long diff = off;
u_long st_value;
const Elf_Sym* es;
- const Elf_Sym* best = 0;
+ const Elf_Sym* best = NULL;
int i;
for (i = 0, es = ef->ddbsymtab; i < ef->ddbsymcnt; i++, es++) {
@@ -1400,7 +1400,7 @@ link_elf_search_symbol(linker_file_t lf, caddr_t value,
}
}
}
- if (best == 0)
+ if (best == NULL)
*diffp = off;
else
*diffp = diff;
diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c
index 575a706..544bd253 100644
--- a/sys/kern/link_elf_obj.c
+++ b/sys/kern/link_elf_obj.c
@@ -1180,7 +1180,7 @@ link_elf_search_symbol(linker_file_t lf, caddr_t value,
u_long diff = off;
u_long st_value;
const Elf_Sym *es;
- const Elf_Sym *best = 0;
+ const Elf_Sym *best = NULL;
int i;
for (i = 0, es = ef->ddbsymtab; i < ef->ddbsymcnt; i++, es++) {
@@ -1198,7 +1198,7 @@ link_elf_search_symbol(linker_file_t lf, caddr_t value,
}
}
}
- if (best == 0)
+ if (best == NULL)
*diffp = off;
else
*diffp = diff;
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c
index 22616b9..0063916 100644
--- a/sys/kern/sysv_sem.c
+++ b/sys/kern/sysv_sem.c
@@ -980,8 +980,8 @@ sys_semop(struct thread *td, struct semop_args *uap)
size_t nsops = uap->nsops;
struct sembuf *sops;
struct semid_kernel *semakptr;
- struct sembuf *sopptr = 0;
- struct sem *semptr = 0;
+ struct sembuf *sopptr = NULL;
+ struct sem *semptr = NULL;
struct sem_undo *suptr;
struct mtx *sema_mtxp;
size_t i, j, k;
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index 62dfda6..84354f3 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -459,7 +459,7 @@ m_copym(struct mbuf *m, int off0, int len, int wait)
m = m->m_next;
}
np = &top;
- top = 0;
+ top = NULL;
while (len > 0) {
if (m == NULL) {
KASSERT(len == M_COPYALL,
diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c
index 0589f4a..e329ef2 100644
--- a/sys/kern/uipc_mqueue.c
+++ b/sys/kern/uipc_mqueue.c
@@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/limits.h>
+#include <sys/malloc.h>
#include <sys/buf.h>
#include <sys/capsicum.h>
#include <sys/dirent.h>
@@ -60,8 +61,8 @@ __FBSDID("$FreeBSD$");
#include <sys/fcntl.h>
#include <sys/file.h>
#include <sys/filedesc.h>
+#include <sys/jail.h>
#include <sys/lock.h>
-#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mount.h>
#include <sys/mqueue.h>
@@ -132,6 +133,7 @@ struct mqfs_node {
LIST_HEAD(,mqfs_node) mn_children;
LIST_ENTRY(mqfs_node) mn_sibling;
LIST_HEAD(,mqfs_vdata) mn_vnodes;
+ const void *mn_pr_root;
int mn_refcount;
mqfs_type_t mn_type;
int mn_deleted;
@@ -152,6 +154,11 @@ struct mqfs_node {
#define FPTOMQ(fp) ((struct mqueue *)(((struct mqfs_node *) \
(fp)->f_data)->mn_data))
+struct mqfs_osd {
+ struct task mo_task;
+ const void *mo_pr_root;
+};
+
TAILQ_HEAD(msgq, mqueue_msg);
struct mqueue;
@@ -219,6 +226,7 @@ static uma_zone_t mvdata_zone;
static uma_zone_t mqnoti_zone;
static struct vop_vector mqfs_vnodeops;
static struct fileops mqueueops;
+static unsigned mqfs_osd_jail_slot;
/*
* Directory structure construction and manipulation
@@ -236,6 +244,9 @@ static int mqfs_destroy(struct mqfs_node *mn);
static void mqfs_fileno_alloc(struct mqfs_info *mi, struct mqfs_node *mn);
static void mqfs_fileno_free(struct mqfs_info *mi, struct mqfs_node *mn);
static int mqfs_allocv(struct mount *mp, struct vnode **vpp, struct mqfs_node *pn);
+static int mqfs_prison_create(void *obj, void *data);
+static void mqfs_prison_destructor(void *data);
+static void mqfs_prison_remove_task(void *context, int pending);
/*
* Message queue construction and maniplation
@@ -436,6 +447,7 @@ mqfs_create_node(const char *name, int namelen, struct ucred *cred, int mode,
node = mqnode_alloc();
strncpy(node->mn_name, name, namelen);
+ node->mn_pr_root = cred->cr_prison->pr_root;
node->mn_type = nodetype;
node->mn_refcount = 1;
vfs_timestamp(&node->mn_birth);
@@ -644,6 +656,10 @@ mqfs_init(struct vfsconf *vfc)
{
struct mqfs_node *root;
struct mqfs_info *mi;
+ struct prison *pr;
+ osd_method_t methods[PR_MAXMETHOD] = {
+ [PR_METHOD_CREATE] = mqfs_prison_create,
+ };
mqnode_zone = uma_zcreate("mqnode", sizeof(struct mqfs_node),
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
@@ -670,6 +686,13 @@ mqfs_init(struct vfsconf *vfc)
EVENTHANDLER_PRI_ANY);
mq_fdclose = mqueue_fdclose;
p31b_setcfg(CTL_P1003_1B_MESSAGE_PASSING, _POSIX_MESSAGE_PASSING);
+
+ /* Note current jails. */
+ mqfs_osd_jail_slot = osd_jail_register(mqfs_prison_destructor, methods);
+ sx_slock(&allprison_lock);
+ TAILQ_FOREACH(pr, &allprison, pr_list)
+ (void)mqfs_prison_create(pr, NULL);
+ sx_sunlock(&allprison_lock);
return (0);
}
@@ -679,10 +702,14 @@ mqfs_init(struct vfsconf *vfc)
static int
mqfs_uninit(struct vfsconf *vfc)
{
+ unsigned slot;
struct mqfs_info *mi;
if (!unloadable)
return (EOPNOTSUPP);
+ slot = mqfs_osd_jail_slot;
+ mqfs_osd_jail_slot = 0;
+ osd_jail_deregister(slot);
EVENTHANDLER_DEREGISTER(process_exit, exit_tag);
mi = &mqfs_data;
mqfs_destroy(mi->mi_root);
@@ -800,13 +827,17 @@ found:
* Search a directory entry
*/
static struct mqfs_node *
-mqfs_search(struct mqfs_node *pd, const char *name, int len)
+mqfs_search(struct mqfs_node *pd, const char *name, int len, struct ucred *cred)
{
struct mqfs_node *pn;
+ const void *pr_root;
sx_assert(&pd->mn_info->mi_lock, SX_LOCKED);
+ pr_root = cred->cr_prison->pr_root;
LIST_FOREACH(pn, &pd->mn_children, mn_sibling) {
- if (strncmp(pn->mn_name, name, len) == 0 &&
+ /* Only match names within the same prison root directory */
+ if ((pn->mn_pr_root == NULL || pn->mn_pr_root == pr_root) &&
+ strncmp(pn->mn_name, name, len) == 0 &&
pn->mn_name[len] == '\0')
return (pn);
}
@@ -878,7 +909,7 @@ mqfs_lookupx(struct vop_cachedlookup_args *ap)
/* named node */
sx_xlock(&mqfs->mi_lock);
- pn = mqfs_search(pd, pname, namelen);
+ pn = mqfs_search(pd, pname, namelen, cnp->cn_cred);
if (pn != NULL)
mqnode_addref(pn);
sx_xunlock(&mqfs->mi_lock);
@@ -1363,6 +1394,7 @@ mqfs_readdir(struct vop_readdir_args *ap)
struct mqfs_node *pn;
struct dirent entry;
struct uio *uio;
+ const void *pr_root;
int *tmp_ncookies = NULL;
off_t offset;
int error, i;
@@ -1387,10 +1419,18 @@ mqfs_readdir(struct vop_readdir_args *ap)
error = 0;
offset = 0;
+ pr_root = ap->a_cred->cr_prison->pr_root;
sx_xlock(&mi->mi_lock);
LIST_FOREACH(pn, &pd->mn_children, mn_sibling) {
entry.d_reclen = sizeof(entry);
+
+ /*
+ * Only show names within the same prison root directory
+ * (or not associated with a prison, e.g. "." and "..").
+ */
+ if (pn->mn_pr_root != NULL && pn->mn_pr_root != pr_root)
+ continue;
if (!pn->mn_fileno)
mqfs_fileno_alloc(mi, pn);
entry.d_fileno = pn->mn_fileno;
@@ -1523,6 +1563,81 @@ mqfs_rmdir(struct vop_rmdir_args *ap)
#endif /* notyet */
+
+/*
+ * Set a destructor task with the prison's root
+ */
+static int
+mqfs_prison_create(void *obj, void *data __unused)
+{
+ struct prison *pr = obj;
+ struct mqfs_osd *mo;
+ void *rsv;
+
+ if (pr->pr_root == pr->pr_parent->pr_root)
+ return(0);
+
+ mo = malloc(sizeof(struct mqfs_osd), M_PRISON, M_WAITOK);
+ rsv = osd_reserve(mqfs_osd_jail_slot);
+ TASK_INIT(&mo->mo_task, 0, mqfs_prison_remove_task, mo);
+ mtx_lock(&pr->pr_mtx);
+ mo->mo_pr_root = pr->pr_root;
+ (void)osd_jail_set_reserved(pr, mqfs_osd_jail_slot, rsv, mo);
+ mtx_unlock(&pr->pr_mtx);
+ return (0);
+}
+
+/*
+ * Queue the task for after jail/OSD locks are released
+ */
+static void
+mqfs_prison_destructor(void *data)
+{
+ struct mqfs_osd *mo = data;
+
+ if (mqfs_osd_jail_slot != 0)
+ taskqueue_enqueue(taskqueue_thread, &mo->mo_task);
+ else
+ free(mo, M_PRISON);
+}
+
+/*
+ * See if this prison root is obsolete, and clean up associated queues if it is
+ */
+static void
+mqfs_prison_remove_task(void *context, int pending)
+{
+ struct mqfs_osd *mo = context;
+ struct mqfs_node *pn, *tpn;
+ const struct prison *pr;
+ const void *pr_root;
+ int found;
+
+ pr_root = mo->mo_pr_root;
+ found = 0;
+ sx_slock(&allprison_lock);
+ TAILQ_FOREACH(pr, &allprison, pr_list) {
+ if (pr->pr_root == pr_root)
+ found = 1;
+ }
+ sx_sunlock(&allprison_lock);
+ if (!found) {
+ /*
+ * No jails are rooted in this directory anymore,
+ * so no queues should be either.
+ */
+ sx_xlock(&mqfs_data.mi_lock);
+ LIST_FOREACH_SAFE(pn, &mqfs_data.mi_root->mn_children,
+ mn_sibling, tpn) {
+ if (pn->mn_pr_root == pr_root)
+ (void)do_unlink(pn, curthread->td_ucred);
+ }
+ sx_xunlock(&mqfs_data.mi_lock);
+ }
+ free(mo, M_PRISON);
+}
+
+
/*
* Allocate a message queue
*/
@@ -1983,7 +2098,7 @@ kern_kmq_open(struct thread *td, const char *upath, int flags, mode_t mode,
return (error);
sx_xlock(&mqfs_data.mi_lock);
- pn = mqfs_search(mqfs_data.mi_root, path + 1, len - 1);
+ pn = mqfs_search(mqfs_data.mi_root, path + 1, len - 1, td->td_ucred);
if (pn == NULL) {
if (!(flags & O_CREAT)) {
error = ENOENT;
@@ -2078,7 +2193,7 @@ sys_kmq_unlink(struct thread *td, struct kmq_unlink_args *uap)
return (EINVAL);
sx_xlock(&mqfs_data.mi_lock);
- pn = mqfs_search(mqfs_data.mi_root, path + 1, len - 1);
+ pn = mqfs_search(mqfs_data.mi_root, path + 1, len - 1, td->td_ucred);
if (pn != NULL)
error = do_unlink(pn, td->td_ucred);
else
diff --git a/sys/kern/uipc_sem.c b/sys/kern/uipc_sem.c
index 1b2c761..0ecff7c 100644
--- a/sys/kern/uipc_sem.c
+++ b/sys/kern/uipc_sem.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <sys/file.h>
#include <sys/filedesc.h>
#include <sys/fnv_hash.h>
+#include <sys/jail.h>
#include <sys/kernel.h>
#include <sys/ksem.h>
#include <sys/lock.h>
@@ -258,7 +259,9 @@ ksem_closef(struct file *fp, struct thread *td)
static int
ksem_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
{
+ const char *path, *pr_path;
struct ksem *ks;
+ size_t pr_pathlen;
kif->kf_type = KF_TYPE_SEM;
ks = fp->f_data;
@@ -268,8 +271,18 @@ ksem_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
mtx_unlock(&sem_lock);
if (ks->ks_path != NULL) {
sx_slock(&ksem_dict_lock);
- if (ks->ks_path != NULL)
- strlcpy(kif->kf_path, ks->ks_path, sizeof(kif->kf_path));
+ if (ks->ks_path != NULL) {
+ path = ks->ks_path;
+ pr_path = curthread->td_ucred->cr_prison->pr_path;
+ if (strcmp(pr_path, "/") != 0) {
+ /* Return the jail-rooted pathname. */
+ pr_pathlen = strlen(pr_path);
+ if (strncmp(path, pr_path, pr_pathlen) == 0 &&
+ path[pr_pathlen] == '/')
+ path += pr_pathlen;
+ }
+ strlcpy(kif->kf_path, path, sizeof(kif->kf_path));
+ }
sx_sunlock(&ksem_dict_lock);
}
return (0);
@@ -449,6 +462,8 @@ ksem_create(struct thread *td, const char *name, semid_t *semidp, mode_t mode,
struct ksem *ks;
struct file *fp;
char *path;
+ const char *pr_path;
+ size_t pr_pathlen;
Fnv32_t fnv;
int error, fd;
@@ -485,10 +500,16 @@ ksem_create(struct thread *td, const char *name, semid_t *semidp, mode_t mode,
ks->ks_flags |= KS_ANONYMOUS;
} else {
path = malloc(MAXPATHLEN, M_KSEM, M_WAITOK);
- error = copyinstr(name, path, MAXPATHLEN, NULL);
+ pr_path = td->td_ucred->cr_prison->pr_path;
+
+ /* Construct a full pathname for jailed callers. */
+ pr_pathlen = strcmp(pr_path, "/") == 0 ? 0
+ : strlcpy(path, pr_path, MAXPATHLEN);
+ error = copyinstr(name, path + pr_pathlen,
+ MAXPATHLEN - pr_pathlen, NULL);
/* Require paths to start with a '/' character. */
- if (error == 0 && path[0] != '/')
+ if (error == 0 && path[pr_pathlen] != '/')
error = EINVAL;
if (error) {
fdclose(td, fp, fd);
@@ -624,11 +645,17 @@ int
sys_ksem_unlink(struct thread *td, struct ksem_unlink_args *uap)
{
char *path;
+ const char *pr_path;
+ size_t pr_pathlen;
Fnv32_t fnv;
int error;
path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
- error = copyinstr(uap->name, path, MAXPATHLEN, NULL);
+ pr_path = td->td_ucred->cr_prison->pr_path;
+ pr_pathlen = strcmp(pr_path, "/") == 0 ? 0
+ : strlcpy(path, pr_path, MAXPATHLEN);
+ error = copyinstr(uap->name, path + pr_pathlen, MAXPATHLEN - pr_pathlen,
+ NULL);
if (error) {
free(path, M_TEMP);
return (error);
diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c
index a2146b9..0657787 100644
--- a/sys/kern/uipc_shm.c
+++ b/sys/kern/uipc_shm.c
@@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/uio.h>
#include <sys/signal.h>
+#include <sys/jail.h>
#include <sys/ktrace.h>
#include <sys/lock.h>
#include <sys/malloc.h>
@@ -687,6 +688,8 @@ kern_shm_open(struct thread *td, const char *userpath, int flags, mode_t mode,
struct shmfd *shmfd;
struct file *fp;
char *path;
+ const char *pr_path;
+ size_t pr_pathlen;
Fnv32_t fnv;
mode_t cmode;
int fd, error;
@@ -723,13 +726,19 @@ kern_shm_open(struct thread *td, const char *userpath, int flags, mode_t mode,
shmfd = shm_alloc(td->td_ucred, cmode);
} else {
path = malloc(MAXPATHLEN, M_SHMFD, M_WAITOK);
- error = copyinstr(userpath, path, MAXPATHLEN, NULL);
+ pr_path = td->td_ucred->cr_prison->pr_path;
+
+ /* Construct a full pathname for jailed callers. */
+ pr_pathlen = strcmp(pr_path, "/") == 0 ? 0
+ : strlcpy(path, pr_path, MAXPATHLEN);
+ error = copyinstr(userpath, path + pr_pathlen,
+ MAXPATHLEN - pr_pathlen, NULL);
#ifdef KTRACE
if (error == 0 && KTRPOINT(curthread, KTR_NAMEI))
ktrnamei(path);
#endif
/* Require paths to start with a '/' character. */
- if (error == 0 && path[0] != '/')
+ if (error == 0 && path[pr_pathlen] != '/')
error = EINVAL;
if (error) {
fdclose(td, fp, fd);
@@ -823,11 +832,17 @@ int
sys_shm_unlink(struct thread *td, struct shm_unlink_args *uap)
{
char *path;
+ const char *pr_path;
+ size_t pr_pathlen;
Fnv32_t fnv;
int error;
path = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
- error = copyinstr(uap->path, path, MAXPATHLEN, NULL);
+ pr_path = td->td_ucred->cr_prison->pr_path;
+ pr_pathlen = strcmp(pr_path, "/") == 0 ? 0
+ : strlcpy(path, pr_path, MAXPATHLEN);
+ error = copyinstr(uap->path, path + pr_pathlen, MAXPATHLEN - pr_pathlen,
+ NULL);
if (error) {
free(path, M_TEMP);
return (error);
@@ -1060,7 +1075,9 @@ shm_unmap(struct file *fp, void *mem, size_t size)
static int
shm_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
{
+ const char *path, *pr_path;
struct shmfd *shmfd;
+ size_t pr_pathlen;
kif->kf_type = KF_TYPE_SHM;
shmfd = fp->f_data;
@@ -1071,9 +1088,18 @@ shm_fill_kinfo(struct file *fp, struct kinfo_file *kif, struct filedesc *fdp)
kif->kf_un.kf_file.kf_file_size = shmfd->shm_size;
if (shmfd->shm_path != NULL) {
sx_slock(&shm_dict_lock);
- if (shmfd->shm_path != NULL)
- strlcpy(kif->kf_path, shmfd->shm_path,
- sizeof(kif->kf_path));
+ if (shmfd->shm_path != NULL) {
+ path = shmfd->shm_path;
+ pr_path = curthread->td_ucred->cr_prison->pr_path;
+ if (strcmp(pr_path, "/") != 0) {
+ /* Return the jail-rooted pathname. */
+ pr_pathlen = strlen(pr_path);
+ if (strncmp(path, pr_path, pr_pathlen) == 0 &&
+ path[pr_pathlen] == '/')
+ path += pr_pathlen;
+ }
+ strlcpy(kif->kf_path, path, sizeof(kif->kf_path));
+ }
sx_sunlock(&shm_dict_lock);
}
return (0);
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c
index 0cdd43b..cf9f4b1 100644
--- a/sys/kern/uipc_sockbuf.c
+++ b/sys/kern/uipc_sockbuf.c
@@ -593,7 +593,7 @@ sbappend_locked(struct sockbuf *sb, struct mbuf *m, int flags)
SOCKBUF_LOCK_ASSERT(sb);
- if (m == 0)
+ if (m == NULL)
return;
sbm_clrprotoflags(m, flags);
SBLASTRECORDCHK(sb);
@@ -746,7 +746,7 @@ sbappendrecord_locked(struct sockbuf *sb, struct mbuf *m0)
SOCKBUF_LOCK_ASSERT(sb);
- if (m0 == 0)
+ if (m0 == NULL)
return;
m_clrprotoflags(m0);
/*
@@ -885,7 +885,7 @@ sbappendcontrol_locked(struct sockbuf *sb, struct mbuf *m0,
SOCKBUF_LOCK_ASSERT(sb);
- if (control == 0)
+ if (control == NULL)
panic("sbappendcontrol_locked");
space = m_length(control, &n) + m_length(m0, NULL);
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 79444e0..05703ef 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -430,7 +430,7 @@ kern_accept4(struct thread *td, int s, struct sockaddr **name,
(void) fo_ioctl(nfp, FIONBIO, &tmp, td->td_ucred, td);
tmp = fflag & FASYNC;
(void) fo_ioctl(nfp, FIOASYNC, &tmp, td->td_ucred, td);
- sa = 0;
+ sa = NULL;
error = soaccept(so, &sa);
if (error != 0)
goto noconnection;
diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c
index 40dc0c0..ea902d7 100644
--- a/sys/kern/vfs_cluster.c
+++ b/sys/kern/vfs_cluster.c
@@ -368,7 +368,7 @@ cluster_rbuild(struct vnode *vp, u_quad_t filesize, daddr_t lbn,
return tbp;
bp = trypbuf(&cluster_pbuf_freecnt);
- if (bp == 0)
+ if (bp == NULL)
return tbp;
/*
diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c
index 9eb523c..e7a709d 100644
--- a/sys/kern/vfs_export.c
+++ b/sys/kern/vfs_export.c
@@ -102,7 +102,7 @@ vfs_hang_addrlist(struct mount *mp, struct netexport *nep,
register struct radix_node_head *rnh;
register int i;
struct radix_node *rn;
- struct sockaddr *saddr, *smask = 0;
+ struct sockaddr *saddr, *smask = NULL;
#if defined(INET6) || defined(INET)
int off;
#endif
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
index f4b0596..a1116e0 100644
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -486,7 +486,7 @@ int
lookup(struct nameidata *ndp)
{
char *cp; /* pointer into pathname argument */
- struct vnode *dp = 0; /* the directory we are searching */
+ struct vnode *dp = NULL; /* the directory we are searching */
struct vnode *tdp; /* saved dp */
struct mount *mp; /* mount table entry */
struct prison *pr;
@@ -949,7 +949,7 @@ bad:
int
relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
{
- struct vnode *dp = 0; /* the directory we are searching */
+ struct vnode *dp = NULL; /* the directory we are searching */
int wantparent; /* 1 => wantparent or lockparent flag */
int rdonly; /* lookup read-only flag bit */
int error = 0;
diff --git a/sys/libkern/strtol.c b/sys/libkern/strtol.c
index 4d64025..ea7dd55 100644
--- a/sys/libkern/strtol.c
+++ b/sys/libkern/strtol.c
@@ -123,7 +123,7 @@ strtol(nptr, endptr, base)
acc = neg ? LONG_MIN : LONG_MAX;
} else if (neg)
acc = -acc;
- if (endptr != 0)
+ if (endptr != NULL)
*endptr = __DECONST(char *, any ? s - 1 : nptr);
return (acc);
}
diff --git a/sys/libkern/strtoq.c b/sys/libkern/strtoq.c
index d855056..e83adb1 100644
--- a/sys/libkern/strtoq.c
+++ b/sys/libkern/strtoq.c
@@ -124,7 +124,7 @@ strtoq(const char *nptr, char **endptr, int base)
acc = neg ? QUAD_MIN : QUAD_MAX;
} else if (neg)
acc = -acc;
- if (endptr != 0)
+ if (endptr != NULL)
*endptr = __DECONST(char *, any ? s - 1 : nptr);
return (acc);
}
diff --git a/sys/libkern/strtoul.c b/sys/libkern/strtoul.c
index f7399dc..44adf5a 100644
--- a/sys/libkern/strtoul.c
+++ b/sys/libkern/strtoul.c
@@ -102,7 +102,7 @@ strtoul(nptr, endptr, base)
acc = ULONG_MAX;
} else if (neg)
acc = -acc;
- if (endptr != 0)
+ if (endptr != NULL)
*endptr = __DECONST(char *, any ? s - 1 : nptr);
return (acc);
}
diff --git a/sys/libkern/strtouq.c b/sys/libkern/strtouq.c
index f8303a0..49c3750 100644
--- a/sys/libkern/strtouq.c
+++ b/sys/libkern/strtouq.c
@@ -101,7 +101,7 @@ strtouq(const char *nptr, char **endptr, int base)
acc = UQUAD_MAX;
} else if (neg)
acc = -acc;
- if (endptr != 0)
+ if (endptr != NULL)
*endptr = __DECONST(char *, any ? s - 1 : nptr);
return (acc);
}
diff --git a/sys/mips/adm5120/obio.c b/sys/mips/adm5120/obio.c
index 8b62629..0e09886 100644
--- a/sys/mips/adm5120/obio.c
+++ b/sys/mips/adm5120/obio.c
@@ -270,7 +270,7 @@ obio_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0) {
+ if (rv == NULL) {
printf("%s: could not reserve resource\n", __func__);
return (0);
}
diff --git a/sys/mips/alchemy/obio.c b/sys/mips/alchemy/obio.c
index 96b1f1d..b85ca48 100644
--- a/sys/mips/alchemy/obio.c
+++ b/sys/mips/alchemy/obio.c
@@ -271,7 +271,7 @@ obio_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0) {
+ if (rv == NULL) {
printf("%s: could not reserve resource\n", __func__);
return (0);
}
diff --git a/sys/mips/atheros/apb.c b/sys/mips/atheros/apb.c
index abae9c2..6a38c7d 100644
--- a/sys/mips/atheros/apb.c
+++ b/sys/mips/atheros/apb.c
@@ -223,7 +223,7 @@ apb_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0) {
+ if (rv == NULL) {
printf("%s: could not reserve resource\n", __func__);
return (0);
}
diff --git a/sys/mips/conf/MEDIATEK b/sys/mips/conf/MEDIATEK
new file mode 100644
index 0000000..4cf8225
--- /dev/null
+++ b/sys/mips/conf/MEDIATEK
@@ -0,0 +1,81 @@
+#
+# MEDIATEK -- Kernel configuration file for FreeBSD/MIPS Mediatek/Ralink SoCs
+#
+# This includes all the configurable parts of the kernel. Please read through
+# the sections below and customize the options to fit your board if needed.
+#
+# $FreeBSD$
+#
+
+#NO_UNIVERSE
+
+# Don't build any modules by default
+makeoptions MODULES_OVERRIDE=""
+
+#
+# Default rootfs device configuration, should be changed to suit target board
+#
+options ROOTDEVNAME=\"ufs:md0.uzip\"
+
+#
+# Optional drivers section
+#
+# What follows is optional support drivers for the Mediatek SoCs.
+# The kernel can be compiled without them if size is a concern.
+# All optional drivers are built by default.
+#
+
+# Support geom_uzip(4) compressed disk images
+device geom_uzip
+options GEOM_UZIP
+
+# Support md(4) and md-based rootfs
+device md
+options MD_ROOT
+
+# SPI and SPI flash support
+device spibus
+device mx25l
+
+# GPIO and gpioled support
+device gpio
+device gpioled
+
+# PCI support
+device pci
+
+#
+# USB (ehci, ohci, xhci, otg) support. Unneeded drivers can be commented in
+# order to lower kernel size. See below for driver SoC support.
+#
+# For all SoCs that require USB support
+device usb
+# For RT3050, RT3052 and RT3350 SoCs
+device dwcotg
+# For RT3352, RT3662, RT3883, RT5350, MT7620, MT7628 and MT7688
+device ohci
+device ehci
+# For MT7621, or cases where the target board has a XHCI controller on PCI
+# (for example Asus RT-N65U)
+device xhci
+
+# USB umass(4) storage and da(4) support
+device umass
+device da
+
+# ahci(4) and ada(4) support, depends on PCI
+device ahci
+device ada
+
+# CAM support, required if either umass(4) or ahci(4) is enabled above
+device pass
+device scbus
+
+# Ethernet, BPS and bridge support
+device rt
+device bpf
+device if_bridge
+
+# Extres
+device ext_resources
+device clk
diff --git a/sys/mips/conf/MEDIATEK_BASE b/sys/mips/conf/MEDIATEK_BASE
new file mode 100644
index 0000000..5e6c0ad
--- /dev/null
+++ b/sys/mips/conf/MEDIATEK_BASE
@@ -0,0 +1,89 @@
+#
+# MEDIATEK_BASE -- Base kernel configuration file for FreeBSD/MIPS
+# Mediatek/Ralink SoCs.
+#
+# This includes all the required drivers for the SoCs.
+# Ususally, users should not build this kernel configuration. It is provided
+# only as a minimum base, from which customizations can be made. Please look
+# at MEDIATEK kernel configuration for customization details.
+#
+# $FreeBSD$
+#
+
+#NO_UNIVERSE
+
+# Include the standard file list for Mediatek SoCs.
+files "../mediatek/files.mtk"
+
+# Building a mips/mipsel kernel
+machine mips mipsel
+
+# Little-endian machine
+makeoptions MIPS_LITTLE_ENDIAN=defined
+
+# Default kernel load address
+makeoptions KERNLOADADDR=0x80001000
+
+# Mediatek/Ralink SoC support depends on FDT (with static DTB for the moment)
+options FDT
+options FDT_DTB_STATIC
+
+# We rely on MIPS_INTRNG code
+options MIPS_INTRNG
+options MIPS_NIRQ=256
+
+# We rely on NEW_PCIB code
+options NEW_PCIB
+
+# Build kernel with gdb(1) debug symbols
+makeoptions DEBUG=-g
+
+# Support for DDB and KDB
+options DDB
+options KDB
+
+# Debugging for use in -current
+options INVARIANTS
+options INVARIANT_SUPPORT
+options WITNESS
+options WITNESS_SKIPSPIN
+options DEBUG_REDZONE
+options DEBUG_MEMGUARD
+
+# For small memory footprints
+options VM_KMEM_SIZE_SCALE=1
+
+# General options, including scheduler, etc.
+options SCHED_ULE # ULE scheduler
+options INET # InterNETworking
+#options INET6 # IPv6
+options PSEUDOFS # Pseude-filesystem framework
+options FFS # Berkeley Fast Filesystem
+#options SOFTUPDATES # Enable FFS soft updates support
+#options UFS_ACL # Support for access control lists
+#options UFS_DIRHASH # Improve big directory performance
+#options MSDOSFS # Enable support for MSDOS filesystems
+options _KPOSIX_PRIORITY_SCHEDULING # Posix P1003_1B real-time ext.
+
+#
+# Standard drivers section
+#
+# The drivers in the following section are required in order to successfully
+# compile the kernel.
+#
+
+# FDT clock and pinctrl framework
+device fdt_clock
+device fdt_pinctrl
+
+# UART support
+device uart
+
+# random support
+device random
+
+# loop device support
+device loop
+
+# ether device support
+device ether
diff --git a/sys/mips/conf/MT7620A_FDT b/sys/mips/conf/MT7620A_FDT
new file mode 100644
index 0000000..8468304
--- /dev/null
+++ b/sys/mips/conf/MT7620A_FDT
@@ -0,0 +1,30 @@
+#
+# MT7620A_FDT -- Kernel configuration file for FreeBSD/MIPS MT7620A SoC
+#
+# This includes all the configurable parts of the kernel. Please read through
+# MEDIATEK kernel config and customize the options to fit your board if needed.
+#
+# $FreeBSD$
+#
+
+#NO_UNIVERSE
+
+#
+# FDT_DTS_FILE should be modified to suit the target board type.
+#
+#makeoptions FDT_DTS_FILE=MT7620a.dts
+
+#
+# The user should never have to edit what's below this line.
+# If customizations are needed, they should be done to the MEDIATEK kernel
+# configuration.
+#
+
+# Start with a base configuration
+include MEDIATEK_BASE
+
+ident MT7620A
+cpu CPU_MIPS24K
+
+# Include optional configuration (to be edited by the user if needed)
+include MEDIATEK
diff --git a/sys/mips/conf/MT7620N_FDT b/sys/mips/conf/MT7620N_FDT
new file mode 100644
index 0000000..64222df
--- /dev/null
+++ b/sys/mips/conf/MT7620N_FDT
@@ -0,0 +1,30 @@
+#
+# MT7620N_FDT -- Kernel configuration file for FreeBSD/MIPS MT7620N SoC
+#
+# This includes all the configurable parts of the kernel. Please read through
+# MEDIATEK kernel config and customize the options to fit your board if needed.
+#
+# $FreeBSD$
+#
+
+#NO_UNIVERSE
+
+#
+# FDT_DTS_FILE should be modified to suit the target board type.
+#
+#makeoptions FDT_DTS_FILE=WRTNODE.dts
+
+#
+# The user should never have to edit what's below this line.
+# If customizations are needed, they should be done to the MEDIATEK kernel
+# configuration.
+#
+
+# Start with a base configuration
+include MEDIATEK_BASE
+
+ident MT7620N
+cpu CPU_MIPS24K
+
+# Include optional configuration (to be edited by the user if needed)
+include MEDIATEK
diff --git a/sys/mips/conf/MT7621_FDT b/sys/mips/conf/MT7621_FDT
new file mode 100644
index 0000000..a80c953
--- /dev/null
+++ b/sys/mips/conf/MT7621_FDT
@@ -0,0 +1,30 @@
+#
+# MT7621_FDT -- Kernel configuration file for FreeBSD/MIPS MT7621 SoC
+#
+# This includes all the configurable parts of the kernel. Please read through
+# MEDIATEK kernel config and customize the options to fit your board if needed.
+#
+# $FreeBSD$
+#
+
+#NO_UNIVERSE
+
+#
+# FDT_DTS_FILE should be modified to suit the target board type.
+#
+#makeoptions FDT_DTS_FILE=ZBT-WG2626.dts
+
+#
+# The user should never have to edit what's below this line.
+# If customizations are needed, they should be done to the MEDIATEK kernel
+# configuration.
+#
+
+# Start with a base configuration
+include MEDIATEK_BASE
+
+ident MT7621
+cpu CPU_MIPS1004K
+
+# Include optional configuration (to be edited by the user if needed)
+include MEDIATEK
diff --git a/sys/mips/conf/MT7628_FDT b/sys/mips/conf/MT7628_FDT
new file mode 100644
index 0000000..bbffa65
--- /dev/null
+++ b/sys/mips/conf/MT7628_FDT
@@ -0,0 +1,30 @@
+#
+# MT7628_FDT -- Kernel configuration file for FreeBSD/MIPS MT7628/MT7688 SoCs
+#
+# This includes all the configurable parts of the kernel. Please read through
+# MEDIATEK kernel config and customize the options to fit your board if needed.
+#
+# $FreeBSD$
+#
+
+#NO_UNIVERSE
+
+#
+# FDT_DTS_FILE should be modified to suit the target board type.
+#
+#makeoptions FDT_DTS_FILE=MT7628.dts
+
+#
+# The user should never have to edit what's below this line.
+# If customizations are needed, they should be done to the MEDIATEK kernel
+# configuration.
+#
+
+# Start with a base configuration
+include MEDIATEK_BASE
+
+ident MT7628
+cpu CPU_MIPS24K
+
+# Include optional configuration (to be edited by the user if needed)
+include MEDIATEK
diff --git a/sys/mips/conf/RT3050_FDT b/sys/mips/conf/RT3050_FDT
new file mode 100644
index 0000000..435020f
--- /dev/null
+++ b/sys/mips/conf/RT3050_FDT
@@ -0,0 +1,31 @@
+#
+# RT3050_FDT -- Kernel configuration file for FreeBSD/MIPS RT3050/RT3052/RT3350
+# SoCs
+#
+# This includes all the configurable parts of the kernel. Please read through
+# MEDIATEK kernel config and customize the options to fit your board if needed.
+#
+# $FreeBSD$
+#
+
+#NO_UNIVERSE
+
+#
+# FDT_DTS_FILE should be modified to suit the target board type.
+#
+#makeoptions FDT_DTS_FILE=DIR-600-B1.dts
+
+#
+# The user should never have to edit what's below this line.
+# If customizations are needed, they should be done to the MEDIATEK kernel
+# configuration.
+#
+
+# Start with a base configuration
+include MEDIATEK_BASE
+
+ident RT3050
+cpu CPU_MIPS24K
+
+# Include optional configuration (to be edited by the user if needed)
+include MEDIATEK
diff --git a/sys/mips/conf/RT3352_FDT b/sys/mips/conf/RT3352_FDT
new file mode 100644
index 0000000..ec33b9c
--- /dev/null
+++ b/sys/mips/conf/RT3352_FDT
@@ -0,0 +1,30 @@
+#
+# RT3352_FDT -- Kernel configuration file for FreeBSD/MIPS RT3352 SoC
+#
+# This includes all the configurable parts of the kernel. Please read through
+# MEDIATEK kernel config and customize the options to fit your board if needed.
+#
+# $FreeBSD$
+#
+
+#NO_UNIVERSE
+
+#
+# FDT_DTS_FILE should be modified to suit the target board type.
+#
+#makeoptions FDT_DTS_FILE=DIR-615-H1.dts
+
+#
+# The user should never have to edit what's below this line.
+# If customizations are needed, they should be done to the MEDIATEK kernel
+# configuration.
+#
+
+# Start with a base configuration
+include MEDIATEK_BASE
+
+ident RT3352
+cpu CPU_MIPS24K
+
+# Include optional configuration (to be edited by the user if needed)
+include MEDIATEK
diff --git a/sys/mips/conf/RT3883_FDT b/sys/mips/conf/RT3883_FDT
new file mode 100644
index 0000000..6229e2c
--- /dev/null
+++ b/sys/mips/conf/RT3883_FDT
@@ -0,0 +1,30 @@
+#
+# RT3883_FDT -- Kernel configuration file for FreeBSD/MIPS RT3662/RT3883 SoCs
+#
+# This includes all the configurable parts of the kernel. Please read through
+# MEDIATEK kernel config and customize the options to fit your board if needed.
+#
+# $FreeBSD$
+#
+
+#NO_UNIVERSE
+
+#
+# FDT_DTS_FILE should be modified to suit the target board type.
+#
+#makeoptions FDT_DTS_FILE=DIR-645.dts
+
+#
+# The user should never have to edit what's below this line.
+# If customizations are needed, they should be done to the MEDIATEK kernel
+# configuration.
+#
+
+# Start with a base configuration
+include MEDIATEK_BASE
+
+ident RT3883
+cpu CPU_MIPS74K
+
+# Include optional configuration (to be edited by the user if needed)
+include MEDIATEK
diff --git a/sys/mips/conf/RT5350_FDT b/sys/mips/conf/RT5350_FDT
new file mode 100644
index 0000000..827bdd3
--- /dev/null
+++ b/sys/mips/conf/RT5350_FDT
@@ -0,0 +1,30 @@
+#
+# RT5350_FDT -- Kernel configuration file for FreeBSD/MIPS RT5350 SoC
+#
+# This includes all the configurable parts of the kernel. Please read through
+# MEDIATEK kernel config and customize the options to fit your board if needed.
+#
+# $FreeBSD$
+#
+
+#NO_UNIVERSE
+
+#
+# FDT_DTS_FILE should be modified to suit the target board type.
+#
+#makeoptions FDT_DTS_FILE=DIR-300-B7.dts
+
+#
+# The user should never have to edit what's below this line.
+# If customizations are needed, they should be done to the MEDIATEK kernel
+# configuration.
+#
+
+# Start with a base configuration
+include MEDIATEK_BASE
+
+ident RT5350
+cpu CPU_MIPS24K
+
+# Include optional configuration (to be edited by the user if needed)
+include MEDIATEK
diff --git a/sys/mips/idt/obio.c b/sys/mips/idt/obio.c
index b95b11a..f151a79 100644
--- a/sys/mips/idt/obio.c
+++ b/sys/mips/idt/obio.c
@@ -204,7 +204,7 @@ obio_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0) {
+ if (rv == NULL) {
printf("%s: could not reserve resource\n", __func__);
return (0);
}
diff --git a/sys/mips/include/intr.h b/sys/mips/include/intr.h
index 28f798f..6e00643 100644
--- a/sys/mips/include/intr.h
+++ b/sys/mips/include/intr.h
@@ -39,7 +39,7 @@
#ifndef _MACHINE_INTR_H_
#define _MACHINE_INTR_H_
-#ifdef MIPS_INTRNG
+#ifdef INTRNG
#ifdef FDT
#include <dev/ofw/openfirm.h>
@@ -47,8 +47,12 @@
#include <sys/intr.h>
-#ifndef NIRQ
-#define NIRQ 128
+#ifndef MIPS_NIRQ
+#define MIPS_NIRQ 128
+#endif
+
+#ifndef NIRQ
+#define NIRQ MIPS_NIRQ
#endif
#define INTR_IRQ_NSPC_SWI 4
@@ -62,6 +66,6 @@ void cpu_establish_softintr(const char *, driver_filter_t *, void (*)(void*),
/* MIPS interrupt C entry point */
void cpu_intr(struct trapframe *);
-#endif /* MIPS_INTRNG */
+#endif /* INTRNG */
#endif /* _MACHINE_INTR_H */
diff --git a/sys/mips/include/smp.h b/sys/mips/include/smp.h
index fa4cb5c..d7a33de 100644
--- a/sys/mips/include/smp.h
+++ b/sys/mips/include/smp.h
@@ -21,7 +21,7 @@
#include <machine/pcb.h>
-#ifdef MIPS_INTRNG
+#ifdef INTRNG
# define MIPS_IPI_COUNT 1
# define INTR_IPI_COUNT MIPS_IPI_COUNT
#endif
diff --git a/sys/mips/mediatek/mtk_ehci.c b/sys/mips/mediatek/mtk_ehci.c
index 109a32a..acc30eb 100644
--- a/sys/mips/mediatek/mtk_ehci.c
+++ b/sys/mips/mediatek/mtk_ehci.c
@@ -78,7 +78,7 @@ ehci_fdt_probe(device_t self)
if (!ofw_bus_status_okay(self))
return (ENXIO);
- if (!ofw_bus_is_compatible(self, "ralink,rt3xxx-ehci"))
+ if (!ofw_bus_is_compatible(self, "generic-ehci"))
return (ENXIO);
device_set_desc(self, EHCI_HC_DEVSTR);
diff --git a/sys/mips/mediatek/mtk_gpio_v1.c b/sys/mips/mediatek/mtk_gpio_v1.c
index 29b2258..ad3a0fc 100644
--- a/sys/mips/mediatek/mtk_gpio_v1.c
+++ b/sys/mips/mediatek/mtk_gpio_v1.c
@@ -281,8 +281,8 @@ mtk_gpio_attach(device_t dev)
sc->do_remap = 0;
}
- if (OF_hasprop(node, "mtk,num-pins") && (OF_getencprop(node,
- "mtk,num-pins", &num_pins, sizeof(num_pins)) >= 0))
+ if (OF_hasprop(node, "ralink,num-gpios") && (OF_getencprop(node,
+ "ralink,num-gpios", &num_pins, sizeof(num_pins)) >= 0))
sc->num_pins = num_pins;
else
sc->num_pins = MTK_GPIO_PINS;
diff --git a/sys/mips/mediatek/mtk_gpio_v2.c b/sys/mips/mediatek/mtk_gpio_v2.c
index 282b112..c7c0326 100644
--- a/sys/mips/mediatek/mtk_gpio_v2.c
+++ b/sys/mips/mediatek/mtk_gpio_v2.c
@@ -121,8 +121,8 @@ static int mtk_gpio_intr(void *arg);
#define GPIO_PIORESET(_sc) GPIO_REG((_sc), 0x0040)
static struct ofw_compat_data compat_data[] = {
- { "mtk,mt7621-gpio", 1 },
- { "mtk,mt7628-gpio", 1 },
+ { "mtk,mt7621-gpio-bank", 1 },
+ { "mtk,mt7628-gpio-bank", 1 },
{ NULL, 0 }
};
@@ -281,7 +281,7 @@ mtk_gpio_attach(device_t dev)
else
sc->num_pins = MTK_GPIO_PINS;
- for (i = 0; i < num_pins; i++) {
+ for (i = 0; i < sc->num_pins; i++) {
sc->pins[i].pin_caps |= GPIO_PIN_INPUT | GPIO_PIN_OUTPUT |
GPIO_PIN_INVIN | GPIO_PIN_INVOUT;
sc->pins[i].intr_polarity = INTR_POLARITY_HIGH;
diff --git a/sys/mips/mediatek/mtk_intr_gic.c b/sys/mips/mediatek/mtk_intr_gic.c
index 3eb6ffc..ab96cac 100644
--- a/sys/mips/mediatek/mtk_intr_gic.c
+++ b/sys/mips/mediatek/mtk_intr_gic.c
@@ -281,10 +281,10 @@ mtk_gic_map_intr(device_t dev, struct intr_map_data *data,
sc = device_get_softc(dev);
if (data == NULL || data->type != INTR_MAP_DATA_FDT ||
- data->fdt.ncells != 1 || data->fdt.cells[0] >= sc->nirqs)
+ data->fdt.ncells != 3 || data->fdt.cells[1] >= sc->nirqs)
return (EINVAL);
- *isrcp = GIC_INTR_ISRC(sc, data->fdt.cells[0]);
+ *isrcp = GIC_INTR_ISRC(sc, data->fdt.cells[1]);
return (0);
#else
return (EINVAL);
diff --git a/sys/mips/mediatek/mtk_ohci.c b/sys/mips/mediatek/mtk_ohci.c
index 91c98ce..0b554e7 100644
--- a/sys/mips/mediatek/mtk_ohci.c
+++ b/sys/mips/mediatek/mtk_ohci.c
@@ -78,7 +78,7 @@ ohci_fdt_probe(device_t self)
if (!ofw_bus_status_okay(self))
return (ENXIO);
- if (!ofw_bus_is_compatible(self, "ralink,rt3xxx-ohci"))
+ if (!ofw_bus_is_compatible(self, "generic-ohci"))
return (ENXIO);
device_set_desc(self, OHCI_HC_DEVSTR);
diff --git a/sys/mips/mediatek/mtk_pcie.c b/sys/mips/mediatek/mtk_pcie.c
index e88b9ab..66d8add 100644
--- a/sys/mips/mediatek/mtk_pcie.c
+++ b/sys/mips/mediatek/mtk_pcie.c
@@ -99,7 +99,7 @@ struct mtk_pci_range {
u_long len;
};
-#define FDT_RANGES_CELLS (3 * 2)
+#define FDT_RANGES_CELLS ((1 + 2 + 3) * 2)
static void
mtk_pci_range_dump(struct mtk_pci_range *range)
@@ -117,30 +117,33 @@ mtk_pci_ranges_decode(phandle_t node, struct mtk_pci_range *io_space,
{
struct mtk_pci_range *pci_space;
pcell_t ranges[FDT_RANGES_CELLS];
+ pcell_t addr_cells, size_cells, par_addr_cells;
pcell_t *rangesptr;
pcell_t cell0, cell1, cell2;
- int tuples, i, rv, len;
+ int tuple_size, tuples, i, rv, len;
/*
* Retrieve 'ranges' property.
*/
- if (!OF_hasprop(node, "ranges")) {
- printf("%s: %d\n", __FUNCTION__, 1);
+ if ((fdt_addrsize_cells(node, &addr_cells, &size_cells)) != 0)
return (EINVAL);
- }
+ if (addr_cells != 3 || size_cells != 2)
+ return (ERANGE);
+
+ par_addr_cells = fdt_parent_addr_cells(node);
+ if (par_addr_cells != 1)
+ return (ERANGE);
len = OF_getproplen(node, "ranges");
- if (len > sizeof(ranges)) {
- printf("%s: %d\n", __FUNCTION__, 2);
+ if (len > sizeof(ranges))
return (ENOMEM);
- }
- if (OF_getprop(node, "ranges", ranges, sizeof(ranges)) <= 0) {
- printf("%s: %d\n", __FUNCTION__, 3);
+ if (OF_getprop(node, "ranges", ranges, sizeof(ranges)) <= 0)
return (EINVAL);
- }
- tuples = len / (sizeof(pcell_t) * 3);
+ tuple_size = sizeof(pcell_t) * (addr_cells + par_addr_cells +
+ size_cells);
+ tuples = len / tuple_size;
/*
* Initialize the ranges so that we don't have to worry about
@@ -159,18 +162,21 @@ mtk_pci_ranges_decode(phandle_t node, struct mtk_pci_range *io_space,
cell2 = fdt_data_get((void *)rangesptr, 1);
rangesptr++;
- if (cell0 == 2) {
+ if (cell0 & 0x02000000) {
pci_space = mem_space;
- } else if (cell0 == 1) {
+ } else if (cell0 & 0x01000000) {
pci_space = io_space;
} else {
rv = ERANGE;
- printf("%s: %d\n", __FUNCTION__, 4);
goto out;
}
- pci_space->base = cell1;
- pci_space->len = cell2;
+ pci_space->base = fdt_data_get((void *)rangesptr,
+ par_addr_cells);
+ rangesptr += par_addr_cells;
+
+ pci_space->len = fdt_data_get((void *)rangesptr, size_cells);
+ rangesptr += size_cells;
}
rv = 0;
@@ -199,6 +205,7 @@ static struct ofw_compat_data compat_data[] = {
{ "ralink,rt3883-pcie", MTK_SOC_RT3883 },
{ "ralink,mt7620a-pcie", MTK_SOC_MT7620A },
{ "ralink,mt7621-pcie", MTK_SOC_MT7621 },
+ { "mediatek,mt7621-pci", MTK_SOC_MT7621 },
{ "ralink,mt7628-pcie", MTK_SOC_MT7628 },
{ "ralink,mt7688-pcie", MTK_SOC_MT7628 },
{ NULL, MTK_SOC_UNKNOWN }
diff --git a/sys/mips/mediatek/mtk_soc.c b/sys/mips/mediatek/mtk_soc.c
index b331467..5784fec 100644
--- a/sys/mips/mediatek/mtk_soc.c
+++ b/sys/mips/mediatek/mtk_soc.c
@@ -63,6 +63,7 @@ static const struct ofw_compat_data compat_data[] = {
{ "ralink,mtk7620a-soc", MTK_SOC_MT7620A },
{ "ralink,mtk7620n-soc", MTK_SOC_MT7620N },
{ "mediatek,mtk7621-soc", MTK_SOC_MT7621 },
+ { "mediatek,mt7621-soc", MTK_SOC_MT7621 },
{ "ralink,mtk7621-soc", MTK_SOC_MT7621 },
{ "ralink,mtk7628an-soc", MTK_SOC_MT7628 },
{ "mediatek,mt7628an-soc", MTK_SOC_MT7628 },
diff --git a/sys/mips/mediatek/mtk_usb_phy.c b/sys/mips/mediatek/mtk_usb_phy.c
index d400720..59b1ffd 100644
--- a/sys/mips/mediatek/mtk_usb_phy.c
+++ b/sys/mips/mediatek/mtk_usb_phy.c
@@ -84,9 +84,10 @@ static void mtk_usb_phy_mt7621_init(device_t);
static void mtk_usb_phy_mt7628_init(device_t);
static struct ofw_compat_data compat_data[] = {
- { "ralink,mt7620a-usbphy", MTK_SOC_MT7620A },
+ { "ralink,mt7620-usbphy", MTK_SOC_MT7620A },
{ "ralink,mt7628an-usbphy", MTK_SOC_MT7628 },
- { "ralink,rt3xxx-usbphy", MTK_SOC_RT3352 },
+ { "ralink,rt3352-usbphy", MTK_SOC_RT3352 },
+ { "ralink,rt3050-usbphy", MTK_SOC_RT3050 },
{ NULL, MTK_SOC_UNKNOWN }
};
diff --git a/sys/mips/mediatek/mtk_xhci.c b/sys/mips/mediatek/mtk_xhci.c
index 0899307..138a4d4 100644
--- a/sys/mips/mediatek/mtk_xhci.c
+++ b/sys/mips/mediatek/mtk_xhci.c
@@ -80,7 +80,7 @@ mtk_xhci_fdt_probe(device_t self)
if (!ofw_bus_status_okay(self))
return (ENXIO);
- if (!ofw_bus_is_compatible(self, "mtk,usb-xhci"))
+ if (!ofw_bus_is_compatible(self, "mediatek,mt8173-xhci"))
return (ENXIO);
device_set_desc(self, XHCI_HC_DEVSTR);
@@ -99,7 +99,6 @@ mtk_xhci_fdt_attach(device_t self)
sc->sc_bus.parent = self;
sc->sc_bus.devices = sc->sc_devices;
sc->sc_bus.devices_max = XHCI_MAX_DEVICES;
- sc->sc_bus.dma_bits = 32;
rid = 0;
sc->sc_io_res = bus_alloc_resource_any(self, SYS_RES_MEMORY, &rid,
diff --git a/sys/mips/mips/exception.S b/sys/mips/mips/exception.S
index ebfd84d..ed02e5a 100644
--- a/sys/mips/mips/exception.S
+++ b/sys/mips/mips/exception.S
@@ -646,7 +646,7 @@ NESTED_NOPROFILE(MipsKernIntr, KERN_EXC_FRAME_SIZE, ra)
* Call the interrupt handler. a0 points at the saved frame.
*/
PTR_LA gp, _C_LABEL(_gp)
-#ifdef MIPS_INTRNG
+#ifdef INTRNG
PTR_LA k0, _C_LABEL(intr_irq_handler)
#else
PTR_LA k0, _C_LABEL(cpu_intr)
@@ -762,7 +762,7 @@ NESTED_NOPROFILE(MipsUserIntr, CALLFRAME_SIZ, ra)
/*
* Call the interrupt handler.
*/
-#ifdef MIPS_INTRNG
+#ifdef INTRNG
PTR_LA k0, _C_LABEL(intr_irq_handler)
#else
PTR_LA k0, _C_LABEL(cpu_intr)
@@ -1198,7 +1198,7 @@ FPReturn:
PTR_ADDU sp, sp, CALLFRAME_SIZ
END(MipsFPTrap)
-#ifndef MIPS_INTRNG
+#ifndef INTRNG
/*
* Interrupt counters for vmstat.
*/
@@ -1225,7 +1225,7 @@ sintrcnt:
#else
.int INTRCNT_COUNT * (_MIPS_SZLONG / 8) * 2
#endif
-#endif /* MIPS_INTRNG */
+#endif /* INTRNG */
/*
diff --git a/sys/mips/mips/machdep.c b/sys/mips/mips/machdep.c
index 5d25d88..3d44cda 100644
--- a/sys/mips/mips/machdep.c
+++ b/sys/mips/mips/machdep.c
@@ -316,7 +316,7 @@ cpu_initclocks(void)
cpu_initclocks_bsp();
}
-struct msgbuf *msgbufp=0;
+struct msgbuf *msgbufp = NULL;
/*
* Initialize the hardware exception vectors, and the jump table used to
diff --git a/sys/mips/mips/nexus.c b/sys/mips/mips/nexus.c
index a2a8e527..45e47ef 100644
--- a/sys/mips/mips/nexus.c
+++ b/sys/mips/mips/nexus.c
@@ -57,7 +57,7 @@ __FBSDID("$FreeBSD$");
#include <machine/resource.h>
#include <machine/vmparam.h>
-#ifdef MIPS_INTRNG
+#ifdef INTRNG
#include <machine/intr.h>
#else
#include <machine/intr_machdep.h>
@@ -115,7 +115,7 @@ static int nexus_setup_intr(device_t dev, device_t child,
driver_intr_t *intr, void *arg, void **cookiep);
static int nexus_teardown_intr(device_t, device_t, struct resource *,
void *);
-#ifdef MIPS_INTRNG
+#ifdef INTRNG
#ifdef SMP
static int nexus_bind_intr(device_t, device_t, struct resource *, int);
#endif
@@ -148,7 +148,7 @@ static device_method_t nexus_methods[] = {
DEVMETHOD(bus_activate_resource,nexus_activate_resource),
DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
DEVMETHOD(bus_hinted_child, nexus_hinted_child),
-#ifdef MIPS_INTRNG
+#ifdef INTRNG
DEVMETHOD(bus_config_intr, nexus_config_intr),
DEVMETHOD(bus_describe_intr, nexus_describe_intr),
#ifdef SMP
@@ -315,7 +315,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0) {
+ if (rv == NULL) {
printf("%s: could not reserve resource for %s\n", __func__,
device_get_nameunit(child));
return (0);
@@ -458,7 +458,7 @@ nexus_setup_intr(device_t dev, device_t child, struct resource *res, int flags,
driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep)
{
-#ifdef MIPS_INTRNG
+#ifdef INTRNG
return (intr_setup_irq(child, res, filt, intr, arg, flags, cookiep));
#else
int irq;
@@ -483,7 +483,7 @@ static int
nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih)
{
-#ifdef MIPS_INTRNG
+#ifdef INTRNG
return (intr_teardown_irq(child, r, ih));
#else
printf("Unimplemented %s at %s:%d\n", __func__, __FILE__, __LINE__);
@@ -491,7 +491,7 @@ nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih)
#endif
}
-#ifdef MIPS_INTRNG
+#ifdef INTRNG
static int
nexus_config_intr(device_t dev, int irq, enum intr_trigger trig,
enum intr_polarity pol)
@@ -527,7 +527,7 @@ nexus_ofw_map_intr(device_t dev, device_t child, phandle_t iparent, int icells,
return (intr_fdt_map_irq(iparent, intr, icells));
}
#endif
-#endif /* MIPS_INTRNG */
+#endif /* INTRNG */
static void
nexus_hinted_child(device_t bus, const char *dname, int dunit)
diff --git a/sys/mips/mips/tick.c b/sys/mips/mips/tick.c
index b146ad7..8bcc534 100644
--- a/sys/mips/mips/tick.c
+++ b/sys/mips/mips/tick.c
@@ -51,7 +51,7 @@ __FBSDID("$FreeBSD$");
#include <machine/locore.h>
#include <machine/md_var.h>
-#ifdef MIPS_INTRNG
+#ifdef INTRNG
#include <machine/intr.h>
#endif
@@ -328,7 +328,7 @@ static int
clock_attach(device_t dev)
{
struct clock_softc *sc;
-#ifndef MIPS_INTRNG
+#ifndef INTRNG
int error;
#endif
@@ -336,7 +336,7 @@ clock_attach(device_t dev)
panic("can't attach more clocks");
softc = sc = device_get_softc(dev);
-#ifdef MIPS_INTRNG
+#ifdef INTRNG
cpu_establish_hardintr("clock", clock_intr, NULL, sc, 5, INTR_TYPE_CLK,
NULL);
#else
diff --git a/sys/mips/nlm/xlp_pci.c b/sys/mips/nlm/xlp_pci.c
index 863c6aa..9e91146 100644
--- a/sys/mips/nlm/xlp_pci.c
+++ b/sys/mips/nlm/xlp_pci.c
@@ -125,8 +125,8 @@ xlp_pci_attach(device_t dev)
XLP_PCI_DEVSCRATCH_REG0 << 2,
(1 << 8) | irq, 4);
}
- dinfo = pci_read_device(pcib, pcib_get_domain(dev),
- busno, s, f, sizeof(*dinfo));
+ dinfo = pci_read_device(pcib, dev, pcib_get_domain(dev),
+ busno, s, f);
pci_add_child(dev, dinfo);
}
}
diff --git a/sys/mips/nlm/xlp_simplebus.c b/sys/mips/nlm/xlp_simplebus.c
index 413775b..eb42a86 100644
--- a/sys/mips/nlm/xlp_simplebus.c
+++ b/sys/mips/nlm/xlp_simplebus.c
@@ -244,7 +244,7 @@ xlp_simplebus_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0) {
+ if (rv == NULL) {
device_printf(bus, "%s: could not reserve resource for %s\n",
__func__, device_get_nameunit(child));
return (NULL);
diff --git a/sys/mips/rmi/xlr_pci.c b/sys/mips/rmi/xlr_pci.c
index 53581a6..3d98503 100644
--- a/sys/mips/rmi/xlr_pci.c
+++ b/sys/mips/rmi/xlr_pci.c
@@ -537,7 +537,7 @@ xlr_pci_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0)
+ if (rv == NULL)
return (0);
rman_set_rid(rv, *rid);
diff --git a/sys/mips/rt305x/obio.c b/sys/mips/rt305x/obio.c
index ac27230..fc8a4ac 100644
--- a/sys/mips/rt305x/obio.c
+++ b/sys/mips/rt305x/obio.c
@@ -326,7 +326,7 @@ obio_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0) {
+ if (rv == NULL) {
printf("%s: could not reserve resource\n", __func__);
return (0);
}
diff --git a/sys/mips/rt305x/rt305x_gpio.c b/sys/mips/rt305x/rt305x_gpio.c
index e4f645f..56b734a 100644
--- a/sys/mips/rt305x/rt305x_gpio.c
+++ b/sys/mips/rt305x/rt305x_gpio.c
@@ -562,7 +562,7 @@ rt305x_gpio_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0) {
+ if (rv == NULL) {
printf("%s: could not reserve resource\n", __func__);
return (0);
}
diff --git a/sys/modules/cam/Makefile b/sys/modules/cam/Makefile
index 19bd9ec..603f055 100644
--- a/sys/modules/cam/Makefile
+++ b/sys/modules/cam/Makefile
@@ -21,7 +21,7 @@ SRCS+= cam_compat.c
.if exists($S/${MACHINE}/${MACHINE}/cam_machdep.c)
SRCS+= cam_machdep.c
.endif
-SRCS+= cam_periph.c cam_queue.c cam_sim.c cam_xpt.c
+SRCS+= cam_iosched.c cam_periph.c cam_queue.c cam_sim.c cam_xpt.c
SRCS+= scsi_all.c scsi_cd.c scsi_ch.c
SRCS+= scsi_da.c
SRCS+= scsi_pass.c
diff --git a/sys/modules/hyperv/vmbus/Makefile b/sys/modules/hyperv/vmbus/Makefile
index 637157b..8187146 100644
--- a/sys/modules/hyperv/vmbus/Makefile
+++ b/sys/modules/hyperv/vmbus/Makefile
@@ -1,7 +1,7 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../../dev/hyperv/vmbus \
- ${.CURDIR}/../../../dev/hyperv/utilities
+ ${.CURDIR}/../../../dev/hyperv/vmbus/${MACHINE_CPUARCH}
KMOD= hv_vmbus
SRCS= hv_channel.c \
@@ -14,8 +14,17 @@ SRCS= hv_channel.c \
hv_vmbus_priv.h
SRCS+= acpi_if.h bus_if.h device_if.h opt_acpi.h
+# XXX: for assym.s
+SRCS+= opt_kstack_pages.h opt_nfs.h opt_apic.h opt_hwpmc_hooks.h opt_compat.h
+
+SRCS+= assym.s \
+ hv_vector.S
+
+hv_vector.o:
+ ${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \
+ ${.IMPSRC} -o ${.TARGET}
+
CFLAGS+= -I${.CURDIR}/../../../dev/hyperv/include \
- -I${.CURDIR}/../../../dev/hyperv/vmbus \
- -I${.CURDIR}/../../../dev/hyperv/utilities
+ -I${.CURDIR}/../../../dev/hyperv/vmbus
.include <bsd.kmod.mk>
diff --git a/sys/modules/ipfw/Makefile b/sys/modules/ipfw/Makefile
index a0045f3..f25762d 100644
--- a/sys/modules/ipfw/Makefile
+++ b/sys/modules/ipfw/Makefile
@@ -4,7 +4,7 @@
KMOD= ipfw
SRCS= ip_fw2.c ip_fw_pfil.c
-SRCS+= ip_fw_dynamic.c ip_fw_log.c
+SRCS+= ip_fw_dynamic.c ip_fw_log.c ip_fw_eaction.c
SRCS+= ip_fw_sockopt.c ip_fw_table.c ip_fw_table_algo.c ip_fw_iface.c
SRCS+= ip_fw_table_value.c
SRCS+= opt_inet.h opt_inet6.h opt_ipdivert.h opt_ipfw.h opt_ipsec.h
diff --git a/sys/net/bpf_filter.c b/sys/net/bpf_filter.c
index 40498a9..ab3198a 100644
--- a/sys/net/bpf_filter.c
+++ b/sys/net/bpf_filter.c
@@ -99,7 +99,7 @@ m_xword(struct mbuf *m, bpf_u_int32 k, int *err)
while (k >= len) {
k -= len;
m = m->m_next;
- if (m == 0)
+ if (m == NULL)
goto bad;
len = m->m_len;
}
@@ -109,7 +109,7 @@ m_xword(struct mbuf *m, bpf_u_int32 k, int *err)
return (EXTRACT_LONG(cp));
}
m0 = m->m_next;
- if (m0 == 0 || m0->m_len + len - k < 4)
+ if (m0 == NULL || m0->m_len + len - k < 4)
goto bad;
*err = 0;
np = mtod(m0, u_char *);
@@ -148,7 +148,7 @@ m_xhalf(struct mbuf *m, bpf_u_int32 k, int *err)
while (k >= len) {
k -= len;
m = m->m_next;
- if (m == 0)
+ if (m == NULL)
goto bad;
len = m->m_len;
}
@@ -158,7 +158,7 @@ m_xhalf(struct mbuf *m, bpf_u_int32 k, int *err)
return (EXTRACT_SHORT(cp));
}
m0 = m->m_next;
- if (m0 == 0)
+ if (m0 == NULL)
goto bad;
*err = 0;
return ((cp[0] << 8) | mtod(m0, u_char *)[0]);
diff --git a/sys/net/if.c b/sys/net/if.c
index 2c44c87..1a11093 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1948,8 +1948,8 @@ link_rtrequest(int cmd, struct rtentry *rt, struct rt_addrinfo *info)
struct sockaddr *dst;
struct ifnet *ifp;
- if (cmd != RTM_ADD || ((ifa = rt->rt_ifa) == 0) ||
- ((ifp = ifa->ifa_ifp) == 0) || ((dst = rt_key(rt)) == 0))
+ if (cmd != RTM_ADD || ((ifa = rt->rt_ifa) == NULL) ||
+ ((ifp = ifa->ifa_ifp) == NULL) || ((dst = rt_key(rt)) == NULL))
return;
ifa = ifaof_ifpforaddr(dst, ifp);
if (ifa) {
@@ -2139,7 +2139,7 @@ if_qflush(struct ifnet *ifp)
ALTQ_PURGE(ifq);
#endif
n = ifq->ifq_head;
- while ((m = n) != 0) {
+ while ((m = n) != NULL) {
n = m->m_nextpkt;
m_freem(m);
}
diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c
index 16adba4..14026b4 100644
--- a/sys/net/if_arcsubr.c
+++ b/sys/net/if_arcsubr.c
@@ -210,7 +210,7 @@ arc_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
isphds = arc_isphds(atype);
M_PREPEND(m, isphds ? ARC_HDRNEWLEN : ARC_HDRLEN, M_NOWAIT);
- if (m == 0)
+ if (m == NULL)
senderr(ENOBUFS);
ah = mtod(m, struct arc_header *);
ah->arc_type = atype;
@@ -261,12 +261,12 @@ arc_frag_next(struct ifnet *ifp)
struct arc_header *ah;
ac = (struct arccom *)ifp->if_l2com;
- if ((m = ac->curr_frag) == 0) {
+ if ((m = ac->curr_frag) == NULL) {
int tfrags;
/* dequeue new packet */
IF_DEQUEUE(&ifp->if_snd, m);
- if (m == 0)
+ if (m == NULL)
return 0;
ah = mtod(m, struct arc_header *);
@@ -296,7 +296,7 @@ arc_frag_next(struct ifnet *ifp)
}
M_PREPEND(m, ARC_HDRNEWLEN, M_NOWAIT);
- if (m == 0) {
+ if (m == NULL) {
m_freem(ac->curr_frag);
ac->curr_frag = 0;
return 0;
@@ -315,7 +315,7 @@ arc_frag_next(struct ifnet *ifp)
ac->curr_frag = 0;
M_PREPEND(m, ARC_HDRNEWLEN_EXC, M_NOWAIT);
- if (m == 0)
+ if (m == NULL)
return 0;
ah = mtod(m, struct arc_header *);
@@ -328,7 +328,7 @@ arc_frag_next(struct ifnet *ifp)
ac->curr_frag = 0;
M_PREPEND(m, ARC_HDRNEWLEN, M_NOWAIT);
- if (m == 0)
+ if (m == NULL)
return 0;
ah = mtod(m, struct arc_header *);
@@ -740,7 +740,7 @@ arc_resolvemulti(struct ifnet *ifp, struct sockaddr **llsa,
sdl = (struct sockaddr_dl *)sa;
if (*LLADDR(sdl) != arcbroadcastaddr)
return EADDRNOTAVAIL;
- *llsa = 0;
+ *llsa = NULL;
return 0;
#ifdef INET
case AF_INET:
@@ -763,7 +763,7 @@ arc_resolvemulti(struct ifnet *ifp, struct sockaddr **llsa,
* (This is used for multicast routers.)
*/
ifp->if_flags |= IFF_ALLMULTI;
- *llsa = 0;
+ *llsa = NULL;
return 0;
}
if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c
index e1c4a67..2d38b8a 100644
--- a/sys/net/if_atmsubr.c
+++ b/sys/net/if_atmsubr.c
@@ -192,7 +192,7 @@ atm_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst,
if (atm_flags & ATM_PH_LLCSNAP)
sz += 8; /* sizeof snap == 8 */
M_PREPEND(m, sz, M_NOWAIT);
- if (m == 0)
+ if (m == NULL)
senderr(ENOBUFS);
ad = mtod(m, struct atm_pseudohdr *);
*ad = atmdst;
@@ -295,7 +295,7 @@ atm_input(struct ifnet *ifp, struct atm_pseudohdr *ah, struct mbuf *m,
struct atmllc *alc;
if (m->m_len < sizeof(*alc) &&
- (m = m_pullup(m, sizeof(*alc))) == 0)
+ (m = m_pullup(m, sizeof(*alc))) == NULL)
return; /* failed */
alc = mtod(m, struct atmllc *);
if (bcmp(alc, ATMLLC_HDR, 6)) {
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index c6bcfdf..6b03711 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -3248,7 +3248,7 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir)
if (hlen < sizeof(struct ip))
goto bad;
if (hlen > (*mp)->m_len) {
- if ((*mp = m_pullup(*mp, hlen)) == 0)
+ if ((*mp = m_pullup(*mp, hlen)) == NULL)
goto bad;
ip = mtod(*mp, struct ip *);
if (ip == NULL)
@@ -3366,7 +3366,7 @@ bridge_ip_checkbasic(struct mbuf **mp)
goto bad;
}
if (hlen > m->m_len) {
- if ((m = m_pullup(m, hlen)) == 0) {
+ if ((m = m_pullup(m, hlen)) == NULL) {
KMOD_IPSTAT_INC(ips_badhlen);
goto bad;
}
diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c
index b6e1d20..d7ea59e 100644
--- a/sys/net/if_disc.c
+++ b/sys/net/if_disc.c
@@ -216,7 +216,7 @@ discioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
case SIOCADDMULTI:
case SIOCDELMULTI:
- if (ifr == 0) {
+ if (ifr == NULL) {
error = EAFNOSUPPORT; /* XXX */
break;
}
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index 2d652ad..8698647 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -1075,7 +1075,7 @@ ether_resolvemulti(struct ifnet *ifp, struct sockaddr **llsa,
e_addr = LLADDR(sdl);
if (!ETHER_IS_MULTICAST(e_addr))
return EADDRNOTAVAIL;
- *llsa = 0;
+ *llsa = NULL;
return 0;
#ifdef INET
@@ -1100,7 +1100,7 @@ ether_resolvemulti(struct ifnet *ifp, struct sockaddr **llsa,
* (This is used for multicast routers.)
*/
ifp->if_flags |= IFF_ALLMULTI;
- *llsa = 0;
+ *llsa = NULL;
return 0;
}
if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c
index 84ee669..1ebd4da 100644
--- a/sys/net/if_fddisubr.c
+++ b/sys/net/if_fddisubr.c
@@ -235,7 +235,7 @@ fddi_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
if (type != 0) {
struct llc *l;
M_PREPEND(m, LLC_SNAPFRAMELEN, M_NOWAIT);
- if (m == 0)
+ if (m == NULL)
senderr(ENOBUFS);
l = mtod(m, struct llc *);
l->llc_control = LLC_UI;
@@ -251,7 +251,7 @@ fddi_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
* allocate another.
*/
M_PREPEND(m, FDDI_HDR_LEN, M_NOWAIT);
- if (m == 0)
+ if (m == NULL)
senderr(ENOBUFS);
fh = mtod(m, struct fddi_header *);
fh->fddi_fc = FDDIFC_LLC_ASYNC|FDDIFC_LLC_PRIO4;
@@ -607,7 +607,7 @@ fddi_resolvemulti(ifp, llsa, sa)
e_addr = LLADDR(sdl);
if ((e_addr[0] & 1) != 1)
return (EADDRNOTAVAIL);
- *llsa = 0;
+ *llsa = NULL;
return (0);
#ifdef INET
@@ -634,7 +634,7 @@ fddi_resolvemulti(ifp, llsa, sa)
* (This is used for multicast routers.)
*/
ifp->if_flags |= IFF_ALLMULTI;
- *llsa = 0;
+ *llsa = NULL;
return (0);
}
if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
diff --git a/sys/net/if_fwsubr.c b/sys/net/if_fwsubr.c
index a070f61..c2253d4 100644
--- a/sys/net/if_fwsubr.c
+++ b/sys/net/if_fwsubr.c
@@ -132,7 +132,7 @@ firewire_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
}
destfw = (struct fw_hwaddr *)(mtag + 1);
} else {
- destfw = 0;
+ destfw = NULL;
}
switch (dst->sa_family) {
@@ -269,7 +269,7 @@ firewire_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
mtail = m_split(m, fsize, M_NOWAIT);
m_tag_copy_chain(mtail, m, M_NOWAIT);
} else {
- mtail = 0;
+ mtail = NULL;
}
/*
@@ -701,7 +701,7 @@ firewire_resolvemulti(struct ifnet *ifp, struct sockaddr **llsa,
/*
* No mapping needed.
*/
- *llsa = 0;
+ *llsa = NULL;
return 0;
#ifdef INET
@@ -709,7 +709,7 @@ firewire_resolvemulti(struct ifnet *ifp, struct sockaddr **llsa,
sin = (struct sockaddr_in *)sa;
if (!IN_MULTICAST(ntohl(sin->sin_addr.s_addr)))
return EADDRNOTAVAIL;
- *llsa = 0;
+ *llsa = NULL;
return 0;
#endif
#ifdef INET6
@@ -722,12 +722,12 @@ firewire_resolvemulti(struct ifnet *ifp, struct sockaddr **llsa,
* (This is used for multicast routers.)
*/
ifp->if_flags |= IFF_ALLMULTI;
- *llsa = 0;
+ *llsa = NULL;
return 0;
}
if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
return EADDRNOTAVAIL;
- *llsa = 0;
+ *llsa = NULL;
return 0;
#endif
diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c
index 466784f..a96e2b9 100644
--- a/sys/net/if_iso88025subr.c
+++ b/sys/net/if_iso88025subr.c
@@ -328,7 +328,7 @@ iso88025_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
if (snap_type != 0) {
struct llc *l;
M_PREPEND(m, LLC_SNAPFRAMELEN, M_NOWAIT);
- if (m == 0)
+ if (m == NULL)
senderr(ENOBUFS);
l = mtod(m, struct llc *);
l->llc_control = LLC_UI;
@@ -344,7 +344,7 @@ iso88025_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
* allocate another.
*/
M_PREPEND(m, ISO88025_HDR_LEN + rif_len, M_NOWAIT);
- if (m == 0)
+ if (m == NULL)
senderr(ENOBUFS);
th = mtod(m, struct iso88025_header *);
bcopy((caddr_t)edst, (caddr_t)&gen_th.iso88025_dhost, ISO88025_ADDR_LEN);
@@ -638,7 +638,7 @@ iso88025_resolvemulti (ifp, llsa, sa)
if ((e_addr[0] & 1) != 1) {
return (EADDRNOTAVAIL);
}
- *llsa = 0;
+ *llsa = NULL;
return (0);
#ifdef INET
@@ -664,7 +664,7 @@ iso88025_resolvemulti (ifp, llsa, sa)
* (This is used for multicast routers.)
*/
ifp->if_flags |= IFF_ALLMULTI;
- *llsa = 0;
+ *llsa = NULL;
return (0);
}
if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) {
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index 1291f7b..1623732 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -380,7 +380,7 @@ loioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
case SIOCADDMULTI:
case SIOCDELMULTI:
- if (ifr == 0) {
+ if (ifr == NULL) {
error = EAFNOSUPPORT; /* XXX */
break;
}
diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c
index 841a0f2..092106e 100644
--- a/sys/net/if_spppsubr.c
+++ b/sys/net/if_spppsubr.c
@@ -4835,7 +4835,7 @@ sppp_get_ip_addrs(struct sppp *sp, u_long *src, u_long *dst, u_long *srcmask)
* Pick the first AF_INET address from the list,
* aliases don't make any sense on a p2p link anyway.
*/
- si = 0;
+ si = NULL;
if_addr_rlock(ifp);
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
if (ifa->ifa_addr->sa_family == AF_INET) {
@@ -4877,7 +4877,7 @@ sppp_set_ip_addr(struct sppp *sp, u_long src)
* Pick the first AF_INET address from the list,
* aliases don't make any sense on a p2p link anyway.
*/
- si = 0;
+ si = NULL;
if_addr_rlock(ifp);
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
if (ifa->ifa_addr->sa_family == AF_INET) {
@@ -5055,7 +5055,7 @@ sppp_params(struct sppp *sp, u_long cmd, void *data)
struct spppreq *spr;
int rv = 0;
- if ((spr = malloc(sizeof(struct spppreq), M_TEMP, M_NOWAIT)) == 0)
+ if ((spr = malloc(sizeof(struct spppreq), M_TEMP, M_NOWAIT)) == NULL)
return (EAGAIN);
/*
* ifr->ifr_data is supposed to point to a struct spppreq.
diff --git a/sys/net/radix.c b/sys/net/radix.c
index 2b4b954..b17858e 100644
--- a/sys/net/radix.c
+++ b/sys/net/radix.c
@@ -519,11 +519,11 @@ rn_addmask(void *n_arg, struct radix_mask_head *maskhead, int search, int skip)
*addmask_key = mlen;
x = rn_search(addmask_key, maskhead->head.rnh_treetop);
if (bcmp(addmask_key, x->rn_key, mlen) != 0)
- x = 0;
+ x = NULL;
if (x || search)
return (x);
R_Zalloc(x, struct radix_node *, RADIX_MAX_KEY_LEN + 2 * sizeof (*x));
- if ((saved_x = x) == 0)
+ if ((saved_x = x) == NULL)
return (0);
netmask = cp = (unsigned char *)(x + 2);
bcopy(addmask_key, cp, mlen);
@@ -599,7 +599,7 @@ rn_addroute(void *v_arg, void *n_arg, struct radix_head *head,
struct radix_node treenodes[2])
{
caddr_t v = (caddr_t)v_arg, netmask = (caddr_t)n_arg;
- struct radix_node *t, *x = 0, *tt;
+ struct radix_node *t, *x = NULL, *tt;
struct radix_node *saved_tt, *top = head->rnh_treetop;
short b = 0, b_leaf = 0;
int keyduplicated;
@@ -722,7 +722,7 @@ rn_addroute(void *v_arg, void *n_arg, struct radix_head *head,
for (mp = &x->rn_mklist; (m = *mp); mp = &m->rm_mklist)
if (m->rm_bit >= b_leaf)
break;
- t->rn_mklist = m; *mp = 0;
+ t->rn_mklist = m; *mp = NULL;
}
on2:
/* Add new route to highest possible ancestor's list */
@@ -785,7 +785,7 @@ rn_delete(void *v_arg, void *netmask_arg, struct radix_head *head)
vlen = LEN(v);
saved_tt = tt;
top = x;
- if (tt == 0 ||
+ if (tt == NULL ||
bcmp(v + head_off, tt->rn_key + head_off, vlen - head_off))
return (0);
/*
@@ -797,10 +797,10 @@ rn_delete(void *v_arg, void *netmask_arg, struct radix_head *head)
return (0);
netmask = x->rn_key;
while (tt->rn_mask != netmask)
- if ((tt = tt->rn_dupedkey) == 0)
+ if ((tt = tt->rn_dupedkey) == NULL)
return (0);
}
- if (tt->rn_mask == 0 || (saved_m = m = tt->rn_mklist) == 0)
+ if (tt->rn_mask == 0 || (saved_m = m = tt->rn_mklist) == NULL)
goto on1;
if (tt->rn_flags & RNF_NORMAL) {
if (m->rm_leaf != tt || m->rm_refs > 0) {
@@ -829,7 +829,7 @@ rn_delete(void *v_arg, void *netmask_arg, struct radix_head *head)
R_Free(m);
break;
}
- if (m == 0) {
+ if (m == NULL) {
log(LOG_ERR, "rn_delete: couldn't find our annotation\n");
if (tt->rn_flags & RNF_NORMAL)
return (0); /* Dangling ref to us */
@@ -1044,7 +1044,7 @@ rn_walktree_from(struct radix_head *h, void *a, void *m,
rn = rn->rn_left;
next = rn;
/* Process leaves */
- while ((rn = base) != 0) {
+ while ((rn = base) != NULL) {
base = rn->rn_dupedkey;
/* printf("leaf %p\n", rn); */
if (!(rn->rn_flags & RNF_ROOT)
diff --git a/sys/net/raw_usrreq.c b/sys/net/raw_usrreq.c
index 87bcd89..9e22528 100644
--- a/sys/net/raw_usrreq.c
+++ b/sys/net/raw_usrreq.c
@@ -83,7 +83,7 @@ raw_input_ext(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src,
struct mbuf *m = m0;
struct socket *last;
- last = 0;
+ last = NULL;
mtx_lock(&rawcb_mtx);
LIST_FOREACH(rp, &V_rawcb_list, list) {
if (rp->rcb_proto.sp_family != proto->sp_family)
diff --git a/sys/netgraph/atm/ccatm/ng_ccatm.c b/sys/netgraph/atm/ccatm/ng_ccatm.c
index cdbc86f..cc3f751 100644
--- a/sys/netgraph/atm/ccatm/ng_ccatm.c
+++ b/sys/netgraph/atm/ccatm/ng_ccatm.c
@@ -441,7 +441,7 @@ send_dump(struct ccdata *data, void *uarg, const char *buf)
m->m_pkthdr.len = 0;
} else {
m = m_getcl(M_NOWAIT, MT_DATA, 0);
- if (m == 0) {
+ if (m == NULL) {
m_freem(priv->dump_first);
return (ENOBUFS);
}
diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c
index 38da313..76d6383 100644
--- a/sys/netgraph/ng_socket.c
+++ b/sys/netgraph/ng_socket.c
@@ -360,7 +360,7 @@ ngc_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
{
struct ngpcb *const pcbp = sotongpcb(so);
- if (pcbp == 0)
+ if (pcbp == NULL)
return (EINVAL);
return (ng_bind(nam, pcbp));
}
@@ -474,7 +474,7 @@ ngd_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
{
struct ngpcb *const pcbp = sotongpcb(so);
- if (pcbp == 0)
+ if (pcbp == NULL)
return (EINVAL);
return (ng_connect_data(nam, pcbp));
}
diff --git a/sys/netgraph/ng_source.c b/sys/netgraph/ng_source.c
index 1883ec0..8332d20 100644
--- a/sys/netgraph/ng_source.c
+++ b/sys/netgraph/ng_source.c
@@ -294,7 +294,7 @@ ng_source_newhook(node_p node, hook_p hook, const char *name)
sc->input = hook;
} else if (strcmp(name, NG_SOURCE_HOOK_OUTPUT) == 0) {
sc->output = hook;
- sc->output_ifp = 0;
+ sc->output_ifp = NULL;
bzero(&sc->stats, sizeof(sc->stats));
} else
return (EINVAL);
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c
index 7a06bea..eac3c1d 100644
--- a/sys/netinet/if_ether.c
+++ b/sys/netinet/if_ether.c
@@ -578,7 +578,7 @@ int
arpresolve(struct ifnet *ifp, int is_gw, struct mbuf *m,
const struct sockaddr *dst, u_char *desten, uint32_t *pflags)
{
- struct llentry *la = 0;
+ struct llentry *la = NULL;
if (pflags != NULL)
*pflags = 0;
diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c
index 2154149..dcadec5 100644
--- a/sys/netinet/igmp.c
+++ b/sys/netinet/igmp.c
@@ -1469,7 +1469,7 @@ igmp_input(struct mbuf **mp, int *offp, int proto)
else
minlen += IGMP_MINLEN;
if ((!M_WRITABLE(m) || m->m_len < minlen) &&
- (m = m_pullup(m, minlen)) == 0) {
+ (m = m_pullup(m, minlen)) == NULL) {
IGMPSTAT_INC(igps_rcv_tooshort);
return (IPPROTO_DONE);
}
diff --git a/sys/netinet/in_mcast.c b/sys/netinet/in_mcast.c
index f2a985b..4037dbf 100644
--- a/sys/netinet/in_mcast.c
+++ b/sys/netinet/in_mcast.c
@@ -1810,7 +1810,7 @@ inp_getmoptions(struct inpcb *inp, struct sockopt *sopt)
break;
case IP_MULTICAST_TTL:
- if (imo == 0)
+ if (imo == NULL)
optval = coptval = IP_DEFAULT_MULTICAST_TTL;
else
optval = coptval = imo->imo_multicast_ttl;
@@ -1822,7 +1822,7 @@ inp_getmoptions(struct inpcb *inp, struct sockopt *sopt)
break;
case IP_MULTICAST_LOOP:
- if (imo == 0)
+ if (imo == NULL)
optval = coptval = IP_DEFAULT_MULTICAST_LOOP;
else
optval = coptval = imo->imo_multicast_loop;
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index f23a3a8..233d1af 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -205,7 +205,7 @@ divert_packet(struct mbuf *m, int incoming)
}
/* Assure header */
if (m->m_len < sizeof(struct ip) &&
- (m = m_pullup(m, sizeof(struct ip))) == 0)
+ (m = m_pullup(m, sizeof(struct ip))) == NULL)
return;
ip = mtod(m, struct ip *);
@@ -600,7 +600,7 @@ div_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
/* Packet must have a header (but that's about it) */
if (m->m_len < sizeof (struct ip) &&
- (m = m_pullup(m, sizeof (struct ip))) == 0) {
+ (m = m_pullup(m, sizeof (struct ip))) == NULL) {
KMOD_IPSTAT_INC(ips_toosmall);
m_freem(m);
return EINVAL;
@@ -666,7 +666,7 @@ div_pcblist(SYSCTL_HANDLER_ARGS)
return error;
inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK);
- if (inp_list == 0)
+ if (inp_list == NULL)
return ENOMEM;
INP_INFO_RLOCK(&V_divcbinfo);
diff --git a/sys/netinet/ip_fw.h b/sys/netinet/ip_fw.h
index e52ff1a..7250527 100644
--- a/sys/netinet/ip_fw.h
+++ b/sys/netinet/ip_fw.h
@@ -256,10 +256,12 @@ enum ipfw_opcodes { /* arguments (4 byte each) */
O_SETDSCP, /* arg1=DSCP value */
O_IP_FLOW_LOOKUP, /* arg1=table number, u32=value */
+ O_EXTERNAL_ACTION, /* arg1=id of external action handler */
+ O_EXTERNAL_INSTANCE, /* arg1=id of eaction handler instance */
+
O_LAST_OPCODE /* not an opcode! */
};
-
/*
* The extension header are filtered only for presence using a bit
* vector with a flag for each header.
@@ -780,6 +782,10 @@ typedef struct _ipfw_obj_tlv {
#define IPFW_TLV_RULE_ENT 7
#define IPFW_TLV_TBLENT_LIST 8
#define IPFW_TLV_RANGE 9
+#define IPFW_TLV_EACTION 10
+
+#define IPFW_TLV_EACTION_BASE 1000
+#define IPFW_TLV_EACTION_NAME(arg) (IPFW_TLV_EACTION_BASE + (arg))
/* Object name TLV */
typedef struct _ipfw_obj_ntlv {
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index 6e6202a..fee980f 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -475,6 +475,23 @@ icmp_input(struct mbuf **mp, int *offp, int proto)
* XXX if the packet contains [IPv4 AH TCP], we can't make a
* notification to TCP layer.
*/
+ i = sizeof(struct ip) + min(icmplen, ICMP_ADVLENPREF(icp));
+ ip_stripoptions(m);
+ if (m->m_len < i && (m = m_pullup(m, i)) == NULL) {
+ /* This should actually not happen */
+ ICMPSTAT_INC(icps_tooshort);
+ return (IPPROTO_DONE);
+ }
+ ip = mtod(m, struct ip *);
+ icp = (struct icmp *)(ip + 1);
+ /*
+ * The upper layer handler can rely on:
+ * - The outer IP header has no options.
+ * - The outer IP header, the ICMP header, the inner IP header,
+ * and the first n bytes of the inner payload are contiguous.
+ * n is at least 8, but might be larger based on
+ * ICMP_ADVLENPREF. See its definition in ip_icmp.h.
+ */
ctlfunc = inetsw[ip_protox[icp->icmp_ip.ip_p]].pr_ctlinput;
if (ctlfunc)
(*ctlfunc)(code, (struct sockaddr *)&icmpsrc,
@@ -657,7 +674,7 @@ icmp_reflect(struct mbuf *m)
struct in_ifaddr *ia;
struct in_addr t;
struct nhop4_extended nh_ext;
- struct mbuf *opts = 0;
+ struct mbuf *opts = NULL;
int optlen = (ip->ip_hl << 2) - sizeof(struct ip);
if (IN_MULTICAST(ntohl(ip->ip_src.s_addr)) ||
@@ -773,7 +790,7 @@ match:
* add on any record-route or timestamp options.
*/
cp = (u_char *) (ip + 1);
- if ((opts = ip_srcroute(m)) == 0 &&
+ if ((opts = ip_srcroute(m)) == NULL &&
(opts = m_gethdr(M_NOWAIT, MT_DATA))) {
opts->m_len = sizeof(struct in_addr);
mtod(opts, struct in_addr *)->s_addr = 0;
diff --git a/sys/netinet/ip_icmp.h b/sys/netinet/ip_icmp.h
index 38d44d7..a046432 100644
--- a/sys/netinet/ip_icmp.h
+++ b/sys/netinet/ip_icmp.h
@@ -136,6 +136,13 @@ struct icmp {
#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
/* N.B.: must separately check that ip_hl >= 5 */
+ /* This is the minimum length required by RFC 792. */
+/*
+ * ICMP_ADVLENPREF is the preferred number of bytes which should be contiguous.
+ * SCTP needs additional 12 bytes to be able to access the initiate tag
+ * in packets containing an INIT chunk.
+ */
+#define ICMP_ADVLENPREF(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8 + 12)
/*
* Definition of type and code field values.
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 6f25e08..773d7ae 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -571,8 +571,7 @@ tooshort:
goto ours;
}
if (m->m_flags & M_IP_NEXTHOP) {
- dchg = (m_tag_find(m, PACKET_TAG_IPFORWARD, NULL) != NULL);
- if (dchg != 0) {
+ if (m_tag_find(m, PACKET_TAG_IPFORWARD, NULL) != NULL) {
/*
* Directly ship the packet on. This allows
* forwarding packets originally destined to us
diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c
index 69e12c3..ba21edc 100644
--- a/sys/netinet/ip_mroute.c
+++ b/sys/netinet/ip_mroute.c
@@ -2601,7 +2601,7 @@ pim_input(struct mbuf **mp, int *offp, int proto)
* Get the IP and PIM headers in contiguous memory, and
* possibly the PIM REGISTER header.
*/
- if (m->m_len < minlen && (m = m_pullup(m, minlen)) == 0) {
+ if (m->m_len < minlen && (m = m_pullup(m, minlen)) == NULL) {
CTR1(KTR_IPMF, "%s: m_pullup() failed", __func__);
return (IPPROTO_DONE);
}
diff --git a/sys/netinet/ip_options.c b/sys/netinet/ip_options.c
index 5daf653..b050423 100644
--- a/sys/netinet/ip_options.c
+++ b/sys/netinet/ip_options.c
@@ -608,7 +608,7 @@ ip_pcbopts(struct inpcb *inp, int optname, struct mbuf *m)
/* turn off any old options */
if (*pcbopt)
(void)m_free(*pcbopt);
- *pcbopt = 0;
+ *pcbopt = NULL;
if (m == NULL || m->m_len == 0) {
/*
* Only turning off any previous options.
diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c
index afdf1a7..3a8be27 100644
--- a/sys/netinet/ip_output.c
+++ b/sys/netinet/ip_output.c
@@ -1348,7 +1348,7 @@ ip_ctloutput(struct socket *so, struct sockopt *sopt)
caddr_t req = NULL;
size_t len = 0;
- if (m != 0) {
+ if (m != NULL) {
req = mtod(m, caddr_t);
len = m->m_len;
}
diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c
index cceccd5..4f8159b 100644
--- a/sys/netinet/libalias/alias_db.c
+++ b/sys/netinet/libalias/alias_db.c
@@ -784,9 +784,9 @@ FindNewPortGroup(struct libalias *la,
struct alias_link *search_result;
for (j = 0; j < port_count; j++)
- if (0 != (search_result = FindLinkIn(la, dst_addr, alias_addr,
- dst_port, htons(port_sys + j),
- link_type, 0)))
+ if ((search_result = FindLinkIn(la, dst_addr,
+ alias_addr, dst_port, htons(port_sys + j),
+ link_type, 0)) != NULL)
break;
/* Found a good range, return base */
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index 9f29444..8de3108 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -1046,7 +1046,7 @@ rip_pcblist(SYSCTL_HANDLER_ARGS)
return (error);
inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK);
- if (inp_list == 0)
+ if (inp_list == NULL)
return (ENOMEM);
INP_INFO_RLOCK(&V_ripcbinfo);
diff --git a/sys/netinet/sctp_syscalls.c b/sys/netinet/sctp_syscalls.c
index 71e2f72..5c16e8d 100644
--- a/sys/netinet/sctp_syscalls.c
+++ b/sys/netinet/sctp_syscalls.c
@@ -562,7 +562,7 @@ sys_sctp_generic_recvmsg(td, uap)
if (fromlen && uap->from) {
len = fromlen;
- if (len <= 0 || fromsa == 0)
+ if (len <= 0 || fromsa == NULL)
len = 0;
else {
len = MIN(len, fromsa->sa_len);
diff --git a/sys/netinet/sctp_usrreq.c b/sys/netinet/sctp_usrreq.c
index 5f43234..81d2478 100644
--- a/sys/netinet/sctp_usrreq.c
+++ b/sys/netinet/sctp_usrreq.c
@@ -254,48 +254,49 @@ sctp_notify(struct sctp_inpcb *inp,
void
sctp_ctlinput(int cmd, struct sockaddr *sa, void *vip)
{
- struct ip *ip = vip;
+ struct ip *outer_ip, *inner_ip;
struct sctphdr *sh;
- struct icmp *icmph;
- uint32_t vrf_id;
+ struct icmp *icmp;
+ struct sctp_inpcb *inp;
+ struct sctp_tcb *stcb;
+ struct sctp_nets *net;
+ struct sctp_init_chunk *ch;
+ struct sockaddr_in to, from;
- /* FIX, for non-bsd is this right? */
- vrf_id = SCTP_DEFAULT_VRFID;
if (sa->sa_family != AF_INET ||
((struct sockaddr_in *)sa)->sin_addr.s_addr == INADDR_ANY) {
return;
}
if (PRC_IS_REDIRECT(cmd)) {
- ip = 0;
+ vip = NULL;
} else if ((unsigned)cmd >= PRC_NCMDS || inetctlerrmap[cmd] == 0) {
return;
}
- if (ip) {
- struct sctp_inpcb *inp = NULL;
- struct sctp_tcb *stcb = NULL;
- struct sctp_nets *net = NULL;
- struct sockaddr_in to, from;
-
- icmph = (struct icmp *)((caddr_t)ip - (sizeof(struct icmp) -
- sizeof(struct ip)));
-
- sh = (struct sctphdr *)((caddr_t)ip + (ip->ip_hl << 2));
+ if (vip != NULL) {
+ inner_ip = (struct ip *)vip;
+ icmp = (struct icmp *)((caddr_t)inner_ip -
+ (sizeof(struct icmp) - sizeof(struct ip)));
+ outer_ip = (struct ip *)((caddr_t)icmp - sizeof(struct ip));
+ sh = (struct sctphdr *)((caddr_t)inner_ip + (inner_ip->ip_hl << 2));
bzero(&to, sizeof(to));
bzero(&from, sizeof(from));
from.sin_family = to.sin_family = AF_INET;
from.sin_len = to.sin_len = sizeof(to);
from.sin_port = sh->src_port;
- from.sin_addr = ip->ip_src;
+ from.sin_addr = inner_ip->ip_src;
to.sin_port = sh->dest_port;
- to.sin_addr = ip->ip_dst;
+ to.sin_addr = inner_ip->ip_dst;
/*
* 'to' holds the dest of the packet that failed to be sent.
* 'from' holds our local endpoint address. Thus we reverse
* the to and the from in the lookup.
*/
+ inp = NULL;
+ net = NULL;
stcb = sctp_findassociation_addr_sa((struct sockaddr *)&to,
(struct sockaddr *)&from,
- &inp, &net, 1, vrf_id);
+ &inp, &net, 1,
+ SCTP_DEFAULT_VRFID);
if ((stcb != NULL) &&
(net != NULL) &&
(inp != NULL) &&
@@ -313,19 +314,30 @@ sctp_ctlinput(int cmd, struct sockaddr *sa, void *vip)
return;
}
} else {
- /*
- * In this case we could check if we got an
- * INIT chunk and if the initiate tag
- * matches. But this is not there yet...
- */
- SCTP_TCB_UNLOCK(stcb);
- return;
+ if (ntohs(outer_ip->ip_len) >=
+ sizeof(struct ip) +
+ 8 + (inner_ip->ip_hl << 2) + 20) {
+ /*
+ * In this case we can check if we
+ * got an INIT chunk and if the
+ * initiate tag matches.
+ */
+ ch = (struct sctp_init_chunk *)(sh + 1);
+ if ((ch->ch.chunk_type != SCTP_INITIATION) ||
+ (ntohl(ch->init.initiate_tag) != stcb->asoc.my_vtag)) {
+ SCTP_TCB_UNLOCK(stcb);
+ return;
+ }
+ } else {
+ SCTP_TCB_UNLOCK(stcb);
+ return;
+ }
}
sctp_notify(inp, stcb, net,
- icmph->icmp_type,
- icmph->icmp_code,
- ntohs(ip->ip_len),
- ntohs(icmph->icmp_nextmtu));
+ icmp->icmp_type,
+ icmp->icmp_code,
+ ntohs(inner_ip->ip_len),
+ ntohs(icmp->icmp_nextmtu));
} else {
if ((stcb == NULL) && (inp != NULL)) {
/* reduce ref-count */
@@ -457,7 +469,7 @@ sctp_attach(struct socket *so, int proto SCTP_UNUSED, struct thread *p SCTP_UNUS
uint32_t vrf_id = SCTP_DEFAULT_VRFID;
inp = (struct sctp_inpcb *)so->so_pcb;
- if (inp != 0) {
+ if (inp != NULL) {
SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_USRREQ, EINVAL);
return (EINVAL);
}
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 56aa56f..fdc2e76 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -308,7 +308,7 @@ udp_append(struct inpcb *inp, struct ip *ip, struct mbuf *n, int off,
{
struct sockaddr *append_sa;
struct socket *so;
- struct mbuf *opts = 0;
+ struct mbuf *opts = NULL;
#ifdef INET6
struct sockaddr_in6 udp_in6;
#endif
@@ -856,7 +856,7 @@ udp_pcblist(SYSCTL_HANDLER_ARGS)
return (error);
inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK);
- if (inp_list == 0)
+ if (inp_list == NULL)
return (ENOMEM);
INP_INFO_RLOCK(&V_udbinfo);
diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c
index 797093a..48f05e7 100644
--- a/sys/netinet6/in6.c
+++ b/sys/netinet6/in6.c
@@ -1823,7 +1823,7 @@ in6_ifawithifp(struct ifnet *ifp, struct in6_addr *dst)
{
int dst_scope = in6_addrscope(dst), blen = -1, tlen;
struct ifaddr *ifa;
- struct in6_ifaddr *besta = 0;
+ struct in6_ifaddr *besta = NULL;
struct in6_ifaddr *dep[2]; /* last-resort: deprecated */
dep[0] = dep[1] = NULL;
diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c
index 7895139..f64d305 100644
--- a/sys/netinet6/ip6_output.c
+++ b/sys/netinet6/ip6_output.c
@@ -256,7 +256,7 @@ ip6_fragment(struct ifnet *ifp, struct mbuf *m0, int hlen, u_char nextproto,
ip6f->ip6f_offlg |= IP6F_MORE_FRAG;
mhip6->ip6_plen = htons((u_short)(mtu + hlen +
sizeof(*ip6f) - sizeof(struct ip6_hdr)));
- if ((m_frgpart = m_copy(m0, off, mtu)) == 0) {
+ if ((m_frgpart = m_copy(m0, off, mtu)) == NULL) {
IP6STAT_INC(ip6s_odropped);
return (ENOBUFS);
}
@@ -503,7 +503,7 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt,
/*
* Route packet.
*/
- if (ro == 0) {
+ if (ro == NULL) {
ro = &ip6route;
bzero((caddr_t)ro, sizeof(*ro));
}
@@ -1116,7 +1116,7 @@ ip6_insert_jumboopt(struct ip6_exthdrs *exthdrs, u_int32_t plen)
* jumbo payload option, allocate a cluster to store the whole options.
* Otherwise, use it to store the options.
*/
- if (exthdrs->ip6e_hbh == 0) {
+ if (exthdrs->ip6e_hbh == NULL) {
mopt = m_get(M_NOWAIT, MT_DATA);
if (mopt == NULL)
return (ENOBUFS);
@@ -1198,7 +1198,7 @@ ip6_insertfraghdr(struct mbuf *m0, struct mbuf *m, int hlen,
if (hlen > sizeof(struct ip6_hdr)) {
n = m_copym(m0, sizeof(struct ip6_hdr),
hlen - sizeof(struct ip6_hdr), M_NOWAIT);
- if (n == 0)
+ if (n == NULL)
return (ENOBUFS);
m->m_next = n;
} else
@@ -2515,7 +2515,7 @@ int
ip6_setpktopts(struct mbuf *control, struct ip6_pktopts *opt,
struct ip6_pktopts *stickyopt, struct ucred *cred, int uproto)
{
- struct cmsghdr *cm = 0;
+ struct cmsghdr *cm = NULL;
if (control == NULL || opt == NULL)
return (EINVAL);
diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c
index 6fee830..aa7baad 100644
--- a/sys/netinet6/nd6_rtr.c
+++ b/sys/netinet6/nd6_rtr.c
@@ -1510,7 +1510,7 @@ pfxlist_onlink_check()
find_pfxlist_reachable_router(pr) == NULL)
pr->ndpr_stateflags |= NDPRF_DETACHED;
if ((pr->ndpr_stateflags & NDPRF_DETACHED) != 0 &&
- find_pfxlist_reachable_router(pr) != 0)
+ find_pfxlist_reachable_router(pr) != NULL)
pr->ndpr_stateflags &= ~NDPRF_DETACHED;
}
} else {
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index 972eb9f..2b95e48 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -163,7 +163,7 @@ rip6_input(struct mbuf **mp, int *offp, int proto)
struct mbuf *m = *mp;
register struct ip6_hdr *ip6 = mtod(m, struct ip6_hdr *);
register struct inpcb *in6p;
- struct inpcb *last = 0;
+ struct inpcb *last = NULL;
struct mbuf *opts = NULL;
struct sockaddr_in6 fromsa;
diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c
index ebcf6d6..03479fd 100644
--- a/sys/netinet6/udp6_usrreq.c
+++ b/sys/netinet6/udp6_usrreq.c
@@ -1212,9 +1212,9 @@ udp6_send(struct socket *so, int flags, struct mbuf *m,
#ifdef INET
if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) {
int hasv4addr;
- struct sockaddr_in6 *sin6 = 0;
+ struct sockaddr_in6 *sin6 = NULL;
- if (addr == 0)
+ if (addr == NULL)
hasv4addr = (inp->inp_vflag & INP_IPV4);
else {
sin6 = (struct sockaddr_in6 *)addr;
diff --git a/sys/netipsec/ipsec_mbuf.c b/sys/netipsec/ipsec_mbuf.c
index b3df0e0..7111210 100644
--- a/sys/netipsec/ipsec_mbuf.c
+++ b/sys/netipsec/ipsec_mbuf.c
@@ -202,7 +202,7 @@ m_pad(struct mbuf *m, int n)
if (pad > M_TRAILINGSPACE(m0)) {
/* Add an mbuf to the chain. */
MGET(m1, M_NOWAIT, MT_DATA);
- if (m1 == 0) {
+ if (m1 == NULL) {
m_freem(m0);
DPRINTF(("%s: unable to get extra mbuf\n", __func__));
return NULL;
diff --git a/sys/netipsec/key.c b/sys/netipsec/key.c
index 865a630..7070c1d 100644
--- a/sys/netipsec/key.c
+++ b/sys/netipsec/key.c
@@ -4923,8 +4923,8 @@ key_update(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp)
dport = (struct sadb_x_nat_t_port *)
mhp->ext[SADB_X_EXT_NAT_T_DPORT];
} else {
- type = 0;
- sport = dport = 0;
+ type = NULL;
+ sport = dport = NULL;
}
if (mhp->ext[SADB_X_EXT_NAT_T_OAI] != NULL &&
mhp->ext[SADB_X_EXT_NAT_T_OAR] != NULL) {
@@ -4949,7 +4949,7 @@ key_update(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp)
frag = (struct sadb_x_nat_t_frag *)
mhp->ext[SADB_X_EXT_NAT_T_FRAG];
} else {
- frag = 0;
+ frag = NULL;
}
#endif
@@ -5215,7 +5215,7 @@ key_add(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp)
KEY_PORTTOSADDR(&saidx.dst,
dport->sadb_x_nat_t_port_port);
} else {
- type = 0;
+ type = NULL;
}
if (mhp->ext[SADB_X_EXT_NAT_T_OAI] != NULL &&
mhp->ext[SADB_X_EXT_NAT_T_OAR] != NULL) {
@@ -5240,7 +5240,7 @@ key_add(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp)
frag = (struct sadb_x_nat_t_frag *)
mhp->ext[SADB_X_EXT_NAT_T_FRAG];
} else {
- frag = 0;
+ frag = NULL;
}
#endif
@@ -6599,7 +6599,7 @@ key_acquire2(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp)
static int
key_register(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp)
{
- struct secreg *reg, *newreg = 0;
+ struct secreg *reg, *newreg = NULL;
IPSEC_ASSERT(so != NULL, ("null socket"));
IPSEC_ASSERT(m != NULL, ("null mbuf"));
diff --git a/sys/netipsec/keysock.c b/sys/netipsec/keysock.c
index 4d12957..73e54bb 100644
--- a/sys/netipsec/keysock.c
+++ b/sys/netipsec/keysock.c
@@ -92,7 +92,7 @@ key_output(struct mbuf *m, struct socket *so, ...)
struct sadb_msg *msg;
int len, error = 0;
- if (m == 0)
+ if (m == NULL)
panic("%s: NULL pointer was passed.\n", __func__);
PFKEYSTAT_INC(out_total);
@@ -106,7 +106,7 @@ key_output(struct mbuf *m, struct socket *so, ...)
}
if (m->m_len < sizeof(struct sadb_msg)) {
- if ((m = m_pullup(m, sizeof(struct sadb_msg))) == 0) {
+ if ((m = m_pullup(m, sizeof(struct sadb_msg))) == NULL) {
PFKEYSTAT_INC(out_nomem);
error = ENOBUFS;
goto end;
@@ -178,7 +178,7 @@ key_sendup(struct socket *so, struct sadb_msg *msg, u_int len, int target)
int tlen;
/* sanity check */
- if (so == 0 || msg == 0)
+ if (so == NULL || msg == NULL)
panic("%s: NULL pointer was passed.\n", __func__);
KEYDEBUG(KEYDEBUG_KEY_DUMP,
@@ -388,7 +388,7 @@ key_attach(struct socket *so, int proto, struct thread *td)
/* XXX */
kp = malloc(sizeof *kp, M_PCB, M_WAITOK | M_ZERO);
- if (kp == 0)
+ if (kp == NULL)
return ENOBUFS;
so->so_pcb = (caddr_t)kp;
diff --git a/sys/netipsec/xform_ipcomp.c b/sys/netipsec/xform_ipcomp.c
index 122fc72..ae19d8d 100644
--- a/sys/netipsec/xform_ipcomp.c
+++ b/sys/netipsec/xform_ipcomp.c
@@ -283,7 +283,7 @@ ipcomp_input_cb(struct cryptop *crp)
/* In case it's not done already, adjust the size of the mbuf chain */
m->m_pkthdr.len = clen + hlen + skip;
- if (m->m_len < skip + hlen && (m = m_pullup(m, skip + hlen)) == 0) {
+ if (m->m_len < skip + hlen && (m = m_pullup(m, skip + hlen)) == NULL) {
IPCOMPSTAT_INC(ipcomps_hdrops); /*XXX*/
DPRINTF(("%s: m_pullup failed\n", __func__));
error = EINVAL; /*XXX*/
diff --git a/sys/netpfil/ipfw/ip_fw2.c b/sys/netpfil/ipfw/ip_fw2.c
index 2d0d2f4..b0a7474 100644
--- a/sys/netpfil/ipfw/ip_fw2.c
+++ b/sys/netpfil/ipfw/ip_fw2.c
@@ -2542,6 +2542,11 @@ do { \
done = 1; /* exit outer loop */
break;
}
+ case O_EXTERNAL_ACTION:
+ l = 0; /* in any case exit inner loop */
+ retval = ipfw_run_eaction(chain, args,
+ cmd, &done);
+ break;
default:
panic("-- unknown opcode %d\n", cmd->opcode);
@@ -2766,6 +2771,7 @@ vnet_ipfw_init(const void *unused)
IPFW_LOCK_INIT(chain);
ipfw_dyn_init(chain);
+ ipfw_eaction_init(chain, first);
#ifdef LINEAR_SKIPTO
ipfw_init_skipto_cache(chain);
#endif
@@ -2830,6 +2836,7 @@ vnet_ipfw_uninit(const void *unused)
IPFW_WUNLOCK(chain);
IPFW_UH_WUNLOCK(chain);
ipfw_destroy_tables(chain, last);
+ ipfw_eaction_uninit(chain, last);
if (reap != NULL)
ipfw_reap_rules(reap);
vnet_ipfw_iface_destroy(chain);
diff --git a/sys/netpfil/ipfw/ip_fw_eaction.c b/sys/netpfil/ipfw/ip_fw_eaction.c
new file mode 100644
index 0000000..144bf49d
--- /dev/null
+++ b/sys/netpfil/ipfw/ip_fw_eaction.c
@@ -0,0 +1,369 @@
+/*-
+ * Copyright (c) 2016 Yandex LLC
+ * Copyright (c) 2016 Andrey V. Elsukov <ae@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/hash.h>
+#include <sys/lock.h>
+#include <sys/rwlock.h>
+#include <sys/rmlock.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/queue.h>
+#include <net/pfil.h>
+
+#include <net/if.h> /* ip_fw.h requires IFNAMSIZ */
+#include <netinet/in.h>
+#include <netinet/ip_var.h> /* struct ipfw_rule_ref */
+#include <netinet/ip_fw.h>
+
+#include <netpfil/ipfw/ip_fw_private.h>
+
+#include "opt_ipfw.h"
+
+/*
+ * External actions support for ipfw.
+ *
+ * This code provides KPI for implementing loadable modules, that
+ * can provide handlers for external action opcodes in the ipfw's
+ * rules.
+ * Module should implement opcode handler with type ipfw_eaction_t.
+ * This handler will be called by ipfw_chk() function when
+ * O_EXTERNAL_ACTION opcode will be matched. The handler must return
+ * value used as return value in ipfw_chk(), i.e. IP_FW_PASS,
+ * IP_FW_DENY (see ip_fw_private.h).
+ * Also the last argument must be set by handler. If it is zero,
+ * the search continues to the next rule. If it has non zero value,
+ * the search terminates.
+ *
+ * The module that implements external action should register its
+ * handler and name with ipfw_add_eaction() function.
+ * This function will return eaction_id, that can be used by module.
+ *
+ * It is possible to pass some additional information to external
+ * action handler via the O_EXTERNAL_INSTANCE opcode. This opcode
+ * will be next after the O_EXTERNAL_ACTION opcode. cmd->arg1 will
+ * contain index of named object related to instance of external action.
+ *
+ * In case when eaction module uses named instances, it should register
+ * opcode rewriting routines for O_EXTERNAL_INSTANCE opcode. The
+ * classifier callback can look back into O_EXTERNAL_ACTION opcode (it
+ * must be in the (ipfw_insn *)(cmd - 1)). By arg1 from O_EXTERNAL_ACTION
+ * it can deteremine eaction_id and compare it with its own.
+ * The macro IPFW_TLV_EACTION_NAME(eaction_id) can be used to deteremine
+ * the type of named_object related to external action instance.
+ *
+ * On module unload handler should be deregistered with ipfw_del_eaction()
+ * function using known eaction_id.
+ */
+
+struct eaction_obj {
+ struct named_object no;
+ ipfw_eaction_t *handler;
+ char name[64];
+};
+
+#define EACTION_OBJ(ch, cmd) \
+ ((struct eaction_obj *)SRV_OBJECT((ch), (cmd)->arg1))
+
+#if 0
+#define EACTION_DEBUG(fmt, ...) do { \
+ printf("%s: " fmt "\n", __func__, ## __VA_ARGS__); \
+} while (0)
+#else
+#define EACTION_DEBUG(fmt, ...)
+#endif
+
+const char *default_eaction_typename = "drop";
+static int
+default_eaction(struct ip_fw_chain *ch, struct ip_fw_args *args,
+ ipfw_insn *cmd, int *done)
+{
+
+ *done = 1; /* terminate the search */
+ return (IP_FW_DENY);
+}
+
+/*
+ * Opcode rewriting callbacks.
+ */
+static int
+eaction_classify(ipfw_insn *cmd, uint16_t *puidx, uint8_t *ptype)
+{
+
+ EACTION_DEBUG("opcode %d, arg1 %d", cmd->opcode, cmd->arg1);
+ *puidx = cmd->arg1;
+ *ptype = 0;
+ return (0);
+}
+
+static void
+eaction_update(ipfw_insn *cmd, uint16_t idx)
+{
+
+ cmd->arg1 = idx;
+ EACTION_DEBUG("opcode %d, arg1 -> %d", cmd->opcode, cmd->arg1);
+}
+
+static int
+eaction_findbyname(struct ip_fw_chain *ch, struct tid_info *ti,
+ struct named_object **pno)
+{
+
+ EACTION_DEBUG("uidx %u, type %u", ti->uidx, ti->type);
+ return (ipfw_objhash_find_type(CHAIN_TO_SRV(ch), ti,
+ IPFW_TLV_EACTION, pno));
+}
+
+static struct named_object *
+eaction_findbykidx(struct ip_fw_chain *ch, uint16_t idx)
+{
+
+ EACTION_DEBUG("kidx %u", idx);
+ return (ipfw_objhash_lookup_kidx(CHAIN_TO_SRV(ch), idx));
+}
+
+static int
+eaction_create_compat(struct ip_fw_chain *ch, struct tid_info *ti,
+ uint16_t *pkidx)
+{
+
+ return (EOPNOTSUPP);
+}
+
+static struct opcode_obj_rewrite eaction_opcodes[] = {
+ {
+ O_EXTERNAL_ACTION, IPFW_TLV_EACTION,
+ eaction_classify, eaction_update,
+ eaction_findbyname, eaction_findbykidx,
+ eaction_create_compat
+ },
+};
+
+static int
+create_eaction_obj(struct ip_fw_chain *ch, ipfw_eaction_t handler,
+ const char *name, uint16_t *eaction_id)
+{
+ struct namedobj_instance *ni;
+ struct eaction_obj *obj;
+
+ IPFW_UH_UNLOCK_ASSERT(ch);
+
+ ni = CHAIN_TO_SRV(ch);
+ obj = malloc(sizeof(*obj), M_IPFW, M_WAITOK | M_ZERO);
+ obj->no.name = obj->name;
+ obj->no.etlv = IPFW_TLV_EACTION;
+ obj->handler = handler;
+ strlcpy(obj->name, name, sizeof(obj->name));
+
+ IPFW_UH_WLOCK(ch);
+ if (ipfw_objhash_lookup_name_type(ni, 0, IPFW_TLV_EACTION,
+ name) != NULL) {
+ /*
+ * Object is already created.
+ * We don't allow eactions with the same name.
+ */
+ IPFW_UH_WUNLOCK(ch);
+ free(obj, M_IPFW);
+ EACTION_DEBUG("External action with typename "
+ "'%s' already exists", name);
+ return (EEXIST);
+ }
+ if (ipfw_objhash_alloc_idx(ni, &obj->no.kidx) != 0) {
+ IPFW_UH_WUNLOCK(ch);
+ free(obj, M_IPFW);
+ EACTION_DEBUG("alloc_idx failed");
+ return (ENOSPC);
+ }
+ ipfw_objhash_add(ni, &obj->no);
+ IPFW_WLOCK(ch);
+ SRV_OBJECT(ch, obj->no.kidx) = obj;
+ IPFW_WUNLOCK(ch);
+ obj->no.refcnt++;
+ IPFW_UH_WUNLOCK(ch);
+
+ if (eaction_id != NULL)
+ *eaction_id = obj->no.kidx;
+ return (0);
+}
+
+static void
+destroy_eaction_obj(struct ip_fw_chain *ch, struct named_object *no)
+{
+ struct namedobj_instance *ni;
+ struct eaction_obj *obj;
+
+ IPFW_UH_WLOCK_ASSERT(ch);
+
+ ni = CHAIN_TO_SRV(ch);
+ IPFW_WLOCK(ch);
+ obj = SRV_OBJECT(ch, no->kidx);
+ SRV_OBJECT(ch, no->kidx) = NULL;
+ IPFW_WUNLOCK(ch);
+ ipfw_objhash_del(ni, no);
+ ipfw_objhash_free_idx(ni, no->kidx);
+ free(obj, M_IPFW);
+}
+
+/*
+ * Resets all eaction opcodes to default handlers.
+ */
+static void
+reset_eaction_obj(struct ip_fw_chain *ch, uint16_t eaction_id)
+{
+ struct named_object *no;
+ struct ip_fw *rule;
+ ipfw_insn *cmd;
+ int i;
+
+ IPFW_UH_WLOCK_ASSERT(ch);
+
+ no = ipfw_objhash_lookup_name_type(CHAIN_TO_SRV(ch), 0,
+ IPFW_TLV_EACTION, default_eaction_typename);
+ if (no == NULL)
+ panic("Default external action handler is not found");
+ if (eaction_id == no->kidx)
+ panic("Wrong eaction_id");
+ EACTION_DEBUG("replace id %u with %u", eaction_id, no->kidx);
+ IPFW_WLOCK(ch);
+ for (i = 0; i < ch->n_rules; i++) {
+ rule = ch->map[i];
+ cmd = ACTION_PTR(rule);
+ if (cmd->opcode != O_EXTERNAL_ACTION)
+ continue;
+ if (cmd->arg1 != eaction_id)
+ continue;
+ cmd->arg1 = no->kidx; /* Set to default id */
+ /*
+ * XXX: we only bump refcount on default_eaction.
+ * Refcount on the original object will be just
+ * ignored on destroy. But on default_eaction it
+ * will be decremented on rule deletion.
+ */
+ no->refcnt++;
+ /*
+ * Since named_object related to this instance will be
+ * also destroyed, truncate the chain of opcodes to
+ * remove O_EXTERNAL_INSTANCE opcode.
+ */
+ if (rule->act_ofs < rule->cmd_len - 1) {
+ EACTION_DEBUG("truncate rule %d", rule->rulenum);
+ rule->cmd_len--;
+ }
+ }
+ IPFW_WUNLOCK(ch);
+}
+
+/*
+ * Initialize external actions framework.
+ * Create object with default eaction handler "drop".
+ */
+int
+ipfw_eaction_init(struct ip_fw_chain *ch, int first)
+{
+ int error;
+
+ error = create_eaction_obj(ch, default_eaction,
+ default_eaction_typename, NULL);
+ if (error != 0)
+ return (error);
+ IPFW_ADD_OBJ_REWRITER(first, eaction_opcodes);
+ EACTION_DEBUG("External actions support initialized");
+ return (0);
+}
+
+void
+ipfw_eaction_uninit(struct ip_fw_chain *ch, int last)
+{
+ struct namedobj_instance *ni;
+ struct named_object *no;
+
+ ni = CHAIN_TO_SRV(ch);
+
+ IPFW_UH_WLOCK(ch);
+ no = ipfw_objhash_lookup_name_type(ni, 0, IPFW_TLV_EACTION,
+ default_eaction_typename);
+ if (no != NULL)
+ destroy_eaction_obj(ch, no);
+ IPFW_UH_WUNLOCK(ch);
+ IPFW_DEL_OBJ_REWRITER(last, eaction_opcodes);
+ EACTION_DEBUG("External actions support uninitialized");
+}
+
+/*
+ * Registers external action handler to the global array.
+ * On success it returns eaction id, otherwise - zero.
+ */
+uint16_t
+ipfw_add_eaction(struct ip_fw_chain *ch, ipfw_eaction_t handler,
+ const char *name)
+{
+ uint16_t eaction_id;
+
+ eaction_id = 0;
+ if (ipfw_check_object_name_generic(name) == 0) {
+ create_eaction_obj(ch, handler, name, &eaction_id);
+ EACTION_DEBUG("Registered external action '%s' with id %u",
+ name, eaction_id);
+ }
+ return (eaction_id);
+}
+
+/*
+ * Deregisters external action handler with id eaction_id.
+ */
+int
+ipfw_del_eaction(struct ip_fw_chain *ch, uint16_t eaction_id)
+{
+ struct named_object *no;
+
+ IPFW_UH_WLOCK(ch);
+ no = ipfw_objhash_lookup_kidx(CHAIN_TO_SRV(ch), eaction_id);
+ if (no == NULL || no->etlv != IPFW_TLV_EACTION) {
+ IPFW_UH_WUNLOCK(ch);
+ return (EINVAL);
+ }
+ if (no->refcnt > 1)
+ reset_eaction_obj(ch, eaction_id);
+ EACTION_DEBUG("External action '%s' with id %u unregistered",
+ no->name, eaction_id);
+ destroy_eaction_obj(ch, no);
+ IPFW_UH_WUNLOCK(ch);
+ return (0);
+}
+
+int
+ipfw_run_eaction(struct ip_fw_chain *ch, struct ip_fw_args *args,
+ ipfw_insn *cmd, int *done)
+{
+
+ return (EACTION_OBJ(ch, cmd)->handler(ch, args, cmd, done));
+}
diff --git a/sys/netpfil/ipfw/ip_fw_iface.c b/sys/netpfil/ipfw/ip_fw_iface.c
index b7c450c..07d24de 100644
--- a/sys/netpfil/ipfw/ip_fw_iface.c
+++ b/sys/netpfil/ipfw/ip_fw_iface.c
@@ -471,7 +471,7 @@ export_iface_internal(struct namedobj_instance *ii, struct named_object *no,
da = (struct dump_iface_args *)arg;
i = (ipfw_iface_info *)ipfw_get_sopt_space(da->sd, sizeof(*i));
- KASSERT(i != 0, ("previously checked buffer is not enough"));
+ KASSERT(i != NULL, ("previously checked buffer is not enough"));
iif = (struct ipfw_iface *)no;
diff --git a/sys/netpfil/ipfw/ip_fw_private.h b/sys/netpfil/ipfw/ip_fw_private.h
index 7be3d1e..62e1a9a 100644
--- a/sys/netpfil/ipfw/ip_fw_private.h
+++ b/sys/netpfil/ipfw/ip_fw_private.h
@@ -313,9 +313,9 @@ struct named_object {
TAILQ_ENTRY(named_object) nn_next; /* namehash */
TAILQ_ENTRY(named_object) nv_next; /* valuehash */
char *name; /* object name */
- uint8_t subtype; /* object subtype within class */
- uint8_t etlv; /* Export TLV id */
- uint16_t spare[2];
+ uint16_t etlv; /* Export TLV id */
+ uint8_t subtype;/* object subtype within class */
+ uint8_t spare[3];
uint16_t kidx; /* object kernel index */
uint32_t set; /* set object belongs to */
uint32_t refcnt; /* number of references */
@@ -516,9 +516,10 @@ struct ip_fw_bcounter0 {
#define IPFW_TABLES_MAX 65536
#define IPFW_TABLES_DEFAULT 128
#define IPFW_OBJECTS_MAX 65536
-#define IPFW_OBJECTS_DEFAULT 128
+#define IPFW_OBJECTS_DEFAULT 1024
#define CHAIN_TO_SRV(ch) ((ch)->srvmap)
+#define SRV_OBJECT(ch, idx) ((ch)->srvstate[(idx)])
struct tid_info {
uint32_t set; /* table set */
@@ -650,9 +651,10 @@ caddr_t ipfw_get_sopt_header(struct sockopt_data *sd, size_t needed);
struct namedobj_instance;
typedef void (objhash_cb_t)(struct namedobj_instance *ni, struct named_object *,
void *arg);
-typedef uint32_t (objhash_hash_f)(struct namedobj_instance *ni, void *key,
+typedef uint32_t (objhash_hash_f)(struct namedobj_instance *ni, const void *key,
+ uint32_t kopt);
+typedef int (objhash_cmp_f)(struct named_object *no, const void *key,
uint32_t kopt);
-typedef int (objhash_cmp_f)(struct named_object *no, void *key, uint32_t kopt);
struct namedobj_instance *ipfw_objhash_create(uint32_t items);
void ipfw_objhash_destroy(struct namedobj_instance *);
void ipfw_objhash_bitmap_alloc(uint32_t items, void **idx, int *pblocks);
@@ -665,7 +667,7 @@ void ipfw_objhash_set_hashf(struct namedobj_instance *ni, objhash_hash_f *f);
struct named_object *ipfw_objhash_lookup_name(struct namedobj_instance *ni,
uint32_t set, char *name);
struct named_object *ipfw_objhash_lookup_name_type(struct namedobj_instance *ni,
- uint32_t set, uint32_t type, char *name);
+ uint32_t set, uint32_t type, const char *name);
struct named_object *ipfw_objhash_lookup_kidx(struct namedobj_instance *ni,
uint16_t idx);
int ipfw_objhash_same_name(struct namedobj_instance *ni, struct named_object *a,
@@ -679,20 +681,14 @@ int ipfw_objhash_free_idx(struct namedobj_instance *ni, uint16_t idx);
int ipfw_objhash_alloc_idx(void *n, uint16_t *pidx);
void ipfw_objhash_set_funcs(struct namedobj_instance *ni,
objhash_hash_f *hash_f, objhash_cmp_f *cmp_f);
+int ipfw_objhash_find_type(struct namedobj_instance *ni, struct tid_info *ti,
+ uint32_t etlv, struct named_object **pno);
void ipfw_export_obj_ntlv(struct named_object *no, ipfw_obj_ntlv *ntlv);
void ipfw_init_obj_rewriter(void);
void ipfw_destroy_obj_rewriter(void);
void ipfw_add_obj_rewriter(struct opcode_obj_rewrite *rw, size_t count);
int ipfw_del_obj_rewriter(struct opcode_obj_rewrite *rw, size_t count);
-int ipfw_rewrite_rule_uidx(struct ip_fw_chain *chain,
- struct rule_check_info *ci);
-int ipfw_mark_object_kidx(struct ip_fw_chain *chain, struct ip_fw *rule,
- uint32_t *bmask);
-int ref_opcode_object(struct ip_fw_chain *ch, ipfw_insn *cmd, struct tid_info *ti,
- struct obj_idx *pidx, int *found, int *unresolved);
-void unref_oib_objects(struct ip_fw_chain *ch, ipfw_insn *cmd,
- struct obj_idx *oib, struct obj_idx *end);
int create_objects_compat(struct ip_fw_chain *ch, ipfw_insn *cmd,
struct obj_idx *oib, struct obj_idx *pidx, struct tid_info *ti);
void update_opcode_kidx(ipfw_insn *cmd, uint16_t idx);
@@ -701,6 +697,18 @@ void ipfw_init_srv(struct ip_fw_chain *ch);
void ipfw_destroy_srv(struct ip_fw_chain *ch);
int ipfw_check_object_name_generic(const char *name);
+/* In ip_fw_eaction.c */
+typedef int (ipfw_eaction_t)(struct ip_fw_chain *ch, struct ip_fw_args *args,
+ ipfw_insn *cmd, int *done);
+int ipfw_eaction_init(struct ip_fw_chain *ch, int first);
+void ipfw_eaction_uninit(struct ip_fw_chain *ch, int last);
+
+uint16_t ipfw_add_eaction(struct ip_fw_chain *ch, ipfw_eaction_t handler,
+ const char *name);
+int ipfw_del_eaction(struct ip_fw_chain *ch, uint16_t eaction_id);
+int ipfw_run_eaction(struct ip_fw_chain *ch, struct ip_fw_args *args,
+ ipfw_insn *cmd, int *done);
+
/* In ip_fw_table.c */
struct table_info;
diff --git a/sys/netpfil/ipfw/ip_fw_sockopt.c b/sys/netpfil/ipfw/ip_fw_sockopt.c
index 857b465..c63a303 100644
--- a/sys/netpfil/ipfw/ip_fw_sockopt.c
+++ b/sys/netpfil/ipfw/ip_fw_sockopt.c
@@ -81,6 +81,8 @@ static int check_ipfw_rule1(struct ip_fw_rule *rule, int size,
struct rule_check_info *ci);
static int check_ipfw_rule0(struct ip_fw_rule0 *rule, int size,
struct rule_check_info *ci);
+static int rewrite_rule_uidx(struct ip_fw_chain *chain,
+ struct rule_check_info *ci);
#define NAMEDOBJ_HASH_SIZE 32
@@ -98,10 +100,11 @@ struct namedobj_instance {
};
#define BLOCK_ITEMS (8 * sizeof(u_long)) /* Number of items for ffsl() */
-static uint32_t objhash_hash_name(struct namedobj_instance *ni, void *key,
- uint32_t kopt);
+static uint32_t objhash_hash_name(struct namedobj_instance *ni,
+ const void *key, uint32_t kopt);
static uint32_t objhash_hash_idx(struct namedobj_instance *ni, uint32_t val);
-static int objhash_cmp_name(struct named_object *no, void *name, uint32_t set);
+static int objhash_cmp_name(struct named_object *no, const void *name,
+ uint32_t set);
MALLOC_DEFINE(M_IPFW, "IpFw/IpAcct", "IpFw/IpAcct chain's");
@@ -153,10 +156,17 @@ static struct ipfw_sopt_handler scodes[] = {
static int
set_legacy_obj_kidx(struct ip_fw_chain *ch, struct ip_fw_rule0 *rule);
-struct opcode_obj_rewrite *ipfw_find_op_rw(uint16_t opcode);
+static struct opcode_obj_rewrite *find_op_rw(ipfw_insn *cmd,
+ uint16_t *puidx, uint8_t *ptype);
static int mark_object_kidx(struct ip_fw_chain *ch, struct ip_fw *rule,
uint32_t *bmask);
+static int ref_rule_objects(struct ip_fw_chain *ch, struct ip_fw *rule,
+ struct rule_check_info *ci, struct obj_idx *oib, struct tid_info *ti);
+static int ref_opcode_object(struct ip_fw_chain *ch, ipfw_insn *cmd,
+ struct tid_info *ti, struct obj_idx *pidx, int *unresolved);
static void unref_rule_objects(struct ip_fw_chain *chain, struct ip_fw *rule);
+static void unref_oib_objects(struct ip_fw_chain *ch, ipfw_insn *cmd,
+ struct obj_idx *oib, struct obj_idx *end);
static int export_objhash_ntlv(struct namedobj_instance *ni, uint16_t kidx,
struct sockopt_data *sd);
@@ -675,7 +685,7 @@ commit_rules(struct ip_fw_chain *chain, struct rule_check_info *rci, int count)
* We need to find (and create non-existing)
* kernel objects, and reference existing ones.
*/
- error = ipfw_rewrite_rule_uidx(chain, ci);
+ error = rewrite_rule_uidx(chain, ci);
if (error != 0) {
/*
@@ -1483,6 +1493,35 @@ check_ipfw_rule_body(ipfw_insn *cmd, int cmd_len, struct rule_check_info *ci)
goto bad_size;
break;
+ case O_EXTERNAL_ACTION:
+ if (cmd->arg1 == 0 ||
+ cmdlen != F_INSN_SIZE(ipfw_insn)) {
+ printf("ipfw: invalid external "
+ "action opcode\n");
+ return (EINVAL);
+ }
+ ci->object_opcodes++;
+ /* Do we have O_EXTERNAL_INSTANCE opcode? */
+ if (l != cmdlen) {
+ l -= cmdlen;
+ cmd += cmdlen;
+ cmdlen = F_LEN(cmd);
+ if (cmd->opcode != O_EXTERNAL_INSTANCE) {
+ printf("ipfw: invalid opcode "
+ "next to external action %u\n",
+ cmd->opcode);
+ return (EINVAL);
+ }
+ if (cmd->arg1 == 0 ||
+ cmdlen != F_INSN_SIZE(ipfw_insn)) {
+ printf("ipfw: invalid external "
+ "action instance opcode\n");
+ return (EINVAL);
+ }
+ ci->object_opcodes++;
+ }
+ goto check_action;
+
case O_FIB:
if (cmdlen != F_INSN_SIZE(ipfw_insn))
goto bad_size;
@@ -2000,11 +2039,10 @@ static int
mark_object_kidx(struct ip_fw_chain *ch, struct ip_fw *rule,
uint32_t *bmask)
{
- int cmdlen, l, count;
+ struct opcode_obj_rewrite *rw;
ipfw_insn *cmd;
+ int bidx, cmdlen, l, count;
uint16_t kidx;
- struct opcode_obj_rewrite *rw;
- int bidx;
uint8_t subtype;
l = rule->cmd_len;
@@ -2014,15 +2052,15 @@ mark_object_kidx(struct ip_fw_chain *ch, struct ip_fw *rule,
for ( ; l > 0 ; l -= cmdlen, cmd += cmdlen) {
cmdlen = F_LEN(cmd);
- rw = ipfw_find_op_rw(cmd->opcode);
+ rw = find_op_rw(cmd, &kidx, &subtype);
if (rw == NULL)
continue;
- if (rw->classifier(cmd, &kidx, &subtype) != 0)
- continue;
-
bidx = kidx / 32;
- /* Maintain separate bitmasks for table and non-table objects */
+ /*
+ * Maintain separate bitmasks for table and
+ * non-table objects.
+ */
if (rw->etlv != IPFW_TLV_TBL_NAME)
bidx += IPFW_TABLES_MAX / 32;
@@ -2194,7 +2232,7 @@ create_objects_compat(struct ip_fw_chain *ch, ipfw_insn *cmd,
ti->type = p->type;
ti->atype = 0;
- rw = ipfw_find_op_rw((cmd + p->off)->opcode);
+ rw = find_op_rw(cmd + p->off, NULL, NULL);
KASSERT(rw != NULL, ("Unable to find handler for op %d",
(cmd + p->off)->opcode));
@@ -2229,14 +2267,14 @@ create_objects_compat(struct ip_fw_chain *ch, ipfw_insn *cmd,
static int
set_legacy_obj_kidx(struct ip_fw_chain *ch, struct ip_fw_rule0 *rule)
{
- int cmdlen, error, l;
- ipfw_insn *cmd;
- uint16_t kidx, uidx;
- struct named_object *no;
struct opcode_obj_rewrite *rw;
- uint8_t subtype;
+ struct named_object *no;
+ ipfw_insn *cmd;
char *end;
long val;
+ int cmdlen, error, l;
+ uint16_t kidx, uidx;
+ uint8_t subtype;
error = 0;
@@ -2246,12 +2284,9 @@ set_legacy_obj_kidx(struct ip_fw_chain *ch, struct ip_fw_rule0 *rule)
for ( ; l > 0 ; l -= cmdlen, cmd += cmdlen) {
cmdlen = F_LEN(cmd);
- rw = ipfw_find_op_rw(cmd->opcode);
- if (rw == NULL)
- continue;
-
/* Check if is index in given opcode */
- if (rw->classifier(cmd, &kidx, &subtype) != 0)
+ rw = find_op_rw(cmd, &kidx, &subtype);
+ if (rw == NULL)
continue;
/* Try to find referenced kernel object */
@@ -2286,7 +2321,7 @@ set_legacy_obj_kidx(struct ip_fw_chain *ch, struct ip_fw_rule0 *rule)
*
* Used to rollback partially converted rule on error.
*/
-void
+static void
unref_oib_objects(struct ip_fw_chain *ch, ipfw_insn *cmd, struct obj_idx *oib,
struct obj_idx *end)
{
@@ -2300,7 +2335,7 @@ unref_oib_objects(struct ip_fw_chain *ch, ipfw_insn *cmd, struct obj_idx *oib,
if (p->kidx == 0)
continue;
- rw = ipfw_find_op_rw((cmd + p->off)->opcode);
+ rw = find_op_rw(cmd + p->off, NULL, NULL);
KASSERT(rw != NULL, ("Unable to find handler for op %d",
(cmd + p->off)->opcode));
@@ -2318,11 +2353,11 @@ unref_oib_objects(struct ip_fw_chain *ch, ipfw_insn *cmd, struct obj_idx *oib,
static void
unref_rule_objects(struct ip_fw_chain *ch, struct ip_fw *rule)
{
- int cmdlen, l;
- ipfw_insn *cmd;
+ struct opcode_obj_rewrite *rw;
struct named_object *no;
+ ipfw_insn *cmd;
+ int cmdlen, l;
uint16_t kidx;
- struct opcode_obj_rewrite *rw;
uint8_t subtype;
IPFW_UH_WLOCK_ASSERT(ch);
@@ -2333,12 +2368,9 @@ unref_rule_objects(struct ip_fw_chain *ch, struct ip_fw *rule)
for ( ; l > 0 ; l -= cmdlen, cmd += cmdlen) {
cmdlen = F_LEN(cmd);
- rw = ipfw_find_op_rw(cmd->opcode);
+ rw = find_op_rw(cmd, &kidx, &subtype);
if (rw == NULL)
continue;
- if (rw->classifier(cmd, &kidx, &subtype) != 0)
- continue;
-
no = rw->find_bykidx(ch, kidx);
KASSERT(no != NULL, ("table id %d not found", kidx));
@@ -2360,31 +2392,23 @@ unref_rule_objects(struct ip_fw_chain *ch, struct ip_fw *rule)
* Find and reference object (if any) stored in instruction @cmd.
*
* Saves object info in @pidx, sets
- * - @found to 1 if object was found and references
* - @unresolved to 1 if object should exists but not found
*
* Returns non-zero value in case of error.
*/
-int
+static int
ref_opcode_object(struct ip_fw_chain *ch, ipfw_insn *cmd, struct tid_info *ti,
- struct obj_idx *pidx, int *found, int *unresolved)
+ struct obj_idx *pidx, int *unresolved)
{
struct named_object *no;
struct opcode_obj_rewrite *rw;
int error;
- *found = 0;
- *unresolved = 0;
-
/* Check if this opcode is candidate for rewrite */
- rw = ipfw_find_op_rw(cmd->opcode);
+ rw = find_op_rw(cmd, &ti->uidx, &ti->type);
if (rw == NULL)
return (0);
- /* Check if we need to rewrite this opcode */
- if (rw->classifier(cmd, &ti->uidx, &ti->type) != 0)
- return (0);
-
/* Need to rewrite. Save necessary fields */
pidx->uidx = ti->uidx;
pidx->type = ti->type;
@@ -2394,19 +2418,146 @@ ref_opcode_object(struct ip_fw_chain *ch, ipfw_insn *cmd, struct tid_info *ti,
if (error != 0)
return (error);
if (no == NULL) {
+ /*
+ * Report about unresolved object for automaic
+ * creation.
+ */
*unresolved = 1;
return (0);
}
- /* Found. bump refcount */
- *found = 1;
+ /* Found. Bump refcount and update kidx. */
no->refcnt++;
- pidx->kidx = no->kidx;
-
+ rw->update(cmd, no->kidx);
return (0);
}
/*
+ * Finds and bumps refcount for objects referenced by given @rule.
+ * Auto-creates non-existing tables.
+ * Fills in @oib array with userland/kernel indexes.
+ *
+ * Returns 0 on success.
+ */
+static int
+ref_rule_objects(struct ip_fw_chain *ch, struct ip_fw *rule,
+ struct rule_check_info *ci, struct obj_idx *oib, struct tid_info *ti)
+{
+ struct obj_idx *pidx;
+ ipfw_insn *cmd;
+ int cmdlen, error, l, unresolved;
+
+ pidx = oib;
+ l = rule->cmd_len;
+ cmd = rule->cmd;
+ cmdlen = 0;
+ error = 0;
+
+ IPFW_UH_WLOCK(ch);
+
+ /* Increase refcount on each existing referenced table. */
+ for ( ; l > 0 ; l -= cmdlen, cmd += cmdlen) {
+ cmdlen = F_LEN(cmd);
+ unresolved = 0;
+
+ error = ref_opcode_object(ch, cmd, ti, pidx, &unresolved);
+ if (error != 0)
+ break;
+ /*
+ * Compability stuff for old clients:
+ * prepare to automaitcally create non-existing objects.
+ */
+ if (unresolved != 0) {
+ pidx->off = rule->cmd_len - l;
+ pidx++;
+ }
+ }
+
+ if (error != 0) {
+ /* Unref everything we have already done */
+ unref_oib_objects(ch, rule->cmd, oib, pidx);
+ IPFW_UH_WUNLOCK(ch);
+ return (error);
+ }
+ IPFW_UH_WUNLOCK(ch);
+
+ /* Perform auto-creation for non-existing objects */
+ if (pidx != oib)
+ error = create_objects_compat(ch, rule->cmd, oib, pidx, ti);
+
+ /* Calculate real number of dynamic objects */
+ ci->object_opcodes = (uint16_t)(pidx - oib);
+
+ return (error);
+}
+
+/*
+ * Checks is opcode is referencing table of appropriate type.
+ * Adds reference count for found table if true.
+ * Rewrites user-supplied opcode values with kernel ones.
+ *
+ * Returns 0 on success and appropriate error code otherwise.
+ */
+static int
+rewrite_rule_uidx(struct ip_fw_chain *chain, struct rule_check_info *ci)
+{
+ int error;
+ ipfw_insn *cmd;
+ uint8_t type;
+ struct obj_idx *p, *pidx_first, *pidx_last;
+ struct tid_info ti;
+
+ /*
+ * Prepare an array for storing opcode indices.
+ * Use stack allocation by default.
+ */
+ if (ci->object_opcodes <= (sizeof(ci->obuf)/sizeof(ci->obuf[0]))) {
+ /* Stack */
+ pidx_first = ci->obuf;
+ } else
+ pidx_first = malloc(
+ ci->object_opcodes * sizeof(struct obj_idx),
+ M_IPFW, M_WAITOK | M_ZERO);
+
+ error = 0;
+ type = 0;
+ memset(&ti, 0, sizeof(ti));
+
+ /*
+ * Use default set for looking up tables (old way) or
+ * use set rule is assigned to (new way).
+ */
+ ti.set = (V_fw_tables_sets != 0) ? ci->krule->set : 0;
+ if (ci->ctlv != NULL) {
+ ti.tlvs = (void *)(ci->ctlv + 1);
+ ti.tlen = ci->ctlv->head.length - sizeof(ipfw_obj_ctlv);
+ }
+
+ /* Reference all used tables and other objects */
+ error = ref_rule_objects(chain, ci->krule, ci, pidx_first, &ti);
+ if (error != 0)
+ goto free;
+ /*
+ * Note that ref_rule_objects() might have updated ci->object_opcodes
+ * to reflect actual number of object opcodes.
+ */
+
+ /* Perform rewrite of remaining opcodes */
+ p = pidx_first;
+ pidx_last = pidx_first + ci->object_opcodes;
+ for (p = pidx_first; p < pidx_last; p++) {
+ cmd = ci->krule->cmd + p->off;
+ update_opcode_kidx(cmd, p->kidx);
+ }
+
+free:
+ if (pidx_first != ci->obuf)
+ free(pidx_first, M_IPFW);
+
+ return (error);
+}
+
+/*
* Adds one or more rules to ipfw @chain.
* Data layout (version 0)(current):
* Request:
@@ -2646,7 +2797,7 @@ dump_soptcodes(struct ip_fw_chain *chain, ip_fw3_opheader *op3,
for (n = 1; n <= count; n++) {
i = (ipfw_sopt_info *)ipfw_get_sopt_space(sd, sizeof(*i));
- KASSERT(i != 0, ("previously checked buffer is not enough"));
+ KASSERT(i != NULL, ("previously checked buffer is not enough"));
sh = &ctl3_handlers[n];
i->opcode = sh->opcode;
i->version = sh->version;
@@ -2680,35 +2831,73 @@ compare_opcodes(const void *_a, const void *_b)
}
/*
- * Finds opcode object rewriter based on @code.
- *
- * Returns pointer to handler or NULL.
+ * XXX: Rewrite bsearch()
*/
-struct opcode_obj_rewrite *
-ipfw_find_op_rw(uint16_t opcode)
+static int
+find_op_rw_range(uint16_t op, struct opcode_obj_rewrite **plo,
+ struct opcode_obj_rewrite **phi)
{
- struct opcode_obj_rewrite *rw, h;
+ struct opcode_obj_rewrite *ctl3_max, *lo, *hi, h, *rw;
memset(&h, 0, sizeof(h));
- h.opcode = opcode;
+ h.opcode = op;
rw = (struct opcode_obj_rewrite *)bsearch(&h, ctl3_rewriters,
ctl3_rsize, sizeof(h), compare_opcodes);
+ if (rw == NULL)
+ return (1);
+
+ /* Find the first element matching the same opcode */
+ lo = rw;
+ for ( ; lo > ctl3_rewriters && (lo - 1)->opcode == op; lo--)
+ ;
- return (rw);
+ /* Find the last element matching the same opcode */
+ hi = rw;
+ ctl3_max = ctl3_rewriters + ctl3_rsize;
+ for ( ; (hi + 1) < ctl3_max && (hi + 1)->opcode == op; hi++)
+ ;
+
+ *plo = lo;
+ *phi = hi;
+
+ return (0);
}
+/*
+ * Finds opcode object rewriter based on @code.
+ *
+ * Returns pointer to handler or NULL.
+ */
+static struct opcode_obj_rewrite *
+find_op_rw(ipfw_insn *cmd, uint16_t *puidx, uint8_t *ptype)
+{
+ struct opcode_obj_rewrite *rw, *lo, *hi;
+ uint16_t uidx;
+ uint8_t subtype;
+
+ if (find_op_rw_range(cmd->opcode, &lo, &hi) != 0)
+ return (NULL);
+
+ for (rw = lo; rw <= hi; rw++) {
+ if (rw->classifier(cmd, &uidx, &subtype) == 0) {
+ if (puidx != NULL)
+ *puidx = uidx;
+ if (ptype != NULL)
+ *ptype = subtype;
+ return (rw);
+ }
+ }
+
+ return (NULL);
+}
int
classify_opcode_kidx(ipfw_insn *cmd, uint16_t *puidx)
{
- struct opcode_obj_rewrite *rw;
- uint8_t subtype;
- rw = ipfw_find_op_rw(cmd->opcode);
- if (rw == NULL)
+ if (find_op_rw(cmd, puidx, NULL) == 0)
return (1);
-
- return (rw->classifier(cmd, puidx, &subtype));
+ return (0);
}
void
@@ -2716,7 +2905,7 @@ update_opcode_kidx(ipfw_insn *cmd, uint16_t idx)
{
struct opcode_obj_rewrite *rw;
- rw = ipfw_find_op_rw(cmd->opcode);
+ rw = find_op_rw(cmd, NULL, NULL);
KASSERT(rw != NULL, ("No handler to update opcode %d", cmd->opcode));
rw->update(cmd, idx);
}
@@ -2784,20 +2973,26 @@ int
ipfw_del_obj_rewriter(struct opcode_obj_rewrite *rw, size_t count)
{
size_t sz;
- struct opcode_obj_rewrite *tmp, *h;
+ struct opcode_obj_rewrite *ctl3_max, *ktmp, *lo, *hi;
int i;
CTL3_LOCK();
for (i = 0; i < count; i++) {
- tmp = &rw[i];
- h = ipfw_find_op_rw(tmp->opcode);
- if (h == NULL)
+ if (find_op_rw_range(rw[i].opcode, &lo, &hi) != 0)
continue;
- sz = (ctl3_rewriters + ctl3_rsize - (h + 1)) * sizeof(*h);
- memmove(h, h + 1, sz);
- ctl3_rsize--;
+ for (ktmp = lo; ktmp <= hi; ktmp++) {
+ if (ktmp->classifier != rw[i].classifier)
+ continue;
+
+ ctl3_max = ctl3_rewriters + ctl3_rsize;
+ sz = (ctl3_max - (ktmp + 1)) * sizeof(*ktmp);
+ memmove(ktmp, ktmp + 1, sz);
+ ctl3_rsize--;
+ break;
+ }
+
}
if (ctl3_rsize == 0) {
@@ -2828,7 +3023,7 @@ export_objhash_ntlv_internal(struct namedobj_instance *ni,
/*
* Lists all service objects.
* Data layout (v0)(current):
- * Request: [ ipfw_obj_lheader ] size = ipfw_cfg_lheader.size
+ * Request: [ ipfw_obj_lheader ] size = ipfw_obj_lheader.size
* Reply: [ ipfw_obj_lheader [ ipfw_obj_ntlv x N ] (optional) ]
* Returns 0 on success
*/
@@ -3843,17 +4038,17 @@ ipfw_objhash_set_funcs(struct namedobj_instance *ni, objhash_hash_f *hash_f,
}
static uint32_t
-objhash_hash_name(struct namedobj_instance *ni, void *name, uint32_t set)
+objhash_hash_name(struct namedobj_instance *ni, const void *name, uint32_t set)
{
- return (fnv_32_str((char *)name, FNV1_32_INIT));
+ return (fnv_32_str((const char *)name, FNV1_32_INIT));
}
static int
-objhash_cmp_name(struct named_object *no, void *name, uint32_t set)
+objhash_cmp_name(struct named_object *no, const void *name, uint32_t set)
{
- if ((strcmp(no->name, (char *)name) == 0) && (no->set == set))
+ if ((strcmp(no->name, (const char *)name) == 0) && (no->set == set))
return (0);
return (1);
@@ -3886,11 +4081,90 @@ ipfw_objhash_lookup_name(struct namedobj_instance *ni, uint32_t set, char *name)
}
/*
+ * Find named object by @uid.
+ * Check @tlvs for valid data inside.
+ *
+ * Returns pointer to found TLV or NULL.
+ */
+static ipfw_obj_ntlv *
+find_name_tlv_type(void *tlvs, int len, uint16_t uidx, uint32_t etlv)
+{
+ ipfw_obj_ntlv *ntlv;
+ uintptr_t pa, pe;
+ int l;
+
+ pa = (uintptr_t)tlvs;
+ pe = pa + len;
+ l = 0;
+ for (; pa < pe; pa += l) {
+ ntlv = (ipfw_obj_ntlv *)pa;
+ l = ntlv->head.length;
+
+ if (l != sizeof(*ntlv))
+ return (NULL);
+
+ if (ntlv->idx != uidx)
+ continue;
+ /*
+ * When userland has specified zero TLV type, do
+ * not compare it with eltv. In some cases userland
+ * doesn't know what type should it have. Use only
+ * uidx and name for search named_object.
+ */
+ if (ntlv->head.type != 0 &&
+ ntlv->head.type != (uint16_t)etlv)
+ continue;
+
+ if (ipfw_check_object_name_generic(ntlv->name) != 0)
+ return (NULL);
+
+ return (ntlv);
+ }
+
+ return (NULL);
+}
+
+/*
+ * Finds object config based on either legacy index
+ * or name in ntlv.
+ * Note @ti structure contains unchecked data from userland.
+ *
+ * Returns 0 in success and fills in @pno with found config
+ */
+int
+ipfw_objhash_find_type(struct namedobj_instance *ni, struct tid_info *ti,
+ uint32_t etlv, struct named_object **pno)
+{
+ char *name;
+ ipfw_obj_ntlv *ntlv;
+ uint32_t set;
+
+ if (ti->tlvs == NULL)
+ return (EINVAL);
+
+ ntlv = find_name_tlv_type(ti->tlvs, ti->tlen, ti->uidx, etlv);
+ if (ntlv == NULL)
+ return (EINVAL);
+ name = ntlv->name;
+
+ /*
+ * Use set provided by @ti instead of @ntlv one.
+ * This is needed due to different sets behavior
+ * controlled by V_fw_tables_sets.
+ */
+ set = ti->set;
+ *pno = ipfw_objhash_lookup_name(ni, set, name);
+ if (*pno == NULL)
+ return (ESRCH);
+ return (0);
+}
+
+/*
* Find named object by name, considering also its TLV type.
*/
struct named_object *
ipfw_objhash_lookup_name_type(struct namedobj_instance *ni, uint32_t set,
- uint32_t type, char *name)
+ uint32_t type, const char *name)
{
struct named_object *no;
uint32_t hash;
@@ -3898,7 +4172,8 @@ ipfw_objhash_lookup_name_type(struct namedobj_instance *ni, uint32_t set,
hash = ni->hash_f(ni, name, set) % ni->nn_size;
TAILQ_FOREACH(no, &ni->names[hash], nn_next) {
- if (ni->cmp_f(no, name, set) == 0 && no->etlv == type)
+ if (ni->cmp_f(no, name, set) == 0 &&
+ no->etlv == (uint16_t)type)
return (no);
}
diff --git a/sys/netpfil/ipfw/ip_fw_table.c b/sys/netpfil/ipfw/ip_fw_table.c
index a1ee5dd..175202a 100644
--- a/sys/netpfil/ipfw/ip_fw_table.c
+++ b/sys/netpfil/ipfw/ip_fw_table.c
@@ -2130,7 +2130,7 @@ export_table_internal(struct namedobj_instance *ni, struct named_object *no,
dta = (struct dump_table_args *)arg;
i = (ipfw_xtable_info *)ipfw_get_sopt_space(dta->sd, sizeof(*i));
- KASSERT(i != 0, ("previously checked buffer is not enough"));
+ KASSERT(i != NULL, ("previously checked buffer is not enough"));
export_table_info(dta->ch, (struct table_config *)no, i);
}
@@ -2746,7 +2746,7 @@ list_table_algo(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
for (n = 1; n <= count; n++) {
i = (ipfw_ta_info *)ipfw_get_sopt_space(sd, sizeof(*i));
- KASSERT(i != 0, ("previously checked buffer is not enough"));
+ KASSERT(i != NULL, ("previously checked buffer is not enough"));
ta = tcfg->algo[n];
strlcpy(i->algoname, ta->name, sizeof(i->algoname));
i->type = ta->type;
@@ -3336,136 +3336,6 @@ ipfw_move_tables_sets(struct ip_fw_chain *ch, ipfw_range_tlv *rt,
return (bad);
}
-/*
- * Finds and bumps refcount for objects referenced by given @rule.
- * Auto-creates non-existing tables.
- * Fills in @oib array with userland/kernel indexes.
- *
- * Returns 0 on success.
- */
-static int
-ref_rule_objects(struct ip_fw_chain *ch, struct ip_fw *rule,
- struct rule_check_info *ci, struct obj_idx *oib, struct tid_info *ti)
-{
- int cmdlen, error, l, numnew;
- ipfw_insn *cmd;
- struct obj_idx *pidx;
- int found, unresolved;
-
- pidx = oib;
- l = rule->cmd_len;
- cmd = rule->cmd;
- cmdlen = 0;
- error = 0;
- numnew = 0;
- found = 0;
- unresolved = 0;
-
- IPFW_UH_WLOCK(ch);
-
- /* Increase refcount on each existing referenced table. */
- for ( ; l > 0 ; l -= cmdlen, cmd += cmdlen) {
- cmdlen = F_LEN(cmd);
-
- error = ref_opcode_object(ch, cmd, ti, pidx, &found, &unresolved);
- if (error != 0)
- break;
- if (found || unresolved) {
- pidx->off = rule->cmd_len - l;
- pidx++;
- }
- /*
- * Compability stuff for old clients:
- * prepare to manually create non-existing objects.
- */
- if (unresolved)
- numnew++;
- }
-
- if (error != 0) {
- /* Unref everything we have already done */
- unref_oib_objects(ch, rule->cmd, oib, pidx);
- IPFW_UH_WUNLOCK(ch);
- return (error);
- }
- IPFW_UH_WUNLOCK(ch);
-
- /* Perform auto-creation for non-existing objects */
- if (numnew != 0)
- error = create_objects_compat(ch, rule->cmd, oib, pidx, ti);
-
- /* Calculate real number of dynamic objects */
- ci->object_opcodes = (uint16_t)(pidx - oib);
-
- return (error);
-}
-
-/*
- * Checks is opcode is referencing table of appropriate type.
- * Adds reference count for found table if true.
- * Rewrites user-supplied opcode values with kernel ones.
- *
- * Returns 0 on success and appropriate error code otherwise.
- */
-int
-ipfw_rewrite_rule_uidx(struct ip_fw_chain *chain,
- struct rule_check_info *ci)
-{
- int error;
- ipfw_insn *cmd;
- uint8_t type;
- struct obj_idx *p, *pidx_first, *pidx_last;
- struct tid_info ti;
-
- /*
- * Prepare an array for storing opcode indices.
- * Use stack allocation by default.
- */
- if (ci->object_opcodes <= (sizeof(ci->obuf)/sizeof(ci->obuf[0]))) {
- /* Stack */
- pidx_first = ci->obuf;
- } else
- pidx_first = malloc(ci->object_opcodes * sizeof(struct obj_idx),
- M_IPFW, M_WAITOK | M_ZERO);
-
- error = 0;
- type = 0;
- memset(&ti, 0, sizeof(ti));
-
- /*
- * Use default set for looking up tables (old way) or
- * use set rule is assigned to (new way).
- */
- ti.set = (V_fw_tables_sets != 0) ? ci->krule->set : 0;
- if (ci->ctlv != NULL) {
- ti.tlvs = (void *)(ci->ctlv + 1);
- ti.tlen = ci->ctlv->head.length - sizeof(ipfw_obj_ctlv);
- }
-
- /* Reference all used tables and other objects */
- error = ref_rule_objects(chain, ci->krule, ci, pidx_first, &ti);
- if (error != 0)
- goto free;
- /*
- * Note that ref_rule_objects() might have updated ci->object_opcodes
- * to reflect actual number of object opcodes.
- */
-
- /* Perform rule rewrite */
- p = pidx_first;
- pidx_last = pidx_first + ci->object_opcodes;
- for (p = pidx_first; p < pidx_last; p++) {
- cmd = ci->krule->cmd + p->off;
- update_opcode_kidx(cmd, p->kidx);
- }
-
-free:
- if (pidx_first != ci->obuf)
- free(pidx_first, M_IPFW);
-
- return (error);
-}
-
static struct ipfw_sopt_handler scodes[] = {
{ IP_FW_TABLE_XCREATE, 0, HDIR_SET, create_table },
{ IP_FW_TABLE_XDESTROY, 0, HDIR_SET, flush_table_v0 },
diff --git a/sys/netpfil/ipfw/ip_fw_table_value.c b/sys/netpfil/ipfw/ip_fw_table_value.c
index a196b03..7e2f5cb 100644
--- a/sys/netpfil/ipfw/ip_fw_table_value.c
+++ b/sys/netpfil/ipfw/ip_fw_table_value.c
@@ -58,9 +58,10 @@ __FBSDID("$FreeBSD$");
#include <netpfil/ipfw/ip_fw_private.h>
#include <netpfil/ipfw/ip_fw_table.h>
-static uint32_t hash_table_value(struct namedobj_instance *ni, void *key,
+static uint32_t hash_table_value(struct namedobj_instance *ni, const void *key,
+ uint32_t kopt);
+static int cmp_table_value(struct named_object *no, const void *key,
uint32_t kopt);
-static int cmp_table_value(struct named_object *no, void *key, uint32_t kopt);
static int list_table_values(struct ip_fw_chain *ch, ip_fw3_opheader *op3,
struct sockopt_data *sd);
@@ -87,14 +88,14 @@ struct vdump_args {
static uint32_t
-hash_table_value(struct namedobj_instance *ni, void *key, uint32_t kopt)
+hash_table_value(struct namedobj_instance *ni, const void *key, uint32_t kopt)
{
return (hash32_buf(key, 56, 0));
}
static int
-cmp_table_value(struct named_object *no, void *key, uint32_t kopt)
+cmp_table_value(struct named_object *no, const void *key, uint32_t kopt)
{
return (memcmp(((struct table_val_link *)no)->pval, key, 56));
diff --git a/sys/ofed/drivers/infiniband/hw/mlx4/main.c b/sys/ofed/drivers/infiniband/hw/mlx4/main.c
index 1f14e5c..5be92a2 100644
--- a/sys/ofed/drivers/infiniband/hw/mlx4/main.c
+++ b/sys/ofed/drivers/infiniband/hw/mlx4/main.c
@@ -1297,7 +1297,7 @@ static int del_gid_entry(struct ib_qp *ibqp, union ib_gid *gid)
pr_warn("could not find mgid entry\n");
mutex_unlock(&mqp->mutex);
- return ge != 0 ? 0 : -EINVAL;
+ return ge != NULL ? 0 : -EINVAL;
}
static int _mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid,
diff --git a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 9a68b23..5bef672 100644
--- a/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -1485,7 +1485,7 @@ ipoib_resolvemulti(struct ifnet *ifp, struct sockaddr **llsa,
e_addr = LLADDR(sdl);
if (!IPOIB_IS_MULTICAST(e_addr))
return EADDRNOTAVAIL;
- *llsa = 0;
+ *llsa = NULL;
return 0;
#ifdef INET
diff --git a/sys/ofed/drivers/net/mlx4/en_netdev.c b/sys/ofed/drivers/net/mlx4/en_netdev.c
index ae7f857..896b782 100644
--- a/sys/ofed/drivers/net/mlx4/en_netdev.c
+++ b/sys/ofed/drivers/net/mlx4/en_netdev.c
@@ -1243,10 +1243,6 @@ int mlx4_en_start_port(struct net_device *dev)
/* Calculate Rx buf size */
dev->if_mtu = min(dev->if_mtu, priv->max_mtu);
mlx4_en_calc_rx_buf(dev);
- priv->rx_alloc_size = max_t(int, 2 * roundup_pow_of_two(priv->rx_mb_size),
- PAGE_SIZE);
- priv->rx_alloc_order = get_order(priv->rx_alloc_size);
- priv->rx_buf_size = roundup_pow_of_two(priv->rx_mb_size);
en_dbg(DRV, priv, "Rx buf size:%d\n", priv->rx_mb_size);
/* Configure rx cq's and rings */
diff --git a/sys/ofed/drivers/net/mlx4/en_rx.c b/sys/ofed/drivers/net/mlx4/en_rx.c
index b29096d..235a9ab 100644
--- a/sys/ofed/drivers/net/mlx4/en_rx.c
+++ b/sys/ofed/drivers/net/mlx4/en_rx.c
@@ -55,7 +55,7 @@ static void mlx4_en_init_rx_desc(struct mlx4_en_priv *priv,
int i;
/* Set size and memtype fields */
- rx_desc->data[0].byte_count = cpu_to_be32(priv->rx_mb_size);
+ rx_desc->data[0].byte_count = cpu_to_be32(priv->rx_mb_size - MLX4_NET_IP_ALIGN);
rx_desc->data[0].lkey = cpu_to_be32(priv->mdev->mr.key);
/*
@@ -87,7 +87,10 @@ mlx4_en_alloc_buf(struct mlx4_en_rx_ring *ring,
if (unlikely(mb == NULL))
return (-ENOMEM);
/* setup correct length */
- mb->m_len = ring->rx_mb_size;
+ mb->m_pkthdr.len = mb->m_len = ring->rx_mb_size;
+
+ /* make sure IP header gets aligned */
+ m_adj(mb, MLX4_NET_IP_ALIGN);
/* load spare mbuf into BUSDMA */
err = -bus_dmamap_load_mbuf_sg(ring->dma_tag, ring->spare.dma_map,
@@ -117,7 +120,10 @@ mlx4_en_alloc_buf(struct mlx4_en_rx_ring *ring,
goto use_spare;
/* setup correct length */
- mb->m_len = ring->rx_mb_size;
+ mb->m_pkthdr.len = mb->m_len = ring->rx_mb_size;
+
+ /* make sure IP header gets aligned */
+ m_adj(mb, MLX4_NET_IP_ALIGN);
err = -bus_dmamap_load_mbuf_sg(ring->dma_tag, mb_list->dma_map,
mb, segs, &nsegs, BUS_DMA_NOWAIT);
@@ -249,7 +255,8 @@ static void mlx4_en_free_rx_buf(struct mlx4_en_priv *priv,
void mlx4_en_calc_rx_buf(struct net_device *dev)
{
struct mlx4_en_priv *priv = netdev_priv(dev);
- int eff_mtu = dev->if_mtu + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN;
+ int eff_mtu = dev->if_mtu + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN +
+ MLX4_NET_IP_ALIGN;
if (eff_mtu > MJUM16BYTES) {
en_err(priv, "MTU(%d) is too big\n", dev->if_mtu);
@@ -384,9 +391,6 @@ int mlx4_en_activate_rx_rings(struct mlx4_en_priv *priv)
ring->cons = 0;
ring->actual_size = 0;
ring->cqn = priv->rx_cq[ring_ind]->mcq.cqn;
- ring->rx_alloc_order = priv->rx_alloc_order;
- ring->rx_alloc_size = priv->rx_alloc_size;
- ring->rx_buf_size = priv->rx_buf_size;
ring->rx_mb_size = priv->rx_mb_size;
ring->stride = stride;
diff --git a/sys/ofed/drivers/net/mlx4/en_tx.c b/sys/ofed/drivers/net/mlx4/en_tx.c
index 4358aa6..463efec 100644
--- a/sys/ofed/drivers/net/mlx4/en_tx.c
+++ b/sys/ofed/drivers/net/mlx4/en_tx.c
@@ -457,7 +457,7 @@ void mlx4_en_tx_irq(struct mlx4_cq *mcq)
struct mlx4_en_priv *priv = netdev_priv(cq->dev);
struct mlx4_en_tx_ring *ring = priv->tx_ring[cq->ring];
- if (!spin_trylock(&ring->comp_lock))
+ if (priv->port_up == 0 || !spin_trylock(&ring->comp_lock))
return;
mlx4_en_process_tx_cq(cq->dev, cq);
mod_timer(&cq->timer, jiffies + 1);
@@ -473,6 +473,8 @@ void mlx4_en_poll_tx_cq(unsigned long data)
INC_PERF_COUNTER(priv->pstats.tx_poll);
+ if (priv->port_up == 0)
+ return;
if (!spin_trylock(&ring->comp_lock)) {
mod_timer(&cq->timer, jiffies + MLX4_EN_TX_POLL_TIMEOUT);
return;
@@ -494,6 +496,9 @@ static inline void mlx4_en_xmit_poll(struct mlx4_en_priv *priv, int tx_ind)
struct mlx4_en_cq *cq = priv->tx_cq[tx_ind];
struct mlx4_en_tx_ring *ring = priv->tx_ring[tx_ind];
+ if (priv->port_up == 0)
+ return;
+
/* If we don't have a pending timer, set one up to catch our recent
post in case the interface becomes idle */
if (!timer_pending(&cq->timer))
@@ -1041,7 +1046,9 @@ mlx4_en_tx_que(void *context, int pending)
priv = dev->if_softc;
tx_ind = cq->ring;
ring = priv->tx_ring[tx_ind];
- if (dev->if_drv_flags & IFF_DRV_RUNNING) {
+
+ if (priv->port_up != 0 &&
+ (dev->if_drv_flags & IFF_DRV_RUNNING) != 0) {
mlx4_en_xmit_poll(priv, tx_ind);
spin_lock(&ring->tx_lock);
if (!drbr_empty(dev, ring->br))
@@ -1058,6 +1065,11 @@ mlx4_en_transmit(struct ifnet *dev, struct mbuf *m)
struct mlx4_en_cq *cq;
int i, err = 0;
+ if (priv->port_up == 0) {
+ m_freem(m);
+ return (ENETDOWN);
+ }
+
/* Compute which queue to use */
if (M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) {
i = (m->m_pkthdr.flowid % 128) % priv->tx_ring_num;
@@ -1091,6 +1103,9 @@ mlx4_en_qflush(struct ifnet *dev)
struct mlx4_en_tx_ring *ring;
struct mbuf *m;
+ if (priv->port_up == 0)
+ return;
+
for (int i = 0; i < priv->tx_ring_num; i++) {
ring = priv->tx_ring[i];
spin_lock(&ring->tx_lock);
diff --git a/sys/ofed/drivers/net/mlx4/mlx4_en.h b/sys/ofed/drivers/net/mlx4/mlx4_en.h
index a584bad..17afa9e 100644
--- a/sys/ofed/drivers/net/mlx4/mlx4_en.h
+++ b/sys/ofed/drivers/net/mlx4/mlx4_en.h
@@ -69,6 +69,7 @@
#define MLX4_EN_PAGE_SHIFT 12
#define MLX4_EN_PAGE_SIZE (1 << MLX4_EN_PAGE_SHIFT)
+#define MLX4_NET_IP_ALIGN 2 /* bytes */
#define DEF_RX_RINGS 16
#define MAX_RX_RINGS 128
#define MIN_RX_RINGS 4
@@ -315,9 +316,6 @@ struct mlx4_en_rx_ring {
u32 cons;
u32 buf_size;
u8 fcs_del;
- u16 rx_alloc_order;
- u32 rx_alloc_size;
- u32 rx_buf_size;
u32 rx_mb_size;
int qpn;
u8 *buf;
@@ -556,9 +554,6 @@ struct mlx4_en_priv {
u32 tx_ring_num;
u32 rx_ring_num;
u32 rx_mb_size;
- u16 rx_alloc_order;
- u32 rx_alloc_size;
- u32 rx_buf_size;
struct mlx4_en_tx_ring **tx_ring;
struct mlx4_en_rx_ring *rx_ring[MAX_RX_RINGS];
diff --git a/sys/powerpc/ofw/ofw_pcibus.c b/sys/powerpc/ofw/ofw_pcibus.c
index 4ce6e73..01e2343 100644
--- a/sys/powerpc/ofw/ofw_pcibus.c
+++ b/sys/powerpc/ofw/ofw_pcibus.c
@@ -59,6 +59,7 @@ typedef uint32_t ofw_pci_intr_t;
/* Methods */
static device_probe_t ofw_pcibus_probe;
static device_attach_t ofw_pcibus_attach;
+static pci_alloc_devinfo_t ofw_pcibus_alloc_devinfo;
static pci_assign_interrupt_t ofw_pcibus_assign_interrupt;
static ofw_bus_get_devinfo_t ofw_pcibus_get_devinfo;
static bus_child_deleted_t ofw_pcibus_child_deleted;
@@ -78,6 +79,7 @@ static device_method_t ofw_pcibus_methods[] = {
DEVMETHOD(bus_child_pnpinfo_str, ofw_pcibus_child_pnpinfo_str_method),
/* PCI interface */
+ DEVMETHOD(pci_alloc_devinfo, ofw_pcibus_alloc_devinfo),
DEVMETHOD(pci_assign_interrupt, ofw_pcibus_assign_interrupt),
/* ofw_bus interface */
@@ -144,6 +146,15 @@ ofw_pcibus_attach(device_t dev)
return (bus_generic_attach(dev));
}
+struct pci_devinfo *
+ofw_pcibus_alloc_devinfo(device_t dev)
+{
+ struct ofw_pcibus_devinfo *dinfo;
+
+ dinfo = malloc(sizeof(*dinfo), M_DEVBUF, M_WAITOK | M_ZERO);
+ return (&dinfo->opd_dinfo);
+}
+
static void
ofw_pcibus_enum_devtree(device_t dev, u_int domain, u_int busno)
{
@@ -185,8 +196,8 @@ ofw_pcibus_enum_devtree(device_t dev, u_int domain, u_int busno)
* to the PCI bus.
*/
- dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib,
- domain, busno, slot, func, sizeof(*dinfo));
+ dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib, dev,
+ domain, busno, slot, func);
if (dinfo == NULL)
continue;
if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) !=
@@ -244,7 +255,7 @@ ofw_pcibus_enum_bus(device_t dev, u_int domain, u_int busno)
continue;
dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(
- pcib, domain, busno, s, f, sizeof(*dinfo));
+ pcib, dev, domain, busno, s, f);
if (dinfo == NULL)
continue;
diff --git a/sys/powerpc/powerpc/db_disasm.c b/sys/powerpc/powerpc/db_disasm.c
index 6d525b3..71c35c5 100644
--- a/sys/powerpc/powerpc/db_disasm.c
+++ b/sys/powerpc/powerpc/db_disasm.c
@@ -836,9 +836,9 @@ disasm_fields(const struct opcode *popcode, instr_t instr, vm_offset_t loc,
reg = "tbu";
break;
default:
- reg = 0;
+ reg = NULL;
}
- if (reg == 0)
+ if (reg == NULL)
pstr += sprintf(pstr, ", [unknown tbr %d ]", tbr);
else
pstr += sprintf(pstr, ", %s", reg);
diff --git a/sys/powerpc/powerpc/elf32_machdep.c b/sys/powerpc/powerpc/elf32_machdep.c
index eed76c9..9954a33 100644
--- a/sys/powerpc/powerpc/elf32_machdep.c
+++ b/sys/powerpc/powerpc/elf32_machdep.c
@@ -257,7 +257,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
void
elf_reloc_self(Elf_Dyn *dynp, Elf_Addr relocbase)
{
- Elf_Rela *rela = 0, *relalim;
+ Elf_Rela *rela = NULL, *relalim;
Elf_Addr relasz = 0;
Elf_Addr *where;
diff --git a/sys/powerpc/powerpc/elf64_machdep.c b/sys/powerpc/powerpc/elf64_machdep.c
index 032728c..084200e 100644
--- a/sys/powerpc/powerpc/elf64_machdep.c
+++ b/sys/powerpc/powerpc/elf64_machdep.c
@@ -312,7 +312,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
void
elf_reloc_self(Elf_Dyn *dynp, Elf_Addr relocbase)
{
- Elf_Rela *rela = 0, *relalim;
+ Elf_Rela *rela = NULL, *relalim;
Elf_Addr relasz = 0;
Elf_Addr *where;
diff --git a/sys/powerpc/psim/iobus.c b/sys/powerpc/psim/iobus.c
index ce4a93a..37a23d1 100644
--- a/sys/powerpc/psim/iobus.c
+++ b/sys/powerpc/psim/iobus.c
@@ -272,7 +272,7 @@ iobus_read_ivar(device_t dev, device_t child, int which, uintptr_t *result)
{
struct iobus_devinfo *dinfo;
- if ((dinfo = device_get_ivars(child)) == 0)
+ if ((dinfo = device_get_ivars(child)) == NULL)
return (ENOENT);
switch (which) {
diff --git a/sys/riscv/riscv/nexus.c b/sys/riscv/riscv/nexus.c
index a4ced76..75e16b8 100644
--- a/sys/riscv/riscv/nexus.c
+++ b/sys/riscv/riscv/nexus.c
@@ -242,7 +242,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
}
rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0)
+ if (rv == NULL)
return (NULL);
rman_set_rid(rv, *rid);
diff --git a/sys/rpc/svc_vc.c b/sys/rpc/svc_vc.c
index 81cb755..58bdd01 100644
--- a/sys/rpc/svc_vc.c
+++ b/sys/rpc/svc_vc.c
@@ -416,7 +416,7 @@ svc_vc_rendezvous_recv(SVCXPRT *xprt, struct rpc_msg *msg,
sx_xunlock(&xprt->xp_lock);
- sa = 0;
+ sa = NULL;
error = soaccept(so, &sa);
if (error) {
diff --git a/sys/sparc64/ebus/ebus.c b/sys/sparc64/ebus/ebus.c
index 49abe18..55a90a3 100644
--- a/sys/sparc64/ebus/ebus.c
+++ b/sys/sparc64/ebus/ebus.c
@@ -370,7 +370,7 @@ ebus_pci_attach(device_t dev)
eri = &sc->sc_rinfo[i];
if (i < rnum)
rman_fini(&eri->eri_rman);
- if (eri->eri_res != 0) {
+ if (eri->eri_res != NULL) {
bus_release_resource(dev, eri->eri_rtype,
PCIR_BAR(rnum), eri->eri_res);
}
diff --git a/sys/sparc64/pci/ofw_pcibus.c b/sys/sparc64/pci/ofw_pcibus.c
index 08ffa5d..11f19cf 100644
--- a/sys/sparc64/pci/ofw_pcibus.c
+++ b/sys/sparc64/pci/ofw_pcibus.c
@@ -70,6 +70,7 @@ static bus_child_pnpinfo_str_t ofw_pcibus_pnpinfo_str;
static device_attach_t ofw_pcibus_attach;
static device_probe_t ofw_pcibus_probe;
static ofw_bus_get_devinfo_t ofw_pcibus_get_devinfo;
+static pci_alloc_devinfo_t ofw_pcibus_alloc_devinfo;
static pci_assign_interrupt_t ofw_pcibus_assign_interrupt;
static device_method_t ofw_pcibus_methods[] = {
@@ -82,6 +83,7 @@ static device_method_t ofw_pcibus_methods[] = {
DEVMETHOD(bus_child_pnpinfo_str, ofw_pcibus_pnpinfo_str),
/* PCI interface */
+ DEVMETHOD(pci_alloc_devinfo, ofw_pcibus_alloc_devinfo),
DEVMETHOD(pci_assign_interrupt, ofw_pcibus_assign_interrupt),
/* ofw_bus interface */
@@ -250,8 +252,8 @@ ofw_pcibus_attach(device_t dev)
if (strcmp(device_get_name(device_get_parent(pcib)), "nexus") == 0 &&
ofw_bus_get_type(pcib) != NULL &&
strcmp(ofw_bus_get_type(pcib), OFW_TYPE_PCIE) != 0 &&
- (dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib,
- domain, busno, 0, 0, sizeof(*dinfo))) != NULL) {
+ (dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib, dev,
+ domain, busno, 0, 0)) != NULL) {
if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, node) != 0)
pci_freecfg((struct pci_devinfo *)dinfo);
else
@@ -270,8 +272,8 @@ ofw_pcibus_attach(device_t dev)
if (pci_find_dbsf(domain, busno, slot, func) != NULL)
continue;
ofw_pcibus_setup_device(pcib, clock, busno, slot, func);
- dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib,
- domain, busno, slot, func, sizeof(*dinfo));
+ dinfo = (struct ofw_pcibus_devinfo *)pci_read_device(pcib, dev,
+ domain, busno, slot, func);
if (dinfo == NULL)
continue;
if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) !=
@@ -286,6 +288,15 @@ ofw_pcibus_attach(device_t dev)
return (bus_generic_attach(dev));
}
+struct pci_devinfo *
+ofw_pcibus_alloc_devinfo(device_t dev)
+{
+ struct ofw_pcibus_devinfo *dinfo;
+
+ dinfo = malloc(sizeof(*dinfo), M_DEVBUF, M_WAITOK | M_ZERO);
+ return (&dinfo->opd_dinfo);
+}
+
static int
ofw_pcibus_assign_interrupt(device_t dev, device_t child)
{
diff --git a/sys/sys/bio.h b/sys/sys/bio.h
index 8b3a5fc..37fefbf 100644
--- a/sys/sys/bio.h
+++ b/sys/sys/bio.h
@@ -77,10 +77,10 @@ typedef void bio_task_t(void *);
* The bio structure describes an I/O operation in the kernel.
*/
struct bio {
- uint8_t bio_cmd; /* I/O operation. */
- uint8_t bio_flags; /* General flags. */
- uint8_t bio_cflags; /* Private use by the consumer. */
- uint8_t bio_pflags; /* Private use by the provider. */
+ uint16_t bio_cmd; /* I/O operation. */
+ uint16_t bio_flags; /* General flags. */
+ uint16_t bio_cflags; /* Private use by the consumer. */
+ uint16_t bio_pflags; /* Private use by the provider. */
struct cdev *bio_dev; /* Device to do I/O on. */
struct disk *bio_disk; /* Valid below geom_disk.c only */
off_t bio_offset; /* Offset into file. */
diff --git a/sys/sys/buf.h b/sys/sys/buf.h
index c85b88f..4255afd 100644
--- a/sys/sys/buf.h
+++ b/sys/sys/buf.h
@@ -98,8 +98,8 @@ struct buf {
void *b_caller1;
caddr_t b_data;
int b_error;
- uint8_t b_iocmd;
- uint8_t b_ioflags;
+ uint16_t b_iocmd; /* BIO_* bio_cmd from bio.h */
+ uint16_t b_ioflags; /* BIO_* bio_flags from bio.h */
off_t b_iooffset;
long b_resid;
void (*b_iodone)(struct buf *);
diff --git a/sys/sys/conf.h b/sys/sys/conf.h
index 6d2cac9..b7d9756 100644
--- a/sys/sys/conf.h
+++ b/sys/sys/conf.h
@@ -328,15 +328,18 @@ EVENTHANDLER_DECLARE(dev_clone, dev_clone_fn);
struct dumperinfo {
dumper_t *dumper; /* Dumping function. */
- void *priv; /* Private parts. */
- u_int blocksize; /* Size of block in bytes. */
+ void *priv; /* Private parts. */
+ u_int blocksize; /* Size of block in bytes. */
u_int maxiosize; /* Max size allowed for an individual I/O */
- off_t mediaoffset; /* Initial offset in bytes. */
- off_t mediasize; /* Space available in bytes. */
+ off_t mediaoffset; /* Initial offset in bytes. */
+ off_t mediasize; /* Space available in bytes. */
+ void *blockbuf; /* Buffer for padding shorter dump blocks */
};
int set_dumper(struct dumperinfo *, const char *_devname, struct thread *td);
int dump_write(struct dumperinfo *, void *, vm_offset_t, off_t, size_t);
+int dump_write_pad(struct dumperinfo *, void *, vm_offset_t, off_t, size_t,
+ size_t *);
int doadump(boolean_t);
extern int dumping; /* system is dumping */
diff --git a/sys/sys/kernel.h b/sys/sys/kernel.h
index dddf087..02628ba 100644
--- a/sys/sys/kernel.h
+++ b/sys/sys/kernel.h
@@ -317,6 +317,44 @@ struct tunable_ulong {
#define TUNABLE_ULONG_FETCH(path, var) getenv_ulong((path), (var))
/*
+ * int64_t
+ */
+extern void tunable_int64_init(void *);
+struct tunable_int64 {
+ const char *path;
+ int64_t *var;
+};
+#define TUNABLE_INT64(path, var) \
+ static struct tunable_int64 __CONCAT(__tunable_int64_, __LINE__) = { \
+ (path), \
+ (var), \
+ }; \
+ SYSINIT(__CONCAT(__Tunable_init_, __LINE__), \
+ SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_int64_init, \
+ &__CONCAT(__tunable_int64_, __LINE__))
+
+#define TUNABLE_INT64_FETCH(path, var) getenv_int64((path), (var))
+
+/*
+ * uint64_t
+ */
+extern void tunable_uint64_init(void *);
+struct tunable_uint64 {
+ const char *path;
+ uint64_t *var;
+};
+#define TUNABLE_UINT64(path, var) \
+ static struct tunable_ulong __CONCAT(__tunable_uint64_, __LINE__) = { \
+ (path), \
+ (var), \
+ }; \
+ SYSINIT(__CONCAT(__Tunable_init_, __LINE__), \
+ SI_SUB_TUNABLES, SI_ORDER_MIDDLE, tunable_uint64_init, \
+ &__CONCAT(__tunable_uint64_, __LINE__))
+
+#define TUNABLE_UINT64_FETCH(path, var) getenv_uint64((path), (var))
+
+/*
* quad
*/
extern void tunable_quad_init(void *);
diff --git a/sys/sys/module.h b/sys/sys/module.h
index f0192d5..07464fc 100644
--- a/sys/sys/module.h
+++ b/sys/sys/module.h
@@ -166,7 +166,7 @@ struct mod_pnp_match_info
/**
* Generic macros to create pnp info hints that modules may export
- * to allow external tools to parse their intenral device tables
+ * to allow external tools to parse their internal device tables
* to make an informed guess about what driver(s) to load.
*/
#define MODULE_PNP_INFO(d, b, unique, t, l, n) \
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index 9c6e450..34ad5ba 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -322,6 +322,8 @@ int getenv_uint(const char *name, unsigned int *data);
int getenv_long(const char *name, long *data);
int getenv_ulong(const char *name, unsigned long *data);
int getenv_string(const char *name, char *data, int size);
+int getenv_int64(const char *name, int64_t *data);
+int getenv_uint64(const char *name, uint64_t *data);
int getenv_quad(const char *name, quad_t *data);
int kern_setenv(const char *name, const char *value);
int kern_unsetenv(const char *name);
diff --git a/sys/x86/acpica/OsdEnvironment.c b/sys/x86/acpica/OsdEnvironment.c
index be612b5..ab8a7fb 100644
--- a/sys/x86/acpica/OsdEnvironment.c
+++ b/sys/x86/acpica/OsdEnvironment.c
@@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <sys/bus.h>
+#include <sys/kernel.h>
#include <sys/sysctl.h>
#include <contrib/dev/acpica/include/acpi.h>
@@ -59,6 +60,16 @@ acpi_get_root_from_loader(void)
{
long acpi_root;
+ if (TUNABLE_ULONG_FETCH("acpi.rsdp", &acpi_root))
+ return (acpi_root);
+
+ /*
+ * The hints mechanism is unreliable (it fails if anybody ever
+ * compiled in hints to the kernel). It has been replaced
+ * by the tunable method, but is used here as a fallback to
+ * retain maximum compatibility between old loaders and new
+ * kernels. It can be removed after 11.0R.
+ */
if (resource_long_value("acpi", 0, "rsdp", &acpi_root) == 0)
return (acpi_root);
diff --git a/sys/x86/x86/busdma_bounce.c b/sys/x86/x86/busdma_bounce.c
index 6e9aa70..78d04b9 100644
--- a/sys/x86/x86/busdma_bounce.c
+++ b/sys/x86/x86/busdma_bounce.c
@@ -476,7 +476,8 @@ _bus_dmamap_count_phys(bus_dma_tag_t dmat, bus_dmamap_t map, vm_paddr_t buf,
while (buflen != 0) {
sgsize = MIN(buflen, dmat->common.maxsegsz);
if (bus_dma_run_filter(&dmat->common, curaddr)) {
- sgsize = MIN(PAGE_SIZE, sgsize);
+ sgsize = MIN(sgsize,
+ PAGE_SIZE - (curaddr & PAGE_MASK));
map->pagesneeded++;
}
curaddr += sgsize;
@@ -516,7 +517,8 @@ _bus_dmamap_count_pages(bus_dma_tag_t dmat, bus_dmamap_t map, pmap_t pmap,
else
paddr = pmap_extract(pmap, vaddr);
if (bus_dma_run_filter(&dmat->common, paddr) != 0) {
- sg_len = PAGE_SIZE;
+ sg_len = roundup2(sg_len,
+ dmat->common.alignment);
map->pagesneeded++;
}
vaddr += sg_len;
@@ -552,7 +554,9 @@ _bus_dmamap_count_ma(bus_dma_tag_t dmat, bus_dmamap_t map, struct vm_page **ma,
max_sgsize = MIN(buflen, dmat->common.maxsegsz);
sg_len = MIN(sg_len, max_sgsize);
if (bus_dma_run_filter(&dmat->common, paddr) != 0) {
- sg_len = MIN(PAGE_SIZE, max_sgsize);
+ sg_len = roundup2(sg_len,
+ dmat->common.alignment);
+ sg_len = MIN(sg_len, max_sgsize);
KASSERT((sg_len & (dmat->common.alignment - 1))
== 0, ("Segment size is not aligned"));
map->pagesneeded++;
@@ -648,7 +652,7 @@ bounce_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map,
int *segp)
{
bus_size_t sgsize;
- bus_addr_t curaddr, nextaddr;
+ bus_addr_t curaddr;
int error;
if (map == NULL)
@@ -672,12 +676,9 @@ bounce_bus_dmamap_load_phys(bus_dma_tag_t dmat, bus_dmamap_t map,
if (((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) &&
map->pagesneeded != 0 &&
bus_dma_run_filter(&dmat->common, curaddr)) {
- nextaddr = 0;
- sgsize = MIN(PAGE_SIZE, sgsize);
- if ((curaddr & PAGE_MASK) + sgsize > PAGE_SIZE)
- nextaddr = roundup2(curaddr, PAGE_SIZE);
- curaddr = add_bounce_page(dmat, map, 0, curaddr,
- nextaddr, sgsize);
+ sgsize = MIN(sgsize, PAGE_SIZE - (curaddr & PAGE_MASK));
+ curaddr = add_bounce_page(dmat, map, 0, curaddr, 0,
+ sgsize);
}
sgsize = _bus_dmamap_addseg(dmat, map, curaddr, sgsize, segs,
segp);
@@ -743,7 +744,8 @@ bounce_bus_dmamap_load_buffer(bus_dma_tag_t dmat, bus_dmamap_t map, void *buf,
if (((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) &&
map->pagesneeded != 0 &&
bus_dma_run_filter(&dmat->common, curaddr)) {
- sgsize = MIN(PAGE_SIZE, max_sgsize);
+ sgsize = roundup2(sgsize, dmat->common.alignment);
+ sgsize = MIN(sgsize, max_sgsize);
curaddr = add_bounce_page(dmat, map, kvaddr, curaddr, 0,
sgsize);
} else {
@@ -772,6 +774,17 @@ bounce_bus_dmamap_load_ma(bus_dma_tag_t dmat, bus_dmamap_t map,
int error, page_index;
bus_size_t sgsize, max_sgsize;
+ if (dmat->common.flags & BUS_DMA_KEEP_PG_OFFSET) {
+ /*
+ * If we have to keep the offset of each page this function
+ * is not suitable, switch back to bus_dmamap_load_ma_triv
+ * which is going to do the right thing in this case.
+ */
+ error = bus_dmamap_load_ma_triv(dmat, map, ma, buflen, ma_offs,
+ flags, segs, segp);
+ return (error);
+ }
+
if (map == NULL)
map = &nobounce_dmamap;
@@ -798,7 +811,10 @@ bounce_bus_dmamap_load_ma(bus_dma_tag_t dmat, bus_dmamap_t map,
if (((dmat->bounce_flags & BUS_DMA_COULD_BOUNCE) != 0) &&
map->pagesneeded != 0 &&
bus_dma_run_filter(&dmat->common, paddr)) {
- sgsize = MIN(PAGE_SIZE, max_sgsize);
+ sgsize = roundup2(sgsize, dmat->common.alignment);
+ sgsize = MIN(sgsize, max_sgsize);
+ KASSERT((sgsize & (dmat->common.alignment - 1)) == 0,
+ ("Segment size is not aligned"));
/*
* Check if two pages of the user provided buffer
* are used.
@@ -1159,6 +1175,13 @@ add_bounce_page(bus_dma_tag_t dmat, bus_dmamap_t map, vm_offset_t vaddr,
bz->active_bpages++;
mtx_unlock(&bounce_lock);
+ if (dmat->common.flags & BUS_DMA_KEEP_PG_OFFSET) {
+ /* Page offset needs to be preserved. */
+ bpage->vaddr |= addr1 & PAGE_MASK;
+ bpage->busaddr |= addr1 & PAGE_MASK;
+ KASSERT(addr2 == 0,
+ ("Trying to bounce multiple pages with BUS_DMA_KEEP_PG_OFFSET"));
+ }
bpage->datavaddr = vaddr;
bpage->datapage[0] = PHYS_TO_VM_PAGE(addr1);
KASSERT((addr2 & PAGE_MASK) == 0, ("Second page is not aligned"));
@@ -1178,6 +1201,15 @@ free_bounce_page(bus_dma_tag_t dmat, struct bounce_page *bpage)
bz = dmat->bounce_zone;
bpage->datavaddr = 0;
bpage->datacount = 0;
+ if (dmat->common.flags & BUS_DMA_KEEP_PG_OFFSET) {
+ /*
+ * Reset the bounce page to start at offset 0. Other uses
+ * of this bounce page may need to store a full page of
+ * data and/or assume it starts on a page boundary.
+ */
+ bpage->vaddr &= ~PAGE_MASK;
+ bpage->busaddr &= ~PAGE_MASK;
+ }
mtx_lock(&bounce_lock);
STAILQ_INSERT_HEAD(&bz->bounce_page_list, bpage, links);
diff --git a/sys/x86/x86/local_apic.c b/sys/x86/x86/local_apic.c
index 5830b77..854bda4 100644
--- a/sys/x86/x86/local_apic.c
+++ b/sys/x86/x86/local_apic.c
@@ -170,7 +170,7 @@ vm_paddr_t lapic_paddr;
int x2apic_mode;
int lapic_eoi_suppression;
static int lapic_timer_tsc_deadline;
-static u_long lapic_timer_divisor;
+static u_long lapic_timer_divisor, count_freq;
static struct eventtimer lapic_et;
#ifdef SMP
static uint64_t lapic_ipi_wait_mult;
@@ -814,20 +814,46 @@ lapic_calibrate_initcount(struct eventtimer *et, struct lapic *la)
printf("lapic: Divisor %lu, Frequency %lu Hz\n",
lapic_timer_divisor, value);
}
- et->et_frequency = value;
+ count_freq = value;
}
static void
lapic_calibrate_deadline(struct eventtimer *et, struct lapic *la __unused)
{
- et->et_frequency = tsc_freq;
if (bootverbose) {
printf("lapic: deadline tsc mode, Frequency %ju Hz\n",
- (uintmax_t)et->et_frequency);
+ (uintmax_t)tsc_freq);
}
}
+static void
+lapic_change_mode(struct eventtimer *et, struct lapic *la,
+ enum lat_timer_mode newmode)
+{
+
+ if (la->la_timer_mode == newmode)
+ return;
+ switch (newmode) {
+ case LAT_MODE_PERIODIC:
+ lapic_timer_set_divisor(lapic_timer_divisor);
+ et->et_frequency = count_freq;
+ break;
+ case LAT_MODE_DEADLINE:
+ et->et_frequency = tsc_freq;
+ break;
+ case LAT_MODE_ONESHOT:
+ lapic_timer_set_divisor(lapic_timer_divisor);
+ et->et_frequency = count_freq;
+ break;
+ default:
+ panic("lapic_change_mode %d", newmode);
+ }
+ la->la_timer_mode = newmode;
+ et->et_min_period = (0x00000002LLU << 32) / et->et_frequency;
+ et->et_max_period = (0xfffffffeLLU << 32) / et->et_frequency;
+}
+
static int
lapic_et_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
{
@@ -835,28 +861,21 @@ lapic_et_start(struct eventtimer *et, sbintime_t first, sbintime_t period)
la = &lapics[PCPU_GET(apic_id)];
if (et->et_frequency == 0) {
+ lapic_calibrate_initcount(et, la);
if (lapic_timer_tsc_deadline)
lapic_calibrate_deadline(et, la);
- else
- lapic_calibrate_initcount(et, la);
- et->et_min_period = (0x00000002LLU << 32) / et->et_frequency;
- et->et_max_period = (0xfffffffeLLU << 32) / et->et_frequency;
}
if (period != 0) {
- if (la->la_timer_mode == LAT_MODE_UNDEF)
- lapic_timer_set_divisor(lapic_timer_divisor);
- la->la_timer_mode = LAT_MODE_PERIODIC;
+ lapic_change_mode(et, la, LAT_MODE_PERIODIC);
la->la_timer_period = ((uint32_t)et->et_frequency * period) >>
32;
lapic_timer_periodic(la);
} else if (lapic_timer_tsc_deadline) {
- la->la_timer_mode = LAT_MODE_DEADLINE;
+ lapic_change_mode(et, la, LAT_MODE_DEADLINE);
la->la_timer_period = (et->et_frequency * first) >> 32;
lapic_timer_deadline(la);
} else {
- if (la->la_timer_mode == LAT_MODE_UNDEF)
- lapic_timer_set_divisor(lapic_timer_divisor);
- la->la_timer_mode = LAT_MODE_ONESHOT;
+ lapic_change_mode(et, la, LAT_MODE_ONESHOT);
la->la_timer_period = ((uint32_t)et->et_frequency * first) >>
32;
lapic_timer_oneshot(la);
diff --git a/sys/x86/x86/nexus.c b/sys/x86/x86/nexus.c
index 8b49d41..5d4c37e 100644
--- a/sys/x86/x86/nexus.c
+++ b/sys/x86/x86/nexus.c
@@ -397,7 +397,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
return (NULL);
rv = rman_reserve_resource(rm, start, end, count, flags, child);
- if (rv == 0)
+ if (rv == NULL)
return 0;
rman_set_rid(rv, *rid);
@@ -526,7 +526,7 @@ nexus_setup_intr(device_t bus, device_t child, struct resource *irq,
if (irq == NULL)
panic("nexus_setup_intr: NULL irq resource!");
- *cookiep = 0;
+ *cookiep = NULL;
if ((rman_get_flags(irq) & RF_SHAREABLE) == 0)
flags |= INTR_EXCL;
diff --git a/sys/xdr/xdr_mem.c b/sys/xdr/xdr_mem.c
index 74bab3b..8a14f17 100644
--- a/sys/xdr/xdr_mem.c
+++ b/sys/xdr/xdr_mem.c
@@ -214,7 +214,7 @@ xdrmem_setpos(XDR *xdrs, u_int pos)
static int32_t *
xdrmem_inline_aligned(XDR *xdrs, u_int len)
{
- int32_t *buf = 0;
+ int32_t *buf = NULL;
if (xdrs->x_handy >= len) {
xdrs->x_handy -= len;
diff --git a/targets/pseudo/userland/lib/Makefile.depend b/targets/pseudo/userland/lib/Makefile.depend
index 7b911fe..dac8074 100644
--- a/targets/pseudo/userland/lib/Makefile.depend
+++ b/targets/pseudo/userland/lib/Makefile.depend
@@ -117,6 +117,7 @@ DIRDEPS = \
lib/libpam/modules/pam_ssh \
lib/libpam/modules/pam_tacplus \
lib/libpam/modules/pam_unix \
+ lib/libpam/static_libpam \
lib/libpcap \
lib/libpe \
lib/libpjdlog \
diff --git a/tests/sys/aio/aio_test.c b/tests/sys/aio/aio_test.c
index 5515161..1b10088 100644
--- a/tests/sys/aio/aio_test.c
+++ b/tests/sys/aio/aio_test.c
@@ -722,6 +722,65 @@ finished:
close(fd);
}
+/*
+ * This tests for a bug where arriving socket data can wakeup multiple
+ * AIO read requests resulting in an uncancellable request.
+ */
+ATF_TC_WITHOUT_HEAD(aio_socket_two_reads);
+ATF_TC_BODY(aio_socket_two_reads, tc)
+{
+ struct ioreq {
+ struct aiocb iocb;
+ char buffer[1024];
+ } ioreq[2];
+ struct aiocb *iocb;
+ unsigned i;
+ int s[2];
+ char c;
+
+ ATF_REQUIRE_KERNEL_MODULE("aio");
+#if __FreeBSD_version < 1100101
+ aft_tc_skip("kernel version %d is too old (%d required)",
+ __FreeBSD_version, 1100101);
+#endif
+
+ ATF_REQUIRE(socketpair(PF_UNIX, SOCK_STREAM, 0, s) != -1);
+
+ /* Queue two read requests. */
+ memset(&ioreq, 0, sizeof(ioreq));
+ for (i = 0; i < nitems(ioreq); i++) {
+ ioreq[i].iocb.aio_nbytes = sizeof(ioreq[i].buffer);
+ ioreq[i].iocb.aio_fildes = s[0];
+ ioreq[i].iocb.aio_buf = ioreq[i].buffer;
+ ATF_REQUIRE(aio_read(&ioreq[i].iocb) == 0);
+ }
+
+ /* Send a single byte. This should complete one request. */
+ c = 0xc3;
+ ATF_REQUIRE(write(s[1], &c, sizeof(c)) == 1);
+
+ ATF_REQUIRE(aio_waitcomplete(&iocb, NULL) == 1);
+
+ /* Determine which request completed and verify the data was read. */
+ if (iocb == &ioreq[0].iocb)
+ i = 0;
+ else
+ i = 1;
+ ATF_REQUIRE(ioreq[i].buffer[0] == c);
+
+ i ^= 1;
+
+ /*
+ * Try to cancel the other request. On broken systems this
+ * will fail and the process will hang on exit.
+ */
+ ATF_REQUIRE(aio_error(&ioreq[i].iocb) == EINPROGRESS);
+ ATF_REQUIRE(aio_cancel(s[0], &ioreq[i].iocb) == AIO_CANCELED);
+
+ close(s[1]);
+ close(s[0]);
+}
+
ATF_TP_ADD_TCS(tp)
{
@@ -732,6 +791,7 @@ ATF_TP_ADD_TCS(tp)
ATF_TP_ADD_TC(tp, aio_pipe_test);
ATF_TP_ADD_TC(tp, aio_md_test);
ATF_TP_ADD_TC(tp, aio_large_read_test);
+ ATF_TP_ADD_TC(tp, aio_socket_two_reads);
return (atf_no_error());
}
diff --git a/tests/sys/file/flock_helper.c b/tests/sys/file/flock_helper.c
index 49e47b8..0fca15e 100644
--- a/tests/sys/file/flock_helper.c
+++ b/tests/sys/file/flock_helper.c
@@ -1566,7 +1566,7 @@ main(int argc, const char *argv[])
} else {
testnum = 0;
test_argc = 0;
- test_argv = 0;
+ test_argv = NULL;
}
sa.sa_handler = ignore_alarm;
diff --git a/tools/build/options/WITHOUT_INSTALLLIB b/tools/build/options/WITHOUT_INSTALLLIB
index bfd313f..e2aba136 100644
--- a/tools/build/options/WITHOUT_INSTALLLIB
+++ b/tools/build/options/WITHOUT_INSTALLLIB
@@ -3,3 +3,6 @@ Set this if you do not want to install optional libraries.
For example when creating a
.Xr nanobsd 8
image.
+.Bf -symbolic
+The option does not work for build targets.
+.Ef
diff --git a/tools/build/options/WITHOUT_TOOLCHAIN b/tools/build/options/WITHOUT_TOOLCHAIN
index 2aa4217..b45f2f3 100644
--- a/tools/build/options/WITHOUT_TOOLCHAIN
+++ b/tools/build/options/WITHOUT_TOOLCHAIN
@@ -2,6 +2,3 @@
Set to not install header or
programs used for program development,
compilers, debuggers etc.
-.Bf -symbolic
-The option does not work for build targets.
-.Ef
diff --git a/tools/build/options/WITH_DIRDEPS_BUILD b/tools/build/options/WITH_DIRDEPS_BUILD
index 981c1a9..334c483 100644
--- a/tools/build/options/WITH_DIRDEPS_BUILD
+++ b/tools/build/options/WITH_DIRDEPS_BUILD
@@ -1,9 +1,9 @@
.\" $FreeBSD$
-Enable building in meta mode.
-This is an experimental build feature.
+This is an experimental build system.
For details see
http://www.crufty.net/sjg/docs/freebsd-meta-mode.htm.
-.Pp
+Build commands can be seen from the top-level with:
+.Dl make show-valid-targets
The build is driven by dirdeps.mk using
.Va DIRDEPS
stored in
@@ -23,17 +23,13 @@ and child directories.
.Va NO_DIRDEPS_BELOW
will skip building any dirdeps and only build the current directory.
.Pp
-As each target is made
-.Xr make 1
-produces a meta file which is used to capture (and compare)
-the command line,
-as well as any command output.
-If
-.Xr filemon 4
-is available the meta file will also capture a record of files
-used to produce the target by tracking syscalls.
+This also utilizes the
+.Va WITH_META_MODE
+logic for incremental builds.
.Pp
The build will hide commands ran unless
.Va NO_SILENT
is defined.
.Pp
+Note that there is currently no mass install feature for this.
+.Pp
diff --git a/tools/build/options/WITH_META_MODE b/tools/build/options/WITH_META_MODE
index 906b557..1d19be1e 100644
--- a/tools/build/options/WITH_META_MODE
+++ b/tools/build/options/WITH_META_MODE
@@ -1,12 +1,41 @@
.\" $FreeBSD$
-Create meta files when not doing DIRDEPS_BUILD.
+Creates
+.Xr make 1
+meta files when building, which can provide a reliable incremental build when
+using
+.Xr filemon 4 .
+The meta file is created in the OBJDIR as
+.Pa target.meta .
+These meta files track the command ran, its output, and the current directory.
When the
.Xr filemon 4
-module is loaded, dependencies will be tracked for all commands.
-If any command, its dependencies, or files it generates are missing then
-the target will be considered out-of-date and rebuilt.
+module is loaded, any files used by the commands executed will be tracked as
+dependencies for the target in its meta file.
+The target will be considered out-of-date and rebuilt if any of the following
+are true compared to the last build:
+.Bl -bullet -compact
+.It
+The command to execute changes.
+.It
+The current working directory changes.
+.It
+The target's meta file is missing.
+.It
+[requires
+.Xr filemon 4 ]
+Files read, executed or linked to are newer than the target.
+.It
+[requires
+.Xr filemon 4 ]
+Files read, written, executed or linked are missing.
+.El
The meta files can also be useful for debugging.
.Pp
The build will hide commands ran unless
.Va NO_SILENT
is defined.
+.Pp
+The build operates as it normally would otherwise.
+This option originally invoked a different build system but that was renamed
+to
+.Va WITH_DIRDEPS_BUILD .
diff --git a/tools/regression/capsicum/libcasper/dns.c b/tools/regression/capsicum/libcasper/dns.c
index eb364da..51839c1 100644
--- a/tools/regression/capsicum/libcasper/dns.c
+++ b/tools/regression/capsicum/libcasper/dns.c
@@ -72,6 +72,63 @@ static int ntest = 1;
#define GETHOSTBYNAME2_AF_INET6 0x04
#define GETHOSTBYADDR_AF_INET 0x08
#define GETHOSTBYADDR_AF_INET6 0x10
+#define GETADDRINFO_AF_UNSPEC 0x20
+#define GETADDRINFO_AF_INET 0x40
+#define GETADDRINFO_AF_INET6 0x80
+
+static bool
+addrinfo_compare(struct addrinfo *ai0, struct addrinfo *ai1)
+{
+ struct addrinfo *at0, *at1;
+
+ if (ai0 == NULL && ai1 == NULL)
+ return (true);
+ if (ai0 == NULL || ai1 == NULL)
+ return (false);
+
+ at0 = ai0;
+ at1 = ai1;
+ while (true) {
+ if ((at0->ai_flags == at1->ai_flags) &&
+ (at0->ai_family == at1->ai_family) &&
+ (at0->ai_socktype == at1->ai_socktype) &&
+ (at0->ai_protocol == at1->ai_protocol) &&
+ (at0->ai_addrlen == at1->ai_addrlen) &&
+ (memcmp(at0->ai_addr, at1->ai_addr,
+ at0->ai_addrlen) == 0)) {
+ if (at0->ai_canonname != NULL &&
+ at1->ai_canonname != NULL) {
+ if (strcmp(at0->ai_canonname,
+ at1->ai_canonname) != 0) {
+ return (false);
+ }
+ }
+
+ if (at0->ai_canonname == NULL &&
+ at1->ai_canonname != NULL) {
+ return (false);
+ }
+ if (at0->ai_canonname != NULL &&
+ at1->ai_canonname == NULL) {
+ return (false);
+ }
+
+ if (at0->ai_next == NULL && at1->ai_next == NULL)
+ return (true);
+ if (at0->ai_next == NULL || at1->ai_next == NULL)
+ return (false);
+
+ at0 = at0->ai_next;
+ at1 = at1->ai_next;
+ } else {
+ return (false);
+ }
+ }
+
+ /* NOTREACHED */
+ fprintf(stderr, "Dead code reached in addrinfo_compare()\n");
+ exit(1);
+}
static bool
hostent_aliases_compare(char **aliases0, char **aliases1)
@@ -161,6 +218,7 @@ static unsigned int
runtest(cap_channel_t *capdns)
{
unsigned int result;
+ struct addrinfo *ais, *aic, hints, *hintsp;
struct hostent *hps, *hpc;
struct in_addr ip4;
struct in6_addr ip6;
@@ -188,6 +246,55 @@ runtest(cap_channel_t *capdns)
if (hostent_compare(hps, hpc))
result |= GETHOSTBYNAME2_AF_INET6;
+ hints.ai_flags = 0;
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = 0;
+ hints.ai_protocol = 0;
+ hints.ai_addrlen = 0;
+ hints.ai_addr = NULL;
+ hints.ai_canonname = NULL;
+ hints.ai_next = NULL;
+
+ hintsp = &hints;
+
+ if (getaddrinfo("freebsd.org", "25", hintsp, &ais) != 0) {
+ fprintf(stderr,
+ "Unable to issue [system] getaddrinfo() for AF_UNSPEC: %s\n",
+ gai_strerror(errno));
+ }
+ if (cap_getaddrinfo(capdns, "freebsd.org", "25", hintsp, &aic) == 0) {
+ if (addrinfo_compare(ais, aic))
+ result |= GETADDRINFO_AF_UNSPEC;
+ freeaddrinfo(ais);
+ freeaddrinfo(aic);
+ }
+
+ hints.ai_family = AF_INET;
+ if (getaddrinfo("freebsd.org", "25", hintsp, &ais) != 0) {
+ fprintf(stderr,
+ "Unable to issue [system] getaddrinfo() for AF_UNSPEC: %s\n",
+ gai_strerror(errno));
+ }
+ if (cap_getaddrinfo(capdns, "freebsd.org", "25", hintsp, &aic) == 0) {
+ if (addrinfo_compare(ais, aic))
+ result |= GETADDRINFO_AF_INET;
+ freeaddrinfo(ais);
+ freeaddrinfo(aic);
+ }
+
+ hints.ai_family = AF_INET6;
+ if (getaddrinfo("freebsd.org", "25", hintsp, &ais) != 0) {
+ fprintf(stderr,
+ "Unable to issue [system] getaddrinfo() for AF_UNSPEC: %s\n",
+ gai_strerror(errno));
+ }
+ if (cap_getaddrinfo(capdns, "freebsd.org", "25", hintsp, &aic) == 0) {
+ if (addrinfo_compare(ais, aic))
+ result |= GETADDRINFO_AF_INET6;
+ freeaddrinfo(ais);
+ freeaddrinfo(aic);
+ }
+
/*
* 8.8.178.135 is IPv4 address of freefall.freebsd.org
* as of 27 October 2013.
@@ -238,7 +345,8 @@ main(void)
CHECK(runtest(capdns) ==
(GETHOSTBYNAME | GETHOSTBYNAME2_AF_INET | GETHOSTBYNAME2_AF_INET6 |
- GETHOSTBYADDR_AF_INET | GETHOSTBYADDR_AF_INET6));
+ GETHOSTBYADDR_AF_INET | GETHOSTBYADDR_AF_INET6 |
+ GETADDRINFO_AF_UNSPEC | GETADDRINFO_AF_INET | GETADDRINFO_AF_INET6));
/*
* Allow:
@@ -258,7 +366,8 @@ main(void)
CHECK(runtest(capdns) ==
(GETHOSTBYNAME | GETHOSTBYNAME2_AF_INET | GETHOSTBYNAME2_AF_INET6 |
- GETHOSTBYADDR_AF_INET | GETHOSTBYADDR_AF_INET6));
+ GETHOSTBYADDR_AF_INET | GETHOSTBYADDR_AF_INET6 |
+ GETADDRINFO_AF_INET | GETADDRINFO_AF_INET6));
cap_close(capdns);
@@ -310,7 +419,8 @@ main(void)
CHECK(cap_dns_family_limit(capdns, families, 2) == 0);
CHECK(runtest(capdns) ==
- (GETHOSTBYADDR_AF_INET | GETHOSTBYADDR_AF_INET6));
+ (GETHOSTBYADDR_AF_INET | GETHOSTBYADDR_AF_INET6 |
+ GETADDRINFO_AF_INET | GETADDRINFO_AF_INET6));
cap_close(capdns);
@@ -336,7 +446,8 @@ main(void)
errno == ENOTCAPABLE);
CHECK(runtest(capdns) ==
- (GETHOSTBYNAME | GETHOSTBYNAME2_AF_INET | GETHOSTBYADDR_AF_INET));
+ (GETHOSTBYNAME | GETHOSTBYNAME2_AF_INET | GETHOSTBYADDR_AF_INET |
+ GETADDRINFO_AF_INET));
cap_close(capdns);
@@ -362,7 +473,8 @@ main(void)
errno == ENOTCAPABLE);
CHECK(runtest(capdns) ==
- (GETHOSTBYNAME2_AF_INET6 | GETHOSTBYADDR_AF_INET6));
+ (GETHOSTBYNAME2_AF_INET6 | GETHOSTBYADDR_AF_INET6 |
+ GETADDRINFO_AF_INET6));
cap_close(capdns);
@@ -472,7 +584,7 @@ main(void)
CHECK(cap_dns_family_limit(capdns, families, 1) == -1 &&
errno == ENOTCAPABLE);
- CHECK(runtest(capdns) == GETHOSTBYADDR_AF_INET);
+ CHECK(runtest(capdns) == (GETHOSTBYADDR_AF_INET | GETADDRINFO_AF_INET));
cap_close(capdns);
@@ -508,7 +620,8 @@ main(void)
CHECK(cap_dns_family_limit(capdns, families, 1) == -1 &&
errno == ENOTCAPABLE);
- CHECK(runtest(capdns) == GETHOSTBYADDR_AF_INET6);
+ CHECK(runtest(capdns) == (GETHOSTBYADDR_AF_INET6 |
+ GETADDRINFO_AF_INET6));
cap_close(capdns);
@@ -578,7 +691,8 @@ main(void)
errno == ENOTCAPABLE);
/* Do the limits still hold? */
- CHECK(runtest(capdns) == GETHOSTBYADDR_AF_INET6);
+ CHECK(runtest(capdns) == (GETHOSTBYADDR_AF_INET6 |
+ GETADDRINFO_AF_INET6));
cap_close(capdns);
diff --git a/usr.bin/awk/Makefile b/usr.bin/awk/Makefile
index 80ca5db..e2e2758 100644
--- a/usr.bin/awk/Makefile
+++ b/usr.bin/awk/Makefile
@@ -24,6 +24,6 @@ proctab.c: maketab
./maketab > proctab.c
build-tools: maketab
-maketab: ytab.h ${AWKSRC}/maketab.c
+maketab: ytab.h ${AWKSRC}/maketab.c ${BUILD_TOOLS_META}
.include <bsd.prog.mk>
diff --git a/usr.bin/bsdiff/bsdiff/bsdiff.c b/usr.bin/bsdiff/bsdiff/bsdiff.c
index 7e39275..e0b3ee7 100644
--- a/usr.bin/bsdiff/bsdiff/bsdiff.c
+++ b/usr.bin/bsdiff/bsdiff/bsdiff.c
@@ -57,24 +57,24 @@ static void split(off_t *I,off_t *V,off_t start,off_t len,off_t h)
if(V[I[k+i]+h]<x) {
x=V[I[k+i]+h];
j=0;
- };
+ }
if(V[I[k+i]+h]==x) {
tmp=I[k+j];I[k+j]=I[k+i];I[k+i]=tmp;
j++;
- };
- };
+ }
+ }
for(i=0;i<j;i++) V[I[k+i]]=k+j-1;
if(j==1) I[k]=-1;
- };
+ }
return;
- };
+ }
x=V[I[start+len/2]+h];
jj=0;kk=0;
for(i=start;i<start+len;i++) {
if(V[I[i]+h]<x) jj++;
if(V[I[i]+h]==x) kk++;
- };
+ }
jj+=start;kk+=jj;
i=start;j=0;k=0;
@@ -87,8 +87,8 @@ static void split(off_t *I,off_t *V,off_t start,off_t len,off_t h)
} else {
tmp=I[i];I[i]=I[kk+k];I[kk+k]=tmp;
k++;
- };
- };
+ }
+ }
while(jj+j<kk) {
if(V[I[jj+j]+h]==x) {
@@ -96,8 +96,8 @@ static void split(off_t *I,off_t *V,off_t start,off_t len,off_t h)
} else {
tmp=I[jj+j];I[jj+j]=I[kk+k];I[kk+k]=tmp;
k++;
- };
- };
+ }
+ }
if(jj>start) split(I,V,start,jj-start,h);
@@ -137,10 +137,10 @@ static void qsufsort(off_t *I,off_t *V,u_char *old,off_t oldsize)
split(I,V,i,len,h);
i+=len;
len=0;
- };
- };
+ }
+ }
if(len) I[i-len]=-len;
- };
+ }
for(i=0;i<oldsize+1;i++) I[V[i]]=i;
}
@@ -171,7 +171,7 @@ static off_t search(off_t *I,u_char *old,off_t oldsize,
*pos=I[en];
return y;
}
- };
+ }
x=st+(en-st)/2;
if(memcmp(old+I[x],new,MIN(oldsize-I[x],newsize))<0) {
@@ -321,24 +321,24 @@ int main(int argc,char *argv[])
if((scan+lastoffset<oldsize) &&
(old[scan+lastoffset] == new[scan]))
oldscore--;
- };
+ }
if((len!=oldscore) || (scan==newsize)) {
s=0;Sf=0;lenf=0;
for(i=0;(lastscan+i<scan)&&(lastpos+i<oldsize);) {
if(old[lastpos+i]==new[lastscan+i]) s++;
i++;
- if(s*2-i>Sf*2-lenf) { Sf=s; lenf=i; };
- };
+ if(s*2-i>Sf*2-lenf) { Sf=s; lenf=i; }
+ }
lenb=0;
if(scan<newsize) {
s=0;Sb=0;
for(i=1;(scan>=lastscan+i)&&(pos>=i);i++) {
if(old[pos-i]==new[scan-i]) s++;
- if(s*2-i>Sb*2-lenb) { Sb=s; lenb=i; };
- };
- };
+ if(s*2-i>Sb*2-lenb) { Sb=s; lenb=i; }
+ }
+ }
if(lastscan+lenf>scan-lenb) {
overlap=(lastscan+lenf)-(scan-lenb);
@@ -348,12 +348,12 @@ int main(int argc,char *argv[])
old[lastpos+lenf-overlap+i]) s++;
if(new[scan-lenb+i]==
old[pos-lenb+i]) s--;
- if(s>Ss) { Ss=s; lens=i+1; };
- };
+ if(s>Ss) { Ss=s; lens=i+1; }
+ }
lenf+=lens-overlap;
lenb-=lens;
- };
+ }
for(i=0;i<lenf;i++)
db[dblen+i]=new[lastscan+i]-old[lastpos+i];
@@ -381,8 +381,8 @@ int main(int argc,char *argv[])
lastscan=scan-lenb;
lastpos=pos-lenb;
lastoffset=pos-scan;
- };
- };
+ }
+ }
BZ2_bzWriteClose(&bz2err, pfbz2, 0, NULL, NULL);
if (bz2err != BZ_OK)
errx(1, "BZ2_bzWriteClose, bz2err = %d", bz2err);
diff --git a/usr.bin/bsdiff/bspatch/bspatch.c b/usr.bin/bsdiff/bspatch/bspatch.c
index db72e5c..eb99e5b 100644
--- a/usr.bin/bsdiff/bspatch/bspatch.c
+++ b/usr.bin/bsdiff/bspatch/bspatch.c
@@ -161,7 +161,7 @@ int main(int argc,char * argv[])
(cbz2err != BZ_STREAM_END)))
errx(1, "Corrupt patch\n");
ctrl[i]=offtin(buf);
- };
+ }
/* Sanity-check */
if(newpos+ctrl[0]>newsize)
@@ -195,7 +195,7 @@ int main(int argc,char * argv[])
/* Adjust pointers */
newpos+=ctrl[1];
oldpos+=ctrl[2];
- };
+ }
/* Clean up the bzip2 reads */
BZ2_bzReadClose(&cbz2err, cpfbz2);
diff --git a/usr.bin/calendar/dates.c b/usr.bin/calendar/dates.c
index a5f5e9f..86d8a1f 100644
--- a/usr.bin/calendar/dates.c
+++ b/usr.bin/calendar/dates.c
@@ -381,7 +381,7 @@ walkthrough_dates(struct event **e)
d = m->days;
*e = d->events;
return (1);
- };
+ }
if (d->nextday != NULL) {
d = d->nextday;
*e = d->events;
diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c
index 89863f4..0a5dd85 100644
--- a/usr.bin/calendar/io.c
+++ b/usr.bin/calendar/io.c
@@ -469,7 +469,7 @@ closecal(FILE *fp)
if (setuid(getuid()) < 0) {
warnx("setuid failed");
_exit(1);
- };
+ }
if (setgid(getegid()) < 0) {
warnx("setgid failed");
_exit(1);
diff --git a/usr.bin/mkcsmapper_static/Makefile b/usr.bin/mkcsmapper_static/Makefile
index 21014e9..a416b20 100644
--- a/usr.bin/mkcsmapper_static/Makefile
+++ b/usr.bin/mkcsmapper_static/Makefile
@@ -13,3 +13,5 @@ build-tools: mkcsmapper_static
.include "${.CURDIR}/../mkcsmapper/Makefile.inc"
.include <bsd.prog.mk>
+
+${PROG}: ${BUILD_TOOLS_META}
diff --git a/usr.bin/mkesdb_static/Makefile b/usr.bin/mkesdb_static/Makefile
index 2696a23..9ce0209 100644
--- a/usr.bin/mkesdb_static/Makefile
+++ b/usr.bin/mkesdb_static/Makefile
@@ -13,3 +13,5 @@ build-tools: mkesdb_static
.include "${.CURDIR}/../mkesdb/Makefile.inc"
.include <bsd.prog.mk>
+
+${PROG}: ${BUILD_TOOLS_META}
diff --git a/usr.bin/rpcgen/rpc_cout.c b/usr.bin/rpcgen/rpc_cout.c
index 4c36ce6..0c2ce20 100644
--- a/usr.bin/rpcgen/rpc_cout.c
+++ b/usr.bin/rpcgen/rpc_cout.c
@@ -81,7 +81,7 @@ emit(definition *def)
if (strcmp(def->def.ty.old_type, def->def_name) == 0)
return;
- };
+ }
print_header(def);
switch (def->def_kind) {
case DEF_UNION:
diff --git a/usr.bin/rpcgen/rpc_main.c b/usr.bin/rpcgen/rpc_main.c
index b7b255a..64a29ad 100644
--- a/usr.bin/rpcgen/rpc_main.c
+++ b/usr.bin/rpcgen/rpc_main.c
@@ -977,7 +977,7 @@ checkfiles(const char *infile, const char *outfile)
{
warn("%s", infile);
crash();
- };
+ }
if (outfile) {
if (stat(outfile, &buf) < 0)
return; /* file does not exist */
diff --git a/usr.bin/rpcgen/rpc_parse.c b/usr.bin/rpcgen/rpc_parse.c
index f7f857a..69392b7 100644
--- a/usr.bin/rpcgen/rpc_parse.c
+++ b/usr.bin/rpcgen/rpc_parse.c
@@ -329,7 +329,7 @@ def_union(definition *defp)
*tailp = cases;
tailp = &cases->next;
cases = XALLOC(case_list);
- };
+ }
get_declaration(&dec, DEF_UNION);
cases->case_decl = dec;
diff --git a/usr.bin/rpcgen/rpc_svcout.c b/usr.bin/rpcgen/rpc_svcout.c
index 4b951a3..aa5a86a 100644
--- a/usr.bin/rpcgen/rpc_svcout.c
+++ b/usr.bin/rpcgen/rpc_svcout.c
@@ -551,7 +551,7 @@ write_program(definition *def, const char *storage)
(void) sprintf(_errbuf, "unable to free results");
print_err_message("\t\t");
f_print(fout, "\n");
- };
+ }
print_return("\t");
f_print(fout, "}\n");
}
diff --git a/usr.bin/rpcgen/rpc_util.c b/usr.bin/rpcgen/rpc_util.c
index bf0ca5d..1474118 100644
--- a/usr.bin/rpcgen/rpc_util.c
+++ b/usr.bin/rpcgen/rpc_util.c
@@ -454,7 +454,7 @@ add_type(int len, const char *type)
{
typ_list_t->next = ptr;
typ_list_t = ptr;
- };
+ }
}
@@ -470,7 +470,7 @@ find_type(const char *type)
return (ptr);
else
ptr = ptr->next;
- };
+ }
return (NULL);
}
diff --git a/usr.bin/showmount/showmount.c b/usr.bin/showmount/showmount.c
index 46e58e4..01c9e26 100644
--- a/usr.bin/showmount/showmount.c
+++ b/usr.bin/showmount/showmount.c
@@ -194,7 +194,7 @@ main(int argc, char **argv)
default:
printf("Hosts on %s:\n", host);
break;
- };
+ }
print_dump(mntdump);
}
if (rpcs & DOEXPORTS) {
@@ -317,7 +317,7 @@ xdr_mntdump(XDR *xdrsp, struct mountlist **mlp)
goto next;
}
break;
- };
+ }
if (val < 0) {
otp = &tp->ml_left;
tp = tp->ml_left;
@@ -407,7 +407,7 @@ print_dump(struct mountlist *mp)
default:
printf("%s\n", mp->ml_host);
break;
- };
+ }
if (mp->ml_right)
print_dump(mp->ml_right);
}
diff --git a/usr.bin/sort/bwstring.c b/usr.bin/sort/bwstring.c
index fc30b56..3965eae 100644
--- a/usr.bin/sort/bwstring.c
+++ b/usr.bin/sort/bwstring.c
@@ -297,7 +297,7 @@ bwscsbdup(const unsigned char *str, size_t len)
/* NOTREACHED */
err(2, "mbrtowc error");
cptr += charlen;
- };
+ }
}
ret->len = chars;
diff --git a/usr.bin/sort/coll.c b/usr.bin/sort/coll.c
index 0b7eb57..7b4ad10 100644
--- a/usr.bin/sort/coll.c
+++ b/usr.bin/sort/coll.c
@@ -688,7 +688,7 @@ static void setsuffix(wchar_t c, unsigned char *si)
break;
default:
*si = 0;
- };
+ }
}
/*
diff --git a/usr.bin/sort/file.c b/usr.bin/sort/file.c
index 0a00889..47d59af 100644
--- a/usr.bin/sort/file.c
+++ b/usr.bin/sort/file.c
@@ -1258,7 +1258,7 @@ sort_list_to_file(struct sort_list *list, const char *outfile)
break;
default:
errx(2, "%s", getstr(10));
- };
+ }
}
if (sort_opts_vals.sort_method == SORT_DEFAULT)
diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c
index 9f291f0..3bf7b9d 100644
--- a/usr.bin/truss/syscalls.c
+++ b/usr.bin/truss/syscalls.c
@@ -1197,7 +1197,7 @@ print_arg(struct syscall_args *sc, unsigned long *args, long *retval,
break;
len--;
truncated = 1;
- };
+ }
fprintf(fp, "\"%s\"%s", tmp3, truncated ?
"..." : "");
free(tmp3);
diff --git a/usr.bin/vi/catalog/Makefile b/usr.bin/vi/catalog/Makefile
index 97ab09e..e095e6d 100644
--- a/usr.bin/vi/catalog/Makefile
+++ b/usr.bin/vi/catalog/Makefile
@@ -105,7 +105,7 @@ english.base: dump ${SCAN} #Makefile
sort -nu > $@
-dump: dump.c
+dump: dump.c ${BUILD_TOOLS_META}
${CC} -o ${.TARGET} ${.ALLSRC}
CLEANFILES+= dump ${CAT} english.base *.check __ck1 __ck2
diff --git a/usr.bin/xlint/lint1/func.c b/usr.bin/xlint/lint1/func.c
index 893121e..e5a0490 100644
--- a/usr.bin/xlint/lint1/func.c
+++ b/usr.bin/xlint/lint1/func.c
@@ -517,7 +517,7 @@ label(int typ, sym_t *sym, tnode_t *tn)
ci->c_default = 1;
}
break;
- };
+ }
reached = 1;
}
diff --git a/usr.bin/xstr/xstr.c b/usr.bin/xstr/xstr.c
index 670e09e..4aad8e6 100644
--- a/usr.bin/xstr/xstr.c
+++ b/usr.bin/xstr/xstr.c
@@ -139,7 +139,7 @@ main(int argc, char *argv[])
argc--, argv++;
else
readstd = 0;
- };
+ }
flushsh();
if (cflg == 0)
xsdotc();
diff --git a/usr.sbin/bhyve/pci_emul.h b/usr.sbin/bhyve/pci_emul.h
index 6b8c4e0..d6e5490 100644
--- a/usr.sbin/bhyve/pci_emul.h
+++ b/usr.sbin/bhyve/pci_emul.h
@@ -142,6 +142,8 @@ struct pci_devinst {
int pba_size;
int function_mask;
struct msix_table_entry *table; /* allocated at runtime */
+ void *pba_page;
+ int pba_page_offset;
} pi_msix;
void *pi_arg; /* devemu-private data */
diff --git a/usr.sbin/bhyve/pci_passthru.c b/usr.sbin/bhyve/pci_passthru.c
index 5b52b05..66d31a2 100644
--- a/usr.sbin/bhyve/pci_passthru.c
+++ b/usr.sbin/bhyve/pci_passthru.c
@@ -31,6 +31,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/types.h>
+#include <sys/mman.h>
#include <sys/pciio.h>
#include <sys/ioctl.h>
@@ -59,6 +60,10 @@ __FBSDID("$FreeBSD$");
#define _PATH_DEVIO "/dev/io"
#endif
+#ifndef _PATH_MEM
+#define _PATH_MEM "/dev/mem"
+#endif
+
#define LEGACY_SUPPORT 1
#define MSIX_TABLE_COUNT(ctrl) (((ctrl) & PCIM_MSIXCTRL_TABLE_SIZE) + 1)
@@ -66,6 +71,7 @@ __FBSDID("$FreeBSD$");
static int pcifd = -1;
static int iofd = -1;
+static int memfd = -1;
struct passthru_softc {
struct pci_devinst *psc_pi;
@@ -279,6 +285,35 @@ msix_table_read(struct passthru_softc *sc, uint64_t offset, int size)
int index;
pi = sc->psc_pi;
+ if (offset >= pi->pi_msix.pba_offset &&
+ offset < pi->pi_msix.pba_offset + pi->pi_msix.pba_size) {
+ switch(size) {
+ case 1:
+ src8 = (uint8_t *)(pi->pi_msix.pba_page + offset -
+ pi->pi_msix.pba_page_offset);
+ data = *src8;
+ break;
+ case 2:
+ src16 = (uint16_t *)(pi->pi_msix.pba_page + offset -
+ pi->pi_msix.pba_page_offset);
+ data = *src16;
+ break;
+ case 4:
+ src32 = (uint32_t *)(pi->pi_msix.pba_page + offset -
+ pi->pi_msix.pba_page_offset);
+ data = *src32;
+ break;
+ case 8:
+ src64 = (uint64_t *)(pi->pi_msix.pba_page + offset -
+ pi->pi_msix.pba_page_offset);
+ data = *src64;
+ break;
+ default:
+ return (-1);
+ }
+ return (data);
+ }
+
if (offset < pi->pi_msix.table_offset)
return (-1);
@@ -320,12 +355,44 @@ msix_table_write(struct vmctx *ctx, int vcpu, struct passthru_softc *sc,
{
struct pci_devinst *pi;
struct msix_table_entry *entry;
- uint32_t *dest;
+ uint8_t *dest8;
+ uint16_t *dest16;
+ uint32_t *dest32;
+ uint64_t *dest64;
size_t entry_offset;
uint32_t vector_control;
int error, index;
pi = sc->psc_pi;
+ if (offset >= pi->pi_msix.pba_offset &&
+ offset < pi->pi_msix.pba_offset + pi->pi_msix.pba_size) {
+ switch(size) {
+ case 1:
+ dest8 = (uint8_t *)(pi->pi_msix.pba_page + offset -
+ pi->pi_msix.pba_page_offset);
+ *dest8 = data;
+ break;
+ case 2:
+ dest16 = (uint16_t *)(pi->pi_msix.pba_page + offset -
+ pi->pi_msix.pba_page_offset);
+ *dest16 = data;
+ break;
+ case 4:
+ dest32 = (uint32_t *)(pi->pi_msix.pba_page + offset -
+ pi->pi_msix.pba_page_offset);
+ *dest32 = data;
+ break;
+ case 8:
+ dest64 = (uint64_t *)(pi->pi_msix.pba_page + offset -
+ pi->pi_msix.pba_page_offset);
+ *dest64 = data;
+ break;
+ default:
+ break;
+ }
+ return;
+ }
+
if (offset < pi->pi_msix.table_offset)
return;
@@ -342,8 +409,8 @@ msix_table_write(struct vmctx *ctx, int vcpu, struct passthru_softc *sc,
assert(entry_offset % 4 == 0);
vector_control = entry->vector_control;
- dest = (uint32_t *)((void *)entry + entry_offset);
- *dest = data;
+ dest32 = (uint32_t *)((void *)entry + entry_offset);
+ *dest32 = data;
/* If MSI-X hasn't been enabled, do nothing */
if (pi->pi_msix.enabled) {
/* If the entry is masked, don't set it up */
@@ -386,28 +453,44 @@ init_msix_table(struct vmctx *ctx, struct passthru_softc *sc, uint64_t base)
table_size += pi->pi_msix.table_count * MSIX_TABLE_ENTRY_SIZE;
table_size = roundup2(table_size, 4096);
+ idx = pi->pi_msix.table_bar;
+ start = pi->pi_bar[idx].addr;
+ remaining = pi->pi_bar[idx].size;
+
if (pi->pi_msix.pba_bar == pi->pi_msix.table_bar) {
pba_offset = pi->pi_msix.pba_offset;
pba_size = pi->pi_msix.pba_size;
if (pba_offset >= table_offset + table_size ||
table_offset >= pba_offset + pba_size) {
/*
- * The PBA can reside in the same BAR as the MSI-x
- * tables as long as it does not overlap with any
- * naturally aligned page occupied by the tables.
+ * If the PBA does not share a page with the MSI-x
+ * tables, no PBA emulation is required.
*/
+ pi->pi_msix.pba_page = NULL;
+ pi->pi_msix.pba_page_offset = 0;
} else {
- /* Need to also emulate the PBA, not supported yet */
- printf("Unsupported MSI-X configuration: %d/%d/%d\n",
- b, s, f);
- return (-1);
+ /*
+ * The PBA overlaps with either the first or last
+ * page of the MSI-X table region. Map the
+ * appropriate page.
+ */
+ if (pba_offset <= table_offset)
+ pi->pi_msix.pba_page_offset = table_offset;
+ else
+ pi->pi_msix.pba_page_offset = table_offset +
+ table_size - 4096;
+ pi->pi_msix.pba_page = mmap(NULL, 4096, PROT_READ |
+ PROT_WRITE, MAP_SHARED, memfd, start +
+ pi->pi_msix.pba_page_offset);
+ if (pi->pi_msix.pba_page == MAP_FAILED) {
+ printf(
+ "Failed to map PBA page for MSI-X on %d/%d/%d: %s\n",
+ b, s, f, strerror(errno));
+ return (-1);
+ }
}
}
- idx = pi->pi_msix.table_bar;
- start = pi->pi_bar[idx].addr;
- remaining = pi->pi_bar[idx].size;
-
/* Map everything before the MSI-X table */
if (table_offset > 0) {
len = table_offset;
@@ -572,6 +655,12 @@ passthru_init(struct vmctx *ctx, struct pci_devinst *pi, char *opts)
goto done;
}
+ if (memfd < 0) {
+ memfd = open(_PATH_MEM, O_RDWR, 0);
+ if (memfd < 0)
+ goto done;
+ }
+
if (opts == NULL ||
sscanf(opts, "%d/%d/%d", &bus, &slot, &func) != 3)
goto done;
diff --git a/usr.sbin/ctm/ctm/ctm.1 b/usr.sbin/ctm/ctm/ctm.1
index 6ba35c9..819a14b 100644
--- a/usr.sbin/ctm/ctm/ctm.1
+++ b/usr.sbin/ctm/ctm/ctm.1
@@ -12,7 +12,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 14, 2015
+.Dd April 14, 2016
.Dt CTM 1
.Os
.Sh NAME
@@ -308,11 +308,6 @@ options.
.Xr ctm_smail 1 ,
.Xr ctm 5
.Rs
-.%B "The FreeBSD Handbook"
-.%T "Using CTM"
-.%U http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/ctm.html
-.Re
-.Rs
.%T "Miscellaneous CTM on FreeBSD Resources"
.%U http://ctm.berklix.org
.Re
diff --git a/usr.sbin/fdformat/fdformat.c b/usr.sbin/fdformat/fdformat.c
index 341a161..b7bab86 100644
--- a/usr.sbin/fdformat/fdformat.c
+++ b/usr.sbin/fdformat/fdformat.c
@@ -95,7 +95,7 @@ verify_track(int fd, int track, int tracksize)
if (bufsz < tracksize)
buf = realloc(buf, bufsz = tracksize);
- if (buf == 0)
+ if (buf == NULL)
errx(EX_UNAVAILABLE, "out of memory");
if (lseek (fd, (long) track * tracksize, 0) < 0)
rv = -1;
@@ -205,7 +205,7 @@ main(int argc, char **argv)
if (stat(argv[optind], &sb) == -1 && errno == ENOENT) {
/* try prepending _PATH_DEV */
device = malloc(strlen(argv[optind]) + sizeof(_PATH_DEV) + 1);
- if (device == 0)
+ if (device == NULL)
errx(EX_UNAVAILABLE, "out of memory");
strcpy(device, _PATH_DEV);
strcat(device, argv[optind]);
@@ -252,7 +252,7 @@ main(int argc, char **argv)
if (format) {
getname(type, &name, &descr);
fdtp = get_fmt(format, type);
- if (fdtp == 0)
+ if (fdtp == NULL)
errx(EX_USAGE,
"unknown format %d KB for drive type %s",
format, name);
diff --git a/usr.sbin/fdread/fdread.c b/usr.sbin/fdread/fdread.c
index 770f92d..f3c2d91 100644
--- a/usr.sbin/fdread/fdread.c
+++ b/usr.sbin/fdread/fdread.c
@@ -170,7 +170,7 @@ doread(int fd, FILE *of, const char *_devname)
secsize = 128 << fdt.secsize;
tracksize = fdt.sectrac * secsize;
mediasize = tracksize * fdt.tracks * fdt.heads;
- if ((trackbuf = malloc(tracksize)) == 0)
+ if ((trackbuf = malloc(tracksize)) == NULL)
errx(EX_TEMPFAIL, "out of memory");
if (!quiet)
diff --git a/usr.sbin/fdread/fdutil.c b/usr.sbin/fdread/fdutil.c
index c66b0c1..bdd295a 100644
--- a/usr.sbin/fdread/fdutil.c
+++ b/usr.sbin/fdread/fdutil.c
@@ -200,10 +200,10 @@ parse_fmt(const char *s, enum fd_drivetype type,
*out = in;
for (i = 0;; i++) {
- if (s == 0)
+ if (s == NULL)
break;
- if ((cp = strchr(s, ',')) == 0) {
+ if ((cp = strchr(s, ',')) == NULL) {
s1 = strdup(s);
if (s1 == NULL)
abort();
diff --git a/usr.sbin/fmtree/excludes.c b/usr.sbin/fmtree/excludes.c
index 21a49b0..9f1c564 100644
--- a/usr.sbin/fmtree/excludes.c
+++ b/usr.sbin/fmtree/excludes.c
@@ -69,10 +69,10 @@ read_excludes_file(const char *name)
size_t len;
fp = fopen(name, "r");
- if (fp == 0)
+ if (fp == NULL)
err(1, "%s", name);
- while ((line = fgetln(fp, &len)) != 0) {
+ while ((line = fgetln(fp, &len)) != NULL) {
if (line[len - 1] == '\n')
len--;
if (len == 0)
@@ -80,7 +80,7 @@ read_excludes_file(const char *name)
str = malloc(len + 1);
e = malloc(sizeof *e);
- if (str == 0 || e == 0)
+ if (str == NULL || e == NULL)
errx(1, "memory allocation error");
e->glob = str;
memcpy(str, line, len);
diff --git a/usr.sbin/fstyp/fstyp.c b/usr.sbin/fstyp/fstyp.c
index cde179f..803a4c8 100644
--- a/usr.sbin/fstyp/fstyp.c
+++ b/usr.sbin/fstyp/fstyp.c
@@ -82,7 +82,7 @@ read_buf(FILE *fp, off_t off, size_t len)
}
buf = malloc(len);
- if (buf == 0) {
+ if (buf == NULL) {
warn("cannot malloc %zd bytes of memory", len);
return (NULL);
}
diff --git a/usr.sbin/keyserv/keyserv.c b/usr.sbin/keyserv/keyserv.c
index 79bf90d..8acbaf6 100644
--- a/usr.sbin/keyserv/keyserv.c
+++ b/usr.sbin/keyserv/keyserv.c
@@ -440,7 +440,7 @@ key_net_put_2_svc_prog(uid, arg)
arg->st_netname, (int)sizeof (arg->st_pub_key),
arg->st_pub_key, (int)sizeof (arg->st_priv_key),
arg->st_priv_key);
- };
+ }
status = pk_netput(uid, arg);
diff --git a/usr.sbin/kgmon/kgmon.c b/usr.sbin/kgmon/kgmon.c
index 3bc5351..60c7507 100644
--- a/usr.sbin/kgmon/kgmon.c
+++ b/usr.sbin/kgmon/kgmon.c
@@ -355,7 +355,7 @@ dumpstate(struct kvmvars *kvp)
setprof(kvp, GMON_PROF_OFF);
fp = fopen("gmon.out", "w");
- if (fp == 0) {
+ if (fp == NULL) {
warn("gmon.out");
return;
}
diff --git a/usr.sbin/lmcconfig/lmcconfig.c b/usr.sbin/lmcconfig/lmcconfig.c
index 7fbc216..eb80dbe 100644
--- a/usr.sbin/lmcconfig/lmcconfig.c
+++ b/usr.sbin/lmcconfig/lmcconfig.c
@@ -1528,7 +1528,7 @@ print_test_pattern(int patt)
case 11:
printf("framed X^23+X^18+1\n");
break;
- case 12:;
+ case 12:
printf("framed X^11+X^9+1 w/7ZS\n");
break;
case 13:
@@ -2008,7 +2008,7 @@ load_xilinx(char *name)
int c;
if (verbose) printf("Load firmware from file %s...\n", name);
- if ((f = fopen(name, "r")) == 0)
+ if ((f = fopen(name, "r")) == NULL)
{
perror("Failed to open file");
exit(1);
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index d6da2bc..a9464f6 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -434,7 +434,7 @@ main(int argc, char **argv)
break;
default:
usage();
- };
+ }
if (modfind("nfsd") < 0) {
/* Not present in kernel, try loading it */
@@ -1241,7 +1241,7 @@ xdr_fhs(XDR *xdrsp, caddr_t cp)
return (0);
return (xdr_long(xdrsp, &auth));
}
- };
+ }
return (0);
}
@@ -2540,7 +2540,7 @@ do_mount(struct exportlist *ep, struct grouplist *grp, int exflags,
*cp = savedc;
ret = 1;
goto error_exit;
- };
+ }
/*
* For V4:, use the nfssvc() syscall, instead of mount().
diff --git a/usr.sbin/nfscbd/nfscbd.c b/usr.sbin/nfscbd/nfscbd.c
index c9153b4..4bcfd6ea 100644
--- a/usr.sbin/nfscbd/nfscbd.c
+++ b/usr.sbin/nfscbd/nfscbd.c
@@ -177,7 +177,7 @@ main(int argc, char *argv[])
default:
case '?':
usage();
- };
+ }
argv += optind;
argc -= optind;
diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c
index f58ed30..349ba8e 100644
--- a/usr.sbin/nfsd/nfsd.c
+++ b/usr.sbin/nfsd/nfsd.c
@@ -214,7 +214,7 @@ main(int argc, char **argv)
default:
case '?':
usage();
- };
+ }
if (!tcpflag && !udpflag)
udpflag = 1;
argv += optind;
diff --git a/usr.sbin/pmcstudy/pmcstudy.c b/usr.sbin/pmcstudy/pmcstudy.c
index 16c9f51..e94addf 100644
--- a/usr.sbin/pmcstudy/pmcstudy.c
+++ b/usr.sbin/pmcstudy/pmcstudy.c
@@ -2873,7 +2873,7 @@ main(int argc, char **argv)
printf("-A -- Run all canned tests\n");
return(0);
break;
- };
+ }
}
if ((run_all == 0) && (name == NULL) && (filename == NULL) &&
(test_mode == 0) && (master_exp == NULL)) {
diff --git a/usr.sbin/portsnap/phttpget/phttpget.c b/usr.sbin/portsnap/phttpget/phttpget.c
index 1bf6d9d..33e969a 100644
--- a/usr.sbin/portsnap/phttpget/phttpget.c
+++ b/usr.sbin/portsnap/phttpget/phttpget.c
@@ -598,7 +598,7 @@ main(int argc, char *argv[])
fd = open(fname, O_CREAT | O_TRUNC | O_WRONLY, 0644);
if (fd == -1)
errx(1, "open(%s)", fname);
- };
+ }
/* Read the message and send data to fd if appropriate */
if (chunked) {
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index e90d96b..d0664e8 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -651,7 +651,7 @@ ShellCommand(struct cmdargs const *arg, int bg)
if ((shpid = fork()) == 0) {
int i, fd;
- if ((shell = getenv("SHELL")) == 0)
+ if ((shell = getenv("SHELL")) == NULL)
shell = _PATH_BSHELL;
timer_TermService();
diff --git a/usr.sbin/ppp/filter.c b/usr.sbin/ppp/filter.c
index f59848e..af5691b 100644
--- a/usr.sbin/ppp/filter.c
+++ b/usr.sbin/ppp/filter.c
@@ -80,7 +80,7 @@ ParsePort(const char *service, const char *proto)
int port;
servent = getservbyname(service, proto);
- if (servent != 0)
+ if (servent != NULL)
return ntohs(servent->s_port);
port = strtol(service, &cp, 0);
diff --git a/usr.sbin/ppp/radius.c b/usr.sbin/ppp/radius.c
index f798141..12b0c0f 100644
--- a/usr.sbin/ppp/radius.c
+++ b/usr.sbin/ppp/radius.c
@@ -1150,7 +1150,7 @@ radius_Account(struct radius *r, struct radacct *ac, struct datalink *dl,
snprintf(ac->multi_session_id, sizeof ac->multi_session_id, "%s",
dl->bundle->ncp.mp.active ?
dl->bundle->ncp.mp.server.socket.sun_path : "");
- };
+ }
if (rad_put_string(r->cx.rad, RAD_USER_NAME, ac->user_name) != 0 ||
rad_put_int(r->cx.rad, RAD_SERVICE_TYPE, RAD_FRAMED) != 0 ||
diff --git a/usr.sbin/rmt/rmt.c b/usr.sbin/rmt/rmt.c
index a5c048f..57c8439 100644
--- a/usr.sbin/rmt/rmt.c
+++ b/usr.sbin/rmt/rmt.c
@@ -84,8 +84,10 @@ main(int argc, char **argv)
argc--, argv++;
if (argc > 0) {
debug = fopen(*argv, "w");
- if (debug == 0)
+ if (debug == NULL) {
+ DEBUG1("rmtd: error to open %s\n", *argv);
exit(1);
+ }
(void)setbuf(debug, (char *)0);
}
top:
@@ -226,10 +228,10 @@ checkbuf(char *rec, int size)
if (size <= maxrecsize)
return (rec);
- if (rec != 0)
+ if (rec != NULL)
free(rec);
rec = malloc(size);
- if (rec == 0) {
+ if (rec == NULL) {
DEBUG("rmtd: cannot allocate buffer space\n");
exit(4);
}
diff --git a/usr.sbin/tzsetup/tzsetup.c b/usr.sbin/tzsetup/tzsetup.c
index fc80364..e571d1f 100644
--- a/usr.sbin/tzsetup/tzsetup.c
+++ b/usr.sbin/tzsetup/tzsetup.c
@@ -344,7 +344,7 @@ read_iso3166_table(void)
err(1, "%s", path_iso3166);
lineno = 0;
- while ((s = fgetln(fp, &len)) != 0) {
+ while ((s = fgetln(fp, &len)) != NULL) {
lineno++;
if (s[len - 1] != '\n')
errx(1, "%s:%d: invalid format", path_iso3166, lineno);
@@ -354,7 +354,7 @@ read_iso3166_table(void)
/* Isolate the two-letter code. */
t = strsep(&s, "\t");
- if (t == 0 || strlen(t) != 2)
+ if (t == NULL || strlen(t) != 2)
errx(1, "%s:%d: invalid format", path_iso3166, lineno);
if (t[0] < 'A' || t[0] > 'Z' || t[1] < 'A' || t[1] > 'Z')
errx(1, "%s:%d: invalid code `%s'", path_iso3166,
@@ -362,10 +362,10 @@ read_iso3166_table(void)
/* Now skip past the three-letter and numeric codes. */
name = strsep(&s, "\t"); /* 3-let */
- if (name == 0 || strlen(name) != 3)
+ if (name == NULL || strlen(name) != 3)
errx(1, "%s:%d: invalid format", path_iso3166, lineno);
name = strsep(&s, "\t"); /* numeric */
- if (name == 0 || strlen(name) != 3)
+ if (name == NULL || strlen(name) != 3)
errx(1, "%s:%d: invalid format", path_iso3166, lineno);
name = s;
@@ -407,7 +407,7 @@ add_zone_to_country(int lineno, const char *tlc, const char *descr,
path_zonetab, lineno);
zp = malloc(sizeof(*zp));
- if (zp == 0)
+ if (zp == NULL)
errx(1, "malloc(%zu)", sizeof(*zp));
if (cp->nzones == 0)
@@ -483,7 +483,7 @@ read_zones(void)
err(1, "%s", path_zonetab);
lineno = 0;
- while ((line = fgetln(fp, &len)) != 0) {
+ while ((line = fgetln(fp, &len)) != NULL) {
lineno++;
if (line[len - 1] != '\n')
errx(1, "%s:%d: invalid format", path_zonetab, lineno);
@@ -498,7 +498,7 @@ read_zones(void)
/* coord = */ strsep(&line, "\t"); /* Unused */
file = strsep(&line, "\t");
p = strchr(file, '/');
- if (p == 0)
+ if (p == NULL)
errx(1, "%s:%d: invalid zone name `%s'", path_zonetab,
lineno, file);
contbuf[0] = '\0';
@@ -558,7 +558,7 @@ make_menus(void)
continent_names[i].continent->menu =
malloc(sizeof(dialogMenuItem) *
continent_names[i].continent->nitems);
- if (continent_names[i].continent->menu == 0)
+ if (continent_names[i].continent->menu == NULL)
errx(1, "malloc for continent menu");
continent_names[i].continent->nitems = 0;
continents[i].prompt = continent_items[i].prompt;
OpenPOWER on IntegriCloud