Blame sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
|
Packit Service |
c82647 |
/* Copyright (C) 2000-2018 Free Software Foundation, Inc.
|
|
Packit Service |
c82647 |
This file is part of the GNU C Library.
|
|
Packit Service |
c82647 |
|
|
Packit Service |
c82647 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
c82647 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
c82647 |
License as published by the Free Software Foundation; either
|
|
Packit Service |
c82647 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
c82647 |
|
|
Packit Service |
c82647 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
c82647 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
c82647 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
c82647 |
Lesser General Public License for more details.
|
|
Packit Service |
c82647 |
|
|
Packit Service |
c82647 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
c82647 |
License along with the GNU C Library; if not, see
|
|
Packit Service |
c82647 |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
c82647 |
|
|
Packit Service |
c82647 |
#include <errno.h>
|
|
Packit Service |
c82647 |
#include <fcntl.h>
|
|
Packit Service |
c82647 |
#include <unistd.h>
|
|
Packit Service |
c82647 |
#include <sys/stat.h>
|
|
Packit Service |
c82647 |
#include <sys/types.h>
|
|
Packit Service |
c82647 |
#include <not-cancel.h>
|
|
Packit Service |
c82647 |
|
|
Packit Service |
c82647 |
static int itc_usable;
|
|
Packit Service |
c82647 |
|
|
Packit Service |
c82647 |
static int
|
|
Packit Service |
c82647 |
has_cpuclock (void)
|
|
Packit Service |
c82647 |
{
|
|
Packit Service |
c82647 |
if (__builtin_expect (itc_usable == 0, 0))
|
|
Packit Service |
c82647 |
{
|
|
Packit Service |
c82647 |
int newval = 1;
|
|
Packit Service |
c82647 |
int fd = __open_nocancel ("/proc/sal/itc_drift", O_RDONLY);
|
|
Packit Service |
c82647 |
if (__builtin_expect (fd != -1, 1))
|
|
Packit Service |
c82647 |
{
|
|
Packit Service |
c82647 |
char buf[16];
|
|
Packit Service |
c82647 |
/* We expect the file to contain a single digit followed by
|
|
Packit Service |
c82647 |
a newline. If the format changes we better not rely on
|
|
Packit Service |
c82647 |
the file content. */
|
|
Packit Service |
c82647 |
if (__read_nocancel (fd, buf, sizeof buf) != 2
|
|
Packit Service |
c82647 |
|| buf[0] != '0' || buf[1] != '\n')
|
|
Packit Service |
c82647 |
newval = -1;
|
|
Packit Service |
c82647 |
|
|
Packit Service |
c82647 |
__close_nocancel_nostatus (fd);
|
|
Packit Service |
c82647 |
}
|
|
Packit Service |
c82647 |
|
|
Packit Service |
c82647 |
itc_usable = newval;
|
|
Packit Service |
c82647 |
}
|
|
Packit Service |
c82647 |
|
|
Packit Service |
c82647 |
return itc_usable;
|
|
Packit Service |
c82647 |
}
|