|
Packit Service |
0b245c |
/* Get a clockid_t for the process CPU clock of a given process. Generic.
|
|
Packit Service |
0b245c |
Copyright (C) 2000-2018 Free Software Foundation, Inc.
|
|
Packit Service |
0b245c |
This file is part of the GNU C Library.
|
|
Packit Service |
0b245c |
|
|
Packit Service |
0b245c |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
0b245c |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
0b245c |
License as published by the Free Software Foundation; either
|
|
Packit Service |
0b245c |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
0b245c |
|
|
Packit Service |
0b245c |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
0b245c |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
0b245c |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
0b245c |
Lesser General Public License for more details.
|
|
Packit Service |
0b245c |
|
|
Packit Service |
0b245c |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
0b245c |
License along with the GNU C Library; if not, see
|
|
Packit Service |
0b245c |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
0b245c |
|
|
Packit Service |
0b245c |
#include <errno.h>
|
|
Packit Service |
0b245c |
#include <time.h>
|
|
Packit Service |
0b245c |
#include <unistd.h>
|
|
Packit Service |
a656f2 |
#include <shlib-compat.h>
|
|
Packit Service |
0b245c |
|
|
Packit Service |
0b245c |
int
|
|
Packit Service |
0b245c |
__clock_getcpuclockid (pid_t pid, clockid_t *clock_id)
|
|
Packit Service |
0b245c |
{
|
|
Packit Service |
0b245c |
/* We don't allow any process ID but our own. */
|
|
Packit Service |
0b245c |
if (pid != 0 && pid != getpid ())
|
|
Packit Service |
0b245c |
return EPERM;
|
|
Packit Service |
0b245c |
|
|
Packit Service |
0b245c |
#ifdef CLOCK_PROCESS_CPUTIME_ID
|
|
Packit Service |
0b245c |
/* Store the number. */
|
|
Packit Service |
0b245c |
*clock_id = CLOCK_PROCESS_CPUTIME_ID;
|
|
Packit Service |
0b245c |
|
|
Packit Service |
0b245c |
return 0;
|
|
Packit Service |
0b245c |
#else
|
|
Packit Service |
0b245c |
/* We don't have a timer for that. */
|
|
Packit Service |
0b245c |
return ENOENT;
|
|
Packit Service |
0b245c |
#endif
|
|
Packit Service |
0b245c |
}
|
|
Packit Service |
a656f2 |
versioned_symbol (libc, __clock_getcpuclockid, clock_getcpuclockid, GLIBC_2_17);
|
|
Packit Service |
a656f2 |
/* clock_getcpuclockid moved to libc in version 2.17;
|
|
Packit Service |
a656f2 |
old binaries may expect the symbol version it had in librt. */
|
|
Packit Service |
a656f2 |
#if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_17)
|
|
Packit Service |
a656f2 |
strong_alias (__clock_getcpuclockid, __clock_getcpuclockid_2);
|
|
Packit Service |
a656f2 |
compat_symbol (libc, __clock_getcpuclockid_2, clock_getcpuclockid, GLIBC_2_2);
|
|
Packit Service |
a656f2 |
#endif
|