summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-10-23 21:09:37 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-10-23 21:09:37 +0000
commitc6879c6c14eedbd060ba588a3129a6c60ebbe783 (patch)
tree5683dd105fe8d67b5a6bdb7b3750882d6d7a1de1 /lib
parent950f620367c0d671ae62df35e8dc12b682c955ef (diff)
parent8c6d2039230c7c4039c8fa42bf95dbec842783f4 (diff)
Notes
Diffstat (limited to 'lib')
-rw-r--r--lib/clang/freebsd_cc_version.h2
-rw-r--r--lib/clang/include/lld/Common/Version.inc2
-rw-r--r--lib/clang/llvm.build.mk2
-rw-r--r--lib/csu/aarch64/Makefile1
-rw-r--r--lib/csu/amd64/Makefile4
-rw-r--r--lib/csu/amd64/crt1.c6
-rw-r--r--lib/csu/amd64/reloc.c (renamed from lib/libc/locale/endian.h)66
-rw-r--r--lib/csu/arm/Makefile1
-rw-r--r--lib/csu/arm/crt1.c4
-rw-r--r--lib/csu/common/crtbrand.c3
-rw-r--r--lib/csu/common/ignore_init.c44
-rw-r--r--lib/csu/common/notes.h4
-rw-r--r--lib/csu/i386/Makefile3
-rw-r--r--lib/csu/i386/crt1_c.c6
-rw-r--r--lib/csu/i386/reloc.c88
-rw-r--r--lib/csu/mips/Makefile1
-rw-r--r--lib/csu/powerpc/Makefile1
-rw-r--r--lib/csu/powerpc64/Makefile2
-rw-r--r--lib/csu/riscv/Makefile1
-rw-r--r--lib/csu/sparc64/Makefile1
-rw-r--r--lib/libbe/be.c20
-rw-r--r--lib/libc/amd64/string/Makefile.inc1
-rw-r--r--lib/libc/amd64/string/bcopy.S103
-rw-r--r--lib/libc/amd64/string/bcopy.c15
-rw-r--r--lib/libc/amd64/string/bzero.S45
-rw-r--r--lib/libc/amd64/string/memcpy.S4
-rw-r--r--lib/libc/amd64/string/memmove.S273
-rw-r--r--lib/libc/amd64/string/memset.S166
-rw-r--r--lib/libc/gen/Makefile.inc1
-rw-r--r--lib/libc/gen/arc4random.c1
-rw-r--r--lib/libc/gen/getentropy.c19
-rw-r--r--lib/libc/gen/getgrent.c48
-rw-r--r--lib/libc/gmon/mcount.c3
-rw-r--r--lib/libc/locale/collate.c43
-rw-r--r--lib/libc/locale/rune.c56
-rw-r--r--lib/libc/net/nsdispatch.37
-rw-r--r--lib/libc/net/nsdispatch.c14
-rw-r--r--lib/libc/net/nslexer.l1
-rw-r--r--lib/libc/quad/adddi3.c3
-rw-r--r--lib/libc/quad/anddi3.c3
-rw-r--r--lib/libc/quad/ashldi3.c4
-rw-r--r--lib/libc/quad/ashrdi3.c4
-rw-r--r--lib/libc/quad/cmpdi2.c3
-rw-r--r--lib/libc/quad/divdi3.c3
-rw-r--r--lib/libc/quad/fixdfdi.c3
-rw-r--r--lib/libc/quad/fixunsdfdi.c3
-rw-r--r--lib/libc/quad/floatdidf.c3
-rw-r--r--lib/libc/quad/floatdisf.c3
-rw-r--r--lib/libc/quad/floatunsdidf.c3
-rw-r--r--lib/libc/quad/iordi3.c3
-rw-r--r--lib/libc/quad/lshldi3.c4
-rw-r--r--lib/libc/quad/lshrdi3.c4
-rw-r--r--lib/libc/quad/moddi3.c3
-rw-r--r--lib/libc/quad/muldi3.c3
-rw-r--r--lib/libc/quad/negdi2.c3
-rw-r--r--lib/libc/quad/notdi2.c3
-rw-r--r--lib/libc/quad/qdivrem.c3
-rw-r--r--lib/libc/quad/subdi3.c3
-rw-r--r--lib/libc/quad/ucmpdi2.c3
-rw-r--r--lib/libc/quad/udivdi3.c3
-rw-r--r--lib/libc/quad/umoddi3.c3
-rw-r--r--lib/libc/quad/xordi3.c3
-rw-r--r--lib/libc/stdio/fgets.32
-rw-r--r--lib/libc/stdio/fopen.34
-rw-r--r--lib/libc/stdtime/strptime.c30
-rw-r--r--lib/libc/string/memmem.c18
-rw-r--r--lib/libc/sys/pdfork.23
-rw-r--r--lib/libc/sys/recv.29
-rw-r--r--lib/libc/sys/sendfile.28
-rw-r--r--lib/libfetch/common.c4
-rw-r--r--lib/libldns/Makefile2
-rw-r--r--lib/libmemstat/memstat_malloc.c66
-rw-r--r--lib/libmp/mpasbn.c118
-rw-r--r--lib/libradius/radlib.c63
-rw-r--r--lib/libsysdecode/Makefile5
-rw-r--r--lib/libsysdecode/mktables2
-rw-r--r--lib/libunbound/Makefile10
-rw-r--r--lib/libusb/libusb.318
-rw-r--r--lib/libzstd/Makefile5
-rw-r--r--lib/ncurses/ncurses/Makefile3
80 files changed, 967 insertions, 541 deletions
diff --git a/lib/clang/freebsd_cc_version.h b/lib/clang/freebsd_cc_version.h
index 9096dc913f141..cd380c58b1aa2 100644
--- a/lib/clang/freebsd_cc_version.h
+++ b/lib/clang/freebsd_cc_version.h
@@ -1,3 +1,3 @@
/* $FreeBSD$ */
-#define FREEBSD_CC_VERSION 1200016
+#define FREEBSD_CC_VERSION 1300001
diff --git a/lib/clang/include/lld/Common/Version.inc b/lib/clang/include/lld/Common/Version.inc
index c9e1301c51fa5..63177c7cceaf8 100644
--- a/lib/clang/include/lld/Common/Version.inc
+++ b/lib/clang/include/lld/Common/Version.inc
@@ -7,4 +7,4 @@
#define LLD_REPOSITORY_STRING "FreeBSD"
// <Upstream revision at import>-<Local identifier in __FreeBSD_version style>
-#define LLD_REVISION_STRING "342383-1200005"
+#define LLD_REVISION_STRING "342383-1300001"
diff --git a/lib/clang/llvm.build.mk b/lib/clang/llvm.build.mk
index 920c79bb11ae2..71c0b17d4fdf3 100644
--- a/lib/clang/llvm.build.mk
+++ b/lib/clang/llvm.build.mk
@@ -33,7 +33,7 @@ TARGET_ABI= -gnueabi
TARGET_ABI=
.endif
VENDOR= unknown
-OS_VERSION= freebsd12.0
+OS_VERSION= freebsd13.0
LLVM_TARGET_TRIPLE?= ${TARGET_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-${VENDOR}-${OS_VERSION}${TARGET_ABI}
LLVM_BUILD_TRIPLE?= ${BUILD_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-${VENDOR}-${OS_VERSION}
diff --git a/lib/csu/aarch64/Makefile b/lib/csu/aarch64/Makefile
index 3f34ff3516230..df1fe6e2343bd 100644
--- a/lib/csu/aarch64/Makefile
+++ b/lib/csu/aarch64/Makefile
@@ -7,6 +7,7 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
CFLAGS+= -I${.CURDIR:H}/common \
-I${SRCTOP}/lib/libc/include
+CFLAGS+= -DCRT_IRELOC_SUPPRESS
FILES= ${OBJS}
FILESMODE= ${LIBMODE}
diff --git a/lib/csu/amd64/Makefile b/lib/csu/amd64/Makefile
index a6a2d5ec658d6..493ad93173b08 100644
--- a/lib/csu/amd64/Makefile
+++ b/lib/csu/amd64/Makefile
@@ -5,9 +5,9 @@
SRCS= crt1.c crti.S crtn.S
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
-CFLAGS+= -I${.CURDIR:H}/common \
+CFLAGS+= -I${.CURDIR} -I${.CURDIR:H}/common \
-I${SRCTOP}/lib/libc/include
-CFLAGS+= -fno-omit-frame-pointer
+CFLAGS+= -fno-omit-frame-pointer -DCRT_IRELOC_RELA
FILES= ${OBJS}
FILESMODE= ${LIBMODE}
diff --git a/lib/csu/amd64/crt1.c b/lib/csu/amd64/crt1.c
index a6001b2d5851e..7b9b442a4c0ac 100644
--- a/lib/csu/amd64/crt1.c
+++ b/lib/csu/amd64/crt1.c
@@ -59,10 +59,12 @@ _start(char **ap, void (*cleanup)(void))
env = ap + 2 + argc;
handle_argv(argc, argv, env);
- if (&_DYNAMIC != NULL)
+ if (&_DYNAMIC != NULL) {
atexit(cleanup);
- else
+ } else {
+ process_irelocs();
_init_tls();
+ }
#ifdef GCRT
atexit(_mcleanup);
diff --git a/lib/libc/locale/endian.h b/lib/csu/amd64/reloc.c
index d3b822788688b..cc4a7e73caba9 100644
--- a/lib/libc/locale/endian.h
+++ b/lib/csu/amd64/reloc.c
@@ -1,14 +1,8 @@
/*-
- * Copyright (c) 2016 Ruslan Bukin <br@bsdpad.com>
- * All rights reserved.
+ * Copyright (c) 2018 The FreeBSD Foundation
*
- * Portions of this software were developed by SRI International and the
- * University of Cambridge Computer Laboratory under DARPA/AFRL contract
- * FA8750-10-C-0237 ("CTSRD"), as part of the DARPA CRASH research programme.
- *
- * Portions of this software were developed by the University of Cambridge
- * Computer Laboratory as part of the CTSRD Project, with support from the
- * UK Higher Education Innovation Fund (HEIF).
+ * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -22,7 +16,7 @@
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -30,23 +24,43 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
- * $FreeBSD$
*/
-#include <sys/endian.h>
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
-/*
- * We assume locale files were generated on EL machine
- * (e.g. during cross build on amd64 host), but used on EB
- * machine (e.g. MIPS64EB), so convert it to host endianness.
- *
- * TODO: detect host endianness on the build machine and use
- * correct macros here.
- */
+#include <machine/specialreg.h>
+#include <machine/cpufunc.h>
+
+static void
+crt1_handle_rela(const Elf_Rela *r)
+{
+ Elf_Addr *ptr, *where, target;
+ u_int p[4];
+ uint32_t cpu_feature, cpu_feature2;
+ uint32_t cpu_stdext_feature, cpu_stdext_feature2;
+
+ do_cpuid(1, p);
+ cpu_feature = p[3];
+ cpu_feature2 = p[2];
+ do_cpuid(0, p);
+ if (p[0] >= 7) {
+ cpuid_count(7, 0, p);
+ cpu_stdext_feature = p[1];
+ cpu_stdext_feature2 = p[2];
+ } else {
+ cpu_stdext_feature = 0;
+ cpu_stdext_feature2 = 0;
+ }
-#if BYTE_ORDER == BIG_ENDIAN && defined(__mips__)
-#define BSWAP(x) le32toh(x)
-#else
-#define BSWAP(x) x
-#endif
+ switch (ELF_R_TYPE(r->r_info)) {
+ case R_X86_64_IRELATIVE:
+ ptr = (Elf_Addr *)r->r_addend;
+ where = (Elf_Addr *)r->r_offset;
+ target = ((Elf_Addr (*)(uint32_t, uint32_t, uint32_t,
+ uint32_t))ptr)(cpu_feature, cpu_feature2,
+ cpu_stdext_feature, cpu_stdext_feature2);
+ *where = target;
+ break;
+ }
+}
diff --git a/lib/csu/arm/Makefile b/lib/csu/arm/Makefile
index 53775967349c5..8a251f8ca09e8 100644
--- a/lib/csu/arm/Makefile
+++ b/lib/csu/arm/Makefile
@@ -7,6 +7,7 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
CFLAGS+= -I${.CURDIR:H}/common \
-I${SRCTOP}/lib/libc/include
+CFLAGS+= -DCRT_IRELOC_SUPPRESS
STATIC_CFLAGS+= -mlong-calls
FILES= ${OBJS}
diff --git a/lib/csu/arm/crt1.c b/lib/csu/arm/crt1.c
index 5fe92947dbfb7..0d61d319f3513 100644
--- a/lib/csu/arm/crt1.c
+++ b/lib/csu/arm/crt1.c
@@ -44,6 +44,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/param.h>
+#include <sys/elf_common.h>
#include <stdlib.h>
#include "libc_private.h"
@@ -120,7 +122,7 @@ static const struct {
} archtag __attribute__ ((section (NOTE_SECTION), aligned(4))) __used = {
.namesz = sizeof(NOTE_FREEBSD_VENDOR),
.descsz = sizeof(MACHINE_ARCH),
- .type = ARCH_NOTETYPE,
+ .type = NT_FREEBSD_ARCH_TAG,
.name = NOTE_FREEBSD_VENDOR,
.desc = MACHINE_ARCH
};
diff --git a/lib/csu/common/crtbrand.c b/lib/csu/common/crtbrand.c
index fcdb824cf7493..c407de435b967 100644
--- a/lib/csu/common/crtbrand.c
+++ b/lib/csu/common/crtbrand.c
@@ -29,6 +29,7 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
+#include <sys/elf_common.h>
#include "notes.h"
/*
@@ -62,7 +63,7 @@ static const struct {
} abitag __attribute__ ((section (NOTE_SECTION), aligned(4))) __used = {
.namesz = sizeof(NOTE_FREEBSD_VENDOR),
.descsz = sizeof(int32_t),
- .type = ABI_NOTETYPE,
+ .type = NT_FREEBSD_ABI_TAG,
.name = NOTE_FREEBSD_VENDOR,
.desc = __FreeBSD_version
};
diff --git a/lib/csu/common/ignore_init.c b/lib/csu/common/ignore_init.c
index 184bcbdf54470..8712661b44f79 100644
--- a/lib/csu/common/ignore_init.c
+++ b/lib/csu/common/ignore_init.c
@@ -2,7 +2,10 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright 2012 Konstantin Belousov <kib@FreeBSD.org>
- * All rights reserved.
+ * Copyright (c) 2018 The FreeBSD Foundation
+ *
+ * Parts of this software was developed by Konstantin Belousov
+ * <kib@FreeBSD.org> under sponsorship from the FreeBSD Foundation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -28,6 +31,10 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/param.h>
+#include <sys/elf.h>
+#include <sys/elf_common.h>
+
#include "notes.h"
extern int main(int, char **, char **);
@@ -44,6 +51,39 @@ extern void _init(void) __hidden;
extern int _DYNAMIC;
#pragma weak _DYNAMIC
+#if defined(CRT_IRELOC_RELA)
+extern const Elf_Rela __rela_iplt_start[] __weak_symbol __hidden;
+extern const Elf_Rela __rela_iplt_end[] __weak_symbol __hidden;
+
+#include "reloc.c"
+
+static void
+process_irelocs(void)
+{
+ const Elf_Rela *r;
+
+ for (r = &__rela_iplt_start[0]; r < &__rela_iplt_end[0]; r++)
+ crt1_handle_rela(r);
+}
+#elif defined(CRT_IRELOC_REL)
+extern const Elf_Rel __rel_iplt_start[] __weak_symbol __hidden;
+extern const Elf_Rel __rel_iplt_end[] __weak_symbol __hidden;
+
+#include "reloc.c"
+
+static void
+process_irelocs(void)
+{
+ const Elf_Rel *r;
+
+ for (r = &__rel_iplt_start[0]; r < &__rel_iplt_end[0]; r++)
+ crt1_handle_rel(r);
+}
+#elif defined(CRT_IRELOC_SUPPRESS)
+#else
+#error "Define platform reloc type"
+#endif
+
char **environ;
const char *__progname = "";
@@ -114,7 +154,7 @@ static const struct {
aligned(4))) __used = {
.namesz = sizeof(NOTE_FREEBSD_VENDOR),
.descsz = sizeof(uint32_t),
- .type = CRT_NOINIT_NOTETYPE,
+ .type = NT_FREEBSD_NOINIT_TAG,
.name = NOTE_FREEBSD_VENDOR,
.desc = 0
};
diff --git a/lib/csu/common/notes.h b/lib/csu/common/notes.h
index aeb5203d8dc1f..44d2d95487cba 100644
--- a/lib/csu/common/notes.h
+++ b/lib/csu/common/notes.h
@@ -34,8 +34,4 @@
#define NOTE_SECTION ".note.tag"
-#define ABI_NOTETYPE 1
-#define CRT_NOINIT_NOTETYPE 2
-#define ARCH_NOTETYPE 3
-
#endif
diff --git a/lib/csu/i386/Makefile b/lib/csu/i386/Makefile
index 9ca3f1fcbd87c..4e8117f350bca 100644
--- a/lib/csu/i386/Makefile
+++ b/lib/csu/i386/Makefile
@@ -5,8 +5,9 @@
SRCS= crti.S crtn.S
OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= gcrt1.o crt1.o Scrt1.o
-CFLAGS+= -I${.CURDIR:H}/common \
+CFLAGS+= -I${.CURDIR} -I${.CURDIR:H}/common \
-I${SRCTOP}/lib/libc/include
+CFLAGS+= -DCRT_IRELOC_REL
FILES= ${OBJS}
FILESMODE= ${LIBMODE}
diff --git a/lib/csu/i386/crt1_c.c b/lib/csu/i386/crt1_c.c
index 8b16f160ea420..b3e6cb330c26a 100644
--- a/lib/csu/i386/crt1_c.c
+++ b/lib/csu/i386/crt1_c.c
@@ -56,10 +56,12 @@ _start1(fptr cleanup, int argc, char *argv[])
env = argv + argc + 1;
handle_argv(argc, argv, env);
- if (&_DYNAMIC != NULL)
+ if (&_DYNAMIC != NULL) {
atexit(cleanup);
- else
+ } else {
+ process_irelocs();
_init_tls();
+ }
#ifdef GCRT
atexit(_mcleanup);
diff --git a/lib/csu/i386/reloc.c b/lib/csu/i386/reloc.c
new file mode 100644
index 0000000000000..46551ffc0c222
--- /dev/null
+++ b/lib/csu/i386/reloc.c
@@ -0,0 +1,88 @@
+/*-
+ * Copyright (c) 2018 The FreeBSD Foundation
+ *
+ * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <machine/specialreg.h>
+#include <machine/cpufunc.h>
+
+static void
+crt1_handle_rel(const Elf_Rel *r)
+{
+ Elf_Addr *where, target;
+ u_int cpuid_supported, p[4];
+ uint32_t cpu_feature, cpu_feature2;
+ uint32_t cpu_stdext_feature, cpu_stdext_feature2;
+
+ __asm __volatile(
+ " pushfl\n"
+ " popl %%eax\n"
+ " movl %%eax,%%ecx\n"
+ " xorl $0x200000,%%eax\n"
+ " pushl %%eax\n"
+ " popfl\n"
+ " pushfl\n"
+ " popl %%eax\n"
+ " xorl %%eax,%%ecx\n"
+ " je 1f\n"
+ " movl $1,%0\n"
+ " jmp 2f\n"
+ "1: movl $0,%0\n"
+ "2:\n"
+ : "=r" (cpuid_supported) : : "eax", "ecx", "cc");
+ if (cpuid_supported) {
+ do_cpuid(1, p);
+ cpu_feature = p[3];
+ cpu_feature2 = p[2];
+ do_cpuid(0, p);
+ if (p[0] >= 7) {
+ cpuid_count(7, 0, p);
+ cpu_stdext_feature = p[1];
+ cpu_stdext_feature2 = p[2];
+ } else {
+ cpu_stdext_feature = 0;
+ cpu_stdext_feature2 = 0;
+ }
+ } else {
+ cpu_feature = 0;
+ cpu_feature2 = 0;
+ cpu_stdext_feature = 0;
+ cpu_stdext_feature2 = 0;
+ }
+
+ switch (ELF_R_TYPE(r->r_info)) {
+ case R_386_IRELATIVE:
+ where = (Elf_Addr *)r->r_offset;
+ target = ((Elf_Addr (*)(uint32_t, uint32_t, uint32_t,
+ uint32_t))*where)(cpu_feature, cpu_feature2,
+ cpu_stdext_feature, cpu_stdext_feature2);
+ *where = target;
+ break;
+ }
+}
diff --git a/lib/csu/mips/Makefile b/lib/csu/mips/Makefile
index 3f34ff3516230..df1fe6e2343bd 100644
--- a/lib/csu/mips/Makefile
+++ b/lib/csu/mips/Makefile
@@ -7,6 +7,7 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
CFLAGS+= -I${.CURDIR:H}/common \
-I${SRCTOP}/lib/libc/include
+CFLAGS+= -DCRT_IRELOC_SUPPRESS
FILES= ${OBJS}
FILESMODE= ${LIBMODE}
diff --git a/lib/csu/powerpc/Makefile b/lib/csu/powerpc/Makefile
index 3f34ff3516230..df1fe6e2343bd 100644
--- a/lib/csu/powerpc/Makefile
+++ b/lib/csu/powerpc/Makefile
@@ -7,6 +7,7 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
CFLAGS+= -I${.CURDIR:H}/common \
-I${SRCTOP}/lib/libc/include
+CFLAGS+= -DCRT_IRELOC_SUPPRESS
FILES= ${OBJS}
FILESMODE= ${LIBMODE}
diff --git a/lib/csu/powerpc64/Makefile b/lib/csu/powerpc64/Makefile
index afd09ca8a2f13..fcacfcb1a90ef 100644
--- a/lib/csu/powerpc64/Makefile
+++ b/lib/csu/powerpc64/Makefile
@@ -7,7 +7,7 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
CFLAGS+= -I${.CURDIR:H}/common \
-I${SRCTOP}/lib/libc/include \
- -mlongcall
+ -mlongcall -DCRT_IRELOC_SUPPRESS
FILES= ${OBJS}
FILESMODE= ${LIBMODE}
diff --git a/lib/csu/riscv/Makefile b/lib/csu/riscv/Makefile
index 3f34ff3516230..df1fe6e2343bd 100644
--- a/lib/csu/riscv/Makefile
+++ b/lib/csu/riscv/Makefile
@@ -7,6 +7,7 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
CFLAGS+= -I${.CURDIR:H}/common \
-I${SRCTOP}/lib/libc/include
+CFLAGS+= -DCRT_IRELOC_SUPPRESS
FILES= ${OBJS}
FILESMODE= ${LIBMODE}
diff --git a/lib/csu/sparc64/Makefile b/lib/csu/sparc64/Makefile
index 874c377a9400d..f87129b5e8905 100644
--- a/lib/csu/sparc64/Makefile
+++ b/lib/csu/sparc64/Makefile
@@ -7,6 +7,7 @@ OBJS= ${SRCS:N*.h:R:S/$/.o/g}
OBJS+= Scrt1.o gcrt1.o
CFLAGS+= -I${.CURDIR:H}/common \
-I${SRCTOP}/lib/libc/include
+CFLAGS+= -DCRT_IRELOC_SUPPRESS
FILES= ${OBJS}
FILESMODE= ${LIBMODE}
diff --git a/lib/libbe/be.c b/lib/libbe/be.c
index c1cdd55825fe9..2872abed6dece 100644
--- a/lib/libbe/be.c
+++ b/lib/libbe/be.c
@@ -928,8 +928,9 @@ be_activate(libbe_handle_t *lbh, const char *bootenv, bool temporary)
{
char be_path[BE_MAXPATHLEN];
char buf[BE_MAXPATHLEN];
- uint64_t pool_guid;
nvlist_t *config, *vdevs;
+ uint64_t pool_guid;
+ zfs_handle_t *zhp;
int err;
be_root_concat(lbh, bootenv, be_path);
@@ -961,14 +962,19 @@ be_activate(libbe_handle_t *lbh, const char *bootenv, bool temporary)
} else {
/* Obtain bootenv zpool */
err = zpool_set_prop(lbh->active_phandle, "bootfs", be_path);
+ if (err)
+ return (-1);
- switch (err) {
- case 0:
- return (BE_ERR_SUCCESS);
+ zhp = zfs_open(lbh->lzh, be_path, ZFS_TYPE_FILESYSTEM);
+ if (zhp == NULL)
+ return (-1);
- default:
- /* XXX TODO correct errors */
+ err = zfs_promote(zhp);
+ zfs_close(zhp);
+
+ if (err)
return (-1);
- }
}
+
+ return (BE_ERR_SUCCESS);
}
diff --git a/lib/libc/amd64/string/Makefile.inc b/lib/libc/amd64/string/Makefile.inc
index 425de40d66bfd..a8a07a1eb5872 100644
--- a/lib/libc/amd64/string/Makefile.inc
+++ b/lib/libc/amd64/string/Makefile.inc
@@ -2,7 +2,6 @@
MDSRCS+= \
bcmp.S \
- bcopy.S \
bzero.S \
memcmp.S \
memcpy.S \
diff --git a/lib/libc/amd64/string/bcopy.S b/lib/libc/amd64/string/bcopy.S
deleted file mode 100644
index 9446e75b8053b..0000000000000
--- a/lib/libc/amd64/string/bcopy.S
+++ /dev/null
@@ -1,103 +0,0 @@
-/*-
- * Copyright (c) 1990 The Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from locore.s.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <machine/asm.h>
-__FBSDID("$FreeBSD$");
-
-#if 0
- RCSID("$NetBSD: bcopy.S,v 1.2 2003/08/07 16:42:36 agc Exp $")
-#endif
-
- /*
- * (ov)bcopy (src,dst,cnt)
- * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
- */
-
-#ifdef MEMCOPY
-ENTRY(memcpy)
-#else
-#ifdef MEMMOVE
-ENTRY(memmove)
-#else
-ENTRY(bcopy)
-#endif
-#endif
-#if defined(MEMCOPY) || defined(MEMMOVE)
- movq %rdi,%rax /* return dst */
-#else
- xchgq %rdi,%rsi
-#endif
- movq %rdx,%rcx
- movq %rdi,%r8
- subq %rsi,%r8
- cmpq %rcx,%r8 /* overlapping? */
- jb 1f
- shrq $3,%rcx /* copy by words */
- rep
- movsq
- movq %rdx,%rcx
- andq $7,%rcx /* any bytes left? */
- jne 2f
- ret
-2:
- rep
- movsb
- ret
-1:
- addq %rcx,%rdi /* copy backwards. */
- addq %rcx,%rsi
- std
- decq %rdi
- decq %rsi
- andq $7,%rcx /* any fractional bytes? */
- je 3f
- rep
- movsb
-3:
- movq %rdx,%rcx /* copy remainder by words */
- shrq $3,%rcx
- subq $7,%rsi
- subq $7,%rdi
- rep
- movsq
- cld
- ret
-#ifdef MEMCOPY
-END(memcpy)
-#else
-#ifdef MEMMOVE
-END(memmove)
-#else
-END(bcopy)
-#endif
-#endif
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/amd64/string/bcopy.c b/lib/libc/amd64/string/bcopy.c
new file mode 100644
index 0000000000000..9e0c4187e439f
--- /dev/null
+++ b/lib/libc/amd64/string/bcopy.c
@@ -0,0 +1,15 @@
+/*-
+ * Public domain.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <string.h>
+
+void
+bcopy(const void *src, void *dst, size_t len)
+{
+
+ memmove(dst, src, len);
+}
diff --git a/lib/libc/amd64/string/bzero.S b/lib/libc/amd64/string/bzero.S
index cf46a2a317b76..123d9c4a7efbd 100644
--- a/lib/libc/amd64/string/bzero.S
+++ b/lib/libc/amd64/string/bzero.S
@@ -1,46 +1,7 @@
-/*
- * Written by J.T. Conklin <jtc@NetBSD.org>.
- * Public domain.
- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
- */
+/* $FreeBSD */
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
-#if 0
- RCSID("$NetBSD: bzero.S,v 1.2 2003/07/26 19:24:38 salo Exp $")
-#endif
-
-ENTRY(bzero)
- cld /* set fill direction forward */
- xorq %rax,%rax /* set fill data to 0 */
-
- /*
- * if the string is too short, it's really not worth the overhead
- * of aligning to word boundries, etc. So we jump to a plain
- * unaligned set.
- */
- cmpq $16,%rsi
- jb L1
-
- movq %rdi,%rcx /* compute misalignment */
- negq %rcx
- andq $7,%rcx
- subq %rcx,%rsi
- rep /* zero until word aligned */
- stosb
-
- movq %rsi,%rcx /* zero by words */
- shrq $3,%rcx
- andq $7,%rsi
- rep
- stosq
-
-L1: movq %rsi,%rcx /* zero remainder by bytes */
- rep
- stosb
-
- ret
-END(bzero)
-
- .section .note.GNU-stack,"",%progbits
+#define BZERO
+#include "memset.S"
diff --git a/lib/libc/amd64/string/memcpy.S b/lib/libc/amd64/string/memcpy.S
index bd1e8422ad847..2b6c73abeb982 100644
--- a/lib/libc/amd64/string/memcpy.S
+++ b/lib/libc/amd64/string/memcpy.S
@@ -1,5 +1,5 @@
/* $NetBSD: memcpy.S,v 1.1 2001/06/19 00:25:05 fvdl Exp $ */
/* $FreeBSD$ */
-#define MEMCOPY
-#include "bcopy.S"
+#define MEMCPY
+#include "memmove.S"
diff --git a/lib/libc/amd64/string/memmove.S b/lib/libc/amd64/string/memmove.S
index 85beb262f8d9a..9d6fa8a7e2962 100644
--- a/lib/libc/amd64/string/memmove.S
+++ b/lib/libc/amd64/string/memmove.S
@@ -1,5 +1,270 @@
-/* $NetBSD: memmove.S,v 1.1 2001/06/19 00:25:05 fvdl Exp $ */
-/* $FreeBSD$ */
+/*-
+ * Copyright (c) 2018 The FreeBSD Foundation
+ *
+ * This software was developed by Mateusz Guzik <mjg@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE 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.
+ */
-#define MEMMOVE
-#include "bcopy.S"
+#include <machine/asm.h>
+__FBSDID("$FreeBSD$");
+
+#define ALIGN_TEXT .p2align 4,0x90 /* 16-byte alignment, nop filled */
+
+/*
+ * memmove(dst, src, cnt)
+ * rdi, rsi, rdx
+ * Contains parts of bcopy written by:
+ * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800
+ */
+
+/*
+ * Register state at entry is supposed to be as follows:
+ * rdi - destination
+ * rsi - source
+ * rdx - count
+ *
+ * The macro possibly clobbers the above and: rcx, r8.
+ * It does not clobber rax, r10 nor r11.
+ */
+.macro MEMMOVE erms overlap begin end
+ \begin
+.if \overlap == 1
+ movq %rdi,%r8
+ subq %rsi,%r8
+ cmpq %rcx,%r8 /* overlapping && src < dst? */
+ jb 2f
+.endif
+
+ cmpq $32,%rcx
+ jb 1016f
+
+ cmpq $256,%rcx
+ ja 1256f
+
+1032:
+ movq (%rsi),%rdx
+ movq %rdx,(%rdi)
+ movq 8(%rsi),%rdx
+ movq %rdx,8(%rdi)
+ movq 16(%rsi),%rdx
+ movq %rdx,16(%rdi)
+ movq 24(%rsi),%rdx
+ movq %rdx,24(%rdi)
+ leaq 32(%rsi),%rsi
+ leaq 32(%rdi),%rdi
+ subq $32,%rcx
+ cmpq $32,%rcx
+ jae 1032b
+ cmpb $0,%cl
+ jne 1016f
+ \end
+ ret
+ ALIGN_TEXT
+1016:
+ cmpb $16,%cl
+ jl 1008f
+ movq (%rsi),%rdx
+ movq %rdx,(%rdi)
+ movq 8(%rsi),%rdx
+ movq %rdx,8(%rdi)
+ subb $16,%cl
+ jz 1000f
+ leaq 16(%rsi),%rsi
+ leaq 16(%rdi),%rdi
+1008:
+ cmpb $8,%cl
+ jl 1004f
+ movq (%rsi),%rdx
+ movq %rdx,(%rdi)
+ subb $8,%cl
+ jz 1000f
+ leaq 8(%rsi),%rsi
+ leaq 8(%rdi),%rdi
+1004:
+ cmpb $4,%cl
+ jl 1002f
+ movl (%rsi),%edx
+ movl %edx,(%rdi)
+ subb $4,%cl
+ jz 1000f
+ leaq 4(%rsi),%rsi
+ leaq 4(%rdi),%rdi
+1002:
+ cmpb $2,%cl
+ jl 1001f
+ movw (%rsi),%dx
+ movw %dx,(%rdi)
+ subb $2,%cl
+ jz 1000f
+ leaq 2(%rsi),%rsi
+ leaq 2(%rdi),%rdi
+1001:
+ cmpb $1,%cl
+ jl 1000f
+ movb (%rsi),%dl
+ movb %dl,(%rdi)
+1000:
+ \end
+ ret
+
+ ALIGN_TEXT
+1256:
+.if \erms == 1
+ rep
+ movsb
+.else
+ shrq $3,%rcx /* copy by 64-bit words */
+ rep
+ movsq
+ movq %rdx,%rcx
+ andb $7,%cl /* any bytes left? */
+ jne 1004b
+.endif
+ \end
+ ret
+
+.if \overlap == 1
+ /*
+ * Copy backwards.
+ */
+ ALIGN_TEXT
+2:
+ addq %rcx,%rdi
+ addq %rcx,%rsi
+
+ cmpq $32,%rcx
+ jb 2016f
+
+ cmpq $256,%rcx
+ ja 2256f
+
+2032:
+ movq -8(%rsi),%rdx
+ movq %rdx,-8(%rdi)
+ movq -16(%rsi),%rdx
+ movq %rdx,-16(%rdi)
+ movq -24(%rsi),%rdx
+ movq %rdx,-24(%rdi)
+ movq -32(%rsi),%rdx
+ movq %rdx,-32(%rdi)
+ leaq -32(%rsi),%rsi
+ leaq -32(%rdi),%rdi
+ subq $32,%rcx
+ cmpq $32,%rcx
+ jae 2032b
+ cmpb $0,%cl
+ jne 2016f
+ \end
+ ret
+ ALIGN_TEXT
+2016:
+ cmpb $16,%cl
+ jl 2008f
+ movq -8(%rsi),%rdx
+ movq %rdx,-8(%rdi)
+ movq -16(%rsi),%rdx
+ movq %rdx,-16(%rdi)
+ subb $16,%cl
+ jz 2000f
+ leaq -16(%rsi),%rsi
+ leaq -16(%rdi),%rdi
+2008:
+ cmpb $8,%cl
+ jl 2004f
+ movq -8(%rsi),%rdx
+ movq %rdx,-8(%rdi)
+ subb $8,%cl
+ jz 2000f
+ leaq -8(%rsi),%rsi
+ leaq -8(%rdi),%rdi
+2004:
+ cmpb $4,%cl
+ jl 2002f
+ movl -4(%rsi),%edx
+ movl %edx,-4(%rdi)
+ subb $4,%cl
+ jz 2000f
+ leaq -4(%rsi),%rsi
+ leaq -4(%rdi),%rdi
+2002:
+ cmpb $2,%cl
+ jl 2001f
+ movw -2(%rsi),%dx
+ movw %dx,-2(%rdi)
+ subb $2,%cl
+ jz 2000f
+ leaq -2(%rsi),%rsi
+ leaq -2(%rdi),%rdi
+2001:
+ cmpb $1,%cl
+ jl 2000f
+ movb -1(%rsi),%dl
+ movb %dl,-1(%rdi)
+2000:
+ \end
+ ret
+ ALIGN_TEXT
+2256:
+ decq %rdi
+ decq %rsi
+ std
+.if \erms == 1
+ rep
+ movsb
+.else
+ andq $7,%rcx /* any fractional bytes? */
+ je 3f
+ rep
+ movsb
+3:
+ movq %rdx,%rcx /* copy remainder by 32-bit words */
+ shrq $3,%rcx
+ subq $7,%rsi
+ subq $7,%rdi
+ rep
+ movsq
+.endif
+ cld
+ \end
+ ret
+.endif
+.endm
+
+.macro MEMMOVE_BEGIN
+ movq %rdi,%rax
+ movq %rdx,%rcx
+.endm
+
+.macro MEMMOVE_END
+.endm
+
+#ifndef MEMCPY
+ENTRY(memmove)
+ MEMMOVE erms=0 overlap=1 begin=MEMMOVE_BEGIN end=MEMMOVE_END
+END(memmove)
+#else
+ENTRY(memcpy)
+ MEMMOVE erms=0 overlap=1 begin=MEMMOVE_BEGIN end=MEMMOVE_END
+END(memcpy)
+#endif
diff --git a/lib/libc/amd64/string/memset.S b/lib/libc/amd64/string/memset.S
index 84d15628766af..b2a871b0038e4 100644
--- a/lib/libc/amd64/string/memset.S
+++ b/lib/libc/amd64/string/memset.S
@@ -1,63 +1,131 @@
-/*
- * Written by J.T. Conklin <jtc@NetBSD.org>.
- * Public domain.
- * Adapted for NetBSD/x86_64 by Frank van der Linden <fvdl@wasabisystems.com>
+/*-
+ * Copyright (c) 2018 The FreeBSD Foundation
+ *
+ * This software was developed by Mateusz Guzik <mjg@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
*/
#include <machine/asm.h>
__FBSDID("$FreeBSD$");
-#if 0
- RCSID("$NetBSD: memset.S,v 1.3 2004/02/26 20:50:06 drochner Exp $")
-#endif
-
-ENTRY(memset)
- movq %rsi,%rax
- andq $0xff,%rax
+.macro MEMSET bzero erms
+.if \bzero == 1
+ movq %rsi,%rcx
+ movq %rsi,%rdx
+ xorl %eax,%eax
+.else
+ movq %rdi,%r9
movq %rdx,%rcx
- movq %rdi,%r11
-
- cld /* set fill direction forward */
-
- /*
- * if the string is too short, it's really not worth the overhead
- * of aligning to word boundries, etc. So we jump to a plain
- * unaligned set.
- */
- cmpq $0x0f,%rcx
- jle L1
-
- movb %al,%ah /* copy char to all bytes in word */
- movl %eax,%edx
- sall $16,%eax
- orl %edx,%eax
-
- movl %eax,%edx
- salq $32,%rax
- orq %rdx,%rax
-
- movq %rdi,%rdx /* compute misalignment */
- negq %rdx
- andq $7,%rdx
- movq %rcx,%r8
- subq %rdx,%r8
-
- movq %rdx,%rcx /* set until word aligned */
+ movzbq %sil,%r8
+ movabs $0x0101010101010101,%rax
+ imulq %r8,%rax
+.endif
+
+ cmpq $32,%rcx
+ jb 1016f
+
+ cmpq $256,%rcx
+ ja 1256f
+
+1032:
+ movq %rax,(%rdi)
+ movq %rax,8(%rdi)
+ movq %rax,16(%rdi)
+ movq %rax,24(%rdi)
+ leaq 32(%rdi),%rdi
+ subq $32,%rcx
+ cmpq $32,%rcx
+ jae 1032b
+ cmpb $0,%cl
+ je 1000f
+1016:
+ cmpb $16,%cl
+ jl 1008f
+ movq %rax,(%rdi)
+ movq %rax,8(%rdi)
+ subb $16,%cl
+ jz 1000f
+ leaq 16(%rdi),%rdi
+1008:
+ cmpb $8,%cl
+ jl 1004f
+ movq %rax,(%rdi)
+ subb $8,%cl
+ jz 1000f
+ leaq 8(%rdi),%rdi
+1004:
+ cmpb $4,%cl
+ jl 1002f
+ movl %eax,(%rdi)
+ subb $4,%cl
+ jz 1000f
+ leaq 4(%rdi),%rdi
+1002:
+ cmpb $2,%cl
+ jl 1001f
+ movw %ax,(%rdi)
+ subb $2,%cl
+ jz 1000f
+ leaq 2(%rdi),%rdi
+1001:
+ cmpb $1,%cl
+ jl 1000f
+ movb %al,(%rdi)
+1000:
+.if \bzero == 0
+ movq %r9,%rax
+.endif
+ ret
+
+1256:
+.if \erms == 1
rep
stosb
-
- movq %r8,%rcx
- shrq $3,%rcx /* set by words */
+.else
+ shrq $3,%rcx
rep
stosq
-
- movq %r8,%rcx /* set remainder by bytes */
- andq $7,%rcx
-L1: rep
- stosb
- movq %r11,%rax
-
+ movq %rdx,%rcx
+ andb $7,%cl
+ jne 1004b
+.endif
+.if \bzero == 0
+ movq %r9,%rax
+.endif
ret
+.endm
+
+#ifndef BZERO
+ENTRY(memset)
+ MEMSET bzero=0 erms=0
END(memset)
+#else
+ENTRY(bzero)
+ MEMSET bzero=1 erms=0
+END(bzero)
+#endif
.section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index d6eb1075dbfa3..ef8f9cba8e871 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -489,6 +489,7 @@ MLINKS+=setjmp.3 _longjmp.3 \
setjmp.3 siglongjmp.3 \
setjmp.3 sigsetjmp.3
MLINKS+=setmode.3 getmode.3
+MLINKS+=setproctitle.3 setproctitle_fast.3
MLINKS+=sigsetops.3 sigaddset.3 \
sigsetops.3 sigdelset.3 \
sigsetops.3 sigemptyset.3 \
diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c
index 3a884fa8ace4e..86e16e3aa8570 100644
--- a/lib/libc/gen/arc4random.c
+++ b/lib/libc/gen/arc4random.c
@@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$");
#include "libc_private.h"
#include "un-namespace.h"
+#define CHACHA_EMBED
#define KEYSTREAM_ONLY
#include "chacha.c"
diff --git a/lib/libc/gen/getentropy.c b/lib/libc/gen/getentropy.c
index 4e91afc6a6a1b..c9a1342c8d092 100644
--- a/lib/libc/gen/getentropy.c
+++ b/lib/libc/gen/getentropy.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysctl.h>
#include <errno.h>
+#include <signal.h>
#include <stdbool.h>
#include <stdlib.h>
@@ -44,6 +45,12 @@ __FBSDID("$FreeBSD$");
extern int __sysctl(int *, u_int, void *, size_t *, void *, size_t);
+static inline void
+_getentropy_fail(void)
+{
+ raise(SIGKILL);
+}
+
static size_t
arnd_sysctl(u_char *buf, size_t size)
{
@@ -87,14 +94,14 @@ getentropy_fallback(void *buf, size_t buflen)
if (errno == EFAULT)
return (-1);
/*
- * This cannot happen. _arc4_sysctl() spins until the random
+ * This cannot happen. arnd_sysctl() spins until the random
* device is seeded and then repeatedly reads until the full
* request is satisfied. The only way for this to return a zero
* byte or short read is if sysctl(2) on the kern.arandom MIB
- * fails. In this case, exceping the user-provided-a-bogus-
+ * fails. In this case, excepting the user-provided-a-bogus-
* buffer EFAULT, give up (like for arc4random(3)'s arc4_stir).
*/
- abort();
+ _getentropy_fail();
}
return (0);
}
@@ -129,8 +136,10 @@ getentropy(void *buf, size_t buflen)
continue;
case EINTR:
continue;
- default:
+ case EFAULT:
return (-1);
+ default:
+ _getentropy_fail();
}
}
} else {
@@ -139,7 +148,7 @@ getentropy(void *buf, size_t buflen)
/* This cannot happen. */
if (rd == 0)
- abort();
+ _getentropy_fail();
buf = (char *)buf + rd;
buflen -= rd;
diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c
index 1b3893cbe0537..3d61b122ccc91 100644
--- a/lib/libc/gen/getgrent.c
+++ b/lib/libc/gen/getgrent.c
@@ -836,8 +836,9 @@ files_group(void *retval, void *mdata, va_list ap)
char *buffer;
size_t bufsize, linesize;
off_t pos;
- int rv, stayopen, *errnop;
+ int fresh, rv, stayopen, *errnop;
+ fresh = 0;
name = NULL;
gid = (gid_t)-1;
how = (enum nss_lookup_type)mdata;
@@ -860,19 +861,24 @@ files_group(void *retval, void *mdata, va_list ap)
*errnop = files_getstate(&st);
if (*errnop != 0)
return (NS_UNAVAIL);
- if (st->fp == NULL &&
- ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) {
- *errnop = errno;
- return (NS_UNAVAIL);
+ if (st->fp == NULL) {
+ st->fp = fopen(_PATH_GROUP, "re");
+ if (st->fp == NULL) {
+ *errnop = errno;
+ return (NS_UNAVAIL);
+ }
+ fresh = 1;
}
if (how == nss_lt_all)
stayopen = 1;
else {
- rewind(st->fp);
+ if (!fresh)
+ rewind(st->fp);
stayopen = st->stayopen;
}
rv = NS_NOTFOUND;
- pos = ftello(st->fp);
+ if (stayopen)
+ pos = ftello(st->fp);
while ((line = fgetln(st->fp, &linesize)) != NULL) {
if (line[linesize-1] == '\n')
linesize--;
@@ -894,7 +900,8 @@ files_group(void *retval, void *mdata, va_list ap)
&buffer[linesize + 1], bufsize - linesize - 1, errnop);
if (rv & NS_TERMINATE)
break;
- pos = ftello(st->fp);
+ if (stayopen)
+ pos = ftello(st->fp);
}
if (st->fp != NULL && !stayopen) {
fclose(st->fp);
@@ -1304,7 +1311,7 @@ compat_group(void *retval, void *mdata, va_list ap)
void *discard;
size_t bufsize, linesize;
off_t pos;
- int rv, stayopen, *errnop;
+ int fresh, rv, stayopen, *errnop;
#define set_lookup_type(x, y) do { \
int i; \
@@ -1312,6 +1319,7 @@ compat_group(void *retval, void *mdata, va_list ap)
x[i].mdata = (void *)y; \
} while (0)
+ fresh = 0;
name = NULL;
gid = (gid_t)-1;
how = (enum nss_lookup_type)mdata;
@@ -1334,16 +1342,20 @@ compat_group(void *retval, void *mdata, va_list ap)
*errnop = compat_getstate(&st);
if (*errnop != 0)
return (NS_UNAVAIL);
- if (st->fp == NULL &&
- ((st->fp = fopen(_PATH_GROUP, "re")) == NULL)) {
- *errnop = errno;
- rv = NS_UNAVAIL;
- goto fin;
+ if (st->fp == NULL) {
+ st->fp = fopen(_PATH_GROUP, "re");
+ if (st->fp == NULL) {
+ *errnop = errno;
+ rv = NS_UNAVAIL;
+ goto fin;
+ }
+ fresh = 1;
}
if (how == nss_lt_all)
stayopen = 1;
else {
- rewind(st->fp);
+ if (!fresh)
+ rewind(st->fp);
stayopen = st->stayopen;
}
docompat:
@@ -1406,7 +1418,8 @@ docompat:
break;
}
rv = NS_NOTFOUND;
- pos = ftello(st->fp);
+ if (stayopen)
+ pos = ftello(st->fp);
while ((line = fgetln(st->fp, &linesize)) != NULL) {
if (line[linesize-1] == '\n')
linesize--;
@@ -1447,7 +1460,8 @@ docompat:
&buffer[linesize + 1], bufsize - linesize - 1, errnop);
if (rv & NS_TERMINATE)
break;
- pos = ftello(st->fp);
+ if (stayopen)
+ pos = ftello(st->fp);
}
fin:
if (st->fp != NULL && !stayopen) {
diff --git a/lib/libc/gmon/mcount.c b/lib/libc/gmon/mcount.c
index ad2877e19b1d6..0d816a7343501 100644
--- a/lib/libc/gmon/mcount.c
+++ b/lib/libc/gmon/mcount.c
@@ -279,8 +279,7 @@ MCOUNT
#ifdef GUPROF
void
-mexitcount(selfpc)
- uintfptr_t selfpc;
+mexitcount(uintfptr_t selfpc)
{
struct gmonparam *p;
uintfptr_t selfpcdiff;
diff --git a/lib/libc/locale/collate.c b/lib/libc/locale/collate.c
index 8d040c194860b..5017433a9d98b 100644
--- a/lib/libc/locale/collate.c
+++ b/lib/libc/locale/collate.c
@@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include "un-namespace.h"
-#include "endian.h"
#include "collate.h"
#include "setlocale.h"
#include "ldpart.h"
@@ -162,7 +161,7 @@ __collate_load_tables_l(const char *encoding, struct xlocale_collate *table)
if ((info->directive_count < 1) ||
(info->directive_count >= COLL_WEIGHTS_MAX) ||
- ((chains = BSWAP(info->chain_count)) < 0)) {
+ ((chains = info->chain_count) < 0)) {
(void) munmap(map, sbuf.st_size);
errno = EINVAL;
return (_LDP_ERROR);
@@ -170,9 +169,9 @@ __collate_load_tables_l(const char *encoding, struct xlocale_collate *table)
i = (sizeof (collate_char_t) * (UCHAR_MAX + 1)) +
(sizeof (collate_chain_t) * chains) +
- (sizeof (collate_large_t) * BSWAP(info->large_count));
+ (sizeof (collate_large_t) * info->large_count);
for (z = 0; z < info->directive_count; z++) {
- i += sizeof (collate_subst_t) * BSWAP(info->subst_count[z]);
+ i += sizeof (collate_subst_t) * info->subst_count[z];
}
if (i != (sbuf.st_size - (TMP - map))) {
(void) munmap(map, sbuf.st_size);
@@ -185,9 +184,9 @@ __collate_load_tables_l(const char *encoding, struct xlocale_collate *table)
TMP += sizeof (collate_char_t) * (UCHAR_MAX + 1);
for (z = 0; z < info->directive_count; z++) {
- if (BSWAP(info->subst_count[z]) > 0) {
+ if (info->subst_count[z] > 0) {
table->subst_table[z] = (void *)TMP;
- TMP += BSWAP(info->subst_count[z]) * sizeof (collate_subst_t);
+ TMP += info->subst_count[z] * sizeof (collate_subst_t);
} else {
table->subst_table[z] = NULL;
}
@@ -198,7 +197,7 @@ __collate_load_tables_l(const char *encoding, struct xlocale_collate *table)
TMP += chains * sizeof (collate_chain_t);
} else
table->chain_pri_table = NULL;
- if (BSWAP(info->large_count) > 0)
+ if (info->large_count > 0)
table->large_pri_table = (void *)TMP;
else
table->large_pri_table = NULL;
@@ -211,7 +210,7 @@ static const int32_t *
substsearch(struct xlocale_collate *table, const wchar_t key, int pass)
{
const collate_subst_t *p;
- int n = BSWAP(table->info->subst_count[pass]);
+ int n = table->info->subst_count[pass];
if (n == 0)
return (NULL);
@@ -223,7 +222,7 @@ substsearch(struct xlocale_collate *table, const wchar_t key, int pass)
return (NULL);
p = table->subst_table[pass] + (key & ~COLLATE_SUBST_PRIORITY);
- assert(BSWAP(p->key) == key);
+ assert(p->key == key);
return (p->pri);
}
@@ -232,7 +231,7 @@ static collate_chain_t *
chainsearch(struct xlocale_collate *table, const wchar_t *key, int *len)
{
int low = 0;
- int high = BSWAP(table->info->chain_count) - 1;
+ int high = table->info->chain_count - 1;
int next, compar, l;
collate_chain_t *p;
collate_chain_t *tab = table->chain_pri_table;
@@ -243,7 +242,7 @@ chainsearch(struct xlocale_collate *table, const wchar_t *key, int *len)
while (low <= high) {
next = (low + high) / 2;
p = tab + next;
- compar = *key - le16toh(*p->str);
+ compar = *key - *p->str;
if (compar == 0) {
l = wcsnlen(p->str, COLLATE_STR_LEN);
compar = wcsncmp(key, p->str, l);
@@ -264,7 +263,7 @@ static collate_large_t *
largesearch(struct xlocale_collate *table, const wchar_t key)
{
int low = 0;
- int high = BSWAP(table->info->large_count) - 1;
+ int high = table->info->large_count - 1;
int next, compar;
collate_large_t *p;
collate_large_t *tab = table->large_pri_table;
@@ -275,7 +274,7 @@ largesearch(struct xlocale_collate *table, const wchar_t key)
while (low <= high) {
next = (low + high) / 2;
p = tab + next;
- compar = key - BSWAP(p->val);
+ compar = key - p->val;
if (compar == 0)
return (p);
if (compar > 0)
@@ -340,15 +339,15 @@ _collate_lookup(struct xlocale_collate *table, const wchar_t *t, int *len,
* Character is a small (8-bit) character.
* We just look these up directly for speed.
*/
- *pri = BSWAP(table->char_pri_table[*t].pri[which]);
+ *pri = table->char_pri_table[*t].pri[which];
- } else if ((BSWAP(table->info->large_count) > 0) &&
+ } else if ((table->info->large_count > 0) &&
((match = largesearch(table, *t)) != NULL)) {
/*
* Character was found in the extended table.
*/
- *pri = BSWAP(match->pri.pri[which]);
+ *pri = match->pri.pri[which];
} else {
/*
@@ -358,7 +357,7 @@ _collate_lookup(struct xlocale_collate *table, const wchar_t *t, int *len,
/* Mask off sign bit to prevent ordering confusion. */
*pri = (*t & COLLATE_MAX_PRIORITY);
} else {
- *pri = BSWAP(table->info->undef_pri[which]);
+ *pri = table->info->undef_pri[which];
}
/* No substitutions for undefined characters! */
return;
@@ -377,9 +376,9 @@ _collate_lookup(struct xlocale_collate *table, const wchar_t *t, int *len,
* code ensures this for us.
*/
if ((sptr = substsearch(table, *pri, which)) != NULL) {
- if ((*pri = BSWAP(*sptr)) > 0) {
+ if ((*pri = *sptr) > 0) {
sptr++;
- *state = BSWAP(*sptr) ? sptr : NULL;
+ *state = *sptr ? sptr : NULL;
}
}
@@ -521,7 +520,7 @@ static int
xfrm(struct xlocale_collate *table, unsigned char *p, int pri, int pass)
{
/* we use unsigned to ensure zero fill on right shift */
- uint32_t val = BSWAP((uint32_t)table->info->pri_count[pass]);
+ uint32_t val = (uint32_t)table->info->pri_count[pass];
int nc = 0;
while (val) {
@@ -681,7 +680,7 @@ __collate_equiv_value(locale_t locale, const wchar_t *str, size_t len)
e = -1;
if (*str <= UCHAR_MAX)
e = table->char_pri_table[*str].pri[0];
- else if (BSWAP(table->info->large_count) > 0) {
+ else if (table->info->large_count > 0) {
collate_large_t *match_large;
match_large = largesearch(table, *str);
if (match_large)
@@ -691,7 +690,7 @@ __collate_equiv_value(locale_t locale, const wchar_t *str, size_t len)
return (1);
return (e > 0 ? e : 0);
}
- if (BSWAP(table->info->chain_count) > 0) {
+ if (table->info->chain_count > 0) {
wchar_t name[COLLATE_STR_LEN];
collate_chain_t *match_chain;
int clen;
diff --git a/lib/libc/locale/rune.c b/lib/libc/locale/rune.c
index 03fe903f74329..6fed13d72d634 100644
--- a/lib/libc/locale/rune.c
+++ b/lib/libc/locale/rune.c
@@ -54,7 +54,6 @@ __FBSDID("$FreeBSD$");
#include <unistd.h>
#include "un-namespace.h"
-#include "endian.h"
#include "runefile.h"
_RuneLocale *
@@ -110,29 +109,29 @@ _Read_RuneMagi(const char *fname)
}
runetype_ext_ranges = (_FileRuneEntry *)variable;
- variable = runetype_ext_ranges + BSWAP(frl->runetype_ext_nranges);
+ variable = runetype_ext_ranges + frl->runetype_ext_nranges;
if (variable > lastp) {
goto invalid;
}
maplower_ext_ranges = (_FileRuneEntry *)variable;
- variable = maplower_ext_ranges + BSWAP(frl->maplower_ext_nranges);
+ variable = maplower_ext_ranges + frl->maplower_ext_nranges;
if (variable > lastp) {
goto invalid;
}
mapupper_ext_ranges = (_FileRuneEntry *)variable;
- variable = mapupper_ext_ranges + BSWAP(frl->mapupper_ext_nranges);
+ variable = mapupper_ext_ranges + frl->mapupper_ext_nranges;
if (variable > lastp) {
goto invalid;
}
frr = runetype_ext_ranges;
- for (x = 0; x < BSWAP(frl->runetype_ext_nranges); ++x) {
+ for (x = 0; x < frl->runetype_ext_nranges; ++x) {
uint32_t *types;
- if (BSWAP(frr[x].map) == 0) {
- int len = BSWAP(frr[x].max) - BSWAP(frr[x].min) + 1;
+ if (frr[x].map == 0) {
+ int len = frr[x].max - frr[x].min + 1;
types = variable;
variable = types + len;
runetype_ext_len += len;
@@ -142,7 +141,7 @@ _Read_RuneMagi(const char *fname)
}
}
- if ((char *)variable + BSWAP(frl->variable_len) > (char *)lastp) {
+ if ((char *)variable + frl->variable_len > (char *)lastp) {
goto invalid;
}
@@ -150,10 +149,9 @@ _Read_RuneMagi(const char *fname)
* Convert from disk format to host format.
*/
data = malloc(sizeof(_RuneLocale) +
- (BSWAP(frl->runetype_ext_nranges) + BSWAP(frl->maplower_ext_nranges) +
- BSWAP(frl->mapupper_ext_nranges)) * sizeof(_RuneEntry) +
- runetype_ext_len * sizeof(*rr->__types) +
- BSWAP(frl->variable_len));
+ (frl->runetype_ext_nranges + frl->maplower_ext_nranges +
+ frl->mapupper_ext_nranges) * sizeof(_RuneEntry) +
+ runetype_ext_len * sizeof(*rr->__types) + frl->variable_len);
if (data == NULL) {
saverr = errno;
munmap(fdata, sb.st_size);
@@ -167,15 +165,15 @@ _Read_RuneMagi(const char *fname)
memcpy(rl->__magic, _RUNE_MAGIC_1, sizeof(rl->__magic));
memcpy(rl->__encoding, frl->encoding, sizeof(rl->__encoding));
- rl->__variable_len = BSWAP(frl->variable_len);
- rl->__runetype_ext.__nranges = BSWAP(frl->runetype_ext_nranges);
- rl->__maplower_ext.__nranges = BSWAP(frl->maplower_ext_nranges);
- rl->__mapupper_ext.__nranges = BSWAP(frl->mapupper_ext_nranges);
+ rl->__variable_len = frl->variable_len;
+ rl->__runetype_ext.__nranges = frl->runetype_ext_nranges;
+ rl->__maplower_ext.__nranges = frl->maplower_ext_nranges;
+ rl->__mapupper_ext.__nranges = frl->mapupper_ext_nranges;
for (x = 0; x < _CACHED_RUNES; ++x) {
- rl->__runetype[x] = BSWAP(frl->runetype[x]);
- rl->__maplower[x] = BSWAP(frl->maplower[x]);
- rl->__mapupper[x] = BSWAP(frl->mapupper[x]);
+ rl->__runetype[x] = frl->runetype[x];
+ rl->__maplower[x] = frl->maplower[x];
+ rl->__mapupper[x] = frl->mapupper[x];
}
rl->__runetype_ext.__ranges = (_RuneEntry *)rl->__variable;
@@ -190,15 +188,15 @@ _Read_RuneMagi(const char *fname)
rl->__variable = rl->__mapupper_ext.__ranges +
rl->__mapupper_ext.__nranges;
- variable = mapupper_ext_ranges + BSWAP(frl->mapupper_ext_nranges);
+ variable = mapupper_ext_ranges + frl->mapupper_ext_nranges;
frr = runetype_ext_ranges;
rr = rl->__runetype_ext.__ranges;
for (x = 0; x < rl->__runetype_ext.__nranges; ++x) {
uint32_t *types;
- rr[x].__min = BSWAP(frr[x].min);
- rr[x].__max = BSWAP(frr[x].max);
- rr[x].__map = BSWAP(frr[x].map);
+ rr[x].__min = frr[x].min;
+ rr[x].__max = frr[x].max;
+ rr[x].__map = frr[x].map;
if (rr[x].__map == 0) {
int len = rr[x].__max - rr[x].__min + 1;
types = variable;
@@ -214,17 +212,17 @@ _Read_RuneMagi(const char *fname)
frr = maplower_ext_ranges;
rr = rl->__maplower_ext.__ranges;
for (x = 0; x < rl->__maplower_ext.__nranges; ++x) {
- rr[x].__min = BSWAP(frr[x].min);
- rr[x].__max = BSWAP(frr[x].max);
- rr[x].__map = BSWAP(frr[x].map);
+ rr[x].__min = frr[x].min;
+ rr[x].__max = frr[x].max;
+ rr[x].__map = frr[x].map;
}
frr = mapupper_ext_ranges;
rr = rl->__mapupper_ext.__ranges;
for (x = 0; x < rl->__mapupper_ext.__nranges; ++x) {
- rr[x].__min = BSWAP(frr[x].min);
- rr[x].__max = BSWAP(frr[x].max);
- rr[x].__map = BSWAP(frr[x].map);
+ rr[x].__min = frr[x].min;
+ rr[x].__max = frr[x].max;
+ rr[x].__map = frr[x].map;
}
memcpy(rl->__variable, variable, rl->__variable_len);
diff --git a/lib/libc/net/nsdispatch.3 b/lib/libc/net/nsdispatch.3
index 9654c841faf4e..e53bbb9647ce8 100644
--- a/lib/libc/net/nsdispatch.3
+++ b/lib/libc/net/nsdispatch.3
@@ -32,7 +32,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd April 4, 2010
+.Dd October 15, 2018
.Dt NSDISPATCH 3
.Os
.Sh NAME
@@ -112,10 +112,7 @@ which case they are selected using the
and
.Fa method_name
arguments along with the configured source.
-(The methods supplied via
-.Fa dtab
-take priority over those implemented in NSS modules in the event
-of a conflict.)
+Modules must use source names different from the built-in ones.
.Pp
.Va defaults
contains a list of default sources to try if
diff --git a/lib/libc/net/nsdispatch.c b/lib/libc/net/nsdispatch.c
index bf605ece65f09..b9533bd1ca46d 100644
--- a/lib/libc/net/nsdispatch.c
+++ b/lib/libc/net/nsdispatch.c
@@ -486,9 +486,19 @@ nss_load_module(const char *source, nss_module_register_fn reg_fn)
*/
mod.handle = nss_builtin_handle;
fn = reg_fn;
- } else if (!is_dynamic())
+ } else if (!is_dynamic()) {
goto fin;
- else {
+ } else if (strcmp(source, NSSRC_CACHE) == 0 ||
+ strcmp(source, NSSRC_COMPAT) == 0 ||
+ strcmp(source, NSSRC_DB) == 0 ||
+ strcmp(source, NSSRC_DNS) == 0 ||
+ strcmp(source, NSSRC_FILES) == 0 ||
+ strcmp(source, NSSRC_NIS) == 0) {
+ /*
+ * Avoid calling dlopen(3) for built-in modules.
+ */
+ goto fin;
+ } else {
if (snprintf(buf, sizeof(buf), "nss_%s.so.%d", mod.name,
NSS_MODULE_INTERFACE_VERSION) >= (int)sizeof(buf))
goto fin;
diff --git a/lib/libc/net/nslexer.l b/lib/libc/net/nslexer.l
index 17cfef8af7a28..946aace3a8a8a 100644
--- a/lib/libc/net/nslexer.l
+++ b/lib/libc/net/nslexer.l
@@ -50,6 +50,7 @@ static char *rcsid =
%}
+%option never-interactive
%option noinput
%option nounput
%option yylineno
diff --git a/lib/libc/quad/adddi3.c b/lib/libc/quad/adddi3.c
index 5f3d897f9df69..6aaaf828ccb6a 100644
--- a/lib/libc/quad/adddi3.c
+++ b/lib/libc/quad/adddi3.c
@@ -47,8 +47,7 @@ __FBSDID("$FreeBSD$");
* either x or y (the choice to compare with x or y is arbitrary).
*/
quad_t
-__adddi3(a, b)
- quad_t a, b;
+__adddi3(quad_t a, quad_t b)
{
union uu aa, bb, sum;
diff --git a/lib/libc/quad/anddi3.c b/lib/libc/quad/anddi3.c
index 5a5dc41a78cdb..c0934571f2d39 100644
--- a/lib/libc/quad/anddi3.c
+++ b/lib/libc/quad/anddi3.c
@@ -45,8 +45,7 @@ __FBSDID("$FreeBSD$");
* Return a & b, in quad.
*/
quad_t
-__anddi3(a, b)
- quad_t a, b;
+__anddi3(quad_t a, quad_t b)
{
union uu aa, bb;
diff --git a/lib/libc/quad/ashldi3.c b/lib/libc/quad/ashldi3.c
index 7b9e0df1c3850..cec1ce7ca1360 100644
--- a/lib/libc/quad/ashldi3.c
+++ b/lib/libc/quad/ashldi3.c
@@ -46,9 +46,7 @@ __FBSDID("$FreeBSD$");
* This is the same as logical shift left!
*/
quad_t
-__ashldi3(a, shift)
- quad_t a;
- qshift_t shift;
+__ashldi3(quad_t a, qshift_t shift)
{
union uu aa;
diff --git a/lib/libc/quad/ashrdi3.c b/lib/libc/quad/ashrdi3.c
index a5e354684fbe8..db471e413cd94 100644
--- a/lib/libc/quad/ashrdi3.c
+++ b/lib/libc/quad/ashrdi3.c
@@ -45,9 +45,7 @@ __FBSDID("$FreeBSD$");
* Shift a (signed) quad value right (arithmetic shift right).
*/
quad_t
-__ashrdi3(a, shift)
- quad_t a;
- qshift_t shift;
+__ashrdi3(quad_t a, qshift_t shift)
{
union uu aa;
diff --git a/lib/libc/quad/cmpdi2.c b/lib/libc/quad/cmpdi2.c
index 1e34735d9bc24..08916702e1eba 100644
--- a/lib/libc/quad/cmpdi2.c
+++ b/lib/libc/quad/cmpdi2.c
@@ -47,8 +47,7 @@ __FBSDID("$FreeBSD$");
* signed.
*/
int
-__cmpdi2(a, b)
- quad_t a, b;
+__cmpdi2(quad_t a, quad_t b)
{
union uu aa, bb;
diff --git a/lib/libc/quad/divdi3.c b/lib/libc/quad/divdi3.c
index eab73c0bcfb71..c5b4a376477eb 100644
--- a/lib/libc/quad/divdi3.c
+++ b/lib/libc/quad/divdi3.c
@@ -46,8 +46,7 @@ __FBSDID("$FreeBSD$");
* ??? if -1/2 should produce -1 on this machine, this code is wrong
*/
quad_t
-__divdi3(a, b)
- quad_t a, b;
+__divdi3(quad_t a, quad_t b)
{
u_quad_t ua, ub, uq;
int neg;
diff --git a/lib/libc/quad/fixdfdi.c b/lib/libc/quad/fixdfdi.c
index fa13f5829c0e9..51a1246bc0553 100644
--- a/lib/libc/quad/fixdfdi.c
+++ b/lib/libc/quad/fixdfdi.c
@@ -46,8 +46,7 @@ __FBSDID("$FreeBSD$");
* We clamp anything that is out of range.
*/
quad_t
-__fixdfdi(x)
- double x;
+__fixdfdi(double x)
{
if (x < 0)
if (x <= QUAD_MIN)
diff --git a/lib/libc/quad/fixunsdfdi.c b/lib/libc/quad/fixunsdfdi.c
index 71a7a1544f542..ac7afc1669676 100644
--- a/lib/libc/quad/fixunsdfdi.c
+++ b/lib/libc/quad/fixunsdfdi.c
@@ -51,8 +51,7 @@ __FBSDID("$FreeBSD$");
* of range becomes UQUAD_MAX.
*/
u_quad_t
-__fixunsdfdi(x)
- double x;
+__fixunsdfdi(double x)
{
double toppart;
union uu t;
diff --git a/lib/libc/quad/floatdidf.c b/lib/libc/quad/floatdidf.c
index da30520ffad7c..78e368b34b2e5 100644
--- a/lib/libc/quad/floatdidf.c
+++ b/lib/libc/quad/floatdidf.c
@@ -45,8 +45,7 @@ __FBSDID("$FreeBSD$");
* Convert (signed) quad to double.
*/
double
-__floatdidf(x)
- quad_t x;
+__floatdidf(quad_t x)
{
double d;
union uu u;
diff --git a/lib/libc/quad/floatdisf.c b/lib/libc/quad/floatdisf.c
index f58f4ac6fbae9..ea14bd34e8346 100644
--- a/lib/libc/quad/floatdisf.c
+++ b/lib/libc/quad/floatdisf.c
@@ -45,8 +45,7 @@ __FBSDID("$FreeBSD$");
* Convert (signed) quad to float.
*/
float
-__floatdisf(x)
- quad_t x;
+__floatdisf(quad_t x)
{
float f;
union uu u;
diff --git a/lib/libc/quad/floatunsdidf.c b/lib/libc/quad/floatunsdidf.c
index 39dc2be1439f2..bb21445757a7b 100644
--- a/lib/libc/quad/floatunsdidf.c
+++ b/lib/libc/quad/floatunsdidf.c
@@ -46,8 +46,7 @@ __FBSDID("$FreeBSD$");
* This is exactly like floatdidf.c except that negatives never occur.
*/
double
-__floatunsdidf(x)
- u_quad_t x;
+__floatunsdidf(u_quad_t x)
{
double d;
union uu u;
diff --git a/lib/libc/quad/iordi3.c b/lib/libc/quad/iordi3.c
index 6cc3a41258411..7d32326453268 100644
--- a/lib/libc/quad/iordi3.c
+++ b/lib/libc/quad/iordi3.c
@@ -45,8 +45,7 @@ __FBSDID("$FreeBSD$");
* Return a | b, in quad.
*/
quad_t
-__iordi3(a, b)
- quad_t a, b;
+__iordi3(quad_t a, quad_t b)
{
union uu aa, bb;
diff --git a/lib/libc/quad/lshldi3.c b/lib/libc/quad/lshldi3.c
index 0d0788af6c66b..d8c7593d49ec1 100644
--- a/lib/libc/quad/lshldi3.c
+++ b/lib/libc/quad/lshldi3.c
@@ -46,9 +46,7 @@ __FBSDID("$FreeBSD$");
* This is the same as arithmetic shift left!
*/
quad_t
-__lshldi3(a, shift)
- quad_t a;
- qshift_t shift;
+__lshldi3(quad_t a, qshift_t shift)
{
union uu aa;
diff --git a/lib/libc/quad/lshrdi3.c b/lib/libc/quad/lshrdi3.c
index 1a21fe847784f..05a2aa0540b01 100644
--- a/lib/libc/quad/lshrdi3.c
+++ b/lib/libc/quad/lshrdi3.c
@@ -45,9 +45,7 @@ __FBSDID("$FreeBSD$");
* Shift an (unsigned) quad value right (logical shift right).
*/
quad_t
-__lshrdi3(a, shift)
- quad_t a;
- qshift_t shift;
+__lshrdi3(quad_t a, qshift_t shift)
{
union uu aa;
diff --git a/lib/libc/quad/moddi3.c b/lib/libc/quad/moddi3.c
index 318fed33ba540..fc13b4da40670 100644
--- a/lib/libc/quad/moddi3.c
+++ b/lib/libc/quad/moddi3.c
@@ -48,8 +48,7 @@ __FBSDID("$FreeBSD$");
* If -1/2 should produce -1 on this machine, this code is wrong.
*/
quad_t
-__moddi3(a, b)
- quad_t a, b;
+__moddi3(quad_t a, quad_t b)
{
u_quad_t ua, ub, ur;
int neg;
diff --git a/lib/libc/quad/muldi3.c b/lib/libc/quad/muldi3.c
index 2f5f21005d0e9..bb11ef798fb05 100644
--- a/lib/libc/quad/muldi3.c
+++ b/lib/libc/quad/muldi3.c
@@ -101,8 +101,7 @@ __FBSDID("$FreeBSD$");
static quad_t __lmulq(u_long, u_long);
quad_t
-__muldi3(a, b)
- quad_t a, b;
+__muldi3(quad_t a, quad_t b)
{
union uu u, v, low, prod;
u_long high, mid, udiff, vdiff;
diff --git a/lib/libc/quad/negdi2.c b/lib/libc/quad/negdi2.c
index 793c63dee07f7..476c32afb55e4 100644
--- a/lib/libc/quad/negdi2.c
+++ b/lib/libc/quad/negdi2.c
@@ -45,8 +45,7 @@ __FBSDID("$FreeBSD$");
* Return -a (or, equivalently, 0 - a), in quad. See subdi3.c.
*/
quad_t
-__negdi2(a)
- quad_t a;
+__negdi2(quad_t a)
{
union uu aa, res;
diff --git a/lib/libc/quad/notdi2.c b/lib/libc/quad/notdi2.c
index 7d0186eb5ddd4..18489f91b91f6 100644
--- a/lib/libc/quad/notdi2.c
+++ b/lib/libc/quad/notdi2.c
@@ -46,8 +46,7 @@ __FBSDID("$FreeBSD$");
* than `not'.
*/
quad_t
-__one_cmpldi2(a)
- quad_t a;
+__one_cmpldi2(quad_t a)
{
union uu aa;
diff --git a/lib/libc/quad/qdivrem.c b/lib/libc/quad/qdivrem.c
index c9910732de6d2..2f1760c047f94 100644
--- a/lib/libc/quad/qdivrem.c
+++ b/lib/libc/quad/qdivrem.c
@@ -82,8 +82,7 @@ shl(digit *p, int len, int sh)
* leading zeros).
*/
u_quad_t
-__qdivrem(uq, vq, arq)
- u_quad_t uq, vq, *arq;
+__qdivrem(u_quad_t uq, u_quad_t vq, u_quad_t *arq)
{
union uu tmp;
digit *u, *v, *q;
diff --git a/lib/libc/quad/subdi3.c b/lib/libc/quad/subdi3.c
index 4cc9534c6b553..3622c323568ca 100644
--- a/lib/libc/quad/subdi3.c
+++ b/lib/libc/quad/subdi3.c
@@ -46,8 +46,7 @@ __FBSDID("$FreeBSD$");
* from a single u_long difference x-y occurs if and only if (x-y) > x.
*/
quad_t
-__subdi3(a, b)
- quad_t a, b;
+__subdi3(quad_t a, quad_t b)
{
union uu aa, bb, diff;
diff --git a/lib/libc/quad/ucmpdi2.c b/lib/libc/quad/ucmpdi2.c
index 341676c596db4..458f8ed008149 100644
--- a/lib/libc/quad/ucmpdi2.c
+++ b/lib/libc/quad/ucmpdi2.c
@@ -46,8 +46,7 @@ __FBSDID("$FreeBSD$");
* Neither a nor b are considered signed.
*/
int
-__ucmpdi2(a, b)
- u_quad_t a, b;
+__ucmpdi2(u_quad_t a, u_quad_t b)
{
union uu aa, bb;
diff --git a/lib/libc/quad/udivdi3.c b/lib/libc/quad/udivdi3.c
index 1e9e7b87e73b9..0e6f27edeb61e 100644
--- a/lib/libc/quad/udivdi3.c
+++ b/lib/libc/quad/udivdi3.c
@@ -45,8 +45,7 @@ __FBSDID("$FreeBSD$");
* Divide two unsigned quads.
*/
u_quad_t
-__udivdi3(a, b)
- u_quad_t a, b;
+__udivdi3(u_quad_t a, u_quad_t b)
{
return (__qdivrem(a, b, (u_quad_t *)0));
diff --git a/lib/libc/quad/umoddi3.c b/lib/libc/quad/umoddi3.c
index f479fa3ef8a14..7f45134213ae6 100644
--- a/lib/libc/quad/umoddi3.c
+++ b/lib/libc/quad/umoddi3.c
@@ -45,8 +45,7 @@ __FBSDID("$FreeBSD$");
* Return remainder after dividing two unsigned quads.
*/
u_quad_t
-__umoddi3(a, b)
- u_quad_t a, b;
+__umoddi3(u_quad_t a, u_quad_t b)
{
u_quad_t r;
diff --git a/lib/libc/quad/xordi3.c b/lib/libc/quad/xordi3.c
index ed289afe23a44..e956ade4607fd 100644
--- a/lib/libc/quad/xordi3.c
+++ b/lib/libc/quad/xordi3.c
@@ -45,8 +45,7 @@ __FBSDID("$FreeBSD$");
* Return a ^ b, in quad.
*/
quad_t
-__xordi3(a, b)
- quad_t a, b;
+__xordi3(quad_t a, quad_t b)
{
union uu aa, bb;
diff --git a/lib/libc/stdio/fgets.3 b/lib/libc/stdio/fgets.3
index 59d92a093b48b..ce334b7493b0c 100644
--- a/lib/libc/stdio/fgets.3
+++ b/lib/libc/stdio/fgets.3
@@ -140,6 +140,8 @@ or
.Pp
The function
.Fn gets
+and
+.Fn gets_s
may also fail and set
.Va errno
for any of the errors specified for the routine
diff --git a/lib/libc/stdio/fopen.3 b/lib/libc/stdio/fopen.3
index c170f189dca63..f79c98309ff01 100644
--- a/lib/libc/stdio/fopen.3
+++ b/lib/libc/stdio/fopen.3
@@ -119,8 +119,8 @@ or the first letter.
This is strictly for compatibility with
.St -isoC
and has effect only for
-.Fn fmemopen
-; otherwise
+.Fn fmemopen ;
+otherwise
.Dq Li b
is ignored.
.Pp
diff --git a/lib/libc/stdtime/strptime.c b/lib/libc/stdtime/strptime.c
index 4db89efdad118..e011a7fe8dc8c 100644
--- a/lib/libc/stdtime/strptime.c
+++ b/lib/libc/stdtime/strptime.c
@@ -95,6 +95,7 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp,
int i, len;
int flags;
int Ealternative, Oalternative;
+ int century, year;
const struct lc_time_T *tptr = __get_current_time_locale(locale);
static int start_of_month[2][13] = {
{0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365},
@@ -102,6 +103,8 @@ _strptime(const char *buf, const char *fmt, struct tm *tm, int *GMTp,
};
flags = FLAG_NONE;
+ century = -1;
+ year = -1;
ptr = fmt;
while (*ptr != 0) {
@@ -146,10 +149,8 @@ label:
i += *buf - '0';
len--;
}
- if (i < 19)
- return (NULL);
- tm->tm_year = i * 100 - TM_YEAR_BASE;
+ century = i;
flags |= FLAG_YEAR;
break;
@@ -291,7 +292,7 @@ label:
if (c == 'H' || c == 'k') {
if (i > 23)
return (NULL);
- } else if (i > 12)
+ } else if (i == 0 || i > 12)
return (NULL);
tm->tm_hour = i;
@@ -419,7 +420,7 @@ label:
i += *buf - '0';
len--;
}
- if (i > 31)
+ if (i == 0 || i > 31)
return (NULL);
tm->tm_mday = i;
@@ -527,13 +528,9 @@ label:
len--;
}
if (c == 'Y')
- i -= TM_YEAR_BASE;
- if (c == 'y' && i < 69)
- i += 100;
- if (i < 0)
- return (NULL);
+ century = i / 100;
+ year = i % 100;
- tm->tm_year = i;
flags |= FLAG_YEAR;
break;
@@ -611,6 +608,17 @@ label:
}
}
+ if (century != -1 || year != -1) {
+ if (year == -1)
+ year = 0;
+ if (century == -1) {
+ if (year < 69)
+ year += 100;
+ } else
+ year += century * 100 - TM_YEAR_BASE;
+ tm->tm_year = year;
+ }
+
if (!(flags & FLAG_YDAY) && (flags & FLAG_YEAR)) {
if ((flags & (FLAG_MONTH | FLAG_MDAY)) ==
(FLAG_MONTH | FLAG_MDAY)) {
diff --git a/lib/libc/string/memmem.c b/lib/libc/string/memmem.c
index 1a0d18c36533f..e0a65a6a3f910 100644
--- a/lib/libc/string/memmem.c
+++ b/lib/libc/string/memmem.c
@@ -31,27 +31,27 @@ __FBSDID("$FreeBSD$");
static char *twobyte_memmem(const unsigned char *h, size_t k, const unsigned char *n)
{
uint16_t nw = n[0]<<8 | n[1], hw = h[0]<<8 | h[1];
- for (h++, k--; k; k--, hw = hw<<8 | *++h)
- if (hw == nw) return (char *)h-1;
- return 0;
+ for (h+=2, k-=2; k; k--, hw = hw<<8 | *h++)
+ if (hw == nw) return (char *)h-2;
+ return hw == nw ? (char *)h-2 : 0;
}
static char *threebyte_memmem(const unsigned char *h, size_t k, const unsigned char *n)
{
uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8;
uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8;
- for (h+=2, k-=2; k; k--, hw = (hw|*++h)<<8)
- if (hw == nw) return (char *)h-2;
- return 0;
+ for (h+=3, k-=3; k; k--, hw = (hw|*h++)<<8)
+ if (hw == nw) return (char *)h-3;
+ return hw == nw ? (char *)h-3 : 0;
}
static char *fourbyte_memmem(const unsigned char *h, size_t k, const unsigned char *n)
{
uint32_t nw = n[0]<<24 | n[1]<<16 | n[2]<<8 | n[3];
uint32_t hw = h[0]<<24 | h[1]<<16 | h[2]<<8 | h[3];
- for (h+=3, k-=3; k; k--, hw = hw<<8 | *++h)
- if (hw == nw) return (char *)h-3;
- return 0;
+ for (h+=4, k-=4; k; k--, hw = hw<<8 | *h++)
+ if (hw == nw) return (char *)h-4;
+ return hw == nw ? (char *)h-4 : 0;
}
#define MAX(a,b) ((a)>(b)?(a):(b))
diff --git a/lib/libc/sys/pdfork.2 b/lib/libc/sys/pdfork.2
index ab1a73dc9ce1f..56a2c880fc1bf 100644
--- a/lib/libc/sys/pdfork.2
+++ b/lib/libc/sys/pdfork.2
@@ -32,7 +32,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 17, 2017
+.Dd October 14, 2018
.Dt PDFORK 2
.Os
.Sh NAME
@@ -162,6 +162,7 @@ for
.Xr fstat 2 ,
.Xr kill 2 ,
.Xr poll 2 ,
+.Xr kqueue 2 ,
.Xr wait4 2 ,
.Xr capsicum 4 ,
.Xr procdesc 4
diff --git a/lib/libc/sys/recv.2 b/lib/libc/sys/recv.2
index 354ba90ebfc62..46e0cf8163ddf 100644
--- a/lib/libc/sys/recv.2
+++ b/lib/libc/sys/recv.2
@@ -260,13 +260,8 @@ struct cmsghdr {
};
.Ed
.Pp
-As an example, one could use this to learn of changes in the data-stream
-in XNS/SPP, or in ISO, to obtain user-connection-request data by requesting
-a
-.Fn recvmsg
-with no data buffer provided immediately after an
-.Fn accept
-system call.
+As an example, the SO_TIMESTAMP socket option returns a reception
+timestamp for UDP packets.
.Pp
With
.Dv AF_UNIX
diff --git a/lib/libc/sys/sendfile.2 b/lib/libc/sys/sendfile.2
index f533f7bfe1b72..eba5d6234858c 100644
--- a/lib/libc/sys/sendfile.2
+++ b/lib/libc/sys/sendfile.2
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd November 17, 2016
+.Dd October 12, 2018
.Dt SENDFILE 2
.Os
.Sh NAME
@@ -336,6 +336,12 @@ is negative.
.It Bq Er EIO
An error occurred while reading from
.Fa fd .
+.It Bq Er ENOTCAPABLE
+The
+.Fa fd
+or the
+.Fa s
+argument has insufficient rights.
.It Bq Er ENOBUFS
The system was unable to allocate an internal buffer.
.It Bq Er ENOTCONN
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
index 6ea92f1d45910..74bc145f68736 100644
--- a/lib/libfetch/common.c
+++ b/lib/libfetch/common.c
@@ -674,7 +674,11 @@ fetch_ssl_verify_altname(STACK_OF(GENERAL_NAME) *altnames,
#else
name = sk_GENERAL_NAME_value(altnames, i);
#endif
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
ns = (const char *)ASN1_STRING_data(name->d.ia5);
+#else
+ ns = (const char *)ASN1_STRING_get0_data(name->d.ia5);
+#endif
nslen = (size_t)ASN1_STRING_length(name->d.ia5);
if (name->type == GEN_DNS && ip == NULL &&
diff --git a/lib/libldns/Makefile b/lib/libldns/Makefile
index 042b4e046a0d1..34ffe7d2ed73c 100644
--- a/lib/libldns/Makefile
+++ b/lib/libldns/Makefile
@@ -19,7 +19,7 @@ SRCS= buffer.c dane.c dname.c dnssec.c dnssec_sign.c dnssec_verify.c \
SRCS+= b64_ntop.c b64_pton.c
-LIBADD= crypto
+LIBADD= ssl crypto
WARNS ?= 3
diff --git a/lib/libmemstat/memstat_malloc.c b/lib/libmemstat/memstat_malloc.c
index a8ca0d8bc8023..9094ee1231370 100644
--- a/lib/libmemstat/memstat_malloc.c
+++ b/lib/libmemstat/memstat_malloc.c
@@ -279,15 +279,28 @@ kread_symbol(kvm_t *kvm, int index, void *address, size_t size,
return (0);
}
+static int
+kread_zpcpu(kvm_t *kvm, u_long base, void *buf, size_t size, int cpu)
+{
+ ssize_t ret;
+
+ ret = kvm_read_zpcpu(kvm, base, buf, size, cpu);
+ if (ret < 0)
+ return (MEMSTAT_ERROR_KVM);
+ if ((size_t)ret != size)
+ return (MEMSTAT_ERROR_KVM_SHORTREAD);
+ return (0);
+}
+
int
memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle)
{
struct memory_type *mtp;
void *kmemstatistics;
- int hint_dontsearch, j, mp_maxcpus, ret;
+ int hint_dontsearch, j, mp_maxcpus, mp_ncpus, ret;
char name[MEMTYPE_MAXNAME];
- struct malloc_type_stats *mts, *mtsp;
- struct malloc_type_internal *mtip;
+ struct malloc_type_stats mts;
+ struct malloc_type_internal mti, *mtip;
struct malloc_type type, *typep;
kvm_t *kvm;
@@ -320,17 +333,12 @@ memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle)
return (-1);
}
- mts = malloc(sizeof(struct malloc_type_stats) * mp_maxcpus);
- if (mts == NULL) {
- list->mtl_error = MEMSTAT_ERROR_NOMEMORY;
- return (-1);
- }
+ mp_ncpus = kvm_getncpus(kvm);
for (typep = kmemstatistics; typep != NULL; typep = type.ks_next) {
ret = kread(kvm, typep, &type, sizeof(type), 0);
if (ret != 0) {
_memstat_mtl_empty(list);
- free(mts);
list->mtl_error = ret;
return (-1);
}
@@ -338,7 +346,6 @@ memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle)
MEMTYPE_MAXNAME);
if (ret != 0) {
_memstat_mtl_empty(list);
- free(mts);
list->mtl_error = ret;
return (-1);
}
@@ -348,11 +355,9 @@ memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle)
* kernel's, we populate our own array.
*/
mtip = type.ks_handle;
- ret = kread(kvm, mtip->mti_stats, mts, mp_maxcpus *
- sizeof(struct malloc_type_stats), 0);
+ ret = kread(kvm, mtip, &mti, sizeof(mti), 0);
if (ret != 0) {
_memstat_mtl_empty(list);
- free(mts);
list->mtl_error = ret;
return (-1);
}
@@ -366,7 +371,6 @@ memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle)
name, mp_maxcpus);
if (mtp == NULL) {
_memstat_mtl_empty(list);
- free(mts);
list->mtl_error = MEMSTAT_ERROR_NOMEMORY;
return (-1);
}
@@ -376,24 +380,34 @@ memstat_kvm_malloc(struct memory_type_list *list, void *kvm_handle)
* be kept in sync.
*/
_memstat_mt_reset_stats(mtp, mp_maxcpus);
- for (j = 0; j < mp_maxcpus; j++) {
- mtsp = &mts[j];
- mtp->mt_memalloced += mtsp->mts_memalloced;
- mtp->mt_memfreed += mtsp->mts_memfreed;
- mtp->mt_numallocs += mtsp->mts_numallocs;
- mtp->mt_numfrees += mtsp->mts_numfrees;
- mtp->mt_sizemask |= mtsp->mts_size;
+ for (j = 0; j < mp_ncpus; j++) {
+ ret = kread_zpcpu(kvm, (u_long)mti.mti_stats, &mts,
+ sizeof(mts), j);
+ if (ret != 0) {
+ _memstat_mtl_empty(list);
+ list->mtl_error = ret;
+ return (-1);
+ }
+ mtp->mt_memalloced += mts.mts_memalloced;
+ mtp->mt_memfreed += mts.mts_memfreed;
+ mtp->mt_numallocs += mts.mts_numallocs;
+ mtp->mt_numfrees += mts.mts_numfrees;
+ mtp->mt_sizemask |= mts.mts_size;
mtp->mt_percpu_alloc[j].mtp_memalloced =
- mtsp->mts_memalloced;
+ mts.mts_memalloced;
mtp->mt_percpu_alloc[j].mtp_memfreed =
- mtsp->mts_memfreed;
+ mts.mts_memfreed;
mtp->mt_percpu_alloc[j].mtp_numallocs =
- mtsp->mts_numallocs;
+ mts.mts_numallocs;
mtp->mt_percpu_alloc[j].mtp_numfrees =
- mtsp->mts_numfrees;
+ mts.mts_numfrees;
mtp->mt_percpu_alloc[j].mtp_sizemask =
- mtsp->mts_size;
+ mts.mts_size;
+ }
+ for (; j < mp_maxcpus; j++) {
+ bzero(&mtp->mt_percpu_alloc[j],
+ sizeof(mtp->mt_percpu_alloc[0]));
}
mtp->mt_bytes = mtp->mt_memalloced - mtp->mt_memfreed;
diff --git a/lib/libmp/mpasbn.c b/lib/libmp/mpasbn.c
index e3b96831167aa..31e366cea5511 100644
--- a/lib/libmp/mpasbn.c
+++ b/lib/libmp/mpasbn.c
@@ -144,16 +144,18 @@ _dtom(const char *msg, const char *s)
void
mp_gcd(const MINT *mp1, const MINT *mp2, MINT *rmp)
{
- BIGNUM b;
+ BIGNUM *b;
BN_CTX *c;
+ b = NULL;
c = BN_CTX_new();
- if (c == NULL)
+ if (c != NULL)
+ b = BN_new();
+ if (c == NULL || b == NULL)
_bnerr("gcd");
- BN_init(&b);
- BN_ERRCHECK("gcd", BN_gcd(&b, mp1->bn, mp2->bn, c));
- _moveb("gcd", &b, rmp);
- BN_free(&b);
+ BN_ERRCHECK("gcd", BN_gcd(b, mp1->bn, mp2->bn, c));
+ _moveb("gcd", b, rmp);
+ BN_free(b);
BN_CTX_free(c);
}
@@ -187,12 +189,14 @@ mp_itom(short n)
static void
_madd(const char *msg, const MINT *mp1, const MINT *mp2, MINT *rmp)
{
- BIGNUM b;
+ BIGNUM *b;
- BN_init(&b);
- BN_ERRCHECK(msg, BN_add(&b, mp1->bn, mp2->bn));
- _moveb(msg, &b, rmp);
- BN_free(&b);
+ b = BN_new();
+ if (b == NULL)
+ _bnerr(msg);
+ BN_ERRCHECK(msg, BN_add(b, mp1->bn, mp2->bn));
+ _moveb(msg, b, rmp);
+ BN_free(b);
}
void
@@ -229,15 +233,19 @@ static void
_mdiv(const char *msg, const MINT *nmp, const MINT *dmp, MINT *qmp, MINT *rmp,
BN_CTX *c)
{
- BIGNUM q, r;
+ BIGNUM *q, *r;
- BN_init(&r);
- BN_init(&q);
- BN_ERRCHECK(msg, BN_div(&q, &r, nmp->bn, dmp->bn, c));
- _moveb(msg, &q, qmp);
- _moveb(msg, &r, rmp);
- BN_free(&q);
- BN_free(&r);
+ q = NULL;
+ r = BN_new();
+ if (r != NULL)
+ q = BN_new();
+ if (r == NULL || q == NULL)
+ _bnerr(msg);
+ BN_ERRCHECK(msg, BN_div(q, r, nmp->bn, dmp->bn, c));
+ _moveb(msg, q, qmp);
+ _moveb(msg, r, rmp);
+ BN_free(q);
+ BN_free(r);
}
void
@@ -402,12 +410,14 @@ mp_msqrt(const MINT *nmp, MINT *xmp, MINT *rmp)
static void
_msub(const char *msg, const MINT *mp1, const MINT *mp2, MINT *rmp)
{
- BIGNUM b;
+ BIGNUM *b;
- BN_init(&b);
- BN_ERRCHECK(msg, BN_sub(&b, mp1->bn, mp2->bn));
- _moveb(msg, &b, rmp);
- BN_free(&b);
+ b = BN_new();
+ if (b == NULL)
+ _bnerr(msg);
+ BN_ERRCHECK(msg, BN_sub(b, mp1->bn, mp2->bn));
+ _moveb(msg, b, rmp);
+ BN_free(b);
}
void
@@ -481,12 +491,14 @@ mp_mtox(const MINT *mp)
static void
_mult(const char *msg, const MINT *mp1, const MINT *mp2, MINT *rmp, BN_CTX *c)
{
- BIGNUM b;
+ BIGNUM *b;
- BN_init(&b);
- BN_ERRCHECK(msg, BN_mul(&b, mp1->bn, mp2->bn, c));
- _moveb(msg, &b, rmp);
- BN_free(&b);
+ b = BN_new();
+ if (b == NULL)
+ _bnerr(msg);
+ BN_ERRCHECK(msg, BN_mul(b, mp1->bn, mp2->bn, c));
+ _moveb(msg, b, rmp);
+ BN_free(b);
}
void
@@ -508,16 +520,18 @@ mp_mult(const MINT *mp1, const MINT *mp2, MINT *rmp)
void
mp_pow(const MINT *bmp, const MINT *emp, const MINT *mmp, MINT *rmp)
{
- BIGNUM b;
+ BIGNUM *b;
BN_CTX *c;
+ b = NULL;
c = BN_CTX_new();
- if (c == NULL)
+ if (c != NULL)
+ b = BN_new();
+ if (c == NULL || b == NULL)
_bnerr("pow");
- BN_init(&b);
- BN_ERRCHECK("pow", BN_mod_exp(&b, bmp->bn, emp->bn, mmp->bn, c));
- _moveb("pow", &b, rmp);
- BN_free(&b);
+ BN_ERRCHECK("pow", BN_mod_exp(b, bmp->bn, emp->bn, mmp->bn, c));
+ _moveb("pow", b, rmp);
+ BN_free(b);
BN_CTX_free(c);
}
@@ -528,18 +542,20 @@ void
mp_rpow(const MINT *bmp, short e, MINT *rmp)
{
MINT *emp;
- BIGNUM b;
+ BIGNUM *b;
BN_CTX *c;
+ b = NULL;
c = BN_CTX_new();
- if (c == NULL)
+ if (c != NULL)
+ b = BN_new();
+ if (c == NULL || b == NULL)
_bnerr("rpow");
- BN_init(&b);
emp = _itom("rpow", e);
- BN_ERRCHECK("rpow", BN_exp(&b, bmp->bn, emp->bn, c));
- _moveb("rpow", &b, rmp);
+ BN_ERRCHECK("rpow", BN_exp(b, bmp->bn, emp->bn, c));
+ _moveb("rpow", b, rmp);
_mfree("rpow", emp);
- BN_free(&b);
+ BN_free(b);
BN_CTX_free(c);
}
@@ -551,16 +567,20 @@ _sdiv(const char *msg, const MINT *nmp, short d, MINT *qmp, short *ro,
BN_CTX *c)
{
MINT *dmp, *rmp;
- BIGNUM q, r;
+ BIGNUM *q, *r;
char *s;
- BN_init(&q);
- BN_init(&r);
+ r = NULL;
+ q = BN_new();
+ if (q != NULL)
+ r = BN_new();
+ if (q == NULL || r == NULL)
+ _bnerr(msg);
dmp = _itom(msg, d);
rmp = _itom(msg, 0);
- BN_ERRCHECK(msg, BN_div(&q, &r, nmp->bn, dmp->bn, c));
- _moveb(msg, &q, qmp);
- _moveb(msg, &r, rmp);
+ BN_ERRCHECK(msg, BN_div(q, r, nmp->bn, dmp->bn, c));
+ _moveb(msg, q, qmp);
+ _moveb(msg, r, rmp);
s = _mtox(msg, rmp);
errno = 0;
*ro = strtol(s, NULL, 16);
@@ -569,8 +589,8 @@ _sdiv(const char *msg, const MINT *nmp, short d, MINT *qmp, short *ro,
free(s);
_mfree(msg, dmp);
_mfree(msg, rmp);
- BN_free(&r);
- BN_free(&q);
+ BN_free(r);
+ BN_free(q);
}
void
diff --git a/lib/libradius/radlib.c b/lib/libradius/radlib.c
index 836111de29ce4..3b6460e26f0d0 100644
--- a/lib/libradius/radlib.c
+++ b/lib/libradius/radlib.c
@@ -156,22 +156,21 @@ insert_message_authenticator(struct rad_handle *h, int resp)
u_char md[EVP_MAX_MD_SIZE];
u_int md_len;
const struct rad_server *srvp;
- HMAC_CTX ctx;
+ HMAC_CTX *ctx;
srvp = &h->servers[h->srv];
if (h->authentic_pos != 0) {
- HMAC_CTX_init(&ctx);
- HMAC_Init(&ctx, srvp->secret, strlen(srvp->secret), EVP_md5());
- HMAC_Update(&ctx, &h->out[POS_CODE], POS_AUTH - POS_CODE);
+ ctx = HMAC_CTX_new();
+ HMAC_Init_ex(ctx, srvp->secret, strlen(srvp->secret), EVP_md5(), NULL);
+ HMAC_Update(ctx, &h->out[POS_CODE], POS_AUTH - POS_CODE);
if (resp)
- HMAC_Update(&ctx, &h->in[POS_AUTH], LEN_AUTH);
+ HMAC_Update(ctx, &h->in[POS_AUTH], LEN_AUTH);
else
- HMAC_Update(&ctx, &h->out[POS_AUTH], LEN_AUTH);
- HMAC_Update(&ctx, &h->out[POS_ATTRS],
+ HMAC_Update(ctx, &h->out[POS_AUTH], LEN_AUTH);
+ HMAC_Update(ctx, &h->out[POS_ATTRS],
h->out_len - POS_ATTRS);
- HMAC_Final(&ctx, md, &md_len);
- HMAC_CTX_cleanup(&ctx);
- HMAC_cleanup(&ctx);
+ HMAC_Final(ctx, md, &md_len);
+ HMAC_CTX_free(ctx);
memcpy(&h->out[h->authentic_pos + 2], md, md_len);
}
#endif
@@ -190,7 +189,7 @@ is_valid_response(struct rad_handle *h, int srv,
const struct rad_server *srvp;
int len;
#ifdef WITH_SSL
- HMAC_CTX hctx;
+ HMAC_CTX *hctx;
u_char resp[MSGSIZE], md[EVP_MAX_MD_SIZE];
u_int md_len;
int pos;
@@ -232,31 +231,33 @@ is_valid_response(struct rad_handle *h, int srv,
pos = POS_ATTRS;
/* Search and verify the Message-Authenticator */
+ hctx = HMAC_CTX_new();
while (pos < len - 2) {
if (h->in[pos] == RAD_MESSAGE_AUTHENTIC) {
/* zero fill the Message-Authenticator */
memset(&resp[pos + 2], 0, MD5_DIGEST_LENGTH);
- HMAC_CTX_init(&hctx);
- HMAC_Init(&hctx, srvp->secret,
- strlen(srvp->secret), EVP_md5());
- HMAC_Update(&hctx, &h->in[POS_CODE],
+ HMAC_Init_ex(hctx, srvp->secret,
+ strlen(srvp->secret), EVP_md5(), NULL);
+ HMAC_Update(hctx, &h->in[POS_CODE],
POS_AUTH - POS_CODE);
- HMAC_Update(&hctx, &h->out[POS_AUTH],
+ HMAC_Update(hctx, &h->out[POS_AUTH],
LEN_AUTH);
- HMAC_Update(&hctx, &resp[POS_ATTRS],
+ HMAC_Update(hctx, &resp[POS_ATTRS],
h->in_len - POS_ATTRS);
- HMAC_Final(&hctx, md, &md_len);
- HMAC_CTX_cleanup(&hctx);
- HMAC_cleanup(&hctx);
+ HMAC_Final(hctx, md, &md_len);
+ HMAC_CTX_reset(hctx);
if (memcmp(md, &h->in[pos + 2],
- MD5_DIGEST_LENGTH) != 0)
+ MD5_DIGEST_LENGTH) != 0) {
+ HMAC_CTX_free(hctx);
return 0;
+ }
break;
}
pos += h->in[pos + 1];
}
+ HMAC_CTX_free(hctx);
}
#endif
return 1;
@@ -273,7 +274,7 @@ is_valid_request(struct rad_handle *h)
const struct rad_server *srvp;
int len;
#ifdef WITH_SSL
- HMAC_CTX hctx;
+ HMAC_CTX *hctx;
u_char resp[MSGSIZE], md[EVP_MAX_MD_SIZE];
u_int md_len;
int pos;
@@ -304,6 +305,7 @@ is_valid_request(struct rad_handle *h)
#ifdef WITH_SSL
/* Search and verify the Message-Authenticator */
pos = POS_ATTRS;
+ hctx = HMAC_CTX_new();
while (pos < len - 2) {
if (h->in[pos] == RAD_MESSAGE_AUTHENTIC) {
memcpy(resp, h->in, MSGSIZE);
@@ -313,20 +315,21 @@ is_valid_request(struct rad_handle *h)
/* zero fill the Message-Authenticator */
memset(&resp[pos + 2], 0, MD5_DIGEST_LENGTH);
- HMAC_CTX_init(&hctx);
- HMAC_Init(&hctx, srvp->secret,
- strlen(srvp->secret), EVP_md5());
- HMAC_Update(&hctx, resp, h->in_len);
- HMAC_Final(&hctx, md, &md_len);
- HMAC_CTX_cleanup(&hctx);
- HMAC_cleanup(&hctx);
+ HMAC_Init_ex(hctx, srvp->secret,
+ strlen(srvp->secret), EVP_md5(), NULL);
+ HMAC_Update(hctx, resp, h->in_len);
+ HMAC_Final(hctx, md, &md_len);
+ HMAC_CTX_reset(hctx);
if (memcmp(md, &h->in[pos + 2],
- MD5_DIGEST_LENGTH) != 0)
+ MD5_DIGEST_LENGTH) != 0) {
+ HMAC_CTX_free(hctx);
return (0);
+ }
break;
}
pos += h->in[pos + 1];
}
+ HMAC_CTX_free(hctx);
#endif
return (1);
}
diff --git a/lib/libsysdecode/Makefile b/lib/libsysdecode/Makefile
index 97af7dc7cadec..b11b75a09a72d 100644
--- a/lib/libsysdecode/Makefile
+++ b/lib/libsysdecode/Makefile
@@ -107,7 +107,7 @@ MLINKS+=sysdecode_mask.3 sysdecode_accessmode.3 \
sysdecode_mask.3 sysdecode_wait4_options.3 \
sysdecode_mask.3 sysdecode_wait6_options.3
-CLEANFILES= ioctl.c tables.h
+CLEANFILES= ioctl.c ioctl.c.tmp tables.h tables.h.tmp
.if defined(COMPAT_32BIT)
CPP+= -m32
@@ -124,7 +124,8 @@ CFLAGS.gcc+= ${CFLAGS.gcc.${.IMPSRC}}
DEPENDOBJS+= tables.h
tables.h: mktables
- sh ${.CURDIR}/mktables ${SYSROOT:U${DESTDIR}}${INCLUDEDIR} ${.TARGET}
+ sh ${.CURDIR}/mktables ${SYSROOT:U${DESTDIR}}${INCLUDEDIR} ${.TARGET}.tmp && \
+ mv -f ${.TARGET}.tmp ${.TARGET}
# mkioctls runs find(1) for headers so needs to rebuild every time. This used
# to be a hack only done in buildworld.
diff --git a/lib/libsysdecode/mktables b/lib/libsysdecode/mktables
index f5a231d9da35b..39f3a4f30b4aa 100644
--- a/lib/libsysdecode/mktables
+++ b/lib/libsysdecode/mktables
@@ -123,7 +123,7 @@ gen_table "rlimit" "RLIMIT_[A-Z]+[[:space:]]+[0-9]+" "sys/
gen_table "rusage" "RUSAGE_[A-Z]+[[:space:]]+[-0-9]+" "sys/resource.h"
gen_table "schedpolicy" "SCHED_[A-Z]+[[:space:]]+[0-9]+" "sched.h"
gen_table "sendfileflags" "SF_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h"
-gen_table "shmatflags" "SHM_[A-Z]+[[:space:]]+[0-9]{6}+" "sys/shm.h"
+gen_table "shmatflags" "SHM_[A-Z]+[[:space:]]+[0-9]{6}" "sys/shm.h"
gen_table "shutdownhow" "SHUT_[A-Z]+[[:space:]]+[0-9]+" "sys/socket.h"
gen_table "sigbuscode" "BUS_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
gen_table "sigchldcode" "CLD_[A-Z]+[[:space:]]+[0-9]+" "sys/signal.h"
diff --git a/lib/libunbound/Makefile b/lib/libunbound/Makefile
index c2a30db0d73f8..9814ac63b1611 100644
--- a/lib/libunbound/Makefile
+++ b/lib/libunbound/Makefile
@@ -16,7 +16,7 @@ CFLAGS+= -I${UNBOUNDDIR} -I${LDNSDIR} -I${.OBJDIR}
SRCS= alloc.c as112.c authzone.c autotrust.c cachedb.c config_file.c \
configlexer.l configparser.y context.c dname.c dns.c dns64.c \
- dnstree.c fptr_wlist.c infra.c iter_delegpt.c iter_donotq.c \
+ dnstree.c edns.c fptr_wlist.c infra.c iter_delegpt.c iter_donotq.c \
iter_fwd.c iter_hints.c iter_priv.c iter_resptype.c iter_scrub.c \
iter_utils.c iterator.c keyraw.c libunbound.c libworker.c \
listen_dnsport.c localzone.c locks.c log.c lookup3.c lruhash.c \
@@ -24,10 +24,10 @@ SRCS= alloc.c as112.c authzone.c autotrust.c cachedb.c config_file.c \
msgreply.c net_help.c netevent.c outbound_list.c outside_network.c \
packed_rrset.c parse.c parseutil.c random.c rbtree.c redis.c \
regional.c respip.c rrdef.c rrset.c rtt.c sbuffer.c slabhash.c \
- str2wire.c timehist.c tube.c ub_event_pluggable.c val_anchor.c \
- val_kcache.c val_kentry.c val_neg.c val_nsec.c val_nsec3.c \
- val_secalgo.c val_sigcrypt.c val_utils.c validator.c view.c \
- winsock_event.c wire2str.c
+ str2wire.c tcp_conn_limit.c timehist.c tube.c ub_event_pluggable.c \
+ val_anchor.c val_kcache.c val_kentry.c val_neg.c val_nsec.c \
+ val_nsec3.c val_secalgo.c val_sigcrypt.c val_utils.c validator.c \
+ view.c winsock_event.c wire2str.c
WARNS?= 3
NO_WTHREAD_SAFETY= true
diff --git a/lib/libusb/libusb.3 b/lib/libusb/libusb.3
index 05bd727d1f3fd..3fd932a07dd2f 100644
--- a/lib/libusb/libusb.3
+++ b/lib/libusb/libusb.3
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 23, 2016
+.Dd October 11, 2018
.Dt LIBUSB 3
.Os
.Sh NAME
@@ -330,7 +330,7 @@ and a LIBUSB_ERROR code on error.
.Ft int
.Fn libusb_get_config_descriptor "libusb_device *dev" "uint8_t config_index" "libusb_config_descriptor **config"
Get a USB configuration descriptor based on its index
-.Fa idx.
+.Fa idx .
Returns 0 on success, LIBUSB_ERROR_NOT_FOUND if the configuration does not exist
and a LIBUSB_ERROR code on error.
.Pp
@@ -581,7 +581,9 @@ are no threads currently handling events.
Acquire the event_waiters lock.
This lock is designed to be obtained in the
situation where you want to be aware when events are completed, but some other
-thread is event handling so calling libusb_handle_events() is not allowed.
+thread is event handling so calling
+.Fn libusb_handle_events
+is not allowed.
.Pp
.Ft void
.Fn libusb_unlock_event_waiters "libusb_context *ctx"
@@ -591,10 +593,12 @@ Release the event_waiters lock.
.Fn libusb_wait_for_event "libusb_context *ctx" "struct timeval *tv"
Wait for another thread to signal completion of an event.
Must be called
-with the event waiters lock held, see libusb_lock_event_waiters().
+with the event waiters lock held, see
+.Fn libusb_lock_event_waiters .
This will
block until the timeout expires or a transfer completes or a thread releases
-the event handling lock through libusb_unlock_events().
+the event handling lock through
+.Fn libusb_unlock_events .
Returns 0 after a
transfer completes or another thread stops event handling, and 1 if the
timeout expired.
@@ -662,7 +666,7 @@ that libusb uses as an event source.
.Pp
.Ft const struct libusb_pollfd **
.Fn libusb_get_pollfds "libusb_context *ctx"
-Retrive a list of file descriptors that should be polled by your main loop as
+Retrieve a list of file descriptors that should be polled by your main loop as
libusb event sources.
Returns a NULL-terminated list on success or NULL on failure.
.Pp
@@ -747,7 +751,7 @@ The library is also compliant with LibUSB version 0.1.12.
.Xr usbconfig 8 ,
.Xr usbdump 8
.Pp
-.Pa http://libusb.sourceforge.net/
+.Lk https://libusb.info/
.Sh HISTORY
.Nm
support first appeared in
diff --git a/lib/libzstd/Makefile b/lib/libzstd/Makefile
index ca56bcb0c828d..4bcb074ab05e2 100644
--- a/lib/libzstd/Makefile
+++ b/lib/libzstd/Makefile
@@ -24,7 +24,10 @@ SRCS= entropy_common.c \
zstd_lazy.c \
zstd_ldm.c \
zstd_opt.c \
- zstd_double_fast.c
+ zstd_double_fast.c \
+ debug.c \
+ hist.c \
+ fastcover.c
WARNS= 2
INCS= zstd.h
CFLAGS+= -I${ZSTDDIR}/lib -I${ZSTDDIR}/lib/common -DXXH_NAMESPACE=ZSTD_ \
diff --git a/lib/ncurses/ncurses/Makefile b/lib/ncurses/ncurses/Makefile
index 2969dfc8948ce..8e6adfcc1fb27 100644
--- a/lib/ncurses/ncurses/Makefile
+++ b/lib/ncurses/ncurses/Makefile
@@ -350,7 +350,8 @@ expanded.c: MKexpanded.sh
sh ${NCURSES_DIR}/ncurses/tty/MKexpanded.sh "${CC:N${CCACHE_BIN}} -E" ${CFLAGS} >expanded.c
fallback.c: MKfallback.sh
- sh ${NCURSES_DIR}/ncurses/tinfo/MKfallback.sh > fallback.c
+ sh -e ${NCURSES_DIR}/ncurses/tinfo/MKfallback.sh "" "" "" > ${.TARGET}.tmp && \
+ mv -f ${.TARGET}.tmp ${.TARGET}
# Generated headers
nomacros.h: MKlib_gen.sh curses.h