Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Dec 2017 13:22:58 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r327150 - in projects/clang600-import: . bin/sh etc/rc.d include lib/libc/gen lib/libc/net lib/libc/stdio lib/libdevinfo sbin/ipfw sbin/reboot share/man/man4 share/man/man9 share/misc s...
Message-ID:  <201712241322.vBODMwnY089807@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Sun Dec 24 13:22:57 2017
New Revision: 327150
URL: https://svnweb.freebsd.org/changeset/base/327150

Log:
  Merge ^/head r326936 through r327149.

Added:
  projects/clang600-import/share/man/man4/nda.4
     - copied unchanged from r327149, head/share/man/man4/nda.4
  projects/clang600-import/sys/dev/extres/syscon/
     - copied from r327149, head/sys/dev/extres/syscon/
  projects/clang600-import/sys/sys/atomic_common.h
     - copied unchanged from r327149, head/sys/sys/atomic_common.h
  projects/clang600-import/usr.bin/truss/aarch64-cloudabi32.c
     - copied unchanged from r327149, head/usr.bin/truss/aarch64-cloudabi32.c
  projects/clang600-import/usr.bin/truss/i386-cloudabi32.c
     - copied unchanged from r327149, head/usr.bin/truss/i386-cloudabi32.c
Deleted:
  projects/clang600-import/sys/dev/ixgbe/ixgbe_netmap.c
  projects/clang600-import/sys/dev/ixgbe/ixgbe_netmap.h
  projects/clang600-import/sys/dev/syscon/
