GSoC 2016: Charles Cui: Add timer related macros

_POSIX_CPUTIME
    _POSIX_THREAD_CPUTIME
    _POSIX_DELAYTIMER_MAX
This commit is contained in:
christos 2016-06-10 23:29:20 +00:00
parent 0cdaab3d0b
commit ea2913a0a2
5 changed files with 31 additions and 7 deletions

View File

@ -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

View File

@ -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.

View File

@ -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);

View File

@ -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);

View File

@ -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