summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/db/hash/hash_page.c13
-rw-r--r--lib/libc/stdlib/hcreate.38
-rw-r--r--lib/libc/sys/recv.255
-rw-r--r--lib/libc/tests/db/Makefile2
-rw-r--r--lib/libc/tests/gen/Makefile12
-rw-r--r--lib/libc/tests/stdio/printbasic_test.c22
-rw-r--r--lib/libc/tests/stdio/printfloat_test.c19
-rw-r--r--lib/libc/tests/sys/Makefile4
-rw-r--r--lib/libc/x86/sys/Makefile.inc4
-rw-r--r--lib/libc/x86/sys/__vdso_gettc.c8
10 files changed, 62 insertions, 85 deletions
diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c
index a2bb7cf..ec2d184 100644
--- a/lib/libc/db/hash/hash_page.c
+++ b/lib/libc/db/hash/hash_page.c
@@ -572,7 +572,9 @@ __get_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_disk,
int
__put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap)
{
- int fd, page, size, wsize;
+ int fd, page, size;
+ ssize_t wsize;
+ char pbuf[MAX_BSIZE];
size = hashp->BSIZE;
if ((hashp->fp == -1) && open_temp(hashp))
@@ -582,15 +584,18 @@ __put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap)
if (hashp->LORDER != BYTE_ORDER) {
int i, max;
+ memcpy(pbuf, p, size);
if (is_bitmap) {
max = hashp->BSIZE >> 2; /* divide by 4 */
for (i = 0; i < max; i++)
- M_32_SWAP(((int *)p)[i]);
+ M_32_SWAP(((int *)pbuf)[i]);
} else {
- max = ((u_int16_t *)p)[0] + 2;
+ uint16_t *bp = (uint16_t *)(void *)pbuf;
+ max = bp[0] + 2;
for (i = 0; i <= max; i++)
- M_16_SWAP(((u_int16_t *)p)[i]);
+ M_16_SWAP(bp[i]);
}
+ p = pbuf;
}
if (is_bucket)
page = BUCKET_TO_PAGE(bucket);
diff --git a/lib/libc/stdlib/hcreate.3 b/lib/libc/stdlib/hcreate.3
index 5709157..260aa91 100644
--- a/lib/libc/stdlib/hcreate.3
+++ b/lib/libc/stdlib/hcreate.3
@@ -28,7 +28,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd December 26, 2015
+.Dd February 6, 2017
.Dt HCREATE 3
.Os
.Sh NAME
@@ -265,9 +265,9 @@ main(void)
.Ed
.Sh ERRORS
The
-.Fn hcreate
+.Fn hcreate ,
.Fn hcreate_r ,
-.Fn hsearch
+.Fn hsearch ,
and
.Fn hsearch_r
functions will fail if:
@@ -281,7 +281,7 @@ The
and
.Fn hsearch_r
functions will also fail if the action is
-.Dv SEARCH
+.Dv FIND
and the element is not found:
.Bl -tag -width Er
.It Bq Er ESRCH
diff --git a/lib/libc/sys/recv.2 b/lib/libc/sys/recv.2
index 4867ea7..36a8a9d 100644
--- a/lib/libc/sys/recv.2
+++ b/lib/libc/sys/recv.2
@@ -28,7 +28,7 @@
.\" @(#)recv.2 8.3 (Berkeley) 2/21/94
.\" $FreeBSD$
.\"
-.Dd January 29, 2016
+.Dd February 3, 2017
.Dt RECV 2
.Os
.Sh NAME
@@ -267,57 +267,10 @@ with no data buffer provided immediately after an
.Fn accept
system call.
.Pp
-Open file descriptors are now passed as ancillary data for
+With
.Dv AF_UNIX
-domain sockets, with
-.Fa cmsg_level
-set to
-.Dv SOL_SOCKET
-and
-.Fa cmsg_type
-set to
-.Dv SCM_RIGHTS .
-The close-on-exec flag on received descriptors is set according to the
-.Dv MSG_CMSG_CLOEXEC
-flag passed to
-.Fn recvmsg .
-.Pp
-Process credentials can also be passed as ancillary data for
-.Dv AF_UNIX
-domain sockets using a
-.Fa cmsg_type
-of
-.Dv SCM_CREDS .
-In this case,
-.Fa cmsg_data
-should be a structure of type
-.Fa cmsgcred ,
-which is defined in
-.In sys/socket.h
-as follows:
-.Bd -literal
-struct cmsgcred {
- pid_t cmcred_pid; /* PID of sending process */
- uid_t cmcred_uid; /* real UID of sending process */
- uid_t cmcred_euid; /* effective UID of sending process */
- gid_t cmcred_gid; /* real GID of sending process */
- short cmcred_ngroups; /* number or groups */
- gid_t cmcred_groups[CMGROUP_MAX]; /* groups */
-};
-.Ed
-.Pp
-If a sender supplies ancillary data with enough space for the above struct
-tagged as
-.Dv SCM_CREDS
-control message type to the
-.Fn sendmsg
-system call, then kernel will fill in the credential information of the
-sending process and deliver it to the receiver.
-Since receiver usually has no control over a sender, this method of retrieving
-credential information isn't reliable.
-For reliable retrieval of remote side credentials it is advised to use the
-.Dv LOCAL_CREDS
-socket option on the receiving socket.
+domain sockets, ancillary data can be used to pass file descriptors and
+process credentials.
See
.Xr unix 4
for details.
diff --git a/lib/libc/tests/db/Makefile b/lib/libc/tests/db/Makefile
index e9c76d2..132cfb3 100644
--- a/lib/libc/tests/db/Makefile
+++ b/lib/libc/tests/db/Makefile
@@ -13,6 +13,8 @@ NETBSD_ATF_TESTS_C+= db_hash_seq_test
NETBSD_ATF_TESTS_SH+= db_test
ATF_TESTS_SH_SED_db_test= -e 's,/bin/csh,/bin/cat,g'
+CFLAGS+= -I${SRCTOP}/lib/libc/db/btree
+
.include "../Makefile.netbsd-tests"
.include <bsd.test.mk>
diff --git a/lib/libc/tests/gen/Makefile b/lib/libc/tests/gen/Makefile
index 0830977..2ec336e 100644
--- a/lib/libc/tests/gen/Makefile
+++ b/lib/libc/tests/gen/Makefile
@@ -13,10 +13,20 @@ ATF_TESTS_C+= posix_spawn_test
ATF_TESTS_C+= wordexp_test
ATF_TESTS_C+= dlopen_empty_test
-# TODO: t_closefrom, t_cpuset, t_fmtcheck, t_randomid, t_sleep
+# TODO: t_closefrom, t_cpuset, t_fmtcheck, t_randomid,
# TODO: t_siginfo (fixes require further inspection)
# TODO: t_sethostname_test (consistently screws up the hostname)
+CFLAGS+= -DTEST_LONG_DOUBLE
+
+# Not sure why this isn't defined for all architectures, since most
+# have long double.
+.if ${MACHINE_CPUARCH} == "aarch64" || \
+ ${MACHINE_CPUARCH} == "amd64" || \
+ ${MACHINE_CPUARCH} == "i386"
+CFLAGS+= -D__HAVE_LONG_DOUBLE
+.endif
+
NETBSD_ATF_TESTS_C= alarm_test
NETBSD_ATF_TESTS_C+= assert_test
NETBSD_ATF_TESTS_C+= basedirname_test
diff --git a/lib/libc/tests/stdio/printbasic_test.c b/lib/libc/tests/stdio/printbasic_test.c
index 7f7c6cb..322e747 100644
--- a/lib/libc/tests/stdio/printbasic_test.c
+++ b/lib/libc/tests/stdio/printbasic_test.c
@@ -78,22 +78,19 @@ _testfmt(const char *result, const char *argstr, const char *fmt,...)
va_copy(ap2, ap);
smash_stack();
vsnprintf(s, sizeof(s), fmt, ap);
- if (strcmp(result, s) != 0) {
- atf_tc_fail(
- "printf(\"%s\", %s) ==> [%s], expected [%s]",
- fmt, argstr, s, result);
- }
+ ATF_CHECK_MSG(strcmp(result, s) == 0,
+ "printf(\"%s\", %s) ==> [%s], expected [%s]",
+ fmt, argstr, s, result);
smash_stack();
mbstowcs(ws, s, BUF - 1);
mbstowcs(wfmt, fmt, BUF - 1);
mbstowcs(wresult, result, BUF - 1);
vswprintf(ws, sizeof(ws) / sizeof(ws[0]), wfmt, ap2);
- if (wcscmp(wresult, ws) != 0) {
- atf_tc_fail(
- "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]",
- wfmt, argstr, ws, wresult);
- }
+ ATF_CHECK_MSG(wcscmp(wresult, ws) == 0,
+ "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]",
+ wfmt, argstr, ws, wresult);
+
va_end(ap);
va_end(ap2);
}
@@ -114,6 +111,11 @@ ATF_TC_BODY(int_within_limits, tc)
testfmt("-1", "%jd", (intmax_t)-1);
testfmt(S_UINT64MAX, "%ju", UINT64_MAX);
+ if (sizeof(ptrdiff_t) != sizeof(uintmax_t))
+ atf_tc_expect_fail("the %%t qualifier is broken on 32-bit "
+ "platforms where there's a mismatch between ptrdiff_t and "
+ "uintmax_t's type width; bug # 191674");
+
testfmt("-1", "%td", (ptrdiff_t)-1);
testfmt(S_SIZEMAX, "%tu", (size_t)-1);
diff --git a/lib/libc/tests/stdio/printfloat_test.c b/lib/libc/tests/stdio/printfloat_test.c
index 974374f..97629fb 100644
--- a/lib/libc/tests/stdio/printfloat_test.c
+++ b/lib/libc/tests/stdio/printfloat_test.c
@@ -70,22 +70,19 @@ _testfmt(const char *result, const char *argstr, const char *fmt,...)
va_copy(ap2, ap);
smash_stack();
vsnprintf(s, sizeof(s), fmt, ap);
- if (strcmp(result, s) != 0) {
- atf_tc_fail(
- "printf(\"%s\", %s) ==> [%s], expected [%s]",
- fmt, argstr, s, result);
- }
+ ATF_CHECK_MSG(strcmp(result, s) == 0,
+ "printf(\"%s\", %s) ==> [%s], expected [%s]",
+ fmt, argstr, s, result);
smash_stack();
mbstowcs(ws, s, BUF - 1);
mbstowcs(wfmt, fmt, BUF - 1);
mbstowcs(wresult, result, BUF - 1);
vswprintf(ws, sizeof(ws) / sizeof(ws[0]), wfmt, ap2);
- if (wcscmp(wresult, ws) != 0) {
- atf_tc_fail(
- "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]",
- wfmt, argstr, ws, wresult);
- }
+ ATF_CHECK_MSG(wcscmp(wresult, ws) == 0,
+ "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]",
+ wfmt, argstr, ws, wresult);
+
va_end(ap);
va_end(ap2);
}
@@ -318,7 +315,7 @@ ATF_TC_BODY(hexadecimal_floating_point, tc)
testfmt("0x1p-1074", "%a", 0x1p-1074);
testfmt("0x1.2345p-1024", "%a", 0x1.2345p-1024);
-#if (LDBL_MANT_DIG == 64) && !defined(__i386__)
+#if (LDBL_MANT_DIG == 64)
testfmt("0x1.921fb54442d18468p+1", "%La", 0x3.243f6a8885a308dp0L);
testfmt("0x1p-16445", "%La", 0x1p-16445L);
testfmt("0x1.30ecap-16381", "%La", 0x9.8765p-16384L);
diff --git a/lib/libc/tests/sys/Makefile b/lib/libc/tests/sys/Makefile
index 42427e8..64b20a8 100644
--- a/lib/libc/tests/sys/Makefile
+++ b/lib/libc/tests/sys/Makefile
@@ -61,8 +61,12 @@ NETBSD_ATF_TESTS_C+= ucontext_test
NETBSD_ATF_TESTS_C+= umask_test
NETBSD_ATF_TESTS_C+= unlink_test
NETBSD_ATF_TESTS_C+= wait_test
+NETBSD_ATF_TESTS_C+= wait_noproc_test
+NETBSD_ATF_TESTS_C+= wait_noproc_wnohang_test
NETBSD_ATF_TESTS_C+= write_test
+CSTD?= c99
+
LIBADD.getpid_test+= pthread
LIBADD.timer_create_test+= rt
diff --git a/lib/libc/x86/sys/Makefile.inc b/lib/libc/x86/sys/Makefile.inc
index c00a217..0e8026a 100644
--- a/lib/libc/x86/sys/Makefile.inc
+++ b/lib/libc/x86/sys/Makefile.inc
@@ -4,3 +4,7 @@
SRCS+= \
__vdso_gettc.c
+
+.if ${MACHINE_CPUARCH} == "amd64" && ${MK_HYPERV} != "no"
+CFLAGS+= -DWANT_HYPERV
+.endif
diff --git a/lib/libc/x86/sys/__vdso_gettc.c b/lib/libc/x86/sys/__vdso_gettc.c
index 723db6e..bf46a10 100644
--- a/lib/libc/x86/sys/__vdso_gettc.c
+++ b/lib/libc/x86/sys/__vdso_gettc.c
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
#include <machine/cpufunc.h>
#include <machine/specialreg.h>
#include <dev/acpica/acpi_hpet.h>
-#ifdef __amd64__
+#ifdef WANT_HYPERV
#include <dev/hyperv/hyperv.h>
#endif
#include "libc_private.h"
@@ -158,7 +158,7 @@ __vdso_init_hpet(uint32_t u)
munmap((void *)new_map, PAGE_SIZE);
}
-#ifdef __amd64__
+#ifdef WANT_HYPERV
#define HYPERV_REFTSC_DEVPATH "/dev/" HYPERV_REFTSC_DEVNAME
@@ -217,7 +217,7 @@ __vdso_hyperv_tsc(struct hyperv_reftsc *tsc_ref, u_int *tc)
return (ENOSYS);
}
-#endif /* __amd64__ */
+#endif /* WANT_HYPERV */
#pragma weak __vdso_gettc
int
@@ -246,7 +246,7 @@ __vdso_gettc(const struct vdso_timehands *th, u_int *tc)
return (ENOSYS);
*tc = *(volatile uint32_t *)(map + HPET_MAIN_COUNTER);
return (0);
-#ifdef __amd64__
+#ifdef WANT_HYPERV
case VDSO_TH_ALGO_X86_HVTSC:
if (hyperv_ref_tsc == NULL)
__vdso_init_hyperv_tsc();
OpenPOWER on IntegriCloud