Modified:
  projects/clang600-import/.arclint
  projects/clang600-import/bin/sh/sh.1
  projects/clang600-import/etc/rc.d/ldconfig
  projects/clang600-import/include/stdlib.h
  projects/clang600-import/lib/libc/gen/Symbol.map
  projects/clang600-import/lib/libc/gen/daemon.3
  projects/clang600-import/lib/libc/gen/daemon.c
  projects/clang600-import/lib/libc/net/getaddrinfo.c
  projects/clang600-import/lib/libc/stdio/fopen.3
  projects/clang600-import/lib/libdevinfo/devinfo.c
  projects/clang600-import/sbin/ipfw/altq.c
  projects/clang600-import/sbin/ipfw/dummynet.c
  projects/clang600-import/sbin/ipfw/ipfw2.c
  projects/clang600-import/sbin/ipfw/ipfw2.h
  projects/clang600-import/sbin/ipfw/ipv6.c
  projects/clang600-import/sbin/ipfw/main.c
  projects/clang600-import/sbin/ipfw/nat.c
  projects/clang600-import/sbin/reboot/reboot.8
  projects/clang600-import/share/man/man4/Makefile
  projects/clang600-import/share/man/man4/ada.4
  projects/clang600-import/share/man/man4/da.4
  projects/clang600-import/share/man/man4/em.4
  projects/clang600-import/share/man/man4/md.4
  projects/clang600-import/share/man/man4/pci.4
  projects/clang600-import/share/man/man4/scsi.4
  projects/clang600-import/share/man/man9/atomic.9
  projects/clang600-import/share/misc/bsd-family-tree
  projects/clang600-import/stand/common/bootstrap.h
  projects/clang600-import/stand/common/interp.c
  projects/clang600-import/stand/common/interp_forth.c
  projects/clang600-import/stand/efi/boot1/boot1.c
  projects/clang600-import/stand/efi/loader/main.c
  projects/clang600-import/stand/i386/Makefile.inc
  projects/clang600-import/stand/i386/boot2/Makefile
  projects/clang600-import/stand/i386/gptboot/Makefile
  projects/clang600-import/stand/i386/libfirewire/Makefile
  projects/clang600-import/stand/i386/libi386/Makefile
  projects/clang600-import/stand/i386/libi386/multiboot.c
  projects/clang600-import/stand/i386/loader/Makefile
  projects/clang600-import/stand/i386/loader/main.c
  projects/clang600-import/stand/i386/zfsboot/Makefile
  projects/clang600-import/stand/mips/beri/loader/main.c
  projects/clang600-import/stand/ofw/common/main.c
  projects/clang600-import/stand/powerpc/kboot/main.c
  projects/clang600-import/stand/powerpc/ps3/main.c
  projects/clang600-import/stand/sparc64/loader/main.c
  projects/clang600-import/stand/uboot/common/main.c
  projects/clang600-import/stand/userboot/userboot/main.c
  projects/clang600-import/sys/amd64/include/atomic.h
  projects/clang600-import/sys/amd64/vmm/intel/vmx.c
  projects/clang600-import/sys/arm/arm/machdep.c
  projects/clang600-import/sys/arm/arm/pmap-v6.c
  projects/clang600-import/sys/arm/include/atomic.h
  projects/clang600-import/sys/arm64/include/atomic.h
  projects/clang600-import/sys/cam/cam_ccb.h
  projects/clang600-import/sys/cam/cam_periph.c
  projects/clang600-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_znode.h
  projects/clang600-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c
  projects/clang600-import/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c
  projects/clang600-import/sys/compat/linuxkpi/common/src/linux_page.c
  projects/clang600-import/sys/compat/linuxkpi/common/src/linux_rcu.c
  projects/clang600-import/sys/conf/NOTES
  projects/clang600-import/sys/conf/files
  projects/clang600-import/sys/conf/ldscript.powerpc64
  projects/clang600-import/sys/conf/options
  projects/clang600-import/sys/dev/acpica/acpi.c
  projects/clang600-import/sys/dev/acpica/acpi_cpu.c
  projects/clang600-import/sys/dev/aha/aha_isa.c
  projects/clang600-import/sys/dev/ahci/ahci_pci.c
  projects/clang600-import/sys/dev/aic/aic_isa.c
  projects/clang600-import/sys/dev/an/if_an_isa.c
  projects/clang600-import/sys/dev/atkbdc/atkbdc_isa.c
  projects/clang600-import/sys/dev/bnxt/bnxt.h
  projects/clang600-import/sys/dev/bnxt/bnxt_hwrm.c
  projects/clang600-import/sys/dev/bnxt/bnxt_hwrm.h
  projects/clang600-import/sys/dev/bnxt/bnxt_sysctl.c
  projects/clang600-import/sys/dev/bnxt/if_bnxt.c
  projects/clang600-import/sys/dev/cs/if_cs_isa.c
  projects/clang600-import/sys/dev/cxgbe/adapter.h
  projects/clang600-import/sys/dev/cxgbe/common/common.h
  projects/clang600-import/sys/dev/cxgbe/common/t4_hw.c
  projects/clang600-import/sys/dev/cxgbe/t4_main.c
  projects/clang600-import/sys/dev/cxgbe/t4_netmap.c
  projects/clang600-import/sys/dev/cxgbe/t4_sge.c
  projects/clang600-import/sys/dev/cxgbe/t4_vf.c
  projects/clang600-import/sys/dev/drm2/i915/i915_drv.c
  projects/clang600-import/sys/dev/drm2/radeon/radeon_drv.c
  projects/clang600-import/sys/dev/e1000/em_txrx.c
  projects/clang600-import/sys/dev/e1000/if_em.c
  projects/clang600-import/sys/dev/e1000/if_em.h
  projects/clang600-import/sys/dev/e1000/igb_txrx.c
  projects/clang600-import/sys/dev/ed/if_ed_isa.c
  projects/clang600-import/sys/dev/ed/if_ed_pci.c
  projects/clang600-import/sys/dev/ep/if_ep_isa.c
  projects/clang600-import/sys/dev/ex/if_ex_isa.c
  projects/clang600-import/sys/dev/fdc/fdc_isa.c
  projects/clang600-import/sys/dev/fdc/fdc_pccard.c
  projects/clang600-import/sys/dev/fe/if_fe_isa.c
  projects/clang600-import/sys/dev/intpm/intpm.c
  projects/clang600-import/sys/dev/ioat/ioat.c
  projects/clang600-import/sys/dev/ixgbe/if_bypass.c
  projects/clang600-import/sys/dev/ixgbe/if_fdir.c
  projects/clang600-import/sys/dev/ixgbe/if_ix.c
  projects/clang600-import/sys/dev/ixgbe/if_ixv.c
  projects/clang600-import/sys/dev/ixgbe/if_sriov.c
  projects/clang600-import/sys/dev/ixgbe/ix_txrx.c
  projects/clang600-import/sys/dev/ixgbe/ixgbe.h
  projects/clang600-import/sys/dev/ixgbe/ixgbe_common.c
  projects/clang600-import/sys/dev/ixgbe/ixgbe_fdir.h
  projects/clang600-import/sys/dev/ixgbe/ixgbe_osdep.c
  projects/clang600-import/sys/dev/ixgbe/ixgbe_osdep.h
  projects/clang600-import/sys/dev/ixgbe/ixgbe_phy.c
  projects/clang600-import/sys/dev/ixgbe/ixgbe_sriov.h
  projects/clang600-import/sys/dev/ixgbe/ixgbe_type.h
  projects/clang600-import/sys/dev/ixgbe/ixgbe_vf.h
  projects/clang600-import/sys/dev/joy/joy_isa.c
  projects/clang600-import/sys/dev/le/if_le_isa.c
  projects/clang600-import/sys/dev/lmc/if_lmc.c
  projects/clang600-import/sys/dev/lmc/if_lmc.h
  projects/clang600-import/sys/dev/md/md.c
  projects/clang600-import/sys/dev/mlx5/mlx5_en/mlx5_en_rx.c
  projects/clang600-import/sys/dev/mse/mse_isa.c
  projects/clang600-import/sys/dev/ntb/ntb_hw/ntb_hw_intel.c
  projects/clang600-import/sys/dev/nvme/nvme.c
  projects/clang600-import/sys/dev/nvme/nvme_ctrlr.c
  projects/clang600-import/sys/dev/nvme/nvme_private.h
  projects/clang600-import/sys/dev/nvme/nvme_sim.c
  projects/clang600-import/sys/dev/pccard/pccardvar.h
  projects/clang600-import/sys/dev/pccbb/pccbb_isa.c
  projects/clang600-import/sys/dev/pci/pci.c
  projects/clang600-import/sys/dev/ppc/ppc_isa.c
  projects/clang600-import/sys/dev/sbni/if_sbni_isa.c
  projects/clang600-import/sys/dev/sio/sio_isa.c
  projects/clang600-import/sys/dev/uart/uart_bus_isa.c
  projects/clang600-import/sys/dev/usb/controller/xhci_pci.c
  projects/clang600-import/sys/fs/devfs/devfs_vnops.c
  projects/clang600-import/sys/fs/ext2fs/ext2_vnops.c
  projects/clang600-import/sys/fs/fdescfs/fdesc_vnops.c
  projects/clang600-import/sys/fs/fifofs/fifo_vnops.c
  projects/clang600-import/sys/fs/fuse/fuse_param.h
  projects/clang600-import/sys/fs/fuse/fuse_vnops.c
  projects/clang600-import/sys/fs/msdosfs/msdosfs_vnops.c
  projects/clang600-import/sys/fs/nandfs/nandfs_vnops.c
  projects/clang600-import/sys/fs/nfs/nfs_commonport.c
  projects/clang600-import/sys/fs/nfs/nfs_commonsubs.c
  projects/clang600-import/sys/fs/nfs/nfsproto.h
  projects/clang600-import/sys/fs/nfsclient/nfs_clcomsubs.c
  projects/clang600-import/sys/fs/nfsclient/nfs_clvnops.c
  projects/clang600-import/sys/fs/smbfs/smbfs_vnops.c
  projects/clang600-import/sys/fs/tmpfs/tmpfs.h
  projects/clang600-import/sys/fs/tmpfs/tmpfs_fifoops.c
  projects/clang600-import/sys/fs/tmpfs/tmpfs_subr.c
  projects/clang600-import/sys/fs/tmpfs/tmpfs_vnops.c
  projects/clang600-import/sys/fs/tmpfs/tmpfs_vnops.h
  projects/clang600-import/sys/fs/udf/udf_vnops.c
  projects/clang600-import/sys/geom/mirror/g_mirror.c
  projects/clang600-import/sys/geom/mirror/g_mirror.h
  projects/clang600-import/sys/i386/include/atomic.h
  projects/clang600-import/sys/isa/isa_common.c
  projects/clang600-import/sys/isa/isavar.h
  projects/clang600-import/sys/isa/pnp.c
  projects/clang600-import/sys/isa/vga_isa.c
  projects/clang600-import/sys/kern/kern_descrip.c
  projects/clang600-import/sys/kern/kern_shutdown.c
  projects/clang600-import/sys/kern/kern_tc.c
  projects/clang600-import/sys/kern/subr_smp.c
  projects/clang600-import/sys/kern/vfs_default.c
  projects/clang600-import/sys/kern/vfs_export.c
  projects/clang600-import/sys/mips/include/atomic.h
  projects/clang600-import/sys/mips/mips/db_interface.c
  projects/clang600-import/sys/mips/mips/support.S
  projects/clang600-import/sys/modules/ix/Makefile
  projects/clang600-import/sys/modules/ixv/Makefile
  projects/clang600-import/sys/net/if_clone.c
  projects/clang600-import/sys/net/ifdi_if.m
  projects/clang600-import/sys/net/iflib.c
  projects/clang600-import/sys/net/iflib.h
  projects/clang600-import/sys/netinet6/nd6_nbr.c
  projects/clang600-import/sys/powerpc/booke/booke_machdep.c
  projects/clang600-import/sys/powerpc/include/atomic.h
  projects/clang600-import/sys/powerpc/include/vmparam.h
  projects/clang600-import/sys/powerpc/powerpc/machdep.c
  projects/clang600-import/sys/riscv/include/atomic.h
  projects/clang600-import/sys/sparc64/include/atomic.h
  projects/clang600-import/sys/sys/gtaskqueue.h
  projects/clang600-import/sys/sys/msg.h
  projects/clang600-import/sys/sys/smp.h
  projects/clang600-import/sys/sys/snoop.h
  projects/clang600-import/sys/sys/syscallsubr.h
  projects/clang600-import/sys/tools/embed_mfs.sh
  projects/clang600-import/sys/ufs/ffs/ffs_snapshot.c
  projects/clang600-import/sys/ufs/ufs/ufs_vnops.c
  projects/clang600-import/sys/vm/uma_core.c
  projects/clang600-import/sys/x86/acpica/acpi_wakeup.c
  projects/clang600-import/sys/x86/include/specialreg.h
  projects/clang600-import/sys/x86/isa/orm.c
  projects/clang600-import/sys/x86/x86/identcpu.c
  projects/clang600-import/sys/x86/x86/mp_x86.c
  projects/clang600-import/tests/sys/kern/ptrace_test.c
  projects/clang600-import/tools/boot/rootgen.sh
  projects/clang600-import/usr.bin/calendar/io.c
  projects/clang600-import/usr.bin/ldd/ldd.1
  projects/clang600-import/usr.bin/patch/patch.c
  projects/clang600-import/usr.bin/patch/pch.c
  projects/clang600-import/usr.bin/truss/Makefile
  projects/clang600-import/usr.sbin/devinfo/devinfo.8
  projects/clang600-import/usr.sbin/devinfo/devinfo.c
  projects/clang600-import/usr.sbin/watch/watch.c
