summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/aarch64/sys/Makefile.inc2
-rw-r--r--lib/libc/aarch64/sys/__vdso_gettc.c74
-rw-r--r--lib/libc/arm/sys/Makefile.inc2
-rw-r--r--lib/libc/arm/sys/__vdso_gettc.c79
-rw-r--r--lib/libc/gen/getnetgrent.c1
-rw-r--r--lib/libc/stdio/open_memstream.c3
-rw-r--r--lib/libc/stdio/open_wmemstream.c3
-rw-r--r--lib/libc/tests/stdio/getdelim_test.c1
-rw-r--r--lib/libc/tests/stdio/printbasic_test.c2
-rw-r--r--lib/libc/tests/stdio/printfloat_test.c2
10 files changed, 166 insertions, 3 deletions
diff --git a/lib/libc/aarch64/sys/Makefile.inc b/lib/libc/aarch64/sys/Makefile.inc
index cb56f73..b33b568 100644
--- a/lib/libc/aarch64/sys/Makefile.inc
+++ b/lib/libc/aarch64/sys/Makefile.inc
@@ -1,6 +1,6 @@
# $FreeBSD$
-SRCS+= trivial-vdso_tc.c
+SRCS+= __vdso_gettc.c
#MDASM= ptrace.S
MDASM= brk.S \
diff --git a/lib/libc/aarch64/sys/__vdso_gettc.c b/lib/libc/aarch64/sys/__vdso_gettc.c
new file mode 100644
index 0000000..f9015e2
--- /dev/null
+++ b/lib/libc/aarch64/sys/__vdso_gettc.c
@@ -0,0 +1,74 @@
+/*-
+ * Copyright (c) 2015 The FreeBSD Foundation
+ *
+ * This software was developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/elf.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <machine/cpufunc.h>
+#include "libc_private.h"
+
+static inline uint64_t
+cp15_cntvct_get(void)
+{
+ uint64_t reg;
+
+ __asm __volatile("mrs %0, cntvct_el0" : "=r" (reg));
+ return (reg);
+}
+
+static inline uint64_t
+cp15_cntpct_get(void)
+{
+ uint64_t reg;
+
+ __asm __volatile("mrs %0, cntpct_el0" : "=r" (reg));
+ return (reg);
+}
+
+#pragma weak __vdso_gettc
+u_int
+__vdso_gettc(const struct vdso_timehands *th)
+{
+ uint64_t val;
+
+ __asm __volatile("isb" : : : "memory");
+ val = th->th_physical == 0 ? cp15_cntvct_get() : cp15_cntpct_get();
+ return (val);
+}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+
+ return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
+}
diff --git a/lib/libc/arm/sys/Makefile.inc b/lib/libc/arm/sys/Makefile.inc
index 60c2dc3..5e89109 100644
--- a/lib/libc/arm/sys/Makefile.inc
+++ b/lib/libc/arm/sys/Makefile.inc
@@ -1,6 +1,6 @@
# $FreeBSD$
-SRCS+= trivial-vdso_tc.c
+SRCS+= __vdso_gettc.c
MDASM= Ovfork.S brk.S cerror.S pipe.S ptrace.S sbrk.S shmat.S sigreturn.S syscall.S
diff --git a/lib/libc/arm/sys/__vdso_gettc.c b/lib/libc/arm/sys/__vdso_gettc.c
new file mode 100644
index 0000000..d75d866
--- /dev/null
+++ b/lib/libc/arm/sys/__vdso_gettc.c
@@ -0,0 +1,79 @@
+/*-
+ * Copyright (c) 2015 The FreeBSD Foundation
+ *
+ * This software was developed by Konstantin Belousov
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+#include <sys/elf.h>
+#include <sys/time.h>
+#include <sys/vdso.h>
+#include <machine/cpufunc.h>
+#include "libc_private.h"
+
+static inline uint64_t
+cp15_cntvct_get(void)
+{
+ uint64_t reg;
+
+ __asm __volatile("mrrc\tp15, 1, %Q0, %R0, c14" : "=r" (reg));
+ return (reg);
+}
+
+static inline uint64_t
+cp15_cntpct_get(void)
+{
+ uint64_t reg;
+
+ __asm __volatile("mrrc\tp15, 0, %Q0, %R0, c14" : "=r" (reg));
+ return (reg);
+}
+
+#pragma weak __vdso_gettc
+u_int
+__vdso_gettc(const struct vdso_timehands *th)
+{
+ uint64_t val;
+
+ /*
+ * Userspace gettimeofday() is only enabled on ARMv7 CPUs, but
+ * libc is compiled for ARMv6. Due to clang issues, .arch
+ * armv7-a directive does not work.
+ */
+ __asm __volatile(".word\t0xf57ff06f" : : : "memory"); /* isb */
+ val = th->th_physical == 0 ? cp15_cntvct_get() : cp15_cntpct_get();
+ return (val);
+}
+
+#pragma weak __vdso_gettimekeep
+int
+__vdso_gettimekeep(struct vdso_timekeep **tk)
+{
+
+ return (_elf_aux_info(AT_TIMEKEEP, tk, sizeof(*tk)));
+}
diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c
index 4c56461..4bf0a14 100644
--- a/lib/libc/gen/getnetgrent.c
+++ b/lib/libc/gen/getnetgrent.c
@@ -512,6 +512,7 @@ parse_netgrp(const char *group)
ng[NG_DOM] == NULL ? "" : ",",
ng[NG_DOM] == NULL ? "" : ng[NG_DOM],
lp->l_groupname);
+ }
#endif
} else {
spos = strsep(&pos, ", \t");
diff --git a/lib/libc/stdio/open_memstream.c b/lib/libc/stdio/open_memstream.c
index baa71e4..f3d1ee5 100644
--- a/lib/libc/stdio/open_memstream.c
+++ b/lib/libc/stdio/open_memstream.c
@@ -31,6 +31,9 @@ __FBSDID("$FreeBSD$");
#include "namespace.h"
#include <assert.h>
#include <errno.h>
+#ifdef DEBUG
+#include <inttypes.h>
+#endif
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/stdio/open_wmemstream.c b/lib/libc/stdio/open_wmemstream.c
index 299e3d8..4585531 100644
--- a/lib/libc/stdio/open_wmemstream.c
+++ b/lib/libc/stdio/open_wmemstream.c
@@ -31,6 +31,9 @@ __FBSDID("$FreeBSD$");
#include "namespace.h"
#include <assert.h>
#include <errno.h>
+#ifdef DEBUG
+#include <inttypes.h>
+#endif
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/lib/libc/tests/stdio/getdelim_test.c b/lib/libc/tests/stdio/getdelim_test.c
index b7596b3..37737ae 100644
--- a/lib/libc/tests/stdio/getdelim_test.c
+++ b/lib/libc/tests/stdio/getdelim_test.c
@@ -207,7 +207,6 @@ ATF_TC_BODY(empty_NULL_buffer, tc)
/* Make sure NULL *linep and zero *linecapp are handled. */
fp = mkfilebuf();
- free(line);
line = NULL;
linecap = 42;
ATF_REQUIRE(getline(&line, &linecap, fp) == sizeof(apothegm) - 1);
diff --git a/lib/libc/tests/stdio/printbasic_test.c b/lib/libc/tests/stdio/printbasic_test.c
index d1fab29..376981e 100644
--- a/lib/libc/tests/stdio/printbasic_test.c
+++ b/lib/libc/tests/stdio/printbasic_test.c
@@ -94,6 +94,8 @@ _testfmt(const char *result, const char *argstr, const char *fmt,...)
"wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]\n",
wfmt, argstr, ws, wresult);
}
+ va_end(ap);
+ va_end(ap2);
}
ATF_TC_WITHOUT_HEAD(int_within_limits);
diff --git a/lib/libc/tests/stdio/printfloat_test.c b/lib/libc/tests/stdio/printfloat_test.c
index 6b4e455..2319747 100644
--- a/lib/libc/tests/stdio/printfloat_test.c
+++ b/lib/libc/tests/stdio/printfloat_test.c
@@ -86,6 +86,8 @@ _testfmt(const char *result, const char *argstr, const char *fmt,...)
"wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]\n",
wfmt, argstr, ws, wresult);
}
+ va_end(ap);
+ va_end(ap2);
}
ATF_TC_WITHOUT_HEAD(float_within_limits);
OpenPOWER on IntegriCloud