aboutsummaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/Makefile3
-rw-r--r--lib/libc/aarch64/gen/makecontext.c3
-rw-r--r--lib/libc/aarch64/string/Makefile.inc33
-rw-r--r--lib/libc/aarch64/string/memcpy.S2
-rw-r--r--lib/libc/aarch64/string/memcpy_resolver.c (renamed from lib/libc/powerpcspe/gen/fabs.S)31
-rw-r--r--lib/libc/aarch64/string/memmove_resolver.c (renamed from lib/libc/powerpcspe/_fpmath.h)40
-rw-r--r--lib/libc/aarch64/string/memset.S1
-rw-r--r--lib/libc/aarch64/string/memset_resolver.c55
-rw-r--r--lib/libc/aarch64/string/memset_zva64.S4
-rw-r--r--lib/libc/amd64/string/stpncpy.S9
-rw-r--r--lib/libc/csu/aarch64/reloc.c31
-rw-r--r--lib/libc/csu/powerpcspe/Makefile.inc3
-rw-r--r--lib/libc/db/btree/bt_seq.c8
-rw-r--r--lib/libc/db/btree/bt_split.c2
-rw-r--r--lib/libc/gen/Makefile.inc10
-rw-r--r--lib/libc/gen/Symbol.map7
-rw-r--r--lib/libc/gen/closedir.c1
-rw-r--r--lib/libc/gen/directory.390
-rw-r--r--lib/libc/gen/dirfd.c9
-rw-r--r--lib/libc/gen/err.316
-rw-r--r--lib/libc/gen/err.c2
-rw-r--r--lib/libc/gen/exterr_cat_filenames.h19
-rw-r--r--lib/libc/gen/fdopendir.c1
-rw-r--r--lib/libc/gen/fmtcheck.c4
-rw-r--r--lib/libc/gen/opendir.c1
-rw-r--r--lib/libc/gen/opendir2.c1
-rw-r--r--lib/libc/gen/posix_spawn.34
-rw-r--r--lib/libc/gen/posix_spawn.c105
-rw-r--r--lib/libc/gen/posix_spawnattr_getexecfd_np.387
-rw-r--r--lib/libc/gen/posix_spawnattr_getprocdescp_np.394
-rw-r--r--lib/libc/gen/rewinddir.c1
-rw-r--r--lib/libc/gen/scandir.c2
-rw-r--r--lib/libc/gen/telldir.c4
-rw-r--r--lib/libc/gen/uexterr_format.c71
-rw-r--r--lib/libc/include/libc_private.h1
-rw-r--r--lib/libc/net/getnetbydns.c3
-rw-r--r--lib/libc/posix1e/mac.conf1
-rw-r--r--lib/libc/posix1e/mac.conf.53
-rw-r--r--lib/libc/powerpcspe/Makefile.inc5
-rw-r--r--lib/libc/powerpcspe/gen/Makefile.inc5
-rw-r--r--lib/libc/powerpcspe/gen/_setjmp.S115
-rw-r--r--lib/libc/powerpcspe/gen/flt_rounds.c54
-rw-r--r--lib/libc/powerpcspe/gen/fpgetmask.c46
-rw-r--r--lib/libc/powerpcspe/gen/fpgetround.c46
-rw-r--r--lib/libc/powerpcspe/gen/fpgetsticky.c48
-rw-r--r--lib/libc/powerpcspe/gen/fpsetmask.c50
-rw-r--r--lib/libc/powerpcspe/gen/fpsetround.c50
-rw-r--r--lib/libc/powerpcspe/gen/setjmp.S136
-rw-r--r--lib/libc/powerpcspe/gen/sigsetjmp.S148
-rw-r--r--lib/libc/powerpcspe/softfloat/milieu.h48
-rw-r--r--lib/libc/powerpcspe/softfloat/powerpc-gcc.h91
-rw-r--r--lib/libc/powerpcspe/softfloat/softfloat.h306
-rw-r--r--lib/libc/resolv/res_init.c67
-rw-r--r--lib/libc/riscv/gen/makecontext.c3
-rw-r--r--lib/libc/rpc/rpc.34
-rw-r--r--lib/libc/rpc/rpc_soc.c46
-rw-r--r--lib/libc/stdio/printf-pos.c12
-rw-r--r--lib/libc/stdio/printfcommon.h4
-rw-r--r--lib/libc/stdio/printflocal.h2
-rw-r--r--lib/libc/stdio/vfprintf.c14
-rw-r--r--lib/libc/stdio/vfscanf.c10
-rw-r--r--lib/libc/stdio/vfwprintf.c12
-rw-r--r--lib/libc/stdio/vfwscanf.c8
-rw-r--r--lib/libc/stdio/xprintf.c6
-rw-r--r--lib/libc/stdlib/Makefile.inc87
-rw-r--r--lib/libc/stdlib/Symbol.map2
-rw-r--r--lib/libc/stdlib/getopt.349
-rw-r--r--lib/libc/stdlib/strtonum.374
-rw-r--r--lib/libc/stdlib/strtonum.c27
-rw-r--r--lib/libc/stdlib/tdestroy.c66
-rw-r--r--lib/libc/stdlib/tsearch.325
-rw-r--r--lib/libc/string/bcmp.310
-rw-r--r--lib/libc/string/swab.c13
-rw-r--r--lib/libc/sys/Symbol.map4
-rw-r--r--lib/libc/sys/pdwait.c20
-rw-r--r--lib/libc/tests/gen/dir2_test.c28
-rw-r--r--lib/libc/tests/stdlib/tsearch_test.c65
-rw-r--r--lib/libc/xdr/xdr.c7
78 files changed, 1057 insertions, 1518 deletions
diff --git a/lib/libc/Makefile b/lib/libc/Makefile
index 34474cfa9fe4..56818e07aa96 100644
--- a/lib/libc/Makefile
+++ b/lib/libc/Makefile
@@ -142,9 +142,6 @@ CFLAGS+= -DYP
.if ${MK_HESIOD} != "no"
CFLAGS+= -DHESIOD
.endif
-.if ${MK_FP_LIBC} == "no"
-CFLAGS+= -DNO_FLOATING_POINT
-.endif
.if ${MK_NS_CACHING} != "no"
CFLAGS+= -DNS_CACHING
.endif
diff --git a/lib/libc/aarch64/gen/makecontext.c b/lib/libc/aarch64/gen/makecontext.c
index 8c9b4edd7a15..2d0ee1043a9b 100644
--- a/lib/libc/aarch64/gen/makecontext.c
+++ b/lib/libc/aarch64/gen/makecontext.c
@@ -74,7 +74,8 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
va_end(ap);
/* Set the stack */
- gp->gp_sp = STACKALIGN(ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
+ gp->gp_sp = STACKALIGN((uintptr_t)ucp->uc_stack.ss_sp +
+ ucp->uc_stack.ss_size);
/* Arrange for return via the trampoline code. */
gp->gp_elr = (__register_t)_ctx_start;
gp->gp_x[19] = (__register_t)func;
diff --git a/lib/libc/aarch64/string/Makefile.inc b/lib/libc/aarch64/string/Makefile.inc
index 35523fb954be..bc05e849aa20 100644
--- a/lib/libc/aarch64/string/Makefile.inc
+++ b/lib/libc/aarch64/string/Makefile.inc
@@ -5,10 +5,8 @@
AARCH64_STRING_FUNCS= \
memcmp \
- memcpy \
memmove \
memrchr \
- memset \
stpcpy \
strchr \
strchrnul \
@@ -16,6 +14,11 @@ AARCH64_STRING_FUNCS= \
strnlen \
strrchr
+AARCH64_STRING_IFUNC_FILES= \
+ memcpy-mops.S \
+ memmove-mops.S \
+ memset-mops.S
+
# SIMD-enhanced routines not derived from Arm's code
MDSRCS+= \
memchr.S \
@@ -34,7 +37,13 @@ MDSRCS+= \
timingsafe_bcmp.S \
timingsafe_memcmp.S \
bcopy.c \
- bzero.c
+ bzero.c \
+ memcpy.S \
+ memcpy_resolver.c \
+ memmove_resolver.c \
+ memset.S \
+ memset_resolver.c \
+ memset_zva64.S
#
# Add the above functions. Generate an asm file that includes the needed
@@ -43,8 +52,8 @@ MDSRCS+= \
# override the generated file in these cases.
#
.for FUNC in ${AARCH64_STRING_FUNCS}
-.if !exists(${FUNC}.S)
-${FUNC}.S:
+.if !exists(${LIBC_SRCTOP}/aarch64/string/${FUNC}.S)
+${FUNC}.S: ${LIBC_SRCTOP}/aarch64/string/Makefile.inc
printf '/* %sgenerated by libc/aarch64/string/Makefile.inc */\n' @ > ${.TARGET}
printf '#define __%s_aarch64 %s\n' ${FUNC} ${FUNC} >> ${.TARGET}
printf '#include "aarch64/%s.S"\n' ${FUNC} >> ${.TARGET}
@@ -55,6 +64,18 @@ MDSRCS+= ${FUNC}.S
CFLAGS.${FUNC}.S+=-I${SRCTOP}/contrib/arm-optimized-routines/string
.endfor
-# memchr.S is a wrapper in the src tree for the implementation from
+.for FILE in ${AARCH64_STRING_IFUNC_FILES}
+${FILE}: ${LIBC_SRCTOP}/aarch64/string/Makefile.inc
+ printf '/* %sgenerated by libc/aarch64/string/Makefile.inc */\n' @ > ${.TARGET}
+ printf '#include "aarch64/%s"\n' ${FILE} >> ${.TARGET}
+CLEANFILES+= ${FILE}
+MDSRCS+= ${FILE}
+CFLAGS.${FILE}+=-I${SRCTOP}/contrib/arm-optimized-routines/string
+.endfor
+
+# Several files are wrappers in the src tree for the implementation from
# arm-optimized-routines
CFLAGS.memchr.S+=-I${SRCTOP}/contrib/arm-optimized-routines/string
+CFLAGS.memcpy.S+=-I${SRCTOP}/contrib/arm-optimized-routines/string
+CFLAGS.memset.S+=-I${SRCTOP}/contrib/arm-optimized-routines/string
+CFLAGS.memset_zva64.S+=-I${SRCTOP}/contrib/arm-optimized-routines/string
diff --git a/lib/libc/aarch64/string/memcpy.S b/lib/libc/aarch64/string/memcpy.S
index 53e860750eb2..c4601d158d6b 100644
--- a/lib/libc/aarch64/string/memcpy.S
+++ b/lib/libc/aarch64/string/memcpy.S
@@ -1,3 +1 @@
-#define __memcpy_aarch64_simd memcpy
-#define __memmove_aarch64_simd memmove
#include "aarch64/memcpy-advsimd.S"
diff --git a/lib/libc/powerpcspe/gen/fabs.S b/lib/libc/aarch64/string/memcpy_resolver.c
index df9196c3273d..c2a7477a939e 100644
--- a/lib/libc/powerpcspe/gen/fabs.S
+++ b/lib/libc/aarch64/string/memcpy_resolver.c
@@ -1,6 +1,7 @@
-/*
- * Copyright (c) 2016 Justin Hibbits
- * All rights reserved.
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2026 Arm Ltd
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,15 +24,19 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+#include <sys/types.h>
+#include <machine/ifunc.h>
-#include <machine/asm.h>
-/*
- * double fabs(double)
- */
-ENTRY(fabs)
- /* arg is split in two words, clear sign bit only, in r3. */
- clrlwi %r3,%r3,1
- blr
-END(fabs)
+#include <elf.h>
+
+void *__memcpy_aarch64_simd(void *, const void *, size_t);
+void *__memcpy_aarch64_mops(void *, const void *, size_t);
+
+DEFINE_UIFUNC(, void *, memcpy, (void *, const void *, size_t))
+{
+ if (ifunc_arg->_hwcap2 & HWCAP2_MOPS)
+ return (__memcpy_aarch64_mops);
+
+ return (__memcpy_aarch64_simd);
+}
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/powerpcspe/_fpmath.h b/lib/libc/aarch64/string/memmove_resolver.c
index 9bc7450aacaf..95cf3deca966 100644
--- a/lib/libc/powerpcspe/_fpmath.h
+++ b/lib/libc/aarch64/string/memmove_resolver.c
@@ -1,8 +1,7 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause
*
- * Copyright (c) 2003 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
+ * Copyright (c) 2026 Arm Ltd
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -25,32 +24,19 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+#include <sys/types.h>
+#include <machine/ifunc.h>
-union IEEEl2bits {
- long double e;
- struct {
-#if _BYTE_ORDER == _LITTLE_ENDIAN
- unsigned int manl :32;
- unsigned int manh :20;
- unsigned int exp :11;
- unsigned int sign :1;
-#else /* _BYTE_ORDER == _LITTLE_ENDIAN */
- unsigned int sign :1;
- unsigned int exp :11;
- unsigned int manh :20;
- unsigned int manl :32;
-#endif
- } bits;
-};
+#include <elf.h>
-#define mask_nbit_l(u) ((void)0)
-#define LDBL_IMPLICIT_NBIT
-#define LDBL_NBIT 0
+void *__memmove_aarch64_simd(void *, const void *, size_t);
+void *__memmove_aarch64_mops(void *, const void *, size_t);
-#define LDBL_MANH_SIZE 20
-#define LDBL_MANL_SIZE 32
+DEFINE_UIFUNC(, void *, memmove, (void *, const void *, size_t))
+{
+ if (ifunc_arg->_hwcap2 & HWCAP2_MOPS)
+ return (__memmove_aarch64_mops);
+
+ return (__memmove_aarch64_simd);
+}
-#define LDBL_TO_ARRAY32(u, a) do { \
- (a)[0] = (uint32_t)(u).bits.manl; \
- (a)[1] = (uint32_t)(u).bits.manh; \
-} while(0)
diff --git a/lib/libc/aarch64/string/memset.S b/lib/libc/aarch64/string/memset.S
new file mode 100644
index 000000000000..acf707cdb7ec
--- /dev/null
+++ b/lib/libc/aarch64/string/memset.S
@@ -0,0 +1 @@
+#include "aarch64/memset.S"
diff --git a/lib/libc/aarch64/string/memset_resolver.c b/lib/libc/aarch64/string/memset_resolver.c
new file mode 100644
index 000000000000..277e8c177de9
--- /dev/null
+++ b/lib/libc/aarch64/string/memset_resolver.c
@@ -0,0 +1,55 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2026 Arm Ltd
+ *
+ * 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/types.h>
+
+#include <machine/armreg.h>
+#include <machine/ifunc.h>
+
+#include <elf.h>
+
+void *__memset_aarch64(void *, int, size_t);
+void *__memset_aarch64_zva64(void *, int, size_t);
+void *__memset_aarch64_mops(void *, int, size_t);
+
+DEFINE_UIFUNC(, void *, memset, (void *, int, size_t))
+{
+ uint64_t dczid;
+
+ if (ifunc_arg->_hwcap2 & HWCAP2_MOPS)
+ return (__memset_aarch64_mops);
+
+ /*
+ * Check for the DC ZVA instruction, and it will
+ * zero 64 bytes (4 * 4byte words).
+ */
+ dczid = READ_SPECIALREG(dczid_el0);
+ if ((dczid & DCZID_DZP) == 0 && DCZID_BS_SIZE(dczid) == 4)
+ return (__memset_aarch64_zva64);
+
+ return (__memset_aarch64);
+}
+
diff --git a/lib/libc/aarch64/string/memset_zva64.S b/lib/libc/aarch64/string/memset_zva64.S
new file mode 100644
index 000000000000..7f1cf6ba577a
--- /dev/null
+++ b/lib/libc/aarch64/string/memset_zva64.S
@@ -0,0 +1,4 @@
+/* Used when we know we have a 64-byte dc zva instruction */
+#define __memset_aarch64 __memset_aarch64_zva64
+#define SKIP_ZVA_CHECK
+#include "aarch64/memset.S"
diff --git a/lib/libc/amd64/string/stpncpy.S b/lib/libc/amd64/string/stpncpy.S
index 764ee1d4008c..2efadc97a435 100644
--- a/lib/libc/amd64/string/stpncpy.S
+++ b/lib/libc/amd64/string/stpncpy.S
@@ -36,9 +36,7 @@
.set stpncpy, __stpncpy
ARCHFUNCS(__stpncpy)
ARCHFUNC(__stpncpy, scalar)
-#if 0 /* temporarily disabled cf. PR 291720 */
ARCHFUNC(__stpncpy, baseline)
-#endif
ENDARCHFUNCS(__stpncpy)
ARCHENTRY(__stpncpy, scalar)
@@ -93,7 +91,6 @@ ARCHEND(__stpncpy, scalar)
/* stpncpy(char *restrict rdi, const char *rsi, size_t rdx) */
ARCHENTRY(__stpncpy, baseline)
#define bounce (-3*16-8) /* location of on-stack bounce buffer */
-
test %rdx, %rdx # no bytes to copy?
jz .L0
@@ -225,8 +222,8 @@ ARCHENTRY(__stpncpy, baseline)
/* 1--32 bytes to copy, bounce through the stack */
.Lrunt: movdqa %xmm1, bounce+16(%rsp) # clear out rest of on-stack copy
- bts %r10, %r8 # treat end of buffer as end of string
and %r9d, %r8d # mask out head before string
+ bts %r10, %r8 # treat end of buffer as end of string
test $0x1ffff, %r8d # end of string within first chunk or right after?
jnz 0f # if yes, do not inspect second buffer
@@ -235,10 +232,10 @@ ARCHENTRY(__stpncpy, baseline)
pcmpeqb %xmm1, %xmm0 # NUL in second chunk?
pmovmskb %xmm0, %r9d
shl $16, %r9d
- or %r9d, %r8d # merge found NUL bytes into NUL mask
+ or %r9, %r8 # merge found NUL bytes into NUL mask
/* end of string after one buffer */
-0: tzcnt %r8d, %r8d # location of last char in string
+0: tzcnt %r8, %r8 # location of last char in string
movdqu %xmm1, bounce(%rsp, %r8, 1) # clear bytes behind string
lea bounce(%rsp, %rcx, 1), %rsi # start of string copy on stack
lea (%rdi, %r8, 1), %rax # return pointer to NUL byte
diff --git a/lib/libc/csu/aarch64/reloc.c b/lib/libc/csu/aarch64/reloc.c
index 4ba7920bcb07..77e8a38176ce 100644
--- a/lib/libc/csu/aarch64/reloc.c
+++ b/lib/libc/csu/aarch64/reloc.c
@@ -25,17 +25,42 @@
*/
#include <sys/cdefs.h>
+#include <machine/ifunc.h>
+
+static __ifunc_arg_t ifunc_arg;
static void
-ifunc_init(const Elf_Auxinfo *aux __unused)
+ifunc_init(const Elf_Auxinfo *aux)
{
+ ifunc_arg._size = sizeof(ifunc_arg);
+ ifunc_arg._hwcap = 0;
+ ifunc_arg._hwcap2 = 0;
+ ifunc_arg._hwcap3 = 0;
+ ifunc_arg._hwcap4 = 0;
+
+ for (; aux->a_type != AT_NULL; aux++) {
+ switch (aux->a_type) {
+ case AT_HWCAP:
+ ifunc_arg._hwcap = aux->a_un.a_val | _IFUNC_ARG_HWCAP;
+ break;
+ case AT_HWCAP2:
+ ifunc_arg._hwcap2 = aux->a_un.a_val;
+ break;
+ case AT_HWCAP3:
+ ifunc_arg._hwcap3 = aux->a_un.a_val;
+ break;
+ case AT_HWCAP4:
+ ifunc_arg._hwcap4 = aux->a_un.a_val;
+ break;
+ }
+ }
}
static void
crt1_handle_rela(const Elf_Rela *r)
{
typedef Elf_Addr (*ifunc_resolver_t)(
- uint64_t, uint64_t, uint64_t, uint64_t,
+ uint64_t, const __ifunc_arg_t *, uint64_t, uint64_t,
uint64_t, uint64_t, uint64_t, uint64_t);
Elf_Addr *ptr, *where, target;
@@ -43,7 +68,7 @@ crt1_handle_rela(const Elf_Rela *r)
case R_AARCH64_IRELATIVE:
ptr = (Elf_Addr *)r->r_addend;
where = (Elf_Addr *)r->r_offset;
- target = ((ifunc_resolver_t)ptr)(0, 0, 0, 0, 0, 0, 0, 0);
+ target = ((ifunc_resolver_t)ptr)(ifunc_arg._hwcap, &ifunc_arg, 0, 0, 0, 0, 0, 0);
*where = target;
break;
}
diff --git a/lib/libc/csu/powerpcspe/Makefile.inc b/lib/libc/csu/powerpcspe/Makefile.inc
deleted file mode 100644
index ddead75f874d..000000000000
--- a/lib/libc/csu/powerpcspe/Makefile.inc
+++ /dev/null
@@ -1,3 +0,0 @@
-#
-
-CFLAGS+= -DCRT_IRELOC_SUPPRESS
diff --git a/lib/libc/db/btree/bt_seq.c b/lib/libc/db/btree/bt_seq.c
index 2562724faf33..fc7fa693b747 100644
--- a/lib/libc/db/btree/bt_seq.c
+++ b/lib/libc/db/btree/bt_seq.c
@@ -325,7 +325,7 @@ usecurrent: F_CLR(c, CURS_AFTER | CURS_BEFORE);
static int
__bt_first(BTREE *t, const DBT *key, EPG *erval, int *exactp)
{
- PAGE *h;
+ PAGE *h, *hprev;
EPG *ep, save;
pgno_t pg;
@@ -338,7 +338,7 @@ __bt_first(BTREE *t, const DBT *key, EPG *erval, int *exactp)
* page) and return it.
*/
if ((ep = __bt_search(t, key, exactp)) == NULL)
- return (0);
+ return (RET_SPECIAL);
if (*exactp) {
if (F_ISSET(t, B_NODUPS)) {
*erval = *ep;
@@ -369,14 +369,14 @@ __bt_first(BTREE *t, const DBT *key, EPG *erval, int *exactp)
break;
if (h->pgno != save.page->pgno)
mpool_put(t->bt_mp, h, 0);
- if ((h = mpool_get(t->bt_mp,
+ if ((hprev = mpool_get(t->bt_mp,
h->prevpg, 0)) == NULL) {
if (h->pgno == save.page->pgno)
mpool_put(t->bt_mp,
save.page, 0);
return (RET_ERROR);
}
- ep->page = h;
+ ep->page = h = hprev;
ep->index = NEXTINDEX(h);
}
--ep->index;
diff --git a/lib/libc/db/btree/bt_split.c b/lib/libc/db/btree/bt_split.c
index 5fbf8c3ac0f3..865543928c35 100644
--- a/lib/libc/db/btree/bt_split.c
+++ b/lib/libc/db/btree/bt_split.c
@@ -542,7 +542,7 @@ bt_broot(BTREE *t, PAGE *h, PAGE *l, PAGE *r)
* If the key is on an overflow page, mark the overflow chain
* so it isn't deleted when the leaf copy of the key is deleted.
*/
- if (bl->flags & P_BIGKEY) {
+ if (bl->flags & P_BIGKEY) {
pgno_t pgno;
memcpy(&pgno, bl->bytes, sizeof(pgno));
if (bt_preserve(t, pgno) == RET_ERROR)
diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc
index 4d064d18d36e..3e68f8400c5c 100644
--- a/lib/libc/gen/Makefile.inc
+++ b/lib/libc/gen/Makefile.inc
@@ -274,8 +274,10 @@ MAN+= alarm.3 \
posix_spawn.3 \
posix_spawn_file_actions_addopen.3 \
posix_spawn_file_actions_init.3 \
+ posix_spawnattr_getexecfd_np.3 \
posix_spawnattr_getflags.3 \
posix_spawnattr_getpgroup.3 \
+ posix_spawnattr_getprocdescp_np.3 \
posix_spawnattr_getschedparam.3 \
posix_spawnattr_getschedpolicy.3 \
posix_spawnattr_init.3 \
@@ -469,7 +471,9 @@ MLINKS+=posix_spawn.3 posix_spawnp.3 \
posix_spawn_file_actions_addopen.3 posix_spawn_file_actions_addfchdir_np.3 \
posix_spawn_file_actions_init.3 posix_spawn_file_actions_destroy.3 \
posix_spawnattr_getflags.3 posix_spawnattr_setflags.3 \
+ posix_spawnattr_getexecfd_np.3 posix_spawnattr_setexecfd_np.3 \
posix_spawnattr_getpgroup.3 posix_spawnattr_setpgroup.3 \
+ posix_spawnattr_getprocdescp_np.3 posix_spawnattr_setprocdescp_np.3 \
posix_spawnattr_getschedparam.3 posix_spawnattr_setschedparam.3 \
posix_spawnattr_getschedpolicy.3 posix_spawnattr_setschedpolicy.3 \
posix_spawnattr_getsigdefault.3 posix_spawnattr_setsigdefault.3 \
@@ -583,8 +587,8 @@ install-passwd: .PHONY
${PWD_MKDB_CMD} -i -p -d ${DESTDIR}/etc ${DESTDIR}/etc/master.passwd
.if defined(NO_ROOT) && defined(METALOG)
( \
- echo ".${DISTBASE}/etc/pwd.db type=file mode=0644 uname=root gname=wheel"; \
- echo ".${DISTBASE}/etc/spwd.db type=file mode=0600 uname=root gname=wheel"; \
- echo ".${DISTBASE}/etc/passwd type=file mode=0644 uname=root gname=wheel"; \
+ echo ".${DISTBASE}/etc/pwd.db type=file uname=root gname=wheel mode=0644"; \
+ echo ".${DISTBASE}/etc/spwd.db type=file uname=root gname=wheel mode=0600"; \
+ echo ".${DISTBASE}/etc/passwd type=file uname=root gname=wheel mode=0644"; \
) | cat -l >> ${METALOG}
.endif
diff --git a/lib/libc/gen/Symbol.map b/lib/libc/gen/Symbol.map
index 494b65bc5cc1..ddbd0522e13f 100644
--- a/lib/libc/gen/Symbol.map
+++ b/lib/libc/gen/Symbol.map
@@ -474,6 +474,13 @@ FBSD_1.8 {
str2sig;
};
+FBSD_1.9 {
+ posix_spawnattr_getexecfd_np;
+ posix_spawnattr_getprocdescp_np;
+ posix_spawnattr_setexecfd_np;
+ posix_spawnattr_setprocdescp_np;
+};
+
FBSDprivate_1.0 {
/* needed by thread libraries */
__thr_jtable;
diff --git a/lib/libc/gen/closedir.c b/lib/libc/gen/closedir.c
index 6015114d6c47..73070d171cd1 100644
--- a/lib/libc/gen/closedir.c
+++ b/lib/libc/gen/closedir.c
@@ -68,6 +68,5 @@ fdclosedir(DIR *dirp)
int
closedir(DIR *dirp)
{
-
return (_close(fdclosedir(dirp)));
}
diff --git a/lib/libc/gen/directory.3 b/lib/libc/gen/directory.3
index 263dfdd6eb95..270abb2d2371 100644
--- a/lib/libc/gen/directory.3
+++ b/lib/libc/gen/directory.3
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd August 1, 2020
+.Dd January 31, 2026
.Dt DIRECTORY 3
.Os
.Sh NAME
@@ -86,13 +86,6 @@ and
returns a pointer to be used to identify the
.Em directory stream
in subsequent operations.
-The pointer
-.Dv NULL
-is returned if
-.Fa filename
-cannot be accessed, or if it cannot
-.Xr malloc 3
-enough memory to hold the whole thing.
.Pp
The
.Fn fdopendir
@@ -134,14 +127,6 @@ or
.Fn closedir
on the same
.Em directory stream .
-The function returns
-.Dv NULL
-upon reaching the end of the directory or on error.
-In the event of an error,
-.Va errno
-may be set to any of the values documented for the
-.Xr getdirentries 2
-system call.
.Pp
The
.Fn readdir_r
@@ -166,10 +151,6 @@ upon reaching the end of the directory
.Fa result
is set to
.Dv NULL .
-The
-.Fn readdir_r
-function
-returns 0 on success or an error number to indicate failure.
.Pp
The
.Fn telldir
@@ -179,12 +160,9 @@ returns a token representing the current location associated with the named
Values returned by
.Fn telldir
are good only for the lifetime of the
-.Dv DIR
-pointer,
-.Fa dirp ,
+.Em directory stream
from which they are derived.
-If the directory is closed and then
-reopened, prior values returned by
+If the directory is closed and then reopened, prior values returned by
.Fn telldir
will no longer be valid.
Values returned by
@@ -217,28 +195,22 @@ The
function
closes the named
.Em directory stream
-and frees the structure associated with the
-.Fa dirp
-pointer,
-returning 0 on success.
-On failure, \-1 is returned and the global variable
-.Va errno
-is set to indicate the error.
+and frees the structure associated with
+.Fa dirp .
.Pp
The
.Fn fdclosedir
function is equivalent to the
.Fn closedir
-function except that this function returns directory file descriptor instead of
-closing it.
+function except that it returns the file descriptor associated with
+.Fa dirp
+instead of closing it.
.Pp
The
.Fn dirfd
function
-returns the integer file descriptor associated with the named
-.Em directory stream ,
-see
-.Xr open 2 .
+returns the file descriptor associated with
+.Fa dirp .
.Sh EXAMPLES
Sample code which searches a directory for entry ``name'' is:
.Bd -literal -offset indent
@@ -255,6 +227,38 @@ while ((dp = readdir(dirp)) != NULL) {
(void)closedir(dirp);
return (NOT_FOUND);
.Ed
+.Sh RETURN VALUES
+The
+.Fn opendir
+and
+.Fn fdopendir
+functions return a pointer to the new
+.Em directory stream
+on success and
+.Dv NULL
+on failure.
+.Pp
+The
+.Fn readdir
+function returns a pointer to a directory entry on success and
+.Dv NULL
+on failure.
+The
+.Fn readdir_r
+function returns 0 on success and an error number on failure.
+.Pp
+The
+.Fn telldir
+function returns a nonnegative value on success and -1 on failure.
+.Pp
+The
+.Fn closedir
+function returns 0 on success and -1 on failure.
+The
+.Fn fdclosedir
+and
+.Fn dirfd
+functions return an open file descriptor on success and -1 on failure.
.Sh ERRORS
The
.Fn opendir
@@ -325,6 +329,16 @@ function may also fail and set
.Va errno
for any of the errors specified for the routine
.Xr close 2 .
+.Pp
+The
+.Fn dirfd
+function will fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The
+.Fa dirp
+argument does not refer to a valid directory stream.
+.El
.Sh SEE ALSO
.Xr close 2 ,
.Xr lseek 2 ,
diff --git a/lib/libc/gen/dirfd.c b/lib/libc/gen/dirfd.c
index 85090bd4da6c..984e69b9ae9a 100644
--- a/lib/libc/gen/dirfd.c
+++ b/lib/libc/gen/dirfd.c
@@ -27,9 +27,9 @@
*/
#include "namespace.h"
-#include <sys/param.h>
-
#include <dirent.h>
+#include <errno.h>
+#include <stddef.h>
#include "un-namespace.h"
#include "gen-private.h"
@@ -37,6 +37,9 @@
int
dirfd(DIR *dirp)
{
-
+ if (dirp == NULL || _dirfd(dirp) < 0) {
+ errno = EINVAL;
+ return (-1);
+ }
return (_dirfd(dirp));
}
diff --git a/lib/libc/gen/err.3 b/lib/libc/gen/err.3
index 088ead71239b..70a214152a19 100644
--- a/lib/libc/gen/err.3
+++ b/lib/libc/gen/err.3
@@ -114,6 +114,22 @@ preceded by another colon and space unless the
argument is
.Dv NULL .
.Pp
+If the kernel returned an extended error string in addition to the
+.Va errno
+code, the
+.Fn err
+function prints the string with interpolated values for parameters,
+as provided to the corresponding invocation of
+.Xr EXTERROR 9 .
+If the extended error string was not provided, but extended error
+information was, or even if string was provided and the
+.Ev EXTERROR_VERBOSE
+environment variable is present, an additional report is printed.
+The report includes at least the category of the error, the name of
+the source file (if known by the used version of libc),
+the source line number, and parameters.
+The format of the printed string is not contractual and might be changed.
+.Pp
In the case of the
.Fn errc ,
.Fn verrc ,
diff --git a/lib/libc/gen/err.c b/lib/libc/gen/err.c
index 16cbe27693e7..793bf7522e42 100644
--- a/lib/libc/gen/err.c
+++ b/lib/libc/gen/err.c
@@ -120,7 +120,7 @@ vexterr(bool doexterr, int code, const char *fmt, va_list ap)
}
fprintf(err_file, "%s", strerror(code));
if (doexterr && extstatus == 0 && exterr[0] != '\0')
- fprintf(err_file, " (extended error %s)", exterr);
+ fprintf(err_file, " (%s)", exterr);
fprintf(err_file, "\n");
}
diff --git a/lib/libc/gen/exterr_cat_filenames.h b/lib/libc/gen/exterr_cat_filenames.h
new file mode 100644
index 000000000000..d55396a1b286
--- /dev/null
+++ b/lib/libc/gen/exterr_cat_filenames.h
@@ -0,0 +1,19 @@
+/*
+ * Automatically @generated, use
+ * tools/build/make_libc_exterr_cat_filenames.sh
+ */
+ [EXTERR_CAT_FUSE_DEVICE] = "fs/fuse/fuse_device.c",
+ [EXTERR_CAT_FUSE_VFS] = "fs/fuse/fuse_vfsops.c",
+ [EXTERR_CAT_FUSE_VNOPS] = "fs/fuse/fuse_vnops.c",
+ [EXTERR_CAT_GEOM] = "geom/geom_subr.c",
+ [EXTERR_CAT_GEOMVFS] = "geom/geom_vfs.c",
+ [EXTERR_CAT_FILEDESC] = "kern/kern_descrip.c",
+ [EXTERR_CAT_PROCEXIT] = "kern/kern_exit.c",
+ [EXTERR_CAT_FORK] = "kern/kern_fork.c",
+ [EXTERR_CAT_GENIO] = "kern/sys_generic.c",
+ [EXTERR_CAT_VFSBIO] = "kern/vfs_bio.c",
+ [EXTERR_CAT_INOTIFY] = "kern/vfs_inotify.c",
+ [EXTERR_CAT_VFSSYSCALL] = "kern/vfs_syscalls.c",
+ [EXTERR_CAT_BRIDGE] = "net/if_bridge.c",
+ [EXTERR_CAT_SWAP] = "vm/swap_pager.c",
+ [EXTERR_CAT_MMAP] = "vm/vm_mmap.c",
diff --git a/lib/libc/gen/fdopendir.c b/lib/libc/gen/fdopendir.c
index 9393cbe28f85..05e1a09fd00c 100644
--- a/lib/libc/gen/fdopendir.c
+++ b/lib/libc/gen/fdopendir.c
@@ -37,6 +37,7 @@
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
+#include <stddef.h>
#include "un-namespace.h"
#include "gen-private.h"
diff --git a/lib/libc/gen/fmtcheck.c b/lib/libc/gen/fmtcheck.c
index de889ad3421c..6d85e3889a4d 100644
--- a/lib/libc/gen/fmtcheck.c
+++ b/lib/libc/gen/fmtcheck.c
@@ -55,10 +55,8 @@ enum __e_fmtcheck_types {
FMTCHECK_INTMAXTPOINTER,
FMTCHECK_PTRDIFFTPOINTER,
FMTCHECK_SIZETPOINTER,
-#ifndef NO_FLOATING_POINT
FMTCHECK_DOUBLE,
FMTCHECK_LONGDOUBLE,
-#endif
FMTCHECK_STRING,
FMTCHECK_WSTRING,
FMTCHECK_WIDTH,
@@ -185,7 +183,6 @@ get_next_format_from_precision(const char **pf)
RETURN(pf,f,FMTCHECK_UNKNOWN);
RETURN(pf,f,FMTCHECK_LONG);
}
-#ifndef NO_FLOATING_POINT
if (strchr("aAeEfFgG", *f)) {
switch (modifier) {
case MOD_LONGDOUBLE:
@@ -197,7 +194,6 @@ get_next_format_from_precision(const char **pf)
RETURN(pf,f,FMTCHECK_UNKNOWN);
}
}
-#endif
if (*f == 'c') {
switch (modifier) {
case MOD_LONG:
diff --git a/lib/libc/gen/opendir.c b/lib/libc/gen/opendir.c
index 08d9eb10eaa2..4c08b7156055 100644
--- a/lib/libc/gen/opendir.c
+++ b/lib/libc/gen/opendir.c
@@ -42,6 +42,5 @@
DIR *
opendir(const char *name)
{
-
return (__opendir2(name, DTF_HIDEW | DTF_NODUP));
}
diff --git a/lib/libc/gen/opendir2.c b/lib/libc/gen/opendir2.c
index c5c2e662efd8..321cb2261b8c 100644
--- a/lib/libc/gen/opendir2.c
+++ b/lib/libc/gen/opendir2.c
@@ -68,7 +68,6 @@ __opendir2(const char *name, int flags)
static int
opendir_compar(const void *p1, const void *p2)
{
-
return (strcmp((*(const struct dirent * const *)p1)->d_name,
(*(const struct dirent * const *)p2)->d_name));
}
diff --git a/lib/libc/gen/posix_spawn.3 b/lib/libc/gen/posix_spawn.3
index 278fee88463a..f7489890db31 100644
--- a/lib/libc/gen/posix_spawn.3
+++ b/lib/libc/gen/posix_spawn.3
@@ -455,15 +455,19 @@ action.
.Xr posix_spawn_file_actions_destroy 3 ,
.Xr posix_spawn_file_actions_init 3 ,
.Xr posix_spawnattr_destroy 3 ,
+.Xr posix_spawnattr_getexecfd_np 3 ,
.Xr posix_spawnattr_getflags 3 ,
.Xr posix_spawnattr_getpgroup 3 ,
+.Xr posix_spawnattr_getprocdescp_np 3 ,
.Xr posix_spawnattr_getschedparam 3 ,
.Xr posix_spawnattr_getschedpolicy 3 ,
.Xr posix_spawnattr_getsigdefault 3 ,
.Xr posix_spawnattr_getsigmask 3 ,
.Xr posix_spawnattr_init 3 ,
+.Xr posix_spawnattr_setexecfd_np 3 ,
.Xr posix_spawnattr_setflags 3 ,
.Xr posix_spawnattr_setpgroup 3 ,
+.Xr posix_spawnattr_setprocdescp_np 3,
.Xr posix_spawnattr_setschedparam 3 ,
.Xr posix_spawnattr_setschedpolicy 3 ,
.Xr posix_spawnattr_setsigdefault 3 ,
diff --git a/lib/libc/gen/posix_spawn.c b/lib/libc/gen/posix_spawn.c
index a5b732696b8c..656c0f20f798 100644
--- a/lib/libc/gen/posix_spawn.c
+++ b/lib/libc/gen/posix_spawn.c
@@ -29,6 +29,7 @@
#include "namespace.h"
#include <sys/param.h>
#include <sys/procctl.h>
+#include <sys/procdesc.h>
#include <sys/queue.h>
#include <sys/wait.h>
@@ -37,6 +38,7 @@
#include <sched.h>
#include <spawn.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -50,6 +52,9 @@ struct __posix_spawnattr {
int sa_schedpolicy;
sigset_t sa_sigdefault;
sigset_t sa_sigmask;
+ int sa_execfd;
+ int *sa_pdrfork_fdp;
+ int sa_pdflags;
};
struct __posix_spawn_file_actions {
@@ -231,7 +236,6 @@ struct posix_spawn_args {
#define PSPAWN_STACK_ALIGN(sz) \
(((sz) + PSPAWN_STACK_ALIGNBYTES) & ~PSPAWN_STACK_ALIGNBYTES)
-#if defined(__i386__) || defined(__amd64__)
/*
* Below we'll assume that _RFORK_THREAD_STACK_SIZE is appropriately aligned for
* the posix_spawn() case where we do not end up calling execvpe and won't ever
@@ -240,7 +244,6 @@ struct posix_spawn_args {
#define _RFORK_THREAD_STACK_SIZE 4096
_Static_assert((_RFORK_THREAD_STACK_SIZE % PSPAWN_STACK_ALIGNMENT) == 0,
"Inappropriate stack size alignment");
-#endif
static int
_posix_spawn_thr(void *data)
@@ -260,7 +263,9 @@ _posix_spawn_thr(void *data)
_exit(127);
}
envp = psa->envp != NULL ? psa->envp : environ;
- if (psa->use_env_path)
+ if (psa->sa != NULL && (*(psa->sa))->sa_execfd != -1)
+ fexecve((*(psa->sa))->sa_execfd, psa->argv, envp);
+ else if (psa->use_env_path)
__libc_execvpe(psa->path, psa->argv, envp);
else
_execve(psa->path, psa->argv, envp);
@@ -278,12 +283,16 @@ do_posix_spawn(pid_t *pid, const char *path,
{
struct posix_spawn_args psa;
pid_t p;
-#ifdef _RFORK_THREAD_STACK_SIZE
+ int pfd;
+ bool do_pfd;
char *stack;
- size_t cnt, stacksz;
+ size_t stacksz;
+#if defined(__i386__) || defined(__amd64__)
stacksz = _RFORK_THREAD_STACK_SIZE;
if (use_env_path) {
+ size_t cnt;
+
/*
* We need to make sure we have enough room on the stack for the
* potential alloca() in execvPe if it gets kicked back an
@@ -310,6 +319,9 @@ do_posix_spawn(pid_t *pid, const char *path,
return (ENOMEM);
stacksz = (((uintptr_t)stack + stacksz) & ~PSPAWN_STACK_ALIGNBYTES) -
(uintptr_t)stack;
+#else
+ stack = NULL;
+ stacksz = 0;
#endif
psa.path = path;
psa.fa = fa;
@@ -319,6 +331,8 @@ do_posix_spawn(pid_t *pid, const char *path,
psa.use_env_path = use_env_path;
psa.error = 0;
+ do_pfd = sa != NULL && (*sa)->sa_pdrfork_fdp != NULL;
+
/*
* Passing RFSPAWN to rfork(2) gives us effectively a vfork that drops
* non-ignored signal handlers. We'll fall back to the slightly less
@@ -330,22 +344,26 @@ do_posix_spawn(pid_t *pid, const char *path,
* a special property of the libthr rtld locks ensure that
* rtld is operational in the child. In particular, libthr
* rtld locks do not store owner' tid into the lock word.
+ *
+ * x86 stores the return address on the stack, so rfork(2)
+ * cannot work as-is because the child would clobber the
+ * return address of the parent. Because of this, we must use
+ * rfork_thread instead.
+ *
+ * Every other architecture stores the return address in a
+ * register, the trivial rfork_thread() wrapper is provided
+ * for them. The only minor drawback is that the stack is
+ * temporarily allocated.
*/
-#ifdef _RFORK_THREAD_STACK_SIZE
- /*
- * x86 stores the return address on the stack, so rfork(2) cannot work
- * as-is because the child would clobber the return address of the
- * parent. Because of this, we must use rfork_thread instead while
- * almost every other arch stores the return address in a register.
- */
- p = rfork_thread(RFSPAWN, stack + stacksz, _posix_spawn_thr, &psa);
+ if (do_pfd) {
+ p = pdrfork_thread(&pfd, PD_CLOEXEC | (*sa)->sa_pdflags,
+ RFSPAWN, stack + stacksz, _posix_spawn_thr, &psa);
+ } else {
+ p = rfork_thread(RFSPAWN, stack + stacksz, _posix_spawn_thr,
+ &psa);
+ }
free(stack);
-#else
- p = rfork(RFSPAWN);
- if (p == 0)
- /* _posix_spawn_thr does not return */
- _posix_spawn_thr(&psa);
-#endif
+
/*
* The above block should leave us in a state where we've either
* succeeded and we're ready to process the results, or we need to
@@ -353,6 +371,8 @@ do_posix_spawn(pid_t *pid, const char *path,
*/
if (p == -1 && errno == EINVAL) {
+ if (do_pfd)
+ return (EOPNOTSUPP);
p = vfork();
if (p == 0)
/* _posix_spawn_thr does not return */
@@ -360,12 +380,18 @@ do_posix_spawn(pid_t *pid, const char *path,
}
if (p == -1)
return (errno);
- if (psa.error != 0)
+ if (psa.error != 0) {
/* Failed; ready to reap */
- _waitpid(p, NULL, WNOHANG);
- else if (pid != NULL)
+ if (do_pfd)
+ (void)_close(pfd);
+ else
+ _waitpid(p, NULL, WNOHANG);
+ } else if (pid != NULL) {
/* exec succeeded */
*pid = p;
+ if (do_pfd)
+ *((*sa)->sa_pdrfork_fdp) = pfd;
+ }
return (psa.error);
}
@@ -578,6 +604,7 @@ posix_spawnattr_init(posix_spawnattr_t *ret)
sa = calloc(1, sizeof(struct __posix_spawnattr));
if (sa == NULL)
return (errno);
+ sa->sa_execfd = -1;
/* Set defaults as specified by POSIX, cleared above */
*ret = sa;
@@ -640,6 +667,23 @@ posix_spawnattr_getsigmask(const posix_spawnattr_t * __restrict sa,
}
int
+posix_spawnattr_getexecfd_np(const posix_spawnattr_t * __restrict sa,
+ int * __restrict fdp)
+{
+ *fdp = (*sa)->sa_execfd;
+ return (0);
+}
+
+int
+posix_spawnattr_getprocdescp_np(const posix_spawnattr_t * __restrict sa,
+ int ** __restrict fdpp, int * __restrict pdrflagsp)
+{
+ *fdpp = (*sa)->sa_pdrfork_fdp;
+ *pdrflagsp = (*sa)->sa_pdflags;
+ return (0);
+}
+
+int
posix_spawnattr_setflags(posix_spawnattr_t *sa, short flags)
{
if ((flags & ~(POSIX_SPAWN_RESETIDS | POSIX_SPAWN_SETPGROUP |
@@ -688,3 +732,20 @@ posix_spawnattr_setsigmask(posix_spawnattr_t * __restrict sa,
(*sa)->sa_sigmask = *sigmask;
return (0);
}
+
+int
+posix_spawnattr_setexecfd_np(posix_spawnattr_t * __restrict sa,
+ int execfd)
+{
+ (*sa)->sa_execfd = execfd;
+ return (0);
+}
+
+int
+posix_spawnattr_setprocdescp_np(const posix_spawnattr_t * __restrict sa,
+ int * __restrict fdp, int pdrflags)
+{
+ (*sa)->sa_pdrfork_fdp = fdp;
+ (*sa)->sa_pdflags = pdrflags;
+ return (0);
+}
diff --git a/lib/libc/gen/posix_spawnattr_getexecfd_np.3 b/lib/libc/gen/posix_spawnattr_getexecfd_np.3
new file mode 100644
index 000000000000..6edcfcdfb42f
--- /dev/null
+++ b/lib/libc/gen/posix_spawnattr_getexecfd_np.3
@@ -0,0 +1,87 @@
+.\" Copyright 2026 The FreeBSD Foundation
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.Dd January 25, 2026
+.Dt POSIX_SPAWNATTR_GETEXECFD_NP 3
+.Os
+.Sh NAME
+.Nm posix_spawnattr_getexecfd_np ,
+.Nm posix_spawnattr_setexecfd_np
+.Nd "get and set the spawn-execfd attribute of a spawn attributes object"
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In spawn.h
+.Ft int
+.Fo posix_spawnattr_getexecfd_np
+.Fa "const posix_spawnattr_t *restrict attr"
+.Fa "int *restrict fdp"
+.Fc
+.Ft int
+.Fo posix_spawnattr_setexecfd_np
+.Fa "posix_spawnattr_t *attr"
+.Fa "int fd"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn posix_spawnattr_getexecfd_np
+function obtains the value of the spawn-execfd attribute from the
+attributes object referenced by
+.Fa attr .
+.Pp
+The
+.Fn posix_spawnattr_setexecfd_np
+function sets the spawn-execfd attribute in an initialized attributes
+object referenced by
+.Fa attr .
+.Pp
+The spawn-execfd attribute provides the file descriptor that is used
+to execute new image in the spawned process by the
+.Xr posix_spawn 3
+family of functions.
+If the attribute is set to a value other then \-1, it must be a valid
+file descriptor which does not have the
+.Va O_CLOFORK
+flag set.
+Then,
+.Fn posix_spawn
+executes the executable image referenced by the file descriptor in the
+newly created process, using the
+.Xr fexecve 2
+system call.
+In this case, the
+.Fa path
+argument to
+.Fn posix_spawn
+is ignored.
+.Pp
+The default value for the spawn-execfd attribute is \-1, which
+means that the executed image is specified by the
+.Fa path
+argument to
+.Fn posix_spawn .
+.Sh RETURN VALUES
+The
+.Fn posix_spawnattr_getexecfd_np
+and
+.Fn posix_spawnattr_setexecfd_np
+functions return zero.
+.Sh SEE ALSO
+.Xr posix_spawn 3 ,
+.Xr posix_spawnattr_destroy 3 ,
+.Xr posix_spawnattr_init 3 ,
+.Xr posix_spawnp 3
+.Sh STANDARDS
+The
+.Fn posix_spawnattr_getexecfd_np
+and
+.Fn posix_spawnattr_setexecfd_np
+are
+.Fx
+extensions that first appeared in
+.Fx 16.0 .
diff --git a/lib/libc/gen/posix_spawnattr_getprocdescp_np.3 b/lib/libc/gen/posix_spawnattr_getprocdescp_np.3
new file mode 100644
index 000000000000..fab529d91313
--- /dev/null
+++ b/lib/libc/gen/posix_spawnattr_getprocdescp_np.3
@@ -0,0 +1,94 @@
+.\" Copyright 2026 The FreeBSD Foundation
+.\"
+.\" SPDX-License-Identifier: BSD-2-Clause
+.\"
+.\" This documentation was written by
+.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship
+.\" from the FreeBSD Foundation.
+.\"
+.Dd January 26, 2026
+.Dt POSIX_SPAWNATTR_GETPROCDESCP_NP 3
+.Os
+.Sh NAME
+.Nm posix_spawnattr_getprocdesp_np ,
+.Nm posix_spawnattr_setprocdescp_np
+.Nd "get and set the spawn-procdescp attribute of a spawn attributes object"
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In spawn.h
+.Ft int
+.Fo posix_spawnattr_getprocdescp_np
+.Fa "const posix_spawnattr_t *restrict attr"
+.Fa "int **restrict fdpp"
+.Fa "int *restrict pdrflagsp"
+.Fc
+.Ft int
+.Fo posix_spawnattr_setprocdescp_np
+.Fa "posix_spawnattr_t *attr"
+.Fa "int *restrict fdp"
+.Fa "int pdrflags"
+.Fc
+.Sh DESCRIPTION
+The
+.Fn posix_spawnattr_getprocdescp_np
+function obtains the value of the spawn-procdescp attribute from the
+attributes object referenced by
+.Fa attr .
+.Pp
+The
+.Fn posix_spawnattr_procdescp_np
+function sets the spawn-procdescp attribute in an initialized attributes
+object referenced by
+.Fa attr .
+.Pp
+The spawn-procdescp attribute provides the location where the child process's
+file descriptor will be stored after a successful spawn.
+Setting the attribute to a non-NULL value implicitly request the creation of
+the file descriptor that references the child process.
+It wiil be created by the
+.Xr pdrfork 2
+system call. which will be used instead of
+.Xr fork/vfork/rfork 2
+when the attribute is set to
+.Va NULL.
+.Pp
+If the attribute is set to a value other then
+.Dv NULL ,
+it must be a valid pointer to a variable of
+.Vt int
+type, where the resulting descriptor will be stored.
+The
+.Fa pdrflags
+argument specifies additional flags that are accepted by the
+.Xr pdfork 2
+system call.
+See its description for the list of the valid flags.
+Note that the
+.Va PD_CLOEXEC
+flag is always set, preventing leakage of the process descriptor
+into the newly created child.
+.Pp
+The default value for the spawn-procdescp attribute is
+.Dv NULL ,
+which means that no process descriptor will be created.
+.Sh RETURN VALUES
+The
+.Fn posix_spawnattr_getprocdescp_np
+and
+.Fn posix_spawnattr_setprocdescp_np
+functions return zero.
+.Sh SEE ALSO
+.Xr posix_spawn 3 ,
+.Xr posix_spawnattr_destroy 3 ,
+.Xr posix_spawnattr_init 3 ,
+.Xr posix_spawnp 3
+.Sh STANDARDS
+The
+.Fn posix_spawnattr_getprocdescp_np
+and
+.Fn posix_spawnattr_setprocdescp_np
+are
+.Fx
+extensions that first appeared in
+.Fx 16.0 .
diff --git a/lib/libc/gen/rewinddir.c b/lib/libc/gen/rewinddir.c
index df829e98d138..5cead2adc6d4 100644
--- a/lib/libc/gen/rewinddir.c
+++ b/lib/libc/gen/rewinddir.c
@@ -43,7 +43,6 @@
void
rewinddir(DIR *dirp)
{
-
if (__isthreaded)
_pthread_mutex_lock(&dirp->dd_lock);
dirp->dd_flags &= ~__DTF_SKIPREAD; /* current contents are invalid */
diff --git a/lib/libc/gen/scandir.c b/lib/libc/gen/scandir.c
index fb589f4b36b6..84b20fbafa03 100644
--- a/lib/libc/gen/scandir.c
+++ b/lib/libc/gen/scandir.c
@@ -232,14 +232,12 @@ scandirat(int dirfd, const char *dirname, struct dirent ***namelist,
int
alphasort(const struct dirent **d1, const struct dirent **d2)
{
-
return (strcoll((*d1)->d_name, (*d2)->d_name));
}
int
versionsort(const struct dirent **d1, const struct dirent **d2)
{
-
return (strverscmp((*d1)->d_name, (*d2)->d_name));
}
diff --git a/lib/libc/gen/telldir.c b/lib/libc/gen/telldir.c
index 1731cc4d7a2c..d71b7bed158c 100644
--- a/lib/libc/gen/telldir.c
+++ b/lib/libc/gen/telldir.c
@@ -53,7 +53,7 @@ telldir(DIR *dirp)
if (__isthreaded)
_pthread_mutex_lock(&dirp->dd_lock);
- /*
+ /*
* Outline:
* 1) If the directory position fits in a packed structure, return that.
* 2) Otherwise, see if it's already been recorded in the linked list
@@ -95,7 +95,7 @@ telldir(DIR *dirp)
LIST_INSERT_HEAD(&dirp->dd_td->td_locq, lp, loc_lqe);
}
ddloc.i.is_packed = 0;
- /*
+ /*
* Technically this assignment could overflow on 32-bit architectures,
* but we would get ENOMEM long before that happens.
*/
diff --git a/lib/libc/gen/uexterr_format.c b/lib/libc/gen/uexterr_format.c
index e8ddfbd578e3..8d3b458ca9f2 100644
--- a/lib/libc/gen/uexterr_format.c
+++ b/lib/libc/gen/uexterr_format.c
@@ -8,28 +8,85 @@
* under sponsorship from the FreeBSD Foundation.
*/
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/exterrvar.h>
#include <exterr.h>
+#include <stdbool.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
+
+static const char * const cat_to_filenames[] = {
+#include "exterr_cat_filenames.h"
+};
+
+static const char *
+cat_to_filename(int category)
+{
+ if (category < 0 || category >= nitems(cat_to_filenames) ||
+ cat_to_filenames[category] == NULL)
+ return ("unknown");
+ return (cat_to_filenames[category]);
+}
+
+static const char exterror_verbose_name[] = "EXTERROR_VERBOSE";
+enum exterr_verbose_state {
+ EXTERR_VERBOSE_UNKNOWN = 100,
+ EXTERR_VERBOSE_DEFAULT,
+ EXTERR_VERBOSE_ALLOW,
+};
+static enum exterr_verbose_state exterror_verbose = EXTERR_VERBOSE_UNKNOWN;
+
+static void
+exterr_verbose_init(void)
+{
+ /*
+ * No need to care about thread-safety, the result is
+ * idempotent.
+ */
+ if (exterror_verbose != EXTERR_VERBOSE_UNKNOWN)
+ return;
+ if (issetugid()) {
+ exterror_verbose = EXTERR_VERBOSE_DEFAULT;
+ } else if (getenv(exterror_verbose_name) != NULL) {
+ exterror_verbose = EXTERR_VERBOSE_ALLOW;
+ } else {
+ exterror_verbose = EXTERR_VERBOSE_DEFAULT;
+ }
+}
int
__uexterr_format(const struct uexterror *ue, char *buf, size_t bufsz)
{
+ bool has_msg;
+
if (bufsz > UEXTERROR_MAXLEN)
bufsz = UEXTERROR_MAXLEN;
if (ue->error == 0) {
strlcpy(buf, "", bufsz);
return (0);
}
- if (ue->msg[0] == '\0') {
- snprintf(buf, bufsz,
- "errno %d category %u (src line %u) p1 %#jx p2 %#jx",
- ue->error, ue->cat, ue->src_line,
- (uintmax_t)ue->p1, (uintmax_t)ue->p2);
+ exterr_verbose_init();
+ has_msg = ue->msg[0] != '\0';
+
+ if (has_msg) {
+ snprintf(buf, bufsz, ue->msg, (uintmax_t)ue->p1,
+ (uintmax_t)ue->p2);
} else {
- strlcpy(buf, ue->msg, bufsz);
+ strlcpy(buf, "", bufsz);
+ }
+
+ if (exterror_verbose == EXTERR_VERBOSE_ALLOW || !has_msg) {
+ char lbuf[128];
+
+ snprintf(lbuf, sizeof(lbuf),
+ "errno %d category %u (src sys/%s:%u) p1 %#jx p2 %#jx",
+ ue->error, ue->cat, cat_to_filename(ue->cat),
+ ue->src_line, (uintmax_t)ue->p1, (uintmax_t)ue->p2);
+ if (has_msg)
+ strlcat(buf, " ", bufsz);
+ strlcat(buf, lbuf, bufsz);
}
return (0);
}
diff --git a/lib/libc/include/libc_private.h b/lib/libc/include/libc_private.h
index db4cbc32be35..299629fce2ad 100644
--- a/lib/libc/include/libc_private.h
+++ b/lib/libc/include/libc_private.h
@@ -252,6 +252,7 @@ enum {
INTERPOS__reserved0, /* was distribute_static_tls */
INTERPOS_pdfork,
INTERPOS_uexterr_gettext,
+ INTERPOS_pdwait,
INTERPOS_MAX
};
diff --git a/lib/libc/net/getnetbydns.c b/lib/libc/net/getnetbydns.c
index deca8c58fca5..b9cc29d5bfdb 100644
--- a/lib/libc/net/getnetbydns.c
+++ b/lib/libc/net/getnetbydns.c
@@ -304,6 +304,9 @@ _dns_getnetbyaddr(void *rval, void *cb_data, va_list ap)
for (nn = 4, net2 = net; net2; net2 >>= 8)
netbr[--nn] = net2 & 0xff;
switch (nn) {
+ case 4: /* net was all-zero i.e. 0.0.0.0 */
+ sprintf(qbuf, "0.0.0.0.in-addr.arpa");
+ break;
case 3: /* Class A */
sprintf(qbuf, "0.0.0.%u.in-addr.arpa", netbr[3]);
break;
diff --git a/lib/libc/posix1e/mac.conf b/lib/libc/posix1e/mac.conf
index 011143abf073..7da9bb8a9638 100644
--- a/lib/libc/posix1e/mac.conf
+++ b/lib/libc/posix1e/mac.conf
@@ -12,6 +12,7 @@
default_labels file ?biba,?lomac,?mls,?sebsd
default_labels ifnet ?biba,?lomac,?mls,?sebsd
+default_labels jail ?
default_labels process ?biba,?lomac,?mls,?partition,?sebsd
default_labels socket ?biba,?lomac,?mls
diff --git a/lib/libc/posix1e/mac.conf.5 b/lib/libc/posix1e/mac.conf.5
index 98aa62dd83a7..99d75584a0d7 100644
--- a/lib/libc/posix1e/mac.conf.5
+++ b/lib/libc/posix1e/mac.conf.5
@@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd July 25, 2015
+.Dd January 19. 2026
.Dt MAC.CONF 5
.Os
.Sh NAME
@@ -79,6 +79,7 @@ and
# Default label set to be used by simple MAC applications
default_labels file ?biba,?lomac,?mls,?sebsd
+default_labels jail ?
default_labels ifnet ?biba,?lomac,?mls,?sebsd
default_labels process ?biba,?lomac,?mls,?partition,?sebsd
default_labels socket ?biba,?lomac,?mls
diff --git a/lib/libc/powerpcspe/Makefile.inc b/lib/libc/powerpcspe/Makefile.inc
deleted file mode 100644
index 0b5879574480..000000000000
--- a/lib/libc/powerpcspe/Makefile.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-CFLAGS+= -I${LIBC_SRCTOP}/powerpc
-
-# Long double is 64-bits
-SRCS+=machdep_ldisd.c
-SYM_MAPS+=${LIBC_SRCTOP}/powerpc/Symbol.map
diff --git a/lib/libc/powerpcspe/gen/Makefile.inc b/lib/libc/powerpcspe/gen/Makefile.inc
deleted file mode 100644
index 502f3dc231bf..000000000000
--- a/lib/libc/powerpcspe/gen/Makefile.inc
+++ /dev/null
@@ -1,5 +0,0 @@
-.include "${LIBC_SRCTOP}/powerpc/gen/Makefile.common"
-
-SRCS += fabs.S flt_rounds.c fpgetmask.c fpgetround.c \
- fpgetsticky.c fpsetmask.c fpsetround.c \
- _setjmp.S setjmp.S sigsetjmp.S
diff --git a/lib/libc/powerpcspe/gen/_setjmp.S b/lib/libc/powerpcspe/gen/_setjmp.S
deleted file mode 100644
index f282e0013f97..000000000000
--- a/lib/libc/powerpcspe/gen/_setjmp.S
+++ /dev/null
@@ -1,115 +0,0 @@
-/*-
- * Copyright (c) 2016 Justin Hibbits
- * 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.
- */
-/* $NetBSD: _setjmp.S,v 1.1 1997/03/29 20:55:53 thorpej Exp $ */
-
-#include <machine/asm.h>
-/*
- * C library -- _setjmp, _longjmp
- *
- * _longjmp(a,v)
- * will generate a "return(v?v:1)" from the last call to
- * _setjmp(a)
- * by restoring registers from the stack.
- * The previous signal state is NOT restored.
- *
- * jmpbuf layout:
- * +------------+
- * | unused |
- * +------------+
- * | unused |
- * | |
- * | (4 words) |
- * | |
- * +------------+
- * | saved regs |
- * | ... |
- */
-
-ENTRY(_setjmp)
- mflr %r11
- mfcr %r12
- evstdd %r1,24+0*8(%r3)
- evstdd %r2,24+1*8(%r3)
- evstdd %r11,24+2*8(%r3)
- evstdd %r12,24+3*8(%r3)
- evstdd %r13,24+4*8(%r3)
- evstdd %r14,24+5*8(%r3)
- evstdd %r15,24+6*8(%r3)
- evstdd %r16,24+7*8(%r3)
- evstdd %r17,24+8*8(%r3)
- evstdd %r18,24+9*8(%r3)
- evstdd %r19,24+10*8(%r3)
- evstdd %r20,24+11*8(%r3)
- evstdd %r21,24+12*8(%r3)
- evstdd %r22,24+13*8(%r3)
- evstdd %r23,24+14*8(%r3)
- evstdd %r24,24+15*8(%r3)
- evstdd %r25,24+16*8(%r3)
- evstdd %r26,24+17*8(%r3)
- evstdd %r27,24+18*8(%r3)
- evstdd %r28,24+19*8(%r3)
- evstdd %r29,24+20*8(%r3)
- evstdd %r30,24+21*8(%r3)
- evstdd %r31,24+22*8(%r3)
-
- li %r3,0
- blr
-END(_setjmp)
-
-ENTRY(_longjmp)
- evldd %r1,24+0*8(%r3)
- evldd %r2,24+1*8(%r3)
- evldd %r11,24+2*8(%r3)
- evldd %r12,24+3*8(%r3)
- evldd %r13,24+4*8(%r3)
- evldd %r14,24+5*8(%r3)
- evldd %r15,24+6*8(%r3)
- evldd %r16,24+7*8(%r3)
- evldd %r17,24+8*8(%r3)
- evldd %r18,24+9*8(%r3)
- evldd %r19,24+10*8(%r3)
- evldd %r20,24+11*8(%r3)
- evldd %r21,24+12*8(%r3)
- evldd %r22,24+13*8(%r3)
- evldd %r23,24+14*8(%r3)
- evldd %r24,24+15*8(%r3)
- evldd %r25,24+16*8(%r3)
- evldd %r26,24+17*8(%r3)
- evldd %r27,24+18*8(%r3)
- evldd %r28,24+19*8(%r3)
- evldd %r29,24+20*8(%r3)
- evldd %r30,24+21*8(%r3)
- evldd %r31,24+22*8(%r3)
-
- mtlr %r11
- mtcr %r12
- or. %r3,%r4,%r4
- bnelr
- li %r3,1
- blr
-END(_longjmp)
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/powerpcspe/gen/flt_rounds.c b/lib/libc/powerpcspe/gen/flt_rounds.c
deleted file mode 100644
index 26dfca0e0e3a..000000000000
--- a/lib/libc/powerpcspe/gen/flt_rounds.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* $NetBSD: flt_rounds.c,v 1.4.10.3 2002/03/22 20:41:53 nathanw Exp $ */
-
-/*
- * Copyright (c) 2016 Justin Hibbits
- * 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Mark Brinicombe
- * for the NetBSD Project.
- * 4. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/types.h>
-#include <machine/float.h>
-#include <machine/spr.h>
-
-#ifndef _SOFT_FLOAT
-static const int map[] = {
- 1, /* round to nearest */
- 0, /* round to zero */
- 2, /* round to positive infinity */
- 3 /* round to negative infinity */
-};
-
-int
-__flt_rounds()
-{
- uint32_t fpscr;
-
- __asm__ __volatile("mfspr %0, %1" : "=r"(fpscr) : "K"(SPR_SPEFSCR));
- return map[(fpscr & 0x03)];
-}
-#endif
diff --git a/lib/libc/powerpcspe/gen/fpgetmask.c b/lib/libc/powerpcspe/gen/fpgetmask.c
deleted file mode 100644
index f7679be4ca54..000000000000
--- a/lib/libc/powerpcspe/gen/fpgetmask.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* $NetBSD: fpgetmask.c,v 1.3 2002/01/13 21:45:47 thorpej Exp $ */
-
-/*
- * Copyright (c) 2016 Justin Hibbits
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Dan Winship.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <sys/types.h>
-#include <machine/spr.h>
-#include <ieeefp.h>
-
-#ifndef _SOFT_FLOAT
-fp_except_t
-fpgetmask()
-{
- uint32_t fpscr;
-
- __asm__ __volatile("mfspr %0, %1" : "=r"(fpscr) : "K"(SPR_SPEFSCR));
- return ((fp_except_t)((fpscr >> 2) & 0x1f));
-}
-#endif
diff --git a/lib/libc/powerpcspe/gen/fpgetround.c b/lib/libc/powerpcspe/gen/fpgetround.c
deleted file mode 100644
index 9c01bcbaf327..000000000000
--- a/lib/libc/powerpcspe/gen/fpgetround.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* $NetBSD: fpgetround.c,v 1.3 2002/01/13 21:45:47 thorpej Exp $ */
-
-/*
- * Copyright (c) 2016 Justin Hibbits
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Dan Winship.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <sys/types.h>
-#include <machine/spr.h>
-#include <ieeefp.h>
-
-#ifndef _SOFT_FLOAT
-fp_rnd_t
-fpgetround()
-{
- uint32_t fpscr;
-
- __asm__ __volatile("mfspr %0, %1" : "=r"(fpscr) : "K"(SPR_SPEFSCR));
- return ((fp_rnd_t)(fpscr & 0x3));
-}
-#endif
diff --git a/lib/libc/powerpcspe/gen/fpgetsticky.c b/lib/libc/powerpcspe/gen/fpgetsticky.c
deleted file mode 100644
index a97c27296cab..000000000000
--- a/lib/libc/powerpcspe/gen/fpgetsticky.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* $NetBSD: fpgetsticky.c,v 1.3 2002/01/13 21:45:48 thorpej Exp $ */
-
-/*
- * Copyright (c) 2016 Justin Hibbits
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Dan Winship.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-#include "namespace.h"
-
-#include <sys/types.h>
-#include <machine/spr.h>
-#include <ieeefp.h>
-
-#ifndef _SOFT_FLOAT
-fp_except_t
-fpgetsticky()
-{
- uint32_t fpscr;
-
- __asm__ __volatile("mfspr %0, %1" : "=r"(fpscr) : "K"(SPR_SPEFSCR));
- return ((fp_except_t)((fpscr >> 25) & 0x1f));
-}
-#endif
diff --git a/lib/libc/powerpcspe/gen/fpsetmask.c b/lib/libc/powerpcspe/gen/fpsetmask.c
deleted file mode 100644
index a7a2569df905..000000000000
--- a/lib/libc/powerpcspe/gen/fpsetmask.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* $NetBSD: fpsetmask.c,v 1.3 2002/01/13 21:45:48 thorpej Exp $ */
-
-/*
- * Copyright (c) 2016 Justin Hibbits
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Dan Winship.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <sys/types.h>
-#include <machine/spr.h>
-#include <ieeefp.h>
-
-#ifndef _SOFT_FLOAT
-fp_except_t
-fpsetmask(fp_except_t mask)
-{
- uint32_t fpscr;
- fp_except_t old;
-
- __asm__ __volatile("mfspr %0, %1" : "=r"(fpscr) : "K"(SPR_SPEFSCR));
- old = (fp_except_t)((fpscr >> 2) & 0x1f);
- fpscr = (fpscr & 0xffffff83) | ((mask & 0x1f) << 2);
- __asm__ __volatile("mtspr %1,%0;isync" :: "r"(fpscr), "K"(SPR_SPEFSCR));
- return (old);
-}
-#endif
diff --git a/lib/libc/powerpcspe/gen/fpsetround.c b/lib/libc/powerpcspe/gen/fpsetround.c
deleted file mode 100644
index 2280e190b2f9..000000000000
--- a/lib/libc/powerpcspe/gen/fpsetround.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/* $NetBSD: fpsetround.c,v 1.3 2002/01/13 21:45:48 thorpej Exp $ */
-
-/*
- * Copyright (c) 2016 Justin Hibbits
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Dan Winship.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <sys/types.h>
-#include <machine/spr.h>
-#include <ieeefp.h>
-
-#ifndef _SOFT_FLOAT
-fp_rnd_t
-fpsetround(fp_rnd_t rnd_dir)
-{
- uint32_t fpscr;
- fp_rnd_t old;
-
- __asm__ __volatile("mfspr %0, %1" : "=r"(fpscr) : "K"(SPR_SPEFSCR) );
- old = (fp_rnd_t)(fpscr & 0x3);
- fpscr = (fpscr & 0xfffffffc) | rnd_dir;
- __asm__ __volatile("mtspr %1, %0;isync" :: "r"(fpscr), "K"(SPR_SPEFSCR));
- return (old);
-}
-#endif
diff --git a/lib/libc/powerpcspe/gen/setjmp.S b/lib/libc/powerpcspe/gen/setjmp.S
deleted file mode 100644
index 1bd3edcf5239..000000000000
--- a/lib/libc/powerpcspe/gen/setjmp.S
+++ /dev/null
@@ -1,136 +0,0 @@
-/*-
- * Copyright (c) 2016 Justin Hibbits
- * 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.
- */
-/* $NetBSD: setjmp.S,v 1.3 1998/10/03 12:30:38 tsubai Exp $ */
-
-#include <machine/asm.h>
-#include <sys/syscall.h>
-
-/*
- * C library -- setjmp, longjmp
- *
- * longjmp(a,v)
- * will generate a "return(v?v:1)" from the last call to
- * setjmp(a)
- * by restoring registers from the stack.
- * The previous signal state is restored.
- *
- * jmpbuf layout:
- * +------------+
- * | unused |
- * +------------+
- * | sig state |
- * | |
- * | (4 words) |
- * | |
- * +------------+
- * | saved regs |
- * | ... |
- */
-
-ENTRY(setjmp)
- mr %r6,%r3
- li %r3,1 /* SIG_BLOCK, but doesn't matter */
- /* since set == NULL */
- li %r4,0 /* set = NULL */
- mr %r5,%r6 /* &oset */
- addi %r5,%r5,4
- li %r0, SYS_sigprocmask /*sigprocmask(SIG_BLOCK, NULL, &oset)*/
- sc /*assume no error XXX */
- mflr %r11 /* r11 <- link reg */
- mfcr %r12 /* r12 <- condition reg */
- mr %r10,%r1 /* r10 <- stackptr */
- mr %r9,%r2 /* r9 <- global ptr */
- evstdd %r9,24+0*8(%r6)
- evstdd %r10,24+1*8(%r6)
- evstdd %r11,24+2*8(%r6)
- evstdd %r12,24+3*8(%r6)
- evstdd %r13,24+4*8(%r6)
- evstdd %r14,24+5*8(%r6)
- evstdd %r15,24+6*8(%r6)
- evstdd %r16,24+7*8(%r6)
- evstdd %r17,24+8*8(%r6)
- evstdd %r18,24+9*8(%r6)
- evstdd %r19,24+10*8(%r6)
- evstdd %r20,24+11*8(%r6)
- evstdd %r21,24+12*8(%r6)
- evstdd %r22,24+13*8(%r6)
- evstdd %r23,24+14*8(%r6)
- evstdd %r24,24+15*8(%r6)
- evstdd %r25,24+16*8(%r6)
- evstdd %r26,24+17*8(%r6)
- evstdd %r27,24+18*8(%r6)
- evstdd %r28,24+19*8(%r6)
- evstdd %r29,24+20*8(%r6)
- evstdd %r30,24+21*8(%r6)
- evstdd %r31,24+22*8(%r6)
-
- li %r3,0 /* return (0) */
- blr
-END(setjmp)
-
- WEAK_REFERENCE(CNAME(__longjmp), longjmp)
-ENTRY(__longjmp)
- evldd %r9,24+0*8(%r3)
- evldd %r10,24+1*8(%r3)
- evldd %r11,24+2*8(%r3)
- evldd %r12,24+3*8(%r3)
- evldd %r13,24+4*8(%r3)
- evldd %r14,24+5*8(%r3)
- evldd %r15,24+6*8(%r3)
- evldd %r16,24+7*8(%r3)
- evldd %r17,24+8*8(%r3)
- evldd %r18,24+9*8(%r3)
- evldd %r19,24+10*8(%r3)
- evldd %r20,24+11*8(%r3)
- evldd %r21,24+12*8(%r3)
- evldd %r22,24+13*8(%r3)
- evldd %r23,24+14*8(%r3)
- evldd %r24,24+15*8(%r3)
- evldd %r25,24+16*8(%r3)
- evldd %r26,24+17*8(%r3)
- evldd %r27,24+18*8(%r3)
- evldd %r28,24+19*8(%r3)
- evldd %r29,24+20*8(%r3)
- evldd %r30,24+21*8(%r3)
- evldd %r31,24+22*8(%r3)
-
- mr %r6,%r4 /* save val param */
- mtlr %r11 /* r11 -> link reg */
- mtcr %r12 /* r12 -> condition reg */
- mr %r1,%r10 /* r10 -> stackptr */
- mr %r4,%r3
- li %r3,3 /* SIG_SETMASK */
- addi %r4,%r4,4 /* &set */
- li %r5,0 /* oset = NULL */
- li %r0,SYS_sigprocmask /* sigprocmask(SIG_SET, &set, NULL) */
- sc /* assume no error XXX */
- or. %r3,%r6,%r6
- bnelr
- li %r3,1
- blr
-END(__longjmp)
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/powerpcspe/gen/sigsetjmp.S b/lib/libc/powerpcspe/gen/sigsetjmp.S
deleted file mode 100644
index 45c85c3fce23..000000000000
--- a/lib/libc/powerpcspe/gen/sigsetjmp.S
+++ /dev/null
@@ -1,148 +0,0 @@
-/*-
- * Copyright (c) 2016 Justin Hibbits
- * 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.
- */
-/* $NetBSD: sigsetjmp.S,v 1.4 1998/10/03 12:30:38 tsubai Exp $ */
-
-#include <machine/asm.h>
-/*
- * C library -- sigsetjmp, siglongjmp
- *
- * siglongjmp(a,v)
- * will generate a "return(v?v:1)" from the last call to
- * sigsetjmp(a, savemask)
- * by restoring registers from the stack.
- * The previous signal state is restored if savemask is non-zero
- *
- * jmpbuf layout:
- * +------------+
- * | savemask |
- * +------------+
- * | sig state |
- * | |
- * | (4 words) |
- * | |
- * +------------+
- * | saved regs |
- * | ... |
- */
-
-
-#include <sys/syscall.h>
-
-ENTRY(sigsetjmp)
- mr %r6,%r3
- stw %r4,0(%r3)
- or. %r7,%r4,%r4
- beq 1f
- li %r3,1 /* SIG_BLOCK, but doesn't matter */
- /* since set == NULL */
- li %r4,0 /* set = NULL */
- mr %r5,%r6 /* &oset */
- addi %r5,%r5,4
- li %r0, SYS_sigprocmask /* sigprocmask(SIG_BLOCK, NULL, &oset)*/
- sc /* assume no error XXX */
-1:
- mflr %r11
- mfcr %r12
- mr %r10,%r1
- mr %r9,%r2
-
- /* FPRs */
- evstdd %r9,24+0*8(%r6)
- evstdd %r10,24+1*8(%r6)
- evstdd %r11,24+2*8(%r6)
- evstdd %r12,24+3*8(%r6)
- evstdd %r13,24+4*8(%r6)
- evstdd %r14,24+5*8(%r6)
- evstdd %r15,24+6*8(%r6)
- evstdd %r16,24+7*8(%r6)
- evstdd %r17,24+8*8(%r6)
- evstdd %r18,24+9*8(%r6)
- evstdd %r19,24+10*8(%r6)
- evstdd %r20,24+11*8(%r6)
- evstdd %r21,24+12*8(%r6)
- evstdd %r22,24+13*8(%r6)
- evstdd %r23,24+14*8(%r6)
- evstdd %r24,24+15*8(%r6)
- evstdd %r25,24+16*8(%r6)
- evstdd %r26,24+17*8(%r6)
- evstdd %r27,24+18*8(%r6)
- evstdd %r28,24+19*8(%r6)
- evstdd %r29,24+20*8(%r6)
- evstdd %r30,24+21*8(%r6)
- evstdd %r31,24+22*8(%r6)
-
- li %r3,0
- blr
-END(sigsetjmp)
-
-ENTRY(siglongjmp)
-
- /* FPRs */
- evldd %r9,24+0*8(%r3)
- evldd %r10,24+1*8(%r3)
- evldd %r11,24+2*8(%r3)
- evldd %r12,24+3*8(%r3)
- evldd %r13,24+4*8(%r3)
- evldd %r14,24+5*8(%r3)
- evldd %r15,24+6*8(%r3)
- evldd %r16,24+7*8(%r3)
- evldd %r17,24+8*8(%r3)
- evldd %r18,24+9*8(%r3)
- evldd %r19,24+10*8(%r3)
- evldd %r20,24+11*8(%r3)
- evldd %r21,24+12*8(%r3)
- evldd %r22,24+13*8(%r3)
- evldd %r23,24+14*8(%r3)
- evldd %r24,24+15*8(%r3)
- evldd %r25,24+16*8(%r3)
- evldd %r26,24+17*8(%r3)
- evldd %r27,24+18*8(%r3)
- evldd %r28,24+19*8(%r3)
- evldd %r29,24+20*8(%r3)
- evldd %r30,24+21*8(%r3)
- evldd %r31,24+22*8(%r3)
-
- lwz %r7,0(%r3)
- mr %r6,%r4
- mtlr %r11
- mtcr %r12
- mr %r1,%r10
- or. %r7,%r7,%r7
- beq 1f
- mr %r4,%r3
- li %r3,3 /* SIG_SETMASK */
- addi %r4,%r4,4 /* &set */
- li %r5,0 /* oset = NULL */
- li %r0,SYS_sigprocmask /* sigprocmask(SIG_SET, &set, NULL) */
- sc /* assume no error XXX */
-1:
- or. %r3,%r6,%r6
- bnelr
- li %r3,1
- blr
-END(siglongjmp)
-
- .section .note.GNU-stack,"",%progbits
diff --git a/lib/libc/powerpcspe/softfloat/milieu.h b/lib/libc/powerpcspe/softfloat/milieu.h
deleted file mode 100644
index 6139aa58b982..000000000000
--- a/lib/libc/powerpcspe/softfloat/milieu.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* $NetBSD: milieu.h,v 1.1 2000/12/29 20:13:54 bjh21 Exp $ */
-
-/*
-===============================================================================
-
-This C header file is part of the SoftFloat IEC/IEEE Floating-point
-Arithmetic Package, Release 2a.
-
-Written by John R. Hauser. This work was made possible in part by the
-International Computer Science Institute, located at Suite 600, 1947 Center
-Street, Berkeley, California 94704. Funding was partially provided by the
-National Science Foundation under grant MIP-9311980. The original version
-of this code was written as part of a project to build a fixed-point vector
-processor in collaboration with the University of California at Berkeley,
-overseen by Profs. Nelson Morgan and John Wawrzynek. More information
-is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
-arithmetic/SoftFloat.html'.
-
-THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
-has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
-TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
-PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
-AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
-
-Derivative works are acceptable, even for commercial purposes, so long as
-(1) they include prominent notice that the work is derivative, and (2) they
-include prominent notice akin to these four paragraphs for those parts of
-this code that are retained.
-
-===============================================================================
-*/
-
-/*
--------------------------------------------------------------------------------
-Include common integer types and flags.
--------------------------------------------------------------------------------
-*/
-#include "powerpc-gcc.h"
-
-/*
--------------------------------------------------------------------------------
-Symbolic Boolean literals.
--------------------------------------------------------------------------------
-*/
-enum {
- FALSE = 0,
- TRUE = 1
-};
diff --git a/lib/libc/powerpcspe/softfloat/powerpc-gcc.h b/lib/libc/powerpcspe/softfloat/powerpc-gcc.h
deleted file mode 100644
index d11198866e39..000000000000
--- a/lib/libc/powerpcspe/softfloat/powerpc-gcc.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* $NetBSD: arm-gcc.h,v 1.2 2001/02/21 18:09:25 bjh21 Exp $ */
-
-/*
--------------------------------------------------------------------------------
-One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined.
--------------------------------------------------------------------------------
-*/
-#define BIGENDIAN
-
-/*
--------------------------------------------------------------------------------
-The macro `BITS64' can be defined to indicate that 64-bit integer types are
-supported by the compiler.
--------------------------------------------------------------------------------
-*/
-#define BITS64
-
-/*
--------------------------------------------------------------------------------
-Each of the following `typedef's defines the most convenient type that holds
-integers of at least as many bits as specified. For example, `uint8' should
-be the most convenient type that can hold unsigned integers of as many as
-8 bits. The `flag' type must be able to hold either a 0 or 1. For most
-implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed
-to the same as `int'.
--------------------------------------------------------------------------------
-*/
-typedef int flag;
-typedef unsigned int uint8;
-typedef int int8;
-typedef unsigned int uint16;
-typedef int int16;
-typedef unsigned int uint32;
-typedef signed int int32;
-#ifdef BITS64
-typedef unsigned long long int uint64;
-typedef signed long long int int64;
-#endif
-
-/*
--------------------------------------------------------------------------------
-Each of the following `typedef's defines a type that holds integers
-of _exactly_ the number of bits specified. For instance, for most
-implementation of C, `bits16' and `sbits16' should be `typedef'ed to
-`unsigned short int' and `signed short int' (or `short int'), respectively.
--------------------------------------------------------------------------------
-*/
-typedef unsigned char bits8;
-typedef signed char sbits8;
-typedef unsigned short int bits16;
-typedef signed short int sbits16;
-typedef unsigned int bits32;
-typedef signed int sbits32;
-#ifdef BITS64
-typedef unsigned long long int bits64;
-typedef signed long long int sbits64;
-#endif
-
-#ifdef BITS64
-/*
--------------------------------------------------------------------------------
-The `LIT64' macro takes as its argument a textual integer literal and
-if necessary ``marks'' the literal as having a 64-bit integer type.
-For example, the GNU C Compiler (`gcc') requires that 64-bit literals be
-appended with the letters `LL' standing for `long long', which is `gcc's
-name for the 64-bit integer type. Some compilers may allow `LIT64' to be
-defined as the identity macro: `#define LIT64( a ) a'.
--------------------------------------------------------------------------------
-*/
-#define LIT64( a ) a##LL
-#endif
-
-/*
--------------------------------------------------------------------------------
-The macro `INLINE' can be used before functions that should be inlined. If
-a compiler does not support explicit inlining, this macro should be defined
-to be `static'.
--------------------------------------------------------------------------------
-*/
-#define INLINE static __inline
-
-/*
--------------------------------------------------------------------------------
-The ARM FPA is odd in that it stores doubles high-order word first, no matter
-what the endianness of the CPU. VFP is sane.
--------------------------------------------------------------------------------
-*/
-#if defined(SOFTFLOAT_FOR_GCC)
-#define FLOAT64_DEMANGLE(a) (a)
-#define FLOAT64_MANGLE(a) (a)
-#endif
diff --git a/lib/libc/powerpcspe/softfloat/softfloat.h b/lib/libc/powerpcspe/softfloat/softfloat.h
deleted file mode 100644
index b20cb3e7aa00..000000000000
--- a/lib/libc/powerpcspe/softfloat/softfloat.h
+++ /dev/null
@@ -1,306 +0,0 @@
-/* $NetBSD: softfloat.h,v 1.6 2002/05/12 13:12:46 bjh21 Exp $ */
-
-/* This is a derivative work. */
-
-/*
-===============================================================================
-
-This C header file is part of the SoftFloat IEC/IEEE Floating-point
-Arithmetic Package, Release 2a.
-
-Written by John R. Hauser. This work was made possible in part by the
-International Computer Science Institute, located at Suite 600, 1947 Center
-Street, Berkeley, California 94704. Funding was partially provided by the
-National Science Foundation under grant MIP-9311980. The original version
-of this code was written as part of a project to build a fixed-point vector
-processor in collaboration with the University of California at Berkeley,
-overseen by Profs. Nelson Morgan and John Wawrzynek. More information
-is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/
-arithmetic/SoftFloat.html'.
-
-THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort
-has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
-TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO
-PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
-AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
-
-Derivative works are acceptable, even for commercial purposes, so long as
-(1) they include prominent notice that the work is derivative, and (2) they
-include prominent notice akin to these four paragraphs for those parts of
-this code that are retained.
-
-===============================================================================
-*/
-
-/*
--------------------------------------------------------------------------------
-The macro `FLOATX80' must be defined to enable the extended double-precision
-floating-point format `floatx80'. If this macro is not defined, the
-`floatx80' type will not be defined, and none of the functions that either
-input or output the `floatx80' type will be defined. The same applies to
-the `FLOAT128' macro and the quadruple-precision format `float128'.
--------------------------------------------------------------------------------
-*/
-/* #define FLOATX80 */
-/* #define FLOAT128 */
-
-#include <machine/ieeefp.h>
-
-/*
--------------------------------------------------------------------------------
-Software IEC/IEEE floating-point types.
--------------------------------------------------------------------------------
-*/
-typedef unsigned int float32;
-typedef unsigned long long float64;
-#ifdef FLOATX80
-typedef struct {
- unsigned short high;
- unsigned long long low;
-} floatx80;
-#endif
-#ifdef FLOAT128
-typedef struct {
- unsigned long long high, low;
-} float128;
-#endif
-
-/*
--------------------------------------------------------------------------------
-Software IEC/IEEE floating-point underflow tininess-detection mode.
--------------------------------------------------------------------------------
-*/
-#ifndef SOFTFLOAT_FOR_GCC
-extern int8 float_detect_tininess;
-#endif
-enum {
- float_tininess_after_rounding = 0,
- float_tininess_before_rounding = 1
-};
-
-/*
--------------------------------------------------------------------------------
-Software IEC/IEEE floating-point rounding mode.
--------------------------------------------------------------------------------
-*/
-extern fp_rnd_t float_rounding_mode;
-enum {
- float_round_nearest_even = FP_RN,
- float_round_to_zero = FP_RZ,
- float_round_down = FP_RM,
- float_round_up = FP_RP
-};
-
-/*
--------------------------------------------------------------------------------
-Software IEC/IEEE floating-point exception flags.
--------------------------------------------------------------------------------
-*/
-typedef fp_except_t fp_except;
-
-extern fp_except float_exception_flags;
-extern fp_except float_exception_mask;
-enum {
- float_flag_inexact = FP_X_IMP,
- float_flag_underflow = FP_X_UFL,
- float_flag_overflow = FP_X_OFL,
- float_flag_divbyzero = FP_X_DZ,
- float_flag_invalid = FP_X_INV
-};
-
-/*
--------------------------------------------------------------------------------
-Routine to raise any or all of the software IEC/IEEE floating-point
-exception flags.
--------------------------------------------------------------------------------
-*/
-void float_raise( fp_except );
-
-/*
--------------------------------------------------------------------------------
-Software IEC/IEEE integer-to-floating-point conversion routines.
--------------------------------------------------------------------------------
-*/
-float32 int32_to_float32( int );
-float64 int32_to_float64( int );
-#ifdef FLOATX80
-floatx80 int32_to_floatx80( int );
-#endif
-#ifdef FLOAT128
-float128 int32_to_float128( int );
-#endif
-float32 int64_to_float32( long long );
-float64 int64_to_float64( long long );
-#ifdef FLOATX80
-floatx80 int64_to_floatx80( long long );
-#endif
-#ifdef FLOAT128
-float128 int64_to_float128( long long );
-#endif
-
-/*
--------------------------------------------------------------------------------
-Software IEC/IEEE single-precision conversion routines.
--------------------------------------------------------------------------------
-*/
-int float32_to_int32( float32 );
-int float32_to_int32_round_to_zero( float32 );
-unsigned int float32_to_uint32_round_to_zero( float32 );
-long long float32_to_int64( float32 );
-long long float32_to_int64_round_to_zero( float32 );
-float64 float32_to_float64( float32 );
-#ifdef FLOATX80
-floatx80 float32_to_floatx80( float32 );
-#endif
-#ifdef FLOAT128
-float128 float32_to_float128( float32 );
-#endif
-
-/*
--------------------------------------------------------------------------------
-Software IEC/IEEE single-precision operations.
--------------------------------------------------------------------------------
-*/
-float32 float32_round_to_int( float32 );
-float32 float32_add( float32, float32 );
-float32 float32_sub( float32, float32 );
-float32 float32_mul( float32, float32 );
-float32 float32_div( float32, float32 );
-float32 float32_rem( float32, float32 );
-float32 float32_sqrt( float32 );
-int float32_eq( float32, float32 );
-int float32_le( float32, float32 );
-int float32_lt( float32, float32 );
-int float32_eq_signaling( float32, float32 );
-int float32_le_quiet( float32, float32 );
-int float32_lt_quiet( float32, float32 );
-#ifndef SOFTFLOAT_FOR_GCC
-int float32_is_signaling_nan( float32 );
-#endif
-
-/*
--------------------------------------------------------------------------------
-Software IEC/IEEE double-precision conversion routines.
--------------------------------------------------------------------------------
-*/
-int float64_to_int32( float64 );
-int float64_to_int32_round_to_zero( float64 );
-unsigned int float64_to_uint32_round_to_zero( float64 );
-long long float64_to_int64( float64 );
-long long float64_to_int64_round_to_zero( float64 );
-float32 float64_to_float32( float64 );
-#ifdef FLOATX80
-floatx80 float64_to_floatx80( float64 );
-#endif
-#ifdef FLOAT128
-float128 float64_to_float128( float64 );
-#endif
-
-/*
--------------------------------------------------------------------------------
-Software IEC/IEEE double-precision operations.
--------------------------------------------------------------------------------
-*/
-float64 float64_round_to_int( float64 );
-float64 float64_add( float64, float64 );
-float64 float64_sub( float64, float64 );
-float64 float64_mul( float64, float64 );
-float64 float64_div( float64, float64 );
-float64 float64_rem( float64, float64 );
-float64 float64_sqrt( float64 );
-int float64_eq( float64, float64 );
-int float64_le( float64, float64 );
-int float64_lt( float64, float64 );
-int float64_eq_signaling( float64, float64 );
-int float64_le_quiet( float64, float64 );
-int float64_lt_quiet( float64, float64 );
-#ifndef SOFTFLOAT_FOR_GCC
-int float64_is_signaling_nan( float64 );
-#endif
-
-#ifdef FLOATX80
-
-/*
--------------------------------------------------------------------------------
-Software IEC/IEEE extended double-precision conversion routines.
--------------------------------------------------------------------------------
-*/
-int floatx80_to_int32( floatx80 );
-int floatx80_to_int32_round_to_zero( floatx80 );
-long long floatx80_to_int64( floatx80 );
-long long floatx80_to_int64_round_to_zero( floatx80 );
-float32 floatx80_to_float32( floatx80 );
-float64 floatx80_to_float64( floatx80 );
-#ifdef FLOAT128
-float128 floatx80_to_float128( floatx80 );
-#endif
-
-/*
--------------------------------------------------------------------------------
-Software IEC/IEEE extended double-precision rounding precision. Valid
-values are 32, 64, and 80.
--------------------------------------------------------------------------------
-*/
-extern int floatx80_rounding_precision;
-
-/*
--------------------------------------------------------------------------------
-Software IEC/IEEE extended double-precision operations.
--------------------------------------------------------------------------------
-*/
-floatx80 floatx80_round_to_int( floatx80 );
-floatx80 floatx80_add( floatx80, floatx80 );
-floatx80 floatx80_sub( floatx80, floatx80 );
-floatx80 floatx80_mul( floatx80, floatx80 );
-floatx80 floatx80_div( floatx80, floatx80 );
-floatx80 floatx80_rem( floatx80, floatx80 );
-floatx80 floatx80_sqrt( floatx80 );
-int floatx80_eq( floatx80, floatx80 );
-int floatx80_le( floatx80, floatx80 );
-int floatx80_lt( floatx80, floatx80 );
-int floatx80_eq_signaling( floatx80, floatx80 );
-int floatx80_le_quiet( floatx80, floatx80 );
-int floatx80_lt_quiet( floatx80, floatx80 );
-int floatx80_is_signaling_nan( floatx80 );
-
-#endif
-
-#ifdef FLOAT128
-
-/*
--------------------------------------------------------------------------------
-Software IEC/IEEE quadruple-precision conversion routines.
--------------------------------------------------------------------------------
-*/
-int float128_to_int32( float128 );
-int float128_to_int32_round_to_zero( float128 );
-long long float128_to_int64( float128 );
-long long float128_to_int64_round_to_zero( float128 );
-float32 float128_to_float32( float128 );
-float64 float128_to_float64( float128 );
-#ifdef FLOATX80
-floatx80 float128_to_floatx80( float128 );
-#endif
-
-/*
--------------------------------------------------------------------------------
-Software IEC/IEEE quadruple-precision operations.
--------------------------------------------------------------------------------
-*/
-float128 float128_round_to_int( float128 );
-float128 float128_add( float128, float128 );
-float128 float128_sub( float128, float128 );
-float128 float128_mul( float128, float128 );
-float128 float128_div( float128, float128 );
-float128 float128_rem( float128, float128 );
-float128 float128_sqrt( float128 );
-int float128_eq( float128, float128 );
-int float128_le( float128, float128 );
-int float128_lt( float128, float128 );
-int float128_eq_signaling( float128, float128 );
-int float128_le_quiet( float128, float128 );
-int float128_lt_quiet( float128, float128 );
-int float128_is_signaling_nan( float128 );
-
-#endif
-
diff --git a/lib/libc/resolv/res_init.c b/lib/libc/resolv/res_init.c
index 5a2fce013c8c..b21a3fa1670f 100644
--- a/lib/libc/resolv/res_init.c
+++ b/lib/libc/resolv/res_init.c
@@ -118,21 +118,12 @@ static u_int32_t net_mask(struct in_addr);
/*%
* Set up default settings. If the configuration file exist, the values
* there will have precedence. Otherwise, the server address is set to
- * INADDR_ANY and the default domain name comes from the gethostname().
- *
- * An interim version of this code (BIND 4.9, pre-4.4BSD) used 127.0.0.1
- * rather than INADDR_ANY ("0.0.0.0") as the default name server address
- * since it was noted that INADDR_ANY actually meant ``the first interface
- * you "ifconfig"'d at boot time'' and if this was a SLIP or PPP interface,
- * it had to be "up" in order for you to reach your own name server. It
- * was later decided that since the recommended practice is to always
- * install local static routes through 127.0.0.1 for all your network
- * interfaces, that we could solve this problem without a code change.
+ * the loopback address the default domain name comes from gethostname().
*
* The configuration file should always be used, since it is the only way
- * to specify a default domain. If you are running a server on your local
- * machine, you should say "nameserver 0.0.0.0" or "nameserver 127.0.0.1"
- * in the configuration file.
+ * to specify options and a default domain. If you are running a server
+ * on your local machine, you should say "nameserver 127.0.0.1" or
+ * "nameserver ::1" in the configuration file.
*
* Return 0 if completes successfully, -1 on error
*/
@@ -146,6 +137,26 @@ res_ninit(res_state statp) {
/*% This function has to be reachable by res_data.c but not publicly. */
int
__res_vinit(res_state statp, int preinit) {
+ union res_sockaddr_union u[] = {
+ { .sin = {
+ .sin_family = AF_INET,
+#ifdef HAVE_SA_LEN
+ .sin_len = sizeof(struct sockaddr_in),
+#endif
+ .sin_port = htons(NAMESERVER_PORT),
+ .sin_addr = { htonl(INADDR_LOOPBACK) },
+ } },
+#ifdef HAS_INET6_STRUCTS
+ { .sin6 = {
+ .sin6_family = AF_INET6,
+#ifdef HAVE_SA_LEN
+ .sin6_len = sizeof(struct sockaddr_in6),
+#endif
+ .sin6_port = htons(NAMESERVER_PORT),
+ .sin6_addr = IN6ADDR_LOOPBACK_INIT,
+ } },
+#endif
+ };
FILE *fp;
char *cp, **pp;
int n;
@@ -158,7 +169,6 @@ __res_vinit(res_state statp, int preinit) {
char *net;
#endif
int dots;
- union res_sockaddr_union u[2];
int maxns = MAXNS;
RES_SET_H_ERRNO(statp, 0);
@@ -173,23 +183,6 @@ __res_vinit(res_state statp, int preinit) {
statp->id = res_nrandomid(statp);
- memset(u, 0, sizeof(u));
- u[nserv].sin.sin_addr.s_addr = INADDR_ANY;
- u[nserv].sin.sin_family = AF_INET;
- u[nserv].sin.sin_port = htons(NAMESERVER_PORT);
-#ifdef HAVE_SA_LEN
- u[nserv].sin.sin_len = sizeof(struct sockaddr_in);
-#endif
- nserv++;
-#ifdef HAS_INET6_STRUCTS
- u[nserv].sin6.sin6_addr = in6addr_any;
- u[nserv].sin6.sin6_family = AF_INET6;
- u[nserv].sin6.sin6_port = htons(NAMESERVER_PORT);
-#ifdef HAVE_SA_LEN
- u[nserv].sin6.sin6_len = sizeof(struct sockaddr_in6);
-#endif
- nserv++;
-#endif
statp->nscount = 0;
statp->ndots = 1;
statp->pfcode = 0;
@@ -224,7 +217,7 @@ __res_vinit(res_state statp, int preinit) {
#ifdef RESOLVSORT
statp->nsort = 0;
#endif
- res_setservers(statp, u, nserv);
+ res_setservers(statp, u, nitems(u));
#ifdef SOLARIS2
/*
@@ -288,7 +281,6 @@ __res_vinit(res_state statp, int preinit) {
(line[sizeof(name) - 1] == ' ' || \
line[sizeof(name) - 1] == '\t'))
- nserv = 0;
if ((fp = fopen(_PATH_RESCONF, "re")) != NULL) {
struct stat sb;
struct timespec now;
@@ -507,15 +499,8 @@ __res_vinit(res_state statp, int preinit) {
#endif
(void) fclose(fp);
}
-/*
- * Last chance to get a nameserver. This should not normally
- * be necessary
- */
-#ifdef NO_RESOLV_CONF
- if(nserv == 0)
- nserv = get_nameservers(statp);
-#endif
+ /* guess default domain if not set */
if (statp->defdname[0] == 0 &&
gethostname(buf, sizeof(statp->defdname) - 1) == 0 &&
(cp = strchr(buf, '.')) != NULL)
diff --git a/lib/libc/riscv/gen/makecontext.c b/lib/libc/riscv/gen/makecontext.c
index e5371d082b2c..8a6498167f13 100644
--- a/lib/libc/riscv/gen/makecontext.c
+++ b/lib/libc/riscv/gen/makecontext.c
@@ -80,7 +80,8 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...)
va_end(ap);
/* Set the stack */
- gp->gp_sp = STACKALIGN(ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size);
+ gp->gp_sp = STACKALIGN((uintptr_t)ucp->uc_stack.ss_sp +
+ ucp->uc_stack.ss_size);
/* Arrange for return via the trampoline code. */
gp->gp_sepc = (__register_t)_ctx_start;
gp->gp_s[0] = (__register_t)func;
diff --git a/lib/libc/rpc/rpc.3 b/lib/libc/rpc/rpc.3
index 12d19df117ad..7ae3ec5c5aeb 100644
--- a/lib/libc/rpc/rpc.3
+++ b/lib/libc/rpc/rpc.3
@@ -254,9 +254,9 @@ enum xdr_op {
* structure of the data type to be decoded. If this points to 0,
* then the type routines should allocate dynamic storage of the
* appropriate size and return it.
- * bool_t (*xdrproc_t)(XDR *, caddr_t *);
+ * bool_t (*xdrproc_t)(XDR *, void *);
*/
-typedef bool_t (*xdrproc_t)();
+typedef bool_t (*xdrproc_t)(XDR *, void *);
/*
* The XDR handle.
diff --git a/lib/libc/rpc/rpc_soc.c b/lib/libc/rpc/rpc_soc.c
index c63b89594ce6..24a19624d366 100644
--- a/lib/libc/rpc/rpc_soc.c
+++ b/lib/libc/rpc/rpc_soc.c
@@ -72,7 +72,8 @@
static CLIENT *clnt_com_create(struct sockaddr_in *, rpcprog_t, rpcvers_t,
int *, u_int, u_int, char *);
static SVCXPRT *svc_com_create(int, u_int, u_int, char *);
-static bool_t rpc_wrap_bcast(char *, struct netbuf *, struct netconfig *);
+static bool_t rpc_wrap_bcast(char *, const struct netbuf *,
+ const struct netconfig *);
/* XXX */
#define IN4_LOCALHOST_STRING "127.0.0.1"
@@ -307,19 +308,10 @@ registerrpc(int prognum, int versnum, int procnum,
}
/*
- * All the following clnt_broadcast stuff is convulated; it supports
- * the earlier calling style of the callback function
+ * Support the earlier calling style of the callback function with a
+ * per-thread temporary copy of the real callback.
*/
-static thread_key_t clnt_broadcast_key;
-static resultproc_t clnt_broadcast_result_main;
-static once_t clnt_broadcast_once = ONCE_INITIALIZER;
-
-static void
-clnt_broadcast_key_init(void)
-{
-
- thr_keycreate(&clnt_broadcast_key, free);
-}
+static _Thread_local clnt_broadcast_resultproc_t clnt_broadcast_result;
/*
* Need to translate the netbuf address into sockaddr_in address.
@@ -327,21 +319,16 @@ clnt_broadcast_key_init(void)
*/
/* ARGSUSED */
static bool_t
-rpc_wrap_bcast(char *resultp, struct netbuf *addr, struct netconfig *nconf)
+rpc_wrap_bcast(char *resultp, const struct netbuf *addr,
+ const struct netconfig *nconf)
/*
* char *resultp; // results of the call
* struct netbuf *addr; // address of the guy who responded
* struct netconfig *nconf; // Netconf of the transport
*/
{
- resultproc_t clnt_broadcast_result;
-
if (strcmp(nconf->nc_netid, "udp"))
return (FALSE);
- if (thr_main())
- clnt_broadcast_result = clnt_broadcast_result_main;
- else
- clnt_broadcast_result = (resultproc_t)thr_getspecific(clnt_broadcast_key);
return (*clnt_broadcast_result)(resultp,
(struct sockaddr_in *)addr->buf);
}
@@ -351,7 +338,8 @@ rpc_wrap_bcast(char *resultp, struct netbuf *addr, struct netconfig *nconf)
*/
enum clnt_stat
clnt_broadcast(u_long prog, u_long vers, u_long proc, xdrproc_t xargs,
- void *argsp, xdrproc_t xresults, void *resultsp, resultproc_t eachresult)
+ void *argsp, xdrproc_t xresults, void *resultsp,
+ clnt_broadcast_resultproc_t eachresult)
/*
* u_long prog; // program number
* u_long vers; // version number
@@ -363,16 +351,16 @@ clnt_broadcast(u_long prog, u_long vers, u_long proc, xdrproc_t xargs,
* resultproc_t eachresult; // call with each result obtained
*/
{
+ enum clnt_stat ret;
- if (thr_main())
- clnt_broadcast_result_main = eachresult;
- else {
- thr_once(&clnt_broadcast_once, clnt_broadcast_key_init);
- thr_setspecific(clnt_broadcast_key, (void *) eachresult);
- }
- return rpc_broadcast((rpcprog_t)prog, (rpcvers_t)vers,
+ clnt_broadcast_result = eachresult;
+
+ ret = rpc_broadcast((rpcprog_t)prog, (rpcvers_t)vers,
(rpcproc_t)proc, xargs, argsp, xresults, resultsp,
- (resultproc_t) rpc_wrap_bcast, "udp");
+ rpc_wrap_bcast, "udp");
+
+ clnt_broadcast_result = NULL;
+ return (ret);
}
/*
diff --git a/lib/libc/stdio/printf-pos.c b/lib/libc/stdio/printf-pos.c
index edbd4e379699..4fa99316321c 100644
--- a/lib/libc/stdio/printf-pos.c
+++ b/lib/libc/stdio/printf-pos.c
@@ -311,11 +311,9 @@ reswitch: switch (ch) {
goto rflag;
}
goto reswitch;
-#ifndef NO_FLOATING_POINT
case 'L':
flags |= LONGDBL;
goto rflag;
-#endif
case 'h':
if (flags & SHORTINT) {
flags &= ~SHORTINT;
@@ -359,7 +357,6 @@ reswitch: switch (ch) {
if ((error = addsarg(&types, flags)))
goto error;
break;
-#ifndef NO_FLOATING_POINT
case 'a':
case 'A':
case 'e':
@@ -372,7 +369,6 @@ reswitch: switch (ch) {
if (error)
goto error;
break;
-#endif /* !NO_FLOATING_POINT */
case 'n':
if (flags & INTMAXT)
error = addtype(&types, TP_INTMAXT);
@@ -504,11 +500,9 @@ reswitch: switch (ch) {
goto rflag;
}
goto reswitch;
-#ifndef NO_FLOATING_POINT
case 'L':
flags |= LONGDBL;
goto rflag;
-#endif
case 'h':
if (flags & SHORTINT) {
flags &= ~SHORTINT;
@@ -552,7 +546,6 @@ reswitch: switch (ch) {
if ((error = addsarg(&types, flags)))
goto error;
break;
-#ifndef NO_FLOATING_POINT
case 'a':
case 'A':
case 'e':
@@ -565,7 +558,6 @@ reswitch: switch (ch) {
if (error)
goto error;
break;
-#endif /* !NO_FLOATING_POINT */
case 'n':
if (flags & INTMAXT)
error = addtype(&types, TP_INTMAXT);
@@ -744,14 +736,10 @@ build_arg_table(struct typetable *types, va_list ap, union arg **argtable)
(*argtable) [n].pintmaxarg = va_arg (ap, intmax_t *);
break;
case T_DOUBLE:
-#ifndef NO_FLOATING_POINT
(*argtable) [n].doublearg = va_arg (ap, double);
-#endif
break;
case T_LONG_DOUBLE:
-#ifndef NO_FLOATING_POINT
(*argtable) [n].longdoublearg = va_arg (ap, long double);
-#endif
break;
case TP_CHAR:
(*argtable) [n].pchararg = va_arg (ap, char *);
diff --git a/lib/libc/stdio/printfcommon.h b/lib/libc/stdio/printfcommon.h
index 411b778dc234..9de2783c4804 100644
--- a/lib/libc/stdio/printfcommon.h
+++ b/lib/libc/stdio/printfcommon.h
@@ -43,7 +43,6 @@
*/
-#ifndef NO_FLOATING_POINT
#define dtoa __dtoa
#define freedtoa __freedtoa
@@ -57,7 +56,6 @@
static int exponent(CHAR *, int, CHAR);
-#endif /* !NO_FLOATING_POINT */
static CHAR *__ujtoa(uintmax_t, CHAR *, int, int, const char *);
static CHAR *__ultoa(u_long, CHAR *, int, int, const char *);
@@ -280,7 +278,6 @@ __ujtoa(uintmax_t val, CHAR *endp, int base, int octzero, const char *xdigs)
return (cp);
}
-#ifndef NO_FLOATING_POINT
static int
exponent(CHAR *p0, int exp, CHAR fmtch)
@@ -318,4 +315,3 @@ exponent(CHAR *p0, int exp, CHAR fmtch)
return (p - p0);
}
-#endif /* !NO_FLOATING_POINT */
diff --git a/lib/libc/stdio/printflocal.h b/lib/libc/stdio/printflocal.h
index f3d0d3e9e216..f3bedcda6678 100644
--- a/lib/libc/stdio/printflocal.h
+++ b/lib/libc/stdio/printflocal.h
@@ -82,10 +82,8 @@ union arg {
ptrdiff_t *pptrdiffarg;
ssize_t *pssizearg;
intmax_t *pintmaxarg;
-#ifndef NO_FLOATING_POINT
double doublearg;
long double longdoublearg;
-#endif
wint_t wintarg;
wchar_t *pwchararg;
};
diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
index 2dc8d9022179..a4633ce7837f 100644
--- a/lib/libc/stdio/vfprintf.c
+++ b/lib/libc/stdio/vfprintf.c
@@ -314,7 +314,6 @@ __vfprintf(FILE *fp, locale_t locale, int serrno, const char *fmt0, va_list ap)
char sign; /* sign prefix (' ', '+', '-', or \0) */
struct grouping_state gs; /* thousands' grouping info */
-#ifndef NO_FLOATING_POINT
/*
* We can decompose the printed representation of floating
* point numbers into several parts, some of which may be empty:
@@ -343,7 +342,6 @@ __vfprintf(FILE *fp, locale_t locale, int serrno, const char *fmt0, va_list ap)
int ndig; /* actual number of digits returned by dtoa */
char expstr[MAXEXPDIG+2]; /* buffer for exponent string: e+ZZZ */
char *dtoaresult; /* buffer allocated by dtoa */
-#endif
u_long ulval; /* integer arguments %[diouxX] */
uintmax_t ujval; /* %j, %ll, %q, %t, %z integers */
int base; /* base for [diouxX] conversion */
@@ -465,12 +463,10 @@ __vfprintf(FILE *fp, locale_t locale, int serrno, const char *fmt0, va_list ap)
va_copy(orgap, ap);
io_init(&io, fp);
ret = 0;
-#ifndef NO_FLOATING_POINT
dtoaresult = NULL;
decimal_point = localeconv_l(locale)->decimal_point;
/* The overwhelmingly common case is decpt_len == 1. */
decpt_len = (decimal_point[1] == '\0' ? 1 : strlen(decimal_point));
-#endif
/*
* Scan the format for conversions (`%' character).
@@ -574,11 +570,9 @@ reswitch: switch (ch) {
}
width = n;
goto reswitch;
-#ifndef NO_FLOATING_POINT
case 'L':
flags |= LONGDBL;
goto rflag;
-#endif
case 'h':
if (flags & SHORTINT) {
flags &= ~SHORTINT;
@@ -704,7 +698,6 @@ reswitch: switch (ch) {
}
base = 10;
goto number;
-#ifndef NO_FLOATING_POINT
case 'a':
case 'A':
if (ch == 'a') {
@@ -823,7 +816,6 @@ fp_common:
size += grouping_init(&gs, expt, locale);
}
break;
-#endif /* !NO_FLOATING_POINT */
case 'm':
error = __strerror_rl(serrno, errnomsg,
sizeof(errnomsg), locale);
@@ -1023,9 +1015,7 @@ invalid:
PAD(width - realsz, zeroes);
/* the string or number proper */
-#ifndef NO_FLOATING_POINT
if ((flags & FPT) == 0) {
-#endif
/* leading zeroes from decimal precision */
PAD(dprec - size, zeroes);
if (gs.grouping) {
@@ -1034,7 +1024,6 @@ invalid:
} else {
PRINT(cp, size);
}
-#ifndef NO_FLOATING_POINT
} else { /* glue together f_p fragments */
if (!expchar) { /* %[fF] or sufficiently short %[gG] */
if (expt <= 0) {
@@ -1071,7 +1060,6 @@ invalid:
PRINT(expstr, expsize);
}
}
-#endif
/* left-adjusting padding (always blank) */
if (flags & LADJUST)
PAD(width - realsz, blanks);
@@ -1085,10 +1073,8 @@ done:
FLUSH();
error:
va_end(orgap);
-#ifndef NO_FLOATING_POINT
if (dtoaresult != NULL)
freedtoa(dtoaresult);
-#endif
if (convbuf != NULL)
free(convbuf);
if (__sferror(fp))
diff --git a/lib/libc/stdio/vfscanf.c b/lib/libc/stdio/vfscanf.c
index 89e9e843969f..576fe7d80485 100644
--- a/lib/libc/stdio/vfscanf.c
+++ b/lib/libc/stdio/vfscanf.c
@@ -56,9 +56,7 @@
#include "local.h"
#include "xlocale_private.h"
-#ifndef NO_FLOATING_POINT
#include <locale.h>
-#endif
#define BUF 513 /* Maximum length of numeric string. */
@@ -89,9 +87,7 @@
#define CT_FLOAT 4 /* %[efgEFG] conversion */
static const u_char *__sccl(char *, const u_char *);
-#ifndef NO_FLOATING_POINT
static int parsefloat(FILE *, char *, char *, locale_t);
-#endif
__weak_reference(__vfscanf, vfscanf);
@@ -648,12 +644,10 @@ literal:
base = 16;
break;
-#ifndef NO_FLOATING_POINT
case 'A': case 'E': case 'F': case 'G':
case 'a': case 'e': case 'f': case 'g':
c = CT_FLOAT;
break;
-#endif
case 'S':
flags |= LONG;
@@ -835,7 +829,6 @@ literal:
}
break;
-#ifndef NO_FLOATING_POINT
case CT_FLOAT:
/* scan a floating point number as if by strtod */
if (width == 0 || width > sizeof(buf) - 1)
@@ -858,7 +851,6 @@ literal:
}
}
break;
-#endif /* !NO_FLOATING_POINT */
}
if (!(flags & SUPPRESS))
nassigned++;
@@ -984,7 +976,6 @@ doswitch:
/* NOTREACHED */
}
-#ifndef NO_FLOATING_POINT
static int
parsefloat(FILE *fp, char *buf, char *end, locale_t locale)
{
@@ -1153,4 +1144,3 @@ parsedone:
*++commit = '\0';
return (commit - buf);
}
-#endif
diff --git a/lib/libc/stdio/vfwprintf.c b/lib/libc/stdio/vfwprintf.c
index 0d77bd74567e..f5324915ec3e 100644
--- a/lib/libc/stdio/vfwprintf.c
+++ b/lib/libc/stdio/vfwprintf.c
@@ -389,7 +389,6 @@ __vfwprintf(FILE *fp, locale_t locale, const wchar_t *fmt0, va_list ap)
int prec; /* precision from format; <0 for N/A */
wchar_t sign; /* sign prefix (' ', '+', '-', or \0) */
struct grouping_state gs; /* thousands' grouping info */
-#ifndef NO_FLOATING_POINT
/*
* We can decompose the printed representation of floating
* point numbers into several parts, some of which may be empty:
@@ -417,7 +416,6 @@ __vfwprintf(FILE *fp, locale_t locale, const wchar_t *fmt0, va_list ap)
int ndig; /* actual number of digits returned by dtoa */
wchar_t expstr[MAXEXPDIG+2]; /* buffer for exponent string: e+ZZZ */
char *dtoaresult; /* buffer allocated by dtoa */
-#endif
u_long ulval; /* integer arguments %[diouxX] */
uintmax_t ujval; /* %j, %ll, %q, %t, %z integers */
int base; /* base for [diouxX] conversion */
@@ -537,9 +535,7 @@ __vfwprintf(FILE *fp, locale_t locale, const wchar_t *fmt0, va_list ap)
va_copy(orgap, ap);
io_init(&io, fp);
ret = 0;
-#ifndef NO_FLOATING_POINT
decimal_point = get_decpt(locale);
-#endif
/*
* Scan the format for conversions (`%' character).
@@ -643,11 +639,9 @@ reswitch: switch (ch) {
}
width = n;
goto reswitch;
-#ifndef NO_FLOATING_POINT
case 'L':
flags |= LONGDBL;
goto rflag;
-#endif
case 'h':
if (flags & SHORTINT) {
flags &= ~SHORTINT;
@@ -761,7 +755,6 @@ reswitch: switch (ch) {
}
base = 10;
goto number;
-#ifndef NO_FLOATING_POINT
case 'a':
case 'A':
if (ch == 'a') {
@@ -885,7 +878,6 @@ fp_common:
size += grouping_init(&gs, expt, locale);
}
break;
-#endif /* !NO_FLOATING_POINT */
case 'n':
/*
* Assignment-like behavior is specified if the
@@ -1080,9 +1072,7 @@ invalid:
PAD(width - realsz, zeroes);
/* the string or number proper */
-#ifndef NO_FLOATING_POINT
if ((flags & FPT) == 0) {
-#endif
/* leading zeroes from decimal precision */
PAD(dprec - size, zeroes);
if (gs.grouping) {
@@ -1091,7 +1081,6 @@ invalid:
} else {
PRINT(cp, size);
}
-#ifndef NO_FLOATING_POINT
} else { /* glue together f_p fragments */
if (!expchar) { /* %[fF] or sufficiently short %[gG] */
if (expt <= 0) {
@@ -1129,7 +1118,6 @@ invalid:
PRINT(expstr, expsize);
}
}
-#endif
/* left-adjusting padding (always blank) */
if (flags & LADJUST)
PAD(width - realsz, blanks);
diff --git a/lib/libc/stdio/vfwscanf.c b/lib/libc/stdio/vfwscanf.c
index 7ca64eb37811..dbe7c6c48c98 100644
--- a/lib/libc/stdio/vfwscanf.c
+++ b/lib/libc/stdio/vfwscanf.c
@@ -84,9 +84,7 @@
#define CT_INT 3 /* %[dioupxX] conversion */
#define CT_FLOAT 4 /* %[efgEFG] conversion */
-#ifndef NO_FLOATING_POINT
static int parsefloat(FILE *, wchar_t *, wchar_t *, locale_t);
-#endif
struct ccl {
const wchar_t *start; /* character class start */
@@ -630,12 +628,10 @@ literal:
base = 16;
break;
-#ifndef NO_FLOATING_POINT
case 'A': case 'E': case 'F': case 'G':
case 'a': case 'e': case 'f': case 'g':
c = CT_FLOAT;
break;
-#endif
case 'S':
flags |= LONG;
@@ -813,7 +809,6 @@ literal:
}
break;
-#ifndef NO_FLOATING_POINT
case CT_FLOAT:
/* scan a floating point number as if by strtod */
if (width == 0 || width > sizeof(buf) /
@@ -835,7 +830,6 @@ literal:
}
}
break;
-#endif /* !NO_FLOATING_POINT */
}
if (!(flags & SUPPRESS))
nassigned++;
@@ -848,7 +842,6 @@ match_failure:
return (nassigned);
}
-#ifndef NO_FLOATING_POINT
static int
parsefloat(FILE *fp, wchar_t *buf, wchar_t *end, locale_t locale)
{
@@ -1007,4 +1000,3 @@ parsedone:
*++commit = '\0';
return (commit - buf);
}
-#endif
diff --git a/lib/libc/stdio/xprintf.c b/lib/libc/stdio/xprintf.c
index a5671db67f58..4af0425792b0 100644
--- a/lib/libc/stdio/xprintf.c
+++ b/lib/libc/stdio/xprintf.c
@@ -60,10 +60,8 @@ union arg {
int intarg;
long longarg;
intmax_t intmaxarg;
-#ifndef NO_FLOATING_POINT
double doublearg;
long double longdoublearg;
-#endif
wint_t wintarg;
char *pchararg;
wchar_t *pwchararg;
@@ -497,14 +495,10 @@ __v2printf(FILE *fp, const char *fmt0, unsigned pct, va_list ap)
args[ch].pwchararg = va_arg (ap, wchar_t *);
break;
case PA_DOUBLE:
-#ifndef NO_FLOATING_POINT
args[ch].doublearg = va_arg (ap, double);
-#endif
break;
case PA_DOUBLE | PA_FLAG_LONG_DOUBLE:
-#ifndef NO_FLOATING_POINT
args[ch].longdoublearg = va_arg (ap, long double);
-#endif
break;
default:
errx(1, "argtype = %x (fmt = \"%s\")\n",
diff --git a/lib/libc/stdlib/Makefile.inc b/lib/libc/stdlib/Makefile.inc
index b878a7625e9f..c2107fdaeaae 100644
--- a/lib/libc/stdlib/Makefile.inc
+++ b/lib/libc/stdlib/Makefile.inc
@@ -1,19 +1,76 @@
# machine-independent stdlib sources
.PATH: ${LIBC_SRCTOP}/${LIBC_ARCH}/stdlib ${LIBC_SRCTOP}/stdlib
-MISRCS+=C99_Exit.c a64l.c abort.c abs.c atexit.c atof.c atoi.c atol.c atoll.c \
- bsearch.c bsearch_b.c \
- cxa_thread_atexit.c cxa_thread_atexit_impl.c \
- div.c exit.c getenv.c getopt.c getopt_long.c \
- getsubopt.c hcreate.c hcreate_r.c hdestroy_r.c heapsort.c heapsort_b.c \
- hsearch_r.c imaxabs.c imaxdiv.c \
- insque.c l64a.c labs.c ldiv.c llabs.c lldiv.c lsearch.c memalignment.c \
- merge.c mergesort_b.c ptsname.c qsort.c qsort_r.c qsort_r_compat.c \
- qsort_s.c quick_exit.c radixsort.c rand.c \
- random.c reallocarray.c reallocf.c realpath.c recallocarray.c remque.c \
- set_constraint_handler_s.c strfmon.c strtoimax.c \
- strtol.c strtold.c strtoll.c strtoq.c strtoul.c strtonum.c strtoull.c \
- strtoumax.c strtouq.c system.c tdelete.c tfind.c tsearch.c twalk.c
+MISRCS+= \
+ C99_Exit.c \
+ a64l.c \
+ abort.c \
+ abs.c \
+ atexit.c \
+ atof.c \
+ atoi.c \
+ atol.c \
+ atoll.c \
+ bsearch.c \
+ bsearch_b.c \
+ cxa_thread_atexit.c \
+ cxa_thread_atexit_impl.c \
+ div.c \
+ exit.c \
+ getenv.c \
+ getopt.c \
+ getopt_long.c \
+ getsubopt.c \
+ hcreate.c \
+ hcreate_r.c \
+ hdestroy_r.c \
+ heapsort.c \
+ heapsort_b.c \
+ hsearch_r.c \
+ imaxabs.c \
+ imaxdiv.c \
+ insque.c \
+ l64a.c \
+ labs.c \
+ ldiv.c \
+ llabs.c \
+ lldiv.c \
+ lsearch.c \
+ memalignment.c \
+ merge.c \
+ mergesort_b.c \
+ ptsname.c \
+ qsort.c \
+ qsort_r.c \
+ qsort_r_compat.c \
+ qsort_s.c \
+ quick_exit.c \
+ radixsort.c \
+ rand.c \
+ random.c \
+ reallocarray.c \
+ reallocf.c \
+ realpath.c \
+ recallocarray.c \
+ remque.c \
+ set_constraint_handler_s.c \
+ strfmon.c \
+ strtoimax.c \
+ strtol.c \
+ strtold.c \
+ strtoll.c \
+ strtoq.c \
+ strtoul.c \
+ strtonum.c \
+ strtoull.c \
+ strtoumax.c \
+ strtouq.c \
+ system.c \
+ tdelete.c \
+ tdestroy.c \
+ tfind.c \
+ tsearch.c \
+ twalk.c
CFLAGS.qsort.c+= -Wsign-compare
@@ -85,9 +142,11 @@ MLINKS+=strtod.3 strtof.3 \
MLINKS+=strtol.3 strtoll.3 \
strtol.3 strtoq.3 \
strtol.3 strtoimax.3
+MLINKS+=strtonum.3 strtonumx.3
MLINKS+=strtoul.3 strtoull.3 \
strtoul.3 strtouq.3 \
strtoul.3 strtoumax.3
MLINKS+=tsearch.3 tdelete.3 \
tsearch.3 tfind.3 \
- tsearch.3 twalk.3
+ tsearch.3 twalk.3 \
+ tsearch.3 tdestroy.3
diff --git a/lib/libc/stdlib/Symbol.map b/lib/libc/stdlib/Symbol.map
index 8b7e97c3cbdc..373006b4a388 100644
--- a/lib/libc/stdlib/Symbol.map
+++ b/lib/libc/stdlib/Symbol.map
@@ -134,6 +134,8 @@ FBSD_1.8 {
FBSD_1.9 {
memalignment;
recallocarray;
+ strtonumx;
+ tdestroy;
};
FBSDprivate_1.0 {
diff --git a/lib/libc/stdlib/getopt.3 b/lib/libc/stdlib/getopt.3
index a5b5bff9d1a7..1b40f6dfea7e 100644
--- a/lib/libc/stdlib/getopt.3
+++ b/lib/libc/stdlib/getopt.3
@@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd June 5, 2014
+.Dd December 14, 2025
.Dt GETOPT 3
.Os
.Sh NAME
@@ -60,30 +60,49 @@ if it has been specified in the string of accepted option characters,
The option string
.Fa optstring
may contain the following elements: individual characters, and
-characters followed by a colon to indicate an option argument
-is to follow.
-If an individual character is followed by two colons, then the
-option argument is optional;
+characters followed by a colon
+.Pq Ql \&:
+to indicate an option argument is to follow.
+If an individual character is followed by two colons
+.Pq Ql \&:\&: ,
+then the option argument is optional;
.Va optarg
is set to the rest of the current
-.Va argv
+.Fa argv
word, or
.Dv NULL
if there were no more characters in the current word.
-This is a
-.Tn GNU
-extension.
+This is an extension not covered by POSIX.
+.Pp
For example, an option string
.Li \&"x"
recognizes an option
-.Dq Fl x ,
-and an option string
+.Dq Fl x .
+.Pp
+An option string
.Li \&"x:"
-recognizes an option and argument
-.Dq Fl x Ar argument .
+recognizes an option with an argument, both
+.Dq Fl x Ns Ar arg\^ ,
+and
+.Dq Fl x Ar arg\^ .
It does not matter to
.Fn getopt
-if a following argument has leading white space.
+if the option's argument is a separate word or not.
+.Pp
+An option string
+.Li \&"x::"
+recognizes the option both without an argument
+.Dq Fl x ,
+and with an argument
+.Dq Fl x Ns Ar arg\^ .
+In the latter case the argument must be part of the same
+.Fa argv
+word.
+The
+.Dq Fl x
+and
+.Dq Ar arg\^
+must not be separated by a whitespace on the command line.
.Pp
On return from
.Fn getopt ,
@@ -267,7 +286,7 @@ Care should be taken not to use
as the first character in
.Fa optstring
to avoid a semantic conflict with
-.Tn GNU
+GNU
.Fn getopt ,
which assigns different meaning to an
.Fa optstring
diff --git a/lib/libc/stdlib/strtonum.3 b/lib/libc/stdlib/strtonum.3
index 2650d147e7cc..7e6111a6ff71 100644
--- a/lib/libc/stdlib/strtonum.3
+++ b/lib/libc/stdlib/strtonum.3
@@ -1,4 +1,5 @@
.\" Copyright (c) 2004 Ted Unangst
+.\" Copyright 2023 Oxide Computer Company
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
@@ -14,11 +15,12 @@
.\"
.\" $OpenBSD: strtonum.3,v 1.13 2006/04/25 05:15:42 tedu Exp $
.\"
-.Dd April 29, 2004
+.Dd January 15, 2026
.Dt STRTONUM 3
.Os
.Sh NAME
-.Nm strtonum
+.Nm strtonum ,
+.Nm strtonumx
.Nd "reliably convert string value to an integer"
.Sh SYNOPSIS
.In stdlib.h
@@ -29,26 +31,33 @@
.Fa "long long maxval"
.Fa "const char **errstr"
.Fc
+.Ft long long
+.Fo strtonumx
+.Fa "const char *nptr"
+.Fa "long long minval"
+.Fa "long long maxval"
+.Fa "const char **errstr"
+.Fa "int base"
+.Fc
.Sh DESCRIPTION
The
.Fn strtonum
-function converts the string in
+and
+.Fn strtonumx
+functions convert the string in
.Fa nptr
to a
.Vt "long long"
value.
-The
-.Fn strtonum
-function was designed to facilitate safe, robust programming
-and overcome the shortcomings of the
+These functions were designed to facilitate safe, robust programming and
+overcome the shortcomings of the
.Xr atoi 3
and
.Xr strtol 3
family of interfaces.
.Pp
The string may begin with an arbitrary amount of whitespace
-(as determined by
-.Xr isspace 3 )
+.Pq as determined by Xr isspace 3
followed by a single optional
.Ql +
or
@@ -57,7 +66,10 @@ sign.
.Pp
The remainder of the string is converted to a
.Vt "long long"
-value according to base 10.
+value according to base 10
+.Pq for Fn strtonum
+or the provided base
+.Pq for Fn strtonumx .
.Pp
The value obtained is then checked against the provided
.Fa minval
@@ -68,13 +80,30 @@ If
.Fa errstr
is non-null,
.Fn strtonum
-stores an error string in
+and
+.Fn strtonumx
+store an error string in
.Fa *errstr
indicating the failure.
+.Pp
+For
+.Fn strtonumx
+the value of
+.Ar base
+is interpreted in the same way as described in
+.Xr strtoll 3 .
+In particular, if the value of
+.Ar base
+is 0, then the expected form of
+.Ar nptr
+is that of a decimal constant, octal constant or hexadecimal constant, any of
+which may be preceded by a + or - sign.
.Sh RETURN VALUES
The
.Fn strtonum
-function returns the result of the conversion,
+and
+.Fn strtonumx
+functions return the result of the conversion,
unless the value would exceed the provided bounds or is invalid.
On error, 0 is returned,
.Va errno
@@ -90,6 +119,8 @@ a successful return of 0 from an error.
.Sh EXAMPLES
Using
.Fn strtonum
+and
+.Fn strtonumx
correctly is meant to be simpler than the alternative functions.
.Bd -literal -offset indent
int iterations;
@@ -107,7 +138,10 @@ The above example will guarantee that the value of iterations is between
.It Bq Er ERANGE
The given string was out of range.
.It Bq Er EINVAL
-The given string did not consist solely of digit characters.
+The given string did not consist solely of digit characters
+.Pq for Fn strtonum ,
+or characters which are valid in the given base
+.Pq for Fn strtonumx .
.It Bq Er EINVAL
The supplied
.Fa minval
@@ -120,12 +154,15 @@ If an error occurs,
will be set to one of the following strings:
.Pp
.Bl -tag -width ".Li too large" -compact
-.It Li "too large"
+.It Qq too large
The result was larger than the provided maximum value.
-.It Li "too small"
+.It Qq too small
The result was smaller than the provided minimum value.
-.It Li invalid
-The string did not consist solely of digit characters.
+.It Qq invalid
+The string did not consist solely of characters valid in the specified base
+.Pq or base 10 for Fn strtonum .
+.It Qq unparsable; invalid base specified
+The specified base was outside the permitted range.
.El
.Sh SEE ALSO
.Xr atof 3 ,
@@ -152,3 +189,6 @@ The
.Fn strtonum
function first appeared in
.Ox 3.6 .
+The
+.Fn strtonumx
+function first appeared in illumos in 2023.
diff --git a/lib/libc/stdlib/strtonum.c b/lib/libc/stdlib/strtonum.c
index 0d0715bf39c1..44c27d6af3ad 100644
--- a/lib/libc/stdlib/strtonum.c
+++ b/lib/libc/stdlib/strtonum.c
@@ -2,6 +2,8 @@
* Copyright (c) 2004 Ted Unangst and Todd Miller
* All rights reserved.
*
+ * Copyright 2023 Oxide Computer Company
+ *
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
@@ -24,10 +26,13 @@
#define INVALID 1
#define TOOSMALL 2
#define TOOLARGE 3
+#define BADBASE 4
+
+#define MBASE ('z' - 'a' + 1 + 10)
long long
-strtonum(const char *numstr, long long minval, long long maxval,
- const char **errstrp)
+strtonumx(const char *numstr, long long minval, long long maxval,
+ const char **errstrp, int base)
{
long long ll = 0;
int error = 0;
@@ -35,20 +40,23 @@ strtonum(const char *numstr, long long minval, long long maxval,
struct errval {
const char *errstr;
int err;
- } ev[4] = {
+ } ev[5] = {
{ NULL, 0 },
{ "invalid", EINVAL },
{ "too small", ERANGE },
{ "too large", ERANGE },
+ { "unparsable; invalid base specified", EINVAL },
};
ev[0].err = errno;
errno = 0;
if (minval > maxval) {
error = INVALID;
+ } else if (base < 0 || base > MBASE || base == 1) {
+ error = BADBASE;
} else {
- ll = strtoll(numstr, &ep, 10);
- if (errno == EINVAL || numstr == ep || *ep != '\0')
+ ll = strtoll(numstr, &ep, base);
+ if (numstr == ep || *ep != '\0')
error = INVALID;
else if ((ll == LLONG_MIN && errno == ERANGE) || ll < minval)
error = TOOSMALL;
@@ -58,8 +66,15 @@ strtonum(const char *numstr, long long minval, long long maxval,
if (errstrp != NULL)
*errstrp = ev[error].errstr;
errno = ev[error].err;
- if (error)
+ if (error != 0)
ll = 0;
return (ll);
}
+
+long long
+strtonum(const char *numstr, long long minval, long long maxval,
+ const char **errstrp)
+{
+ return (strtonumx(numstr, minval, maxval, errstrp, 10));
+}
diff --git a/lib/libc/stdlib/tdestroy.c b/lib/libc/stdlib/tdestroy.c
new file mode 100644
index 000000000000..2aeb02228e46
--- /dev/null
+++ b/lib/libc/stdlib/tdestroy.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2025 The FreeBSD Foundation
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ */
+
+#define _SEARCH_PRIVATE
+#include <search.h>
+#include <stdlib.h>
+
+static void
+nul_node_free(void *node __unused)
+{
+}
+
+void
+tdestroy(void *rootp, void (*node_free)(void *))
+{
+ posix_tnode *back, *curr, **front;
+
+ if (rootp == NULL)
+ return;
+ if (node_free == NULL)
+ node_free = nul_node_free;
+
+ back = rootp;
+ front = &back;
+
+ for (;;) {
+ /*
+ * The sequence of nodes from back to just before *front linked
+ * by llink have been found to have non-NULL rlink.
+ *
+ * Extend *front to (*front)->llink, deleting *front from the
+ * sequence if it has a NULL rlink.
+ */
+ curr = *front;
+ if (curr->rlink != NULL)
+ front = &curr->llink;
+ else {
+ *front = curr->llink;
+ node_free(curr->key);
+ free(curr);
+ }
+ if (*front != NULL)
+ continue;
+ if (back == NULL)
+ break;
+
+ /*
+ * The sequence cannot be extended because *front is NULL. Make
+ * the rlink of the back node the new *front, the llink of the
+ * back node the new back, and free the old back node.
+ */
+ curr = back;
+ back = curr->llink;
+ if (back == NULL)
+ front = &back;
+ *front = curr->rlink;
+ node_free(curr->key);
+ free(curr);
+ }
+}
diff --git a/lib/libc/stdlib/tsearch.3 b/lib/libc/stdlib/tsearch.3
index edee01cafc52..f412c37a4ef0 100644
--- a/lib/libc/stdlib/tsearch.3
+++ b/lib/libc/stdlib/tsearch.3
@@ -36,6 +36,7 @@
.In search.h
.Ft void *
.Fn tdelete "const void * restrict key" "posix_tnode ** restrict rootp" "int (*compar) (const void *, const void *)"
+.Fn tdestroy "posix_tnode *root" "(void (*node_free)(void *)"
.Ft posix_tnode *
.Fn tfind "const void *key" "posix_tnode * const *rootp" "int (*compar) (const void *, const void *)"
.Ft posix_tnode *
@@ -45,6 +46,7 @@
.Sh DESCRIPTION
The
.Fn tdelete ,
+.Fn tdestroy ,
.Fn tfind ,
.Fn tsearch ,
and
@@ -95,6 +97,13 @@ If the node to be deleted is the root of the binary search tree,
will be adjusted.
.Pp
The
+.Fn tdestroy
+function destroys the whole search tree, freeing all allocated nodes.
+If tree keys need special handling on free, the
+.Fa node_free
+function can be provided, which is called on each key.
+.Pp
+The
.Fn twalk
function
walks the binary search tree rooted in
@@ -128,7 +137,9 @@ is NULL or the datum cannot be found.
.Pp
The
.Fn twalk
-function returns no value.
+and
+.Fn tdestroy
+functions return no value.
.Sh EXAMPLES
This example uses
.Fn tsearch
@@ -184,6 +195,7 @@ main(void)
tdelete(four, &root, comp);
twalk(root, printwalk);
+ tdestroy(root, NULL);
return 0;
}
.Ed
@@ -192,8 +204,17 @@ main(void)
.Xr hsearch 3 ,
.Xr lsearch 3
.Sh STANDARDS
-These functions conform to
+These
+.Fn tdelete ,
+.Fn tfind ,
+.Fn tsearch ,
+and
+.Fn twalk
+functions conform to
.St -p1003.1-2008 .
+The
+.Fn tdestroy
+function is the glibc extension.
.Pp
The
.Fa posix_tnode
diff --git a/lib/libc/string/bcmp.3 b/lib/libc/string/bcmp.3
index 954e10bfdeab..ec3caa0f1c9f 100644
--- a/lib/libc/string/bcmp.3
+++ b/lib/libc/string/bcmp.3
@@ -27,7 +27,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd August 15, 2016
+.Dd October 8, 2025
.Dt BCMP 3
.Os
.Sh NAME
@@ -73,3 +73,11 @@ before it was moved to
for
.St -p1003.1-2001
compliance.
+.Pp
+.St -p1003.1-2008
+removes the specification of
+.Fn bcmp
+and it is marked as LEGACY in
+.St -p1003.1-2004 .
+For portability with other systems new programs should use
+.Xr memcmp 3 .
diff --git a/lib/libc/string/swab.c b/lib/libc/string/swab.c
index ed4436a49810..4f4fb26379c6 100644
--- a/lib/libc/string/swab.c
+++ b/lib/libc/string/swab.c
@@ -3,14 +3,16 @@
* Copyright (c) 2024 rilysh <nightquick@proton.me>
*/
+#include <string.h>
#include <unistd.h>
#include <sys/endian.h>
void
swab(const void * __restrict from, void * __restrict to, ssize_t len)
{
- const uint16_t *f __aligned(1) = from;
- uint16_t *t __aligned(1) = to;
+ const char *f = from;
+ char *t = to;
+ uint16_t tmp;
/*
* POSIX says overlapping copy behavior is undefined, however many
@@ -19,7 +21,12 @@ swab(const void * __restrict from, void * __restrict to, ssize_t len)
* and swapping them before writing them back accomplishes this.
*/
while (len > 1) {
- *t++ = bswap16(*f++);
+ memcpy(&tmp, f, 2);
+ tmp = bswap16(tmp);
+ memcpy(t, &tmp, 2);
+
+ f += 2;
+ t += 2;
len -= 2;
}
}
diff --git a/lib/libc/sys/Symbol.map b/lib/libc/sys/Symbol.map
index 32b1b0ecee05..8acffcfd714e 100644
--- a/lib/libc/sys/Symbol.map
+++ b/lib/libc/sys/Symbol.map
@@ -71,3 +71,7 @@ FBSD_1.6 {
FBSD_1.7 {
_Fork;
};
+
+FBSD_1.9 {
+ pdwait;
+};
diff --git a/lib/libc/sys/pdwait.c b/lib/libc/sys/pdwait.c
new file mode 100644
index 000000000000..89d43b7fca2e
--- /dev/null
+++ b/lib/libc/sys/pdwait.c
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2026 The FreeBSD Foundation.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * This software was developed by Konstantin Belousov <kib@FreeBSD.org>
+ * under sponsorship from the FreeBSD Foundation.
+ */
+
+#include <sys/types.h>
+#include <sys/procdesc.h>
+#include "libc_private.h"
+
+#pragma weak pdwait
+int
+pdwait(int fd, int *status, int options, struct __wrusage *ru,
+ struct __siginfo *infop)
+{
+ return (INTERPOS_SYS(pdwait, fd, status, options, ru, infop));
+}
diff --git a/lib/libc/tests/gen/dir2_test.c b/lib/libc/tests/gen/dir2_test.c
index 4ec5a1759d06..dac8ccbe472a 100644
--- a/lib/libc/tests/gen/dir2_test.c
+++ b/lib/libc/tests/gen/dir2_test.c
@@ -41,7 +41,6 @@
ATF_TC(telldir_after_seekdir);
ATF_TC_HEAD(telldir_after_seekdir, tc)
{
-
atf_tc_set_md_var(tc, "descr", "Calling telldir(3) after seekdir(3) "
"should return the argument passed to seekdir.");
}
@@ -50,7 +49,7 @@ ATF_TC_BODY(telldir_after_seekdir, tc)
const int NUMFILES = 1000;
char template[] = "dXXXXXX";
char *tmpdir;
- int i, dirfd;
+ int i, dd;
DIR *dirp;
struct dirent *de;
long beginning, middle, end, td;
@@ -58,8 +57,8 @@ ATF_TC_BODY(telldir_after_seekdir, tc)
/* Create a temporary directory */
tmpdir = mkdtemp(template);
ATF_REQUIRE_MSG(tmpdir != NULL, "mkdtemp failed");
- dirfd = open(tmpdir, O_RDONLY | O_DIRECTORY);
- ATF_REQUIRE(dirfd > 0);
+ dd = open(tmpdir, O_RDONLY | O_DIRECTORY);
+ ATF_REQUIRE(dd > 0);
/*
* Fill it with files. Must be > 128 to ensure that the directory
@@ -70,14 +69,14 @@ ATF_TC_BODY(telldir_after_seekdir, tc)
char filename[16];
snprintf(filename, sizeof(filename), "%d", i);
- fd = openat(dirfd, filename, O_WRONLY | O_CREAT, 0600);
+ fd = openat(dd, filename, O_WRONLY | O_CREAT, 0600);
ATF_REQUIRE(fd > 0);
close(fd);
}
/* Get some directory bookmarks in various locations */
- dirp = fdopendir(dirfd);
- ATF_REQUIRE_MSG(dirfd >= 0, "fdopendir failed");
+ dirp = fdopendir(dd);
+ ATF_REQUIRE_MSG(dd >= 0, "fdopendir failed");
beginning = telldir(dirp);
for (i = 0; i < NUMFILES / 2; i = i+1) {
de = readdir(dirp);
@@ -126,7 +125,7 @@ ATF_TC_BODY(telldir_at_end_of_block, tc)
const int NUMFILES = 129;
char template[] = "dXXXXXX";
char *tmpdir;
- int i, dirfd;
+ int i, dd;
DIR *dirp;
struct dirent *de;
long td;
@@ -135,8 +134,8 @@ ATF_TC_BODY(telldir_at_end_of_block, tc)
/* Create a temporary directory */
tmpdir = mkdtemp(template);
ATF_REQUIRE_MSG(tmpdir != NULL, "mkdtemp failed");
- dirfd = open(tmpdir, O_RDONLY | O_DIRECTORY);
- ATF_REQUIRE(dirfd > 0);
+ dd = open(tmpdir, O_RDONLY | O_DIRECTORY);
+ ATF_REQUIRE(dd > 0);
/*
* Fill it with files. Must be > 128 to ensure that the directory
@@ -147,14 +146,14 @@ ATF_TC_BODY(telldir_at_end_of_block, tc)
char filename[16];
snprintf(filename, sizeof(filename), "%d", i);
- fd = openat(dirfd, filename, O_WRONLY | O_CREAT, 0600);
+ fd = openat(dd, filename, O_WRONLY | O_CREAT, 0600);
ATF_REQUIRE(fd > 0);
close(fd);
}
/* Read all entries within the first page */
- dirp = fdopendir(dirfd);
- ATF_REQUIRE_MSG(dirfd >= 0, "fdopendir failed");
+ dirp = fdopendir(dd);
+ ATF_REQUIRE_MSG(dd >= 0, "fdopendir failed");
for (i = 0; i < NUMFILES - 1; i = i + 1)
ATF_REQUIRE_MSG(readdir(dirp) != NULL, "readdir failed");
@@ -178,9 +177,8 @@ ATF_TC_BODY(telldir_at_end_of_block, tc)
ATF_TP_ADD_TCS(tp)
{
-
ATF_TP_ADD_TC(tp, telldir_after_seekdir);
ATF_TP_ADD_TC(tp, telldir_at_end_of_block);
- return atf_no_error();
+ return (atf_no_error());
}
diff --git a/lib/libc/tests/stdlib/tsearch_test.c b/lib/libc/tests/stdlib/tsearch_test.c
index ee9deec588cb..f42729e5e75c 100644
--- a/lib/libc/tests/stdlib/tsearch_test.c
+++ b/lib/libc/tests/stdlib/tsearch_test.c
@@ -147,10 +147,75 @@ ATF_TC_BODY(tsearch_test, tc)
ATF_CHECK_EQ(NULL, root);
}
+static int nodes;
+
+struct my_data {
+ int key;
+};
+
+static struct my_data *
+new_my_data(int key)
+{
+ struct my_data *res;
+
+ res = malloc(sizeof(struct my_data));
+ res->key = key;
+ nodes++;
+ return (res);
+}
+
+void
+free_my_data(void *mdp)
+{
+ free(mdp);
+ nodes--;
+}
+
+static int
+compare_my_data(const void *mdp1, const void *mdp2)
+{
+ const struct my_data *md1, *md2;
+
+ md1 = mdp1;
+ md2 = mdp2;
+
+ return (md1->key - md2->key);
+}
+
+static posix_tnode *root = NULL;
+
+static void
+insert(int x)
+{
+ struct my_data *md;
+
+ md = new_my_data(x);
+ tsearch(md, &root, compare_my_data);
+}
+
+ATF_TC_WITHOUT_HEAD(tdestroy_test);
+ATF_TC_BODY(tdestroy_test, tc)
+{
+ root = NULL;
+ insert(1);
+ insert(100);
+ insert(1000);
+ insert(5);
+ insert(6);
+ insert(12);
+ insert(2000);
+ insert(3);
+
+ ATF_CHECK_EQ(8, nodes);
+ tdestroy(root, free_my_data);
+ ATF_CHECK_EQ(0, nodes);
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, tsearch_test);
+ ATF_TP_ADD_TC(tp, tdestroy_test);
return (atf_no_error());
}
diff --git a/lib/libc/xdr/xdr.c b/lib/libc/xdr/xdr.c
index 59a843405abf..47aafea4bc30 100644
--- a/lib/libc/xdr/xdr.c
+++ b/lib/libc/xdr/xdr.c
@@ -696,6 +696,13 @@ xdr_string(XDR *xdrs, char **cpp, u_int maxsize)
if (sp == NULL) {
return(TRUE); /* already free */
}
+ /*
+ * XXX: buggy software may call this without a third
+ * argument via xdr_free(). Ignore maxsize since it may
+ * be invalid. Otherwise, if it's very small, we might
+ * fail to free the string.
+ */
+ maxsize = RPC_MAXDATASIZE;
/* FALLTHROUGH */
case XDR_ENCODE:
size = strlen(sp);