summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2016-06-10 23:29:20 +0000
committerchristos <christos@NetBSD.org>2016-06-10 23:29:20 +0000
commit7d287d4798cc0a133e2ebf847fd33c5b2d4bf0bf (patch)
tree01ff5d4420332f5d6a2a6a13a4dd6d619e123e87
parent82d726f805ed0d9c30c5557cc0fb71012394b031 (diff)
GSoC 2016: Charles Cui: Add timer related macros
_POSIX_CPUTIME _POSIX_THREAD_CPUTIME _POSIX_DELAYTIMER_MAX
-rw-r--r--include/limits.h5
-rw-r--r--lib/libc/gen/sysconf.311
-rw-r--r--lib/libc/gen/sysconf.c10
-rw-r--r--sys/kern/kern_time.c7
-rw-r--r--sys/sys/unistd.h5
5 files changed, 31 insertions, 7 deletions
diff --git a/include/limits.h b/include/limits.h
index 9b619d79632..bbd659c1fe8 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -1,4 +1,4 @@
-/* $NetBSD: limits.h,v 1.37 2016/06/10 23:24:33 christos Exp $ */
+/* $NetBSD: limits.h,v 1.38 2016/06/10 23:29:20 christos Exp $ */
/*
* Copyright (c) 1988, 1993
@@ -94,6 +94,9 @@
#define _POSIX_TIMER_MAX 32
#define _POSIX_SEM_NSEMS_MAX 256
+#define _POSIX_CPUTIME 200112L
+#define _POSIX_THREAD_CPUTIME 200112L
+#define _POSIX_DELAYTIMER_MAX 32
#define _POSIX_TTY_NAME_MAX 9
#define _POSIX_TZNAME_MAX 6
diff --git a/lib/libc/gen/sysconf.3 b/lib/libc/gen/sysconf.3
index dfdbaf0fa07..165d705d0cb 100644
--- a/lib/libc/gen/sysconf.3
+++ b/lib/libc/gen/sysconf.3
@@ -1,4 +1,4 @@
-.\" $NetBSD: sysconf.3,v 1.47 2016/06/10 23:26:43 wiz Exp $
+.\" $NetBSD: sysconf.3,v 1.48 2016/06/10 23:29:20 christos Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
@@ -185,6 +185,15 @@ and its
Timers
option to which the system attempts to conform,
otherwise \-1.
+.It Li _SC_CPUTIME
+The clockID CLOCK_PROCESS_CPUTIME_ID is supported,
+otherwise \-1.
+.It Li _SC_THREAD_CPUTIME
+The clockID CLOCK_THREAD_CPUTIME_ID is supported,
+otherwise \-1.
+.It Li _SC_DELAYTIMER_MAX
+The maximum number of overrun for a specific timer,
+otherwise \-1.
.It Li _SC_TZNAME_MAX
The minimum maximum number of types supported for the name of a
timezone.
diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c
index 173d85427ef..c320b17f893 100644
--- a/lib/libc/gen/sysconf.c
+++ b/lib/libc/gen/sysconf.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sysconf.c,v 1.38 2016/06/10 23:24:33 christos Exp $ */
+/* $NetBSD: sysconf.c,v 1.39 2016/06/10 23:29:20 christos Exp $ */
/*-
* Copyright (c) 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)sysconf.c 8.2 (Berkeley) 3/20/94";
#else
-__RCSID("$NetBSD: sysconf.c,v 1.38 2016/06/10 23:24:33 christos Exp $");
+__RCSID("$NetBSD: sysconf.c,v 1.39 2016/06/10 23:29:20 christos Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -422,6 +422,12 @@ yesno: if (sysctl(mib, mib_len, &value, &len, NULL, 0) == -1)
return _POSIX_TIMER_MAX;
case _SC_SEM_NSEMS_MAX:
return _POSIX_SEM_NSEMS_MAX;
+ case _SC_CPUTIME:
+ return _POSIX_CPUTIME;
+ case _SC_THREAD_CPUTIME:
+ return _POSIX_THREAD_CPUTIME;
+ case _SC_DELAYTIMER_MAX:
+ return _POSIX_DELAYTIMER_MAX;
default:
errno = EINVAL;
return (-1);
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index eb3c42e3488..c38dc137918 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_time.c,v 1.186 2016/04/23 23:08:26 christos Exp $ */
+/* $NetBSD: kern_time.c,v 1.187 2016/06/10 23:29:20 christos Exp $ */
/*-
* Copyright (c) 2000, 2004, 2005, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.186 2016/04/23 23:08:26 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_time.c,v 1.187 2016/06/10 23:29:20 christos Exp $");
#include <sys/param.h>
#include <sys/resourcevar.h>
@@ -97,6 +97,7 @@ CTASSERT(ITIMER_VIRTUAL == CLOCK_VIRTUAL);
CTASSERT(ITIMER_PROF == CLOCK_PROF);
CTASSERT(ITIMER_MONOTONIC == CLOCK_MONOTONIC);
+#define DELAYTIMER_MAX 32
/*
* Initialize timekeeping.
@@ -980,6 +981,8 @@ sys_timer_getoverrun(struct lwp *l, const struct sys_timer_getoverrun_args *uap,
return (EINVAL);
}
*retval = pt->pt_poverruns;
+ if (*retval >= DELAYTIMER_MAX)
+ *retval = DELAYTIMER_MAX;
mutex_spin_exit(&timer_lock);
return (0);
diff --git a/sys/sys/unistd.h b/sys/sys/unistd.h
index e11d5c011f4..a507e9a9149 100644
--- a/sys/sys/unistd.h
+++ b/sys/sys/unistd.h
@@ -1,4 +1,4 @@
-/* $NetBSD: unistd.h,v 1.57 2016/06/10 23:24:33 christos Exp $ */
+/* $NetBSD: unistd.h,v 1.58 2016/06/10 23:29:20 christos Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -309,6 +309,9 @@
#define _SC_TIMER_MAX 88
#define _SC_SEM_NSEMS_MAX 89
+#define _SC_CPUTIME 90
+#define _SC_THREAD_CPUTIME 91
+#define _SC_DELAYTIMER_MAX 92
/* Extensions found in Solaris and Linux. */
#define _SC_PHYS_PAGES 121