From f9b8cfd2873b0bee86a45cbfc63ee5093c359e77 Mon Sep 17 00:00:00 2001 From: brarcher Date: Sun, 25 Nov 2012 15:24:58 +0000 Subject: [PATCH] Adding files that were missed in the previous commit The libcompat files for creating/modifying/deleting timers was missed in the previous commit. git-svn-id: svn+ssh://svn.code.sf.net/p/check/code/trunk@680 64e312b2-a51f-0410-8e61-82d0ca0eb02a --- lib/timer_create.c | 14 ++++++++++++++ lib/timer_delete.c | 14 ++++++++++++++ lib/timer_settime.c | 22 ++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 lib/timer_create.c create mode 100644 lib/timer_delete.c create mode 100644 lib/timer_settime.c diff --git a/lib/timer_create.c b/lib/timer_create.c new file mode 100644 index 0000000..4d01b61 --- /dev/null +++ b/lib/timer_create.c @@ -0,0 +1,14 @@ +#include "libcompat.h" + +int timer_create(int clockid CK_ATTRIBUTE_UNUSED, + struct sigevent *sevp CK_ATTRIBUTE_UNUSED, + timer_t *timerid CK_ATTRIBUTE_UNUSED) +{ + /* + * The create function does nothing. timer_settime will use + * alarm to set the timer, and timer_delete will stop the + * alarm + */ + + return 0; +} diff --git a/lib/timer_delete.c b/lib/timer_delete.c new file mode 100644 index 0000000..4228b37 --- /dev/null +++ b/lib/timer_delete.c @@ -0,0 +1,14 @@ +#include "libcompat.h" + +int timer_delete(timer_t timerid CK_ATTRIBUTE_UNUSED) +{ + /* + * There is only one timer, that used by alarm. + * Setting alarm(0) will not set a new alarm, and + * will kill the previous timer. + */ + + alarm(0); + + return 0; +} diff --git a/lib/timer_settime.c b/lib/timer_settime.c new file mode 100644 index 0000000..39ec613 --- /dev/null +++ b/lib/timer_settime.c @@ -0,0 +1,22 @@ +#include "libcompat.h" + +int timer_settime(timer_t timerid CK_ATTRIBUTE_UNUSED, + int flags CK_ATTRIBUTE_UNUSED, + const struct itimerspec *new_value, + struct itimerspec * old_value CK_ATTRIBUTE_UNUSED) +{ + int seconds = new_value->it_value.tv_sec; + + /* + * As the alarm() call has only second precision, if the caller + * specifies partial seconds, we round up to the nearest second. + */ + if(new_value->it_value.tv_nsec > 0) + { + seconds += 1; + } + + alarm(seconds); + + return 0; +} -- 2.40.0