| 285 | } |
| 286 | |
| 287 | static int |
| 288 | get_cputime(struct thread *td, clockid_t clock_id, struct timespec *ats) |
| 289 | { |
| 290 | struct proc *p, *p2; |
| 291 | struct thread *td2; |
| 292 | lwpid_t tid; |
| 293 | pid_t pid; |
| 294 | int error; |
| 295 | |
| 296 | p = td->td_proc; |
| 297 | if ((clock_id & CPUCLOCK_PROCESS_BIT) == 0) { |
| 298 | tid = clock_id & CPUCLOCK_ID_MASK; |
| 299 | td2 = tdfind(tid, p->p_pid); |
| 300 | if (td2 == NULL) |
| 301 | return (EINVAL); |
| 302 | kern_thread_cputime(td2, ats); |
| 303 | PROC_UNLOCK(td2->td_proc); |
| 304 | } else { |
| 305 | pid = clock_id & CPUCLOCK_ID_MASK; |
| 306 | error = pget(pid, PGET_CANSEE, &p2); |
| 307 | if (error != 0) |
| 308 | return (EINVAL); |
| 309 | kern_process_cputime(p2, ats); |
| 310 | PROC_UNLOCK(p2); |
| 311 | } |
| 312 | return (0); |
| 313 | } |
| 314 | |
| 315 | int |
| 316 | kern_clock_gettime(struct thread *td, clockid_t clock_id, struct timespec *ats) |
no test coverage detected