Blame time/clock_getcpuclockid.c

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