aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 cde0f2cdc592..a45706fe5108 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 1ce13627a906..aadcc3623866 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 2c15a9bbd3cd..2cbaf2e0f196 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 5f29f4b3048c..d1cfd7f34c9e 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 2e4c37bb08d0..dcff31551e0d 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 aa3b83becd16..6e3c32d40745 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 419ff7915bf6..d3422b43beff 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 3f9732cbbff3..e72a6f1c7e2e 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 ec7350336d5a..9b27076d8096 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 5848eab7d3f7..143413847851 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 d75570e29267..bd465761a34e 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 2a0024cb459b..ccedf768e7a7 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 ee6ffa4dcc6e..b8025ba8ba89 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 e050bc46f339..cb71d522bb51 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 e7bc61dfc127..d1db4386ce4b 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 bc4463d363b9..4db374b394f5 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 1e7acc7984be..ba63702920c5 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 513063fb1508..7c0a1d33f932 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 3dbb7d41a364..f08f2340ecdb 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 cceebfa3a3d7..194a0962b428 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 88bcce2999df..310b21cae366 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 614e7fec728a..000000000000
--- 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 000000000000..087954631516
--- /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 89c010391d51..79af3fa39f3d 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 80dceca916be..487b50bafb9b 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 b291d07c9db8..0e18234f1020 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 70b712da2acb..ab87be296c6c 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 0131a6f50ac5..7e61f558146c 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 296a34ef996a..de23baad0b16 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 ead320e0e610..7c0b3de061a6 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 2b8e2969a062..f6c7290366fb 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 c8f2dbcb329f..0fdcbd18005b 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 69e3faa62126..3fc12a173148 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 e65897fe7244..2c7397f5e20a 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 2ecf537dd21b..71cd130ab350 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 46f501e24724..da80e681b27b 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 c7f4bfe8d98b..c331dceafe62 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 000000000000..e69de29bb2d1
--- /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 000000000000..1c899a165664
--- /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 000000000000..e69de29bb2d1
--- /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 000000000000..5cbac1797776
--- /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 000000000000..e69de29bb2d1
--- /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 000000000000..9b5fea1ca4af
--- /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 000000000000..e69de29bb2d1
--- /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 000000000000..1e0e9233fbe5
--- /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 000000000000..e69de29bb2d1
--- /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 000000000000..118bb760eefb
--- /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 000000000000..e69de29bb2d1
--- /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 000000000000..3e15e0d554cc
--- /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 000000000000..e69de29bb2d1
--- /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 000000000000..6f777c7a1f44
--- /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 000000000000..e69de29bb2d1
--- /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 000000000000..ed2d8e44e07a
--- /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 000000000000..e69de29bb2d1
--- /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 000000000000..73eec4c675b6
--- /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 f7fe61ec1ebe..05d778a0bca4 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 abddcf273c97..9a0268009915 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 000000000000..17d26a6dae54
--- /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 a0200c2926c4..d63674745d6d 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 d014681f1dd1..d8ed1a27cbfa 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 1e9a2156476f..c403b43f98f1 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 26c61bc7cc3e..9d87275e8246 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 4880cc2a8c9d..87b82d4ec9ea 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 b7024a6d6097..8986230ac68a 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 e505c77c43af..4fa6a67d8988 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 873af4cdcdde..0ecf047027b2 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 4dcca18a3251..34e29b1a2b71 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 ed0e217d65be..0e33e191ec85 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 dff3b545f78f..b55a796dedad 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 c9f2a0c545ef..59e03e819284 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 d07db8865d3f..2d742e7ee232 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 c250d717a62f..c74682329585 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 fa3d68d035fe..704d7fcc2c78 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 2f9431694a5f..1cf046ab86b6 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 15a870676da4..7038a576e7c2 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 d77de6c42caa..6500542449a5 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 5c3a2ae60cc5..fa73b95b140d 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 c7122c72abda..531feab83b44 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 cacf0115da7a..ee1359bd3acc 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 2da5a7b524ad..899c3cbbc8f6 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 429e6601e620..f7180e93ef05 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 373bac45e6da..373bac45e6da 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 86eccc15e0eb..3f5107815de3 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 0e032f512841..d314685baf2e 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 8e718fd144a3..b26fdedaf5a4 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 c7ee7eafb108..86844eb48e99 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 8bd4d93aaa65..447cdbaa6793 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 6d720edaa051..c361e29cb4ec 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 ba1ca80c050c..a8efa2c26150 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 83c4c767400a..b358dcb325b1 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 311e2551affc..bffcdc8bb7e8 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 e910bc9f4e83..af3b72bd7e57 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 d92ee2cb2a32..0fa29a3d150d 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 95a96adb18b2..21b6229d42cd 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 86f2a41733f5..d18803d510b9 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 36ee675bdf9a..c04dd702b93d 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 7eff340845f1..2264e3218980 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 810cf59da0c4..149d127a11d9 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 9b22a6b032cc..a03ddbcfa3be 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 d006c3f20c0b..8b72b9ad10de 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 a90fdebae217..d9bbb259e31e 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 7809c58d579d..1d00ed24aa5b 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 827afa90eb4b..f92610786e6e 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 d7ab30ce55f6..d230066106d4 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 e6388033a5f2..e9326f24e554 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 36603dac5ac3..a605c2846bd2 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 bda9a8c1a3bc..e38695592821 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 50ed33c2838d..d80cb9de117a 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 216992576d5f..caf8942174f5 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 00dd5663fab9..d26ba76f85e3 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 8471699dbc3e..5660bd43b83f 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 f6a98245a857..e3d212c6b384 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 2b1ae071c3d9..1dac25938d85 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 1c5dc88382a1..1e14e5052738 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 1ca7ea6cd95d..356d0ad20bda 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 a1279e6c9a85..b3ca520fd3b0 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 caabfd9f0cd4..fd8cdac989f2 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 cc32cdc21007..df04f425100c 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 0ed672dd8506..272da432e50e 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 3e7876aaaa44..c87ad640be1e 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 d20853a0af40..82be0c043ab5 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 3615c947af98..740d342f6792 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 1ad25b4191e7..50371804503b 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 5d45b553e07d..cf905569275d 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 5c0aece1987f..85d15576571c 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 504d26212127..b21dfa16f9fd 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 699881c753de..db52622ef014 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 b718c1d9133a..a84e0a804334 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 529e9f1d4518..2d9a941f9bf7 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 609b291c1f60..9fb0b20be101 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 bc13196bffb1..37f94d72c8a6 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 ba6040f68179..cf884b93019f 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 0de46c5b9ff1..0d9bd46a4215 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 16f62ec14331..e93e3b731b4c 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 6ed044abfea3..7bb80b94bd1d 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 8a32f55d42b2..d79020b8b493 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 f9a7294e4044..28676fc7cd85 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 ac200b4a05b2..082b24f3fdfe 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 bcb84b792481..e7ce52b2a898 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 d448fc5cd4ed..7c67a3813cb1 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 936dc529deb7..8124c968575f 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 f9a2fcc62f44..16c1e4b74e14 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 14abfe2e49b7..6068975ee79f 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 a361319a115b..bbbc514a2893 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 20bc07e7167f..2ae3d22d6637 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 8f56523c2c6c..f28080c623f5 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 fa3086542fe8..55e4468d3df7 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 13c3aa264baf..1903e62d961f 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 1885c0c94437..4497b0ff8303 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 770a69088666..c9979160edb8 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 6b383e28ccfd..bc1145f4c65f 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 550da8702e27..16802d31f5c8 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 4eaa471e35dc..69a82525701e 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 ec6ddb86b1ca..e3e5ac8fcf36 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 9bc2636e0919..5f6bc2769064 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 3cee50d3f1ff..e669580d9055 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 3365929d9d68..3db9457c7fec 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 aabe6369157f..374af8726b4b 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 96e3ba4a703d..c08060a3bcac 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 471b8d5bda6c..3e15e42a7a25 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 41ec23a82ef5..1c024cc0414e 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 061355dce1fa..d5417c2fb35f 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 50922e6aab4b..c423873c80c3 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 df0f2addda5f..ba82f5c4a01a 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 913902a71cb5..494f5d60e0c1 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 e81bc7dd7ab7..7a91525a909d 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 e685cc36755e..704fffa961a5 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 d4b25172fa63..db7c300aa326 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 4f246a47ba0d..4c5856a6dc8f 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 a1d2a2d12667..5a1999347f05 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 127b001efd45..35de22534f46 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 572fee8e7fcb..03cba309308d 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 723c4291e039..aa66b72101a3 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 8818f0453d40..b91e0830e1ec 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 8a544d00edbb..ebe486422e2d 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 fc5fb975b76e..e83e6eeb1994 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 aaf9a6a7bcf6..41c5a72c210c 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 633fbf0c0a03..54e50426027f 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 f16728b7c373..174dd62aaba0 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 c47c298ce8d8..aca54b7eb8ee 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 4b436839ecf0..dd179b7f6994 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 cb6c8defc948..822623c12ccb 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 34d8009ad223..f92cd83c0ea6 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 aef6346e6e9b..c830c99cab98 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 f48a7aab0a96..ec714095a671 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 f8a7fddb74a5..2cf3c3325c40 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 8dc880924cb0..3d46ece5850d 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 1b95cdede4b5..a1096d9a650b 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 000000000000..8f4c9d56dcc8
--- /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 000000000000..c1d537b5d993
--- /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 000000000000..91ae1b12fbf8
--- /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 000000000000..42401b57d1c2
--- /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 000000000000..96ebafea5b52
--- /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 000000000000..13eb530fee5e
--- /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 000000000000..a6a688733d20
--- /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 000000000000..de32f9ba16cc
--- /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 000000000000..5cc5383d7bc5
--- /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 bedc722e850d..8167fca7b622 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 d5220e874c78..51231b7bbd78 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 91e941c8f757..0eda4f4d5051 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 38cf46e8e190..05134d78addc 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;