Directory Properties:
  projects/clang600-import/   (props changed)
  projects/clang600-import/contrib/llvm/   (props changed)
  projects/clang600-import/contrib/llvm/tools/lld/   (props changed)
  projects/clang600-import/sys/cddl/contrib/opensolaris/   (props changed)

Modified: projects/clang600-import/.arclint
==============================================================================
--- projects/clang600-import/.arclint	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/.arclint	Sun Dec 24 13:22:57 2017	(r327150)
@@ -24,4 +24,3 @@
     }
   }
 }
-

Modified: projects/clang600-import/bin/sh/sh.1
==============================================================================
--- projects/clang600-import/bin/sh/sh.1	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/bin/sh/sh.1	Sun Dec 24 13:22:57 2017	(r327150)
@@ -343,7 +343,7 @@ Write each command
 variable subjected to parameter expansion and arithmetic expansion)
 to standard error before it is executed.
 Useful for debugging.
-.It nolog
+.It Li nolog
 Another do-nothing option for
 .Tn POSIX
 compliance.
@@ -2739,7 +2739,7 @@ were a known job that exited with exit status 127.
 If no operands are given, wait for all jobs to complete
 and return an exit status of zero.
 .El
-.Ss Commandline Editing
+.Ss Command Line Editing
 When
 .Nm
 is being used interactively from a terminal, the current command

Modified: projects/clang600-import/etc/rc.d/ldconfig
==============================================================================
--- projects/clang600-import/etc/rc.d/ldconfig	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/etc/rc.d/ldconfig	Sun Dec 24 13:22:57 2017	(r327150)
@@ -63,7 +63,7 @@ ldconfig_start()
 		esac
 
 		case `sysctl -n hw.machine_arch` in
-		armv6)
+		armv[67])
 			for i in ${ldconfig_localsoft_dirs}; do
 				if [ -d "${i}" ]; then
 					_files=`find ${i} -type f`

Modified: projects/clang600-import/include/stdlib.h
==============================================================================
--- projects/clang600-import/include/stdlib.h	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/include/stdlib.h	Sun Dec 24 13:22:57 2017	(r327150)
@@ -274,6 +274,7 @@ int	 cgetstr(char *, const char *, char **);
 int	 cgetustr(char *, const char *, char **);
 
 int	 daemon(int, int);
+int	 daemonfd(int, int);
 char	*devname(__dev_t, __mode_t);
 char	*devname_r(__dev_t, __mode_t, char *, int);
 char	*fdevname(int);

