Welcome to The Fiwix Project
A UNIX-like kernel for the i386 architecture
1 /* 2 * fiwix/kernel/syscalls/getitimer.c 3 * 4 * Copyright 2018, Jordi Sanfeliu. All rights reserved. 5 * Distributed under the terms of the Fiwix License. 6 */ 7 8 #include <fiwix/fs.h> 9 #include <fiwix/time.h> 10 #include <fiwix/process.h> 11 #include <fiwix/errno.h> 12 13 #ifdef __DEBUG__ 14 #include <fiwix/stdio.h> 15 #endif /*__DEBUG__ */ 16 17 int sys_getitimer(int which, struct itimerval *curr_value) 18 { 19 int errno; 20 21 #ifdef __DEBUG__ 22 printk("(pid %d) sys_getitimer(%d, 0x%08x) -> \n", current->pid, which, (unsigned int)curr_value); 23 #endif /*__DEBUG__ */ 24 25 if((unsigned int)curr_value) { 26 if((errno = check_user_area(VERIFY_WRITE, curr_value, sizeof(struct itimerval)))) { 27 return errno; 28 } 29 } 30 31 switch(which) { 32 case ITIMER_REAL: 33 ticks2tv(current->it_real_interval, &curr_value->it_interval); 34 ticks2tv(current->it_real_value, &curr_value->it_value); 35 break; 36 case ITIMER_VIRTUAL: 37 ticks2tv(current->it_virt_interval, &curr_value->it_interval); 38 ticks2tv(current->it_virt_value, &curr_value->it_value); 39 break; 40 case ITIMER_PROF: 41 ticks2tv(current->it_prof_interval, &curr_value->it_interval); 42 ticks2tv(current->it_prof_value, &curr_value->it_value); 43 break; 44 default: 45 return -EINVAL; 46 } 47 return 0; 48 }