Blame rt/clock_getcpuclockid.c

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