]> granicus.if.org Git - check/commitdiff
Adding files that were missed in the previous commit
authorbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Sun, 25 Nov 2012 15:24:58 +0000 (15:24 +0000)
committerbrarcher <brarcher@64e312b2-a51f-0410-8e61-82d0ca0eb02a>
Sun, 25 Nov 2012 15:24:58 +0000 (15:24 +0000)
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 [new file with mode: 0644]
lib/timer_delete.c [new file with mode: 0644]
lib/timer_settime.c [new file with mode: 0644]

diff --git a/lib/timer_create.c b/lib/timer_create.c
new file mode 100644 (file)
index 0000000..4d01b61
--- /dev/null
@@ -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 (file)
index 0000000..4228b37
--- /dev/null
@@ -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 (file)
index 0000000..39ec613
--- /dev/null
@@ -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;
+}