Skip to content

Commit

Permalink
GSoC 2016: Charles Cui: Add timer related macros
Browse files Browse the repository at this point in the history
    _POSIX_CPUTIME
    _POSIX_THREAD_CPUTIME
    _POSIX_DELAYTIMER_MAX
  • Loading branch information
zoulasc committed Jun 10, 2016
1 parent c89ebb2 commit 053c58f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 7 deletions.
5 changes: 4 additions & 1 deletion include/limits.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Expand Down
11 changes: 10 additions & 1 deletion lib/libc/gen/sysconf.3
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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.
Expand Down
10 changes: 8 additions & 2 deletions lib/libc/gen/sysconf.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 */

Expand Down Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions sys/kern/kern_time.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion sys/sys/unistd.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 053c58f

Please sign in to comment.