From 7b36c281ba1c99d528efca950572c207acd2e184 Mon Sep 17 00:00:00 2001 From: guenther Date: Mon, 17 Jun 2013 19:11:54 +0000 Subject: Add support for the _POSIX_CPUTIME and _POSIX_THREAD_CPUTIME options, including CLOCK_{PROCESS,THREAD}_CPUTIME_ID constants and {clock,pthread}_getcpuclockid() functions. Worked out at t2k13 with help from tedu@ and matthew@ and testing by aja@ ok matthew@ --- lib/libc/gen/clock_getcpuclockid.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/libc/gen/clock_getcpuclockid.c (limited to 'lib/libc/gen/clock_getcpuclockid.c') diff --git a/lib/libc/gen/clock_getcpuclockid.c b/lib/libc/gen/clock_getcpuclockid.c new file mode 100644 index 00000000000..f0c18aac1f5 --- /dev/null +++ b/lib/libc/gen/clock_getcpuclockid.c @@ -0,0 +1,31 @@ +/* $OpenBSD: clock_getcpuclockid.c,v 1.1 2013/06/17 19:11:54 guenther Exp $ */ +/* + * Copyright (c) 2013 Philip Guenther + * All Rights Reserved. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include + +int +clock_getcpuclockid(pid_t pid, clockid_t *clock_id) +{ + if (pid != 0 && pid != getpid()) + return (EPERM); + + *clock_id = CLOCK_PROCESS_CPUTIME_ID; + return (0); +} -- cgit v1.2.3-59-g8ed1b