Modified: projects/clang600-import/lib/libc/gen/Symbol.map
==============================================================================
--- projects/clang600-import/lib/libc/gen/Symbol.map	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/lib/libc/gen/Symbol.map	Sun Dec 24 13:22:57 2017	(r327150)
@@ -394,6 +394,7 @@ FBSD_1.4 {
 FBSD_1.5 {
 	alphasort;
 	basename;
+	daemonfd;
 	devname;
 	devname_r;
 	dirname;

Modified: projects/clang600-import/lib/libc/gen/daemon.3
==============================================================================
--- projects/clang600-import/lib/libc/gen/daemon.3	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/lib/libc/gen/daemon.3	Sun Dec 24 13:22:57 2017	(r327150)
@@ -28,7 +28,7 @@
 .\"	@(#)daemon.3	8.1 (Berkeley) 6/9/93
 .\" $FreeBSD$
 .\"
-.Dd June 9, 1993
+.Dd December 23, 2017
 .Dt DAEMON 3
 .Os
 .Sh NAME
@@ -40,6 +40,8 @@
 .In stdlib.h
 .Ft int
 .Fn daemon "int nochdir" "int noclose"
+.Ft int
+.Fn daemonfd "int chdirfd" "int nullfd"
 .Sh DESCRIPTION
 The
 .Fn daemon
@@ -59,15 +61,39 @@ is non-zero,
 .Fn daemon
 will redirect standard input, standard output, and standard error to
 .Pa /dev/null .
+.Pp
+The
+.Fn daemonfd
+function is equivalent to the
+.Fn daemon
+function except that arguments are the descriptors for the current working
+directory and to the descriptor to
+.Pa /dev/null .
+.Pp
+If
+.Fa chdirfd
+is equal to
+.Pq -1
+the current working directory is not changed.
+.Pp
+If
+.Fa nullfd
+is equals to
+.Pq -1
+the redirection of standard input, standard output, and standard error is not
+closed.
 .Sh RETURN VALUES
-.Rv -std daemon
+.Rv -std daemon daemonfd
 .Sh ERRORS
 The
 .Fn daemon
+and
+.Fn daemonfd
 function may fail and set
 .Va errno
 for any of the errors specified for the library functions
 .Xr fork 2
+.Xr open 2,
 and
 .Xr setsid 2 .
 .Sh SEE ALSO
@@ -79,6 +105,10 @@ The
 .Fn daemon
 function first appeared in
 .Bx 4.4 .
+The
+.Fn daemonfd
+function first appeared in
+.Fx 12.0 .
 .Sh CAVEATS
 Unless the
 .Fa noclose

Modified: projects/clang600-import/lib/libc/gen/daemon.c
==============================================================================
--- projects/clang600-import/lib/libc/gen/daemon.c	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/lib/libc/gen/daemon.c	Sun Dec 24 13:22:57 2017	(r327150)
@@ -1,8 +1,9 @@
 /*-
  * SPDX-License-Identifier: BSD-3-Clause
  *
- * Copyright (c) 1990, 1993
- *	The Regents of the University of California.  All rights reserved.
+ * Copyright (c) 1990, 1993 The Regents of the University of California.
+ * Copyright (c) 2017 Mariusz Zaborski <oshogbo@FreeBSD.org>
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -46,10 +47,9 @@ __FBSDID("$FreeBSD$");
 #include "libc_private.h"
 
 int
-daemon(int nochdir, int noclose)
+daemonfd(int chdirfd, int nullfd)
 {
 	struct sigaction osa, sa;
-	int fd;
 	pid_t newgrp;
 	int oerrno;
 	int osa_ok;
@@ -83,15 +83,39 @@ daemon(int nochdir, int noclose)
 		return (-1);
 	}
 
-	if (!nochdir)
-		(void)chdir("/");
+	if (chdirfd != -1)
+		(void)fchdir(chdirfd);
 
-	if (!noclose && (fd = _open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
-		(void)_dup2(fd, STDIN_FILENO);
-		(void)_dup2(fd, STDOUT_FILENO);
-		(void)_dup2(fd, STDERR_FILENO);
-		if (fd > 2)
-			(void)_close(fd);
+	if (nullfd != -1) {
+		(void)_dup2(nullfd, STDIN_FILENO);
+		(void)_dup2(nullfd, STDOUT_FILENO);
+		(void)_dup2(nullfd, STDERR_FILENO);
 	}
 	return (0);
+}
+
+int
+daemon(int nochdir, int noclose)
+{
+	int chdirfd, nullfd, ret;
+
+	if (!noclose)
+		nullfd = _open(_PATH_DEVNULL, O_RDWR, 0);
+	else
+		nullfd = -1;
+
+	if (!nochdir)
+		chdirfd = _open("/", O_EXEC);
+	else
+		chdirfd = -1;
+
+	ret = daemonfd(chdirfd, nullfd);
+
+	if (chdirfd != -1)
+		_close(chdirfd);
+
+	if (nullfd > 2)
+		_close(nullfd);
+
+	return (ret);
 }

Modified: projects/clang600-import/lib/libc/net/getaddrinfo.c
==============================================================================
--- projects/clang600-import/lib/libc/net/getaddrinfo.c	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/lib/libc/net/getaddrinfo.c	Sun Dec 24 13:22:57 2017	(r327150)
@@ -1277,7 +1277,8 @@ explore_numeric(const struct addrinfo *pai, const char
 		 * does not accept.  So we need to separate the case for
 		 * AF_INET.
 		 */
-		if (inet_aton(hostname, (struct in_addr *)pton) != 1)
+		if (inet_aton(hostname, (struct in_addr *)pton) != 1 ||
+		    hostname[strspn(hostname, "0123456789.xabcdefXABCDEF")] != '\0')
 			return 0;
 		p = pton;
 		break;

Modified: projects/clang600-import/lib/libc/stdio/fopen.3
==============================================================================
--- projects/clang600-import/lib/libc/stdio/fopen.3	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/lib/libc/stdio/fopen.3	Sun Dec 24 13:22:57 2017	(r327150)
@@ -72,7 +72,7 @@ Fail if the file does not exist.
 .It Dq Li w
 Open for writing.
 The stream is positioned at the beginning of the file.
-Create the file if it does not exist.
+Truncate the file to zero length if it exists or create the file if it does not exist.
 .It Dq Li a
 Open for writing.
 The stream is positioned at the end of the file.

Modified: projects/clang600-import/lib/libdevinfo/devinfo.c
==============================================================================
--- projects/clang600-import/lib/libdevinfo/devinfo.c	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/lib/libdevinfo/devinfo.c	Sun Dec 24 13:22:57 2017	(r327150)
@@ -204,7 +204,7 @@ devinfo_init_devices(int generation)
 	 * Stop after a fairly insane number to avoid death in the case
 	 * of kernel corruption.
 	 */
-	for (dev_idx = 0; dev_idx < 1000; dev_idx++) {
+	for (dev_idx = 0; dev_idx < 10000; dev_idx++) {
 
 		/*
 		 * Get the device information.

Modified: projects/clang600-import/sbin/ipfw/altq.c
==============================================================================
--- projects/clang600-import/sbin/ipfw/altq.c	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/sbin/ipfw/altq.c	Sun Dec 24 13:22:57 2017	(r327150)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 2002-2003 Luigi Rizzo
  * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp
  * Copyright (c) 1994 Ugen J.S.Antsilevich

Modified: projects/clang600-import/sbin/ipfw/dummynet.c
==============================================================================
--- projects/clang600-import/sbin/ipfw/dummynet.c	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/sbin/ipfw/dummynet.c	Sun Dec 24 13:22:57 2017	(r327150)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Codel/FQ_Codel and PIE/FQ_PIE Code:
  * Copyright (C) 2016 Centre for Advanced Internet Architectures,
  *  Swinburne University of Technology, Melbourne, Australia.

Modified: projects/clang600-import/sbin/ipfw/ipfw2.c
==============================================================================
--- projects/clang600-import/sbin/ipfw/ipfw2.c	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/sbin/ipfw/ipfw2.c	Sun Dec 24 13:22:57 2017	(r327150)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 2002-2003 Luigi Rizzo
  * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp
  * Copyright (c) 1994 Ugen J.S.Antsilevich
@@ -2256,12 +2256,13 @@ do_range_cmd(int cmd, ipfw_range_tlv *rt)
 void
 ipfw_sets_handler(char *av[])
 {
-	uint32_t masks[2];
-	int i;
-	uint8_t cmd, rulenum;
 	ipfw_range_tlv rt;
 	char *msg;
 	size_t size;
+	uint32_t masks[2];
+	int i;
+	uint16_t rulenum;
+	uint8_t cmd;
 
 	av++;
 	memset(&rt, 0, sizeof(rt));

Modified: projects/clang600-import/sbin/ipfw/ipfw2.h
==============================================================================
--- projects/clang600-import/sbin/ipfw/ipfw2.h	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/sbin/ipfw/ipfw2.h	Sun Dec 24 13:22:57 2017	(r327150)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 2002-2003 Luigi Rizzo
  * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp
  * Copyright (c) 1994 Ugen J.S.Antsilevich

Modified: projects/clang600-import/sbin/ipfw/ipv6.c
==============================================================================
--- projects/clang600-import/sbin/ipfw/ipv6.c	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/sbin/ipfw/ipv6.c	Sun Dec 24 13:22:57 2017	(r327150)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 2002-2003 Luigi Rizzo
  * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp
  * Copyright (c) 1994 Ugen J.S.Antsilevich

Modified: projects/clang600-import/sbin/ipfw/main.c
==============================================================================
--- projects/clang600-import/sbin/ipfw/main.c	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/sbin/ipfw/main.c	Sun Dec 24 13:22:57 2017	(r327150)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 2002-2003,2010 Luigi Rizzo
  * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp
  * Copyright (c) 1994 Ugen J.S.Antsilevich

Modified: projects/clang600-import/sbin/ipfw/nat.c
==============================================================================
--- projects/clang600-import/sbin/ipfw/nat.c	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/sbin/ipfw/nat.c	Sun Dec 24 13:22:57 2017	(r327150)
@@ -1,4 +1,4 @@
-/*
+/*-
  * Copyright (c) 2002-2003 Luigi Rizzo
  * Copyright (c) 1996 Alex Nash, Paul Traina, Poul-Henning Kamp
  * Copyright (c) 1994 Ugen J.S.Antsilevich

Modified: projects/clang600-import/sbin/reboot/reboot.8
==============================================================================
--- projects/clang600-import/sbin/reboot/reboot.8	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/sbin/reboot/reboot.8	Sun Dec 24 13:22:57 2017	(r327150)
@@ -28,7 +28,7 @@
 .\"	@(#)reboot.8	8.1 (Berkeley) 6/9/93
 .\" $FreeBSD$
 .\"
-.Dd October 23, 2017
+.Dd December 20, 2017
 .Dt REBOOT 8
 .Os
 .Sh NAME
@@ -142,6 +142,12 @@ After changing vfs.root.mountfrom with
 .Xr kenv 1 ,
 .Nm Fl r
 can be used to change the root filesystem while preserving kernel state.
+This requires the
+.Xr tmpfs 5
+kernel module to be loaded because
+.Xr init 8
+needs a place to store itself after the old root is unmounted, but
+before the new root is in place.
 .El
 .Pp
 The

Modified: projects/clang600-import/share/man/man4/Makefile
==============================================================================
--- projects/clang600-import/share/man/man4/Makefile	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/share/man/man4/Makefile	Sun Dec 24 13:22:57 2017	(r327150)
@@ -382,6 +382,7 @@ MAN=	aac.4 \
 	${_ntb_hw_intel.4} \
 	${_ntb_hw_plx.4} \
 	${_ntb_transport.4} \
+	${_nda.4} \
 	${_if_ntb.4} \
 	null.4 \
 	numa.4 \
@@ -808,6 +809,7 @@ _if_wpi.4=	if_wpi.4
 _ipmi.4=	ipmi.4
 _io.4=		io.4
 _linux.4=	linux.4
+_nda.4=		nda.4
 _ndis.4=	ndis.4
 _nfe.4=		nfe.4
 _nfsmb.4=	nfsmb.4

Modified: projects/clang600-import/share/man/man4/ada.4
==============================================================================
--- projects/clang600-import/share/man/man4/ada.4	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/share/man/man4/ada.4	Sun Dec 24 13:22:57 2017	(r327150)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd June 19, 2015
+.Dd December 20, 2017
 .Dt ADA 4
 .Os
 .Sh NAME
@@ -157,6 +157,7 @@ ATA device nodes
 .Xr cam 4 ,
 .Xr da 4 ,
 .Xr mvs 4 ,
+.Xr nda 4 ,
 .Xr siis 4
 .Sh HISTORY
 The

Modified: projects/clang600-import/share/man/man4/da.4
==============================================================================
--- projects/clang600-import/share/man/man4/da.4	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/share/man/man4/da.4	Sun Dec 24 13:22:57 2017	(r327150)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd October 11, 2015
+.Dd December 20, 2017
 .Dt DA 4
 .Os
 .Sh NAME
@@ -214,6 +214,7 @@ None.
 .Xr ada 4 ,
 .Xr cam 4 ,
 .Xr geom 4 ,
+.Xr nda 4 ,
 .Xr gpart 8
 .Sh HISTORY
 The

Modified: projects/clang600-import/share/man/man4/em.4
==============================================================================
--- projects/clang600-import/share/man/man4/em.4	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/share/man/man4/em.4	Sun Dec 24 13:22:57 2017	(r327150)
@@ -319,6 +319,6 @@ The
 driver was originally written by
 .An Intel Corporation Aq Mt freebsd@intel.com .
 It was merged with igb driver and converted to the iflib framework by
-.An Matthew Macy Aq Mt mmacy@nextbsd.org
+.An Matthew Macy Aq Mt mmacy@mattmacy.io
 and
 .An Sean Bruno Aq Mt sbruno@FreeBSD.org .

Modified: projects/clang600-import/share/man/man4/md.4
==============================================================================
--- projects/clang600-import/share/man/man4/md.4	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/share/man/man4/md.4	Sun Dec 24 13:22:57 2017	(r327150)
@@ -7,7 +7,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd November 5, 2017
+.Dd December 7, 2017
 .Dt MD 4
 .Os
 .Sh NAME
@@ -79,7 +79,8 @@ To create a kernel with a ramdisk or MD file system, y
 needs the following options:
 .Bd -literal -offset indent
 options 	MD_ROOT			# MD is a potential root device
-options		MD_ROOT_SIZE=8192	# 8MB ram disk
+options 	MD_ROOT_READONLY	# disallow mounting root writeable
+options 	MD_ROOT_SIZE=8192	# 8MB ram disk
 makeoptions	MFS_IMAGE=/h/foo/ARM-MD
 options 	ROOTDEVNAME=\\"ufs:md0\\"
 .Ed

Copied: projects/clang600-import/share/man/man4/nda.4 (from r327149, head/share/man/man4/nda.4)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/clang600-import/share/man/man4/nda.4	Sun Dec 24 13:22:57 2017	(r327150, copy of r327149, head/share/man/man4/nda.4)
@@ -0,0 +1,87 @@
+.\" Copyright (c) 2017 Netflix, Inc
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\"
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd December 20, 2017
+.Dt NDA 4
+.Os
+.Sh NAME
+.Nm nda
+.Nd NVMe Direct Access device driver
+.Sh SYNOPSIS
+.Cd device nvme
+.Cd device scbus
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for direct access devices, implementing the
+.Tn NVMe
+command protocol, that are attached to the system through a host adapter
+supported by the CAM subsystem.
+.Sh SYSCTL VARIABLES
+The following variables are available as both
+.Xr sysctl 8
+variables and
+.Xr loader 8
+tunables:
+.Bl -tag -width 12
+.It Va kern.cam.nda.sort_io_queue
+.Pp
+This variable determines whether the software queued entries are
+sorted in LBA order or not.
+Sorting is almost always a waste of time.
+The default is to not sort.
+.El
+.Pp
+The following report per-device settings, and are read-only unless
+otherwise indicated. Replace
+.Va N
+with the device unit number.
+.Bl -tag -width 12
+.It Va kern.cam.nda.N.rotating
+.Pp
+This variable reports whether the storage volume is spinning or
+flash.
+It's value is hard coded to 0 indicating flash.
+.It Va kern.cam.nda.N.unmapped_io
+This variable reports whether the
+.Nm
+driver accepts unmapped I/O for this unit.
+.Sh FILES
+.Bl -tag -width ".Pa /dev/nda*" -compact
+.It Pa /dev/nda*
+NVMe storage device nodes
+.El
+.Sh SEE ALSO
+.Xr nvme 4 ,
+.Xr nvd 4
+.Sh HISTORY
+The
+.Nm
+driver first appeared in
+.Fx 12.0 .
+.Sh AUTHORS
+.An Warner Losh Aq Mt imp@FreeBSD.org

Modified: projects/clang600-import/share/man/man4/pci.4
==============================================================================
--- projects/clang600-import/share/man/man4/pci.4	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/share/man/man4/pci.4	Sun Dec 24 13:22:57 2017	(r327150)
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd September 8, 2016
+.Dd December 20, 2017
 .Dt PCI 4
 .Os
 .Sh NAME
@@ -492,6 +492,59 @@ The value of the tunable is the raw IRQ value to use f
 pin identified by the tunable name.
 Mapping of IRQ values to platform interrupt sources is machine dependent.
 .El
+.Sh DEVICE WIRING
+You can wire the device unit at a given location with device.hints.
+Entries of the form
+.Va hints.<name>.<unit>.at="pci<B>:<S>:<F>"
+or
+.Va hints.<name>.<unit>.at="pci<D>:<B>:<S>:<F>"
+will force the driver
+.Va name
+to probe and attach at unit
+.Va unit
+for any PCI device found to match the specification, where:
+.Bl -tag -width -indent
+.It <D>
+The domain
+.Pq or segment
+of the PCI device in decimal.
+Defaults to 0 if unspecified
+.It <B>
+The bus address of the PCI device in decimal.
+.It <S>
+The slot of the PCI device in decimal.
+.It <F>
+The function of the PCI device in decimal.
+.El
+.Pp
+The code to do the matching requires an exact string match.
+Do not specify the angle brackets
+.Pq < >
+in the hints file.
+Wiring multiple devices to the same
+.Va name
+and
+.Va unit
+produces undefined results.
+.Ss Examples
+Given the following lines in
+.Pa /boot/device.hints :
+.Cd hint.nvme.3.at="pci6:0:0"
+.Cd hint.igb.8.at="pci14:0:0"
+If there is a device that supports
+.Xr igb 4
+at PCI bus 14 slot 0 function 0,
+then it will be assigned igb8 for probe and attach.
+Likewise, if there is an
+.Xr nvme 4
+card at PCI bus 6 slot 0 function 0,
+then it will be assigned nvme3 for probe and attach.
+If another type of card is in either of these locations, the name and
+unit of that card will be the default names and will be unaffected by
+these hints.
+If other igb or nvme cards are located elsewhere, they will be
+assigned their unit numbers sequentially, skipping the unit numbers
+that have 'at' hints.
 .Sh FILES
 .Bl -tag -width /dev/pci -compact
 .It Pa /dev/pci

Modified: projects/clang600-import/share/man/man4/scsi.4
==============================================================================
--- projects/clang600-import/share/man/man4/scsi.4	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/share/man/man4/scsi.4	Sun Dec 24 13:22:57 2017	(r327150)
@@ -24,12 +24,12 @@
 .\" SUCH DAMAGE.
 .\"
 .\" $FreeBSD$
-.Dd January 15, 2017
+.Dd December 20, 2017
 .Dt CAM 4
 .Os
 .Sh NAME
 .Nm CAM
-.Nd Common Access Method SCSI/ATA subsystem
+.Nd Common Access Method Storage subsystem
 .Sh SYNOPSIS
 .Cd "device scbus"
 .Cd "device ada"
@@ -54,13 +54,17 @@ The
 .Nm
 subsystem provides a uniform and modular system for the implementation
 of drivers to control various
-.Tn SCSI
+.Tn SCSI ,
+.Tn ATA ,
+.Tn NMVe ,
 and
-.Tn ATA
+.Tn MMC / SD
 devices, and to utilize different
-.Tn SCSI
+.Tn SCSI ,
+.Tn ATA ,
+.Tn NVMe ,
 and
-.Tn ATA
+.Tn MMC / SD
 host adapters through host adapter drivers.
 When the system probes buses, it attaches any devices it finds to the
 appropriate drivers.
@@ -213,6 +217,31 @@ and use the first respective counted instances.
 These examples can be combined together to allow a peripheral device to be
 wired to any particular controller, bus, target, and/or unit instance.
 .Pp
+This also works with
+.Xr nvme 4
+drives as well.
+.Bd -literal -offset indent
+hint.nvme.4.at="pci7:0:0"
+hint.scbus.10.at="nvme4"
+hint.nda.10.at="scbus10"
+hint.nda.10.target="1"
+hint.nda.10.unit="12"
+hint.nda.11.at="scbus10"
+hint.nda.11.target="1"
+hint.nda.11.unit="2"
+.Ed
+.Pp
+This assigns the NVMe card living at PCI bus 7 to scbus 10 (in PCIe,
+slot and function are rarely used and usually 0).
+The target for
+.Xr nda 4
+devices is always 1.
+The unit is the namespace identifier from the drive.
+The namespace id 1 is exported as
+.Tn nda10
+and namespace id 2 is exported as
+.Tn nda11 .
+.Pp
 When you have a mixture of wired down and counted devices then the
 counting begins with the first non-wired down unit for a particular
 type.
@@ -225,9 +254,11 @@ The system allows common device drivers to work throug
 types of adapters.
 The adapters take requests from the upper layers and do
 all IO between the
-.Tn SCSI
+.Tn SCSI ,
+.Tn ATA ,
+.Tn NVMe ,
 or
-.Tn ATA
+.Tn MMC / SD
 bus and the system.
 The maximum size of a transfer is governed by the
 adapter.
@@ -322,6 +353,8 @@ for details.
 .Xr cd 4 ,
 .Xr ch 4 ,
 .Xr da 4 ,
+.Xr nda 4 ,
+.Xr nvme 4 ,
 .Xr pass 4 ,
 .Xr pt 4 ,
 .Xr sa 4 ,
@@ -351,3 +384,8 @@ The
 .Tn ATA
 support was added by
 .An Alexander Motin Aq Mt mav@FreeBSD.org .
+The
+.Nm
+.Tn NVMe
+support was added by
+.An Warner Losh Aq Mt imp@FreeBSD.org .

Modified: projects/clang600-import/share/man/man9/atomic.9
==============================================================================
--- projects/clang600-import/share/man/man9/atomic.9	Sun Dec 24 13:19:02 2017	(r327149)
+++ projects/clang600-import/share/man/man9/atomic.9	Sun Dec 24 13:22:57 2017	(r327150)
@@ -23,7 +23,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 23, 2017
+.Dd December 22, 2017
 .Dt ATOMIC 9
 .Os
 .Sh NAME
@@ -36,7 +36,8 @@
 .Nm atomic_readandclear ,
 .Nm atomic_set ,
 .Nm atomic_subtract ,
-.Nm atomic_store
+.Nm atomic_store ,
+.Nm atomic_thread_fence
 .Nd atomic operations
 .Sh SYNOPSIS
 .In sys/types.h
@@ -60,7 +61,7 @@
 .Ft <type>
 .Fn atomic_fetchadd_<type> "volatile <type> *p" "<type> v"
 .Ft <type>
-.Fn atomic_load_acq_<type> "volatile <type> *p"
+.Fn atomic_load_[acq_]<type> "volatile <type> *p"
 .Ft <type>
 .Fn atomic_readandclear_<type> "volatile <type> *p"
 .Ft void
@@ -68,19 +69,33 @@
 .Ft void
 .Fn atomic_subtract_[acq_|rel_]<type> "volatile <type> *p" "<type> v"
 .Ft void
-.Fn atomic_store_rel_<type> "volatile <type> *p" "<type> v"
+.Fn atomic_store_[rel_]<type> "volatile <type> *p" "<type> v"
 .Ft <type>
 .Fn atomic_swap_<type> "volatile <type> *p" "<type> v"
 .Ft int
 .Fn atomic_testandclear_<type> "volatile <type> *p" "u_int v"
 .Ft int
 .Fn atomic_testandset_<type> "volatile <type> *p" "u_int v"
+.Ft void
+.Fn atomic_thread_fence_[acq|acq_rel|rel|seq_cst] "void"
 .Sh DESCRIPTION
-All of these operations are performed atomically across multiple
-threads and in the presence of interrupts, meaning that they are               
-performed in an indivisible manner from the perspective of concurrently
+Atomic operations are commonly used to implement reference counts and as
+building blocks for synchronization primitives, such as mutexes.
+.Pp
+All of these operations are performed
+.Em atomically
+across multiple threads and in the presence of interrupts, meaning that they
+are performed in an indivisible manner from the perspective of concurrently
 running threads and interrupt handlers.
 .Pp
+On all architectures supported by
+.Fx ,
+ordinary loads and stores of integers in cache-coherent memory are
+inherently atomic if the integer is naturally aligned and its size does not
+exceed the processor's word size.
+However, such loads and stores may be elided from the program by
+the compiler, whereas atomic operations are always performed.
+.Pp
 When atomic operations are performed on cache-coherent memory, all
 operations on the same location are totally ordered.
 .Pp
@@ -93,29 +108,16 @@ interrupt handler will observe a
 .Em torn write ,
 or partial modification of the location.
 .Pp
-On all architectures supported by
-.Fx ,
-ordinary loads and stores of naturally aligned integer types
-are atomic, as executed by the processor.
-.Pp
-Atomic operations can be used to implement reference counts or as
-building blocks for synchronization primitives such as mutexes.
-.Pp
-The semantics of
-.Fx Ns 's
-atomic operations are almost identical to those of the similarly named
-C11 operations.
-The one important difference is that the C11 standard does not
-require ordinary loads and stores to ever be atomic.
-This is is why the
-.Fn atomic_load_explicit memory_order_relaxed
-operation exists in the C11 standard, but is not provided by
-.In machine/atomic.h .
+Except as noted below, the semantics of these operations are almost
+identical to the semantics of similarly named C11 atomic operations.
 .Ss Types
-Each atomic operation operates on a specific
+Most atomic operations act upon a specific
 .Fa type .
-The type to use is indicated in the function name.
-The available types that can be used are:
+That type is indicated in the function name.
+In contrast to C11 atomic operations,
+.Fx Ns 's
+atomic operations are performed on ordinary integer types.
+The available types are:
 .Pp
 .Bl -tag -offset indent -width short -compact
 .It Li int
@@ -147,8 +149,7 @@ unsigned 8-bit integer
 unsigned 16-bit integer
 .El
 .Pp
-These must not be used in MI code because the instructions to implement them
-efficiently might not be available.
+These types must not be used in machine-independent code.
 .Ss Acquire and Release Operations
 By default, a thread's accesses to different memory locations might not be
 performed in
@@ -167,52 +168,67 @@ Moreover, in some cases, such as the implementation of
 threads, arbitrary reordering might result in the incorrect execution of the
 program.
 To constrain the reordering that both the compiler and processor might perform
-on a thread's accesses, the thread should use atomic operations with
+on a thread's accesses, a programmer can use atomic operations with
 .Em acquire
 and
 .Em release
 semantics.
 .Pp
-Most of the atomic operations on memory have three variants.
-The first variant performs the operation without imposing any ordering
-constraints on memory accesses to other locations.
+Atomic operations on memory have up to three variants.
+The first, or
+.Em relaxed
+variant, performs the operation without imposing any ordering constraints on
+accesses to other memory locations.
+This variant is the default.
 The second variant has acquire semantics, and the third variant has release
 semantics.
-In effect, operations with acquire and release semantics establish one-way
-barriers to reordering.
 .Pp
-When an atomic operation has acquire semantics, the effects of the operation
-must have completed before any subsequent load or store (by program order) is
+When an atomic operation has acquire semantics, the operation must have
+completed before any subsequent load or store (by program order) is
 performed.
 Conversely, acquire semantics do not require that prior loads or stores have
 completed before the atomic operation is performed.
+An atomic operation can only have acquire semantics if it performs a load
+from memory.
 To denote acquire semantics, the suffix
 .Dq Li _acq
 is inserted into the function name immediately prior to the
 .Dq Li _ Ns Aq Fa type
 suffix.
-For example, to subtract two integers ensuring that subsequent loads and
-stores happen after the subtraction is performed, use
+For example, to subtract two integers ensuring that the subtraction is
+completed before any subsequent loads and stores are performed, use
 .Fn atomic_subtract_acq_int .
 .Pp
-When an atomic operation has release semantics, the effects of all prior
-loads or stores (by program order) must have completed before the operation
-is performed.
-Conversely, release semantics do not require that the effects of the
-atomic operation must have completed before any subsequent load or store is
-performed.
+When an atomic operation has release semantics, all prior loads or stores
+(by program order) must have completed before the operation is performed.
+Conversely, release semantics do not require that the atomic operation must
+have completed before any subsequent load or store is performed.
+An atomic operation can only have release semantics if it performs a store
+to memory.
 To denote release semantics, the suffix
 .Dq Li _rel
 is inserted into the function name immediately prior to the
 .Dq Li _ Ns Aq Fa type
 suffix.
 For example, to add two long integers ensuring that all prior loads and
-stores happen before the addition, use
+stores are completed before the addition is performed, use
 .Fn atomic_add_rel_long .
 .Pp
-The one-way barriers provided by acquire and release operations allow the
-implementations of common synchronization primitives to express their
-ordering requirements without also imposing unnecessary ordering.
+When a release operation by one thread
+.Em synchronizes with
+an acquire operation by another thread, usually meaning that the acquire
+operation reads the value written by the release operation, then the effects
+of all prior stores by the releasing thread must become visible to
+subsequent loads by the acquiring thread.
+Moreover, the effects of all stores (by other threads) that were visible to
+the releasing thread must also become visible to the acquiring thread.
+These rules only apply to the synchronizing threads.
+Other threads might observe these stores in a different order.
+.Pp
+In effect, atomic operations with acquire and release semantics establish
+one-way barriers to reordering that enable the implementations of
+synchronization primitives to express their ordering requirements without
+also imposing unnecessary ordering.
 For example, for a critical section guarded by a mutex, an acquire operation
 when the mutex is locked and a release operation when the mutex is unlocked
 will prevent any loads or stores from moving outside of the critical
@@ -220,6 +236,61 @@ section.
 However, they will not prevent the compiler or processor from moving loads
 or stores into the critical section, which does not violate the semantics of
 a mutex.
+.Ss Thread Fence Operations
+Alternatively, a programmer can use atomic thread fence operations to
+constrain the reordering of accesses.
+In contrast to other atomic operations, fences do not, themselves, access
+memory.
+.Pp
+When a fence has acquire semantics, all prior loads (by program order) must
+have completed before any subsequent load or store is performed.
+Thus, an acquire fence is a two-way barrier for load operations.
+To denote acquire semantics, the suffix
+.Dq Li _acq
+is appended to the function name, for example,
+.Fn atomic_thread_fence_acq .
+.Pp
+When a fence has release semantics, all prior loads or stores (by program
+order) must have completed before any subsequent store operation is
+performed.
+Thus, a release fence is a two-way barrier for store operations.
+To denote release semantics, the suffix
+.Dq Li _rel
+is appended to the function name, for example,
+.Fn atomic_thread_fence_rel .
+.Pp
+Although
+.Fn atomic_thread_fence_acq_rel
+implements both acquire and release semantics, it is not a full barrier.
+For example, a store prior to the fence (in program order) may be completed
+after a load subsequent to the fence.
+In contrast,
+.Fn atomic_thread_fence_seq_cst
+implements a full barrier.
+Neither loads nor stores may cross this barrier in either direction.
+.Pp
+In C11, a release fence by one thread synchronizes with an acquire fence by
+another thread when an atomic load that is prior to the acquire fence (by
+program order) reads the value written by an atomic store that is subsequent
+to the release fence.
+In constrast, in FreeBSD, because of the atomicity of ordinary, naturally
+aligned loads and stores, fences can also be synchronized by ordinary loads
+and stores.
+This simplifies the implementation and use of some synchronization
+primitives in
+.Fx .
+.Pp
+Since neither a compiler nor a processor can foresee which (atomic) load
+will read the value written by an (atomic) store, the ordering constraints
+imposed by fences must be more restrictive than acquire loads and release
+stores.
+Essentially, this is why fences are two-way barriers.
+.Pp
+Although fences impose more restrictive ordering than acquire loads and
+release stores, by separating access from ordering, they can sometimes
+facilitate more efficient implementations of synchronization primitives.
+For example, they can be used to avoid executing a memory barrier until a
+memory access shows that some condition is satisfied.
 .Ss Multiple Processors
 In multiprocessor systems, the atomicity of the atomic operations on memory
 depends on support for cache coherence in the underlying architecture.
@@ -326,12 +397,6 @@ and do not have any variants with memory barriers at t
 .Bd -literal -compact
 return (*p);
 .Ed
-.El
-.Pp
-The
-.Fn atomic_load
-functions are only provided with acquire memory barriers.
-.Bl -hang
 .It Fn atomic_readandclear p
 .Bd -literal -compact
 tmp = *p;
@@ -363,12 +428,6 @@ and do not have any variants with memory barriers at t
 .Bd -literal -compact
 *p = v;
 .Ed
-.El
-.Pp
-The
-.Fn atomic_store
-functions are only provided with release memory barriers.
-.Bl -hang
 .It Fn atomic_swap p v
 .Bd -literal -compact
 tmp = *p;
@@ -490,43 +549,54 @@ The
 .Fn atomic_set ,
 and
 .Fn atomic_subtract
-operations were first introduced in
+operations were introduced in
 .Fx 3.0 .
-This first set only supported the types
+Initially, these operations were defined on the types
 .Dq Li char ,
 .Dq Li short ,
 .Dq Li int ,
 and
 .Dq Li long .
+.Pp
 The
 .Fn atomic_cmpset ,
-.Fn atomic_load ,
+.Fn atomic_load_acq ,
 .Fn atomic_readandclear ,
 and
-.Fn atomic_store

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712241322.vBODMwnY089807>