diff options
author | 2013-06-17 19:11:54 +0000 | |
---|---|---|
committer | 2013-06-17 19:11:54 +0000 | |
commit | 7b36c281ba1c99d528efca950572c207acd2e184 (patch) | |
tree | f5c2b481403a1c10e5fb3838834ab4fd89d0397e /lib/libc/gen/clock_getcpuclockid.c | |
parent | 2nd part of: (diff) | |
download | wireguard-openbsd-7b36c281ba1c99d528efca950572c207acd2e184.tar.xz wireguard-openbsd-7b36c281ba1c99d528efca950572c207acd2e184.zip |
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@
Diffstat (limited to 'lib/libc/gen/clock_getcpuclockid.c')
-rw-r--r-- | lib/libc/gen/clock_getcpuclockid.c | 31 |
1 files changed, 31 insertions, 0 deletions
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 <guenther@openbsd.org> + * 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 <time.h> +#include <unistd.h> +#include <errno.h> + +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); +} |