Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
git-mirror
/
glibc
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
0
Security
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security
Insights
Files
5722153
abilist
aout
argp
assert
bare
bits
catgets
conf
conform
crypt
csu
ctype
debug
dirent
dlfcn
elf
gmon
gnulib
grp
hesiod
hurd
iconv
iconvdata
include
inet
intl
io
libidn
libio
linuxthreads
linuxthreads_db
locale
localedata
login
mach
malloc
manual
math
misc
nis
nptl
nptl_db
nscd
nss
po
posix
pwd
resolv
resource
rt
scripts
setjmp
shadow
signal
socket
soft-fp
stdio-common
stdlib
streams
string
sunrpc
sysdeps
alpha
arm
generic
gnu
hppa
i386
ia64
ieee754
m68k
mach
mips
posix
powerpc
pthread
rs6000
s390
sh
sparc
unix
alpha
arm
bsd
common
i386
inet
mips
mman
powerpc
sh
sparc
sysv
bits
i386
linux
alpha
arm
bits
hppa
i386
ia64
m68k
mips
net
netash
netatalk
netax25
neteconet
netinet
netipx
netpacket
netrom
netrose
nfs
powerpc
s390
scsi
sh
sparc
sys
wordsize-64
x86_64
Dist
Implies
Makefile
Versions
_exit.c
a.out.h
accept.S
adjtime.c
aio_sigqueue.c
bind.S
check_pf.c
clock.c
clock_getcpuclockid.c
clock_getres.c
clock_gettime.c
clock_nanosleep.c
clock_settime.c
cmsg_nxthdr.c
configure
configure.in
connect.S
device-nrs.h
dl-brk.c
dl-execstack.c
dl-librecon.h
dl-origin.c
dl-osinfo.h
dl-sbrk.c
dl-sysdep.c
dl-sysdep.h
errqueue.h
execve.c
exit-thread.S
fatal-prepare.h
fcntl.c
fd_to_filename.h
fexecve.c
fpathconf.c
fstatfs64.c
fstatvfs.c
fstatvfs64.c
ftime.c
ftruncate64.c
futimes.c
fxstat.c
fxstat64.c
gai_sigqueue.c
getclktck.c
getcwd.c
getdents.c
getdents64.c
getdirentries.c
getdirentries64.c
getdtsz.c
gethostid.c
getipv4sourcefilter.c
getloadavg.c
getpagesize.c
getpeername.S
getpriority.c
getpt.c
getsockname.S
getsockopt.S
getsourcefilter.c
getsysstats.c
grantpt.c
if_index.c
ifaddrs.c
ifreq.c
ifreq.h
init-first.c
internal_statvfs.c
internal_statvfs64.c
ipc_priv.h
kernel-features.h
kernel-posix-cpu-timers.h
kernel_sigaction.h
kernel_stat.h
kernel_termios.h
ldd-rewrite.sed
lddlibc4.c
ldsodefs.h
libc_fatal.c
linux_fsinfo.h
listen.S
llseek.c
lseek64.c
lxstat.c
lxstat64.c
makedev.c
mmap64.c
mq_close.c
mq_getattr.c
mq_notify.c
mq_open.c
mq_receive.c
mq_send.c
mq_unlink.c
msgctl.c
msgget.c
msgrcv.c
msgsnd.c
netlinkaccess.h
nice.c
not-cancel.h
nscd_setup_thread.c
ntp_gettime.c
open64.c
opendir.c
opensock.c
pathconf.c
pathconf.h
paths.h
poll.c
posix_fadvise.c
posix_fadvise64.c
pread.c
pread64.c
prof-freq.c
profil.c
ptrace.c
ptsname.c
pwrite.c
pwrite64.c
readahead.c
readdir64.c
readdir64_r.c
readonly-area.c
readv.c
reboot.c
recv.S
recvfrom.S
recvmsg.S
sa_len.c
sched_getaffinity.c
sched_setaffinity.c
segfault.c
semctl.c
semget.c
semop.c
semtimedop.c
send.S
sendmsg.S
sendto.S
setegid.c
seteuid.c
setgid.c
sethostid.c
setipv4sourcefilter.c
setregid.c
setresgid.c
setresuid.c
setreuid.c
setsockopt.S
setsourcefilter.c
setuid.c
shm_open.c
shm_unlink.c
shmat.c
shmctl.c
shmdt.c
shmget.c
shutdown.S
sigaction.c
siglist.h
signal.c
sigpending.c
sigprocmask.c
sigqueue.c
sigreturn.c
sigset-cvt-mask.h
sigstack.c
sigsuspend.c
sigtimedwait.c
sigwait.c
sigwaitinfo.c
sizes.h
sleep.c
socketcall.h
socketpair.S
speed.c
statfs64.c
statvfs.c
statvfs64.c
syscalls.list
sysconf.c
sysctl.c
syslog.c
system.c
tcdrain.c
tcflow.c
tcflush.c
tcgetattr.c
tcgetpgrp.c
tcsetattr.c
tcsetpgrp.c
termio.h
testrtsig.h
truncate64.c
ttyname.c
ttyname_r.c
ualarm.c
ulimit.c
umount.S
umount2.S
unlockpt.c
updwtmp.c
usleep.c
ustat.c
utimes.c
utmp_file.c
vfork.c
wait.c
wait3.c
waitid.c
waitpid.c
writev.c
xmknod.c
xstat.c
xstat64.c
xstatconv.c
xstatconv.h
Dist
Makefile
Versions
direct.h
getdents.c
gethostname.c
setrlimit.c
settimeofday.c
sigaction.c
syscalls.list
sysv_termio.h
tcdrain.c
tcflow.c
tcflush.c
tcgetattr.c
tcgetpgrp.c
tcsendbrk.c
tcsetattr.c
tcsetpgrp.c
x86_64
Dist
Implies
Makefile
Subdirs
_exit.S
alarm.c
clock_gettime.c
clock_nanosleep.c
clock_settime.c
closedir.c
configure
configure.in
confstr.h
dirfd.c
dirstream.h
errnos-tmpl.c
errnos.awk
execve.S
fork.S
fxstat.c
getdents.c
getegid.S
geteuid.S
getlogin.c
getlogin_r.c
getpagesize.c
getppid.S
grantpt.c
ioctls-tmpl.c
ioctls.awk
make-syscalls.sh
make_errlist.c
mk-local_lim.c
mkdir.c
mkfifo.c
nice.c
opendir.c
readdir.c
readdir_r.c
rewinddir.c
rmdir.c
s-proto-bp.S
s-proto-cancel.S
s-proto.S
seekdir.c
setxid.h
siglist.c
snarf-ioctls
sockatmark.c
start.c
stime.c
syscall.S
syscalls.list
sysdep.h
system.c
telldir.c
time.c
utime.c
xmknod.c
xstat.c
wordsize-32
wordsize-64
x86_64
linkmap.h
sysvipc
termios
time
timezone
wcsmbs
wctype
.cvsignore
BUGS
CANCEL-FCT-WAIVE
CANCEL-FILE-WAIVE
CONFORMANCE
COPYING
COPYING.LIB
ChangeLog
ChangeLog.1
ChangeLog.10
ChangeLog.11
ChangeLog.12
ChangeLog.13
ChangeLog.14
ChangeLog.15
ChangeLog.2
ChangeLog.3
ChangeLog.4
ChangeLog.5
ChangeLog.6
ChangeLog.7
ChangeLog.8
ChangeLog.9
FAQ
FAQ.in
INSTALL
INTERFACE
LICENSES
MakeTAGS
Makeconfig
Makefile
Makefile.in
Makerules
NAMESPACE
NEWS
NOTES
PROJECTS
README
README.libm
README.template
Rules
Versions.def
WUR-REPORT
abi-tags
aclocal.m4
config-name.in
config.h.in
config.make.in
configure
configure.in
cppflags-iterator.mk
extra-lib.mk
extra-modules.mk
o-iterator.mk
shlib-versions
test-skeleton.c
tls.make.c
version.h
Breadcrumbs
glibc
/
sysdeps
/
unix
/
sysv
/
linux
/
clock_getcpuclockid.c
Blame
Blame
Latest commit
History
History
103 lines (90 loc) · 3.06 KB
Breadcrumbs
glibc
/
sysdeps
/
unix
/
sysv
/
linux
/
clock_getcpuclockid.c
Top
File metadata and controls
Code
Blame
103 lines (90 loc) · 3.06 KB
Raw
/* clock_getcpuclockid -- Get a clockid_t for process CPU time. Linux version. Copyright (C) 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include <errno.h> #include <time.h> #include <unistd.h> #include "kernel-features.h" #include "kernel-posix-cpu-timers.h" #ifndef HAS_CPUCLOCK # define HAS_CPUCLOCK 1 #endif int clock_getcpuclockid (pid_t pid, clockid_t *clock_id) { #ifdef __NR_clock_getres /* The clockid_t value is a simple computation from the PID. But we do a clock_getres call to validate it. */ const clockid_t pidclock = MAKE_PROCESS_CPUCLOCK (pid, CPUCLOCK_SCHED); # if !(__ASSUME_POSIX_CPU_TIMERS > 0) extern int __libc_missing_posix_cpu_timers attribute_hidden; # if !(__ASSUME_POSIX_TIMERS > 0) extern int __libc_missing_posix_timers attribute_hidden; if (__libc_missing_posix_timers && !__libc_missing_posix_cpu_timers) __libc_missing_posix_cpu_timers = 1; # endif if (!__libc_missing_posix_cpu_timers) # endif { INTERNAL_SYSCALL_DECL (err); int r = INTERNAL_SYSCALL (clock_getres, err, 2, pidclock, NULL); if (!INTERNAL_SYSCALL_ERROR_P (r, err)) { *clock_id = pidclock; return 0; } # if !(__ASSUME_POSIX_TIMERS > 0) if (INTERNAL_SYSCALL_ERRNO (r, err) == ENOSYS) { /* The kernel doesn't support these calls at all. */ __libc_missing_posix_timers = 1; __libc_missing_posix_cpu_timers = 1; } else # endif if (INTERNAL_SYSCALL_ERRNO (r, err) == EINVAL) { # if !(__ASSUME_POSIX_CPU_TIMERS > 0) if (pidclock == MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED) || INTERNAL_SYSCALL_ERROR_P (INTERNAL_SYSCALL (clock_getres, err, 2, MAKE_PROCESS_CPUCLOCK (0, CPUCLOCK_SCHED), NULL), err)) /* The kernel doesn't support these clocks at all. */ __libc_missing_posix_cpu_timers = 1; else # endif /* The clock_getres system call checked the PID for us. */ return ESRCH; } else return INTERNAL_SYSCALL_ERRNO (r, err); } #endif /* We don't allow any process ID but our own. */ if (pid != 0 && pid != getpid ()) return EPERM; #ifdef CLOCK_PROCESS_CPUTIME_ID if (HAS_CPUCLOCK) { /* Store the number. */ *clock_id = CLOCK_PROCESS_CPUTIME_ID; return 0; } #endif /* We don't have a timer for that. */ return ENOENT; }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
You can’t perform that action at this time.