From 0a5a512cc3bf8d41ca92a6f6cad4042032eed878 Mon Sep 17 00:00:00 2001
From: Tommy Olofsson <tommy.olofsson.90@gmail.com>
Date: Thu, 30 Jun 2016 14:32:53 +0200
Subject: [PATCH] Undo more unnecc. changes.

---
 lib/c/2014/labcomm2014_fd_reader.c |  1 +
 lib/c/2014/labcomm2014_fd_writer.c |  1 +
 lib/c/2014/labcomm2014_time.c      | 16 ++++++++++------
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/lib/c/2014/labcomm2014_fd_reader.c b/lib/c/2014/labcomm2014_fd_reader.c
index 23d5ba5..ad2d222 100644
--- a/lib/c/2014/labcomm2014_fd_reader.c
+++ b/lib/c/2014/labcomm2014_fd_reader.c
@@ -20,6 +20,7 @@
 */
 
 #include <errno.h>
+#include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 #include "labcomm2014_private.h"
diff --git a/lib/c/2014/labcomm2014_fd_writer.c b/lib/c/2014/labcomm2014_fd_writer.c
index 0e4d009..42c9dbc 100644
--- a/lib/c/2014/labcomm2014_fd_writer.c
+++ b/lib/c/2014/labcomm2014_fd_writer.c
@@ -20,6 +20,7 @@
 */
 
 #include <errno.h>
+#include <unistd.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdarg.h>
diff --git a/lib/c/2014/labcomm2014_time.c b/lib/c/2014/labcomm2014_time.c
index 8805f90..eb5e1f5 100644
--- a/lib/c/2014/labcomm2014_time.c
+++ b/lib/c/2014/labcomm2014_time.c
@@ -22,17 +22,21 @@
 #include <errno.h>
 #include "labcomm2014_scheduler_private.h"
 
+#define TIME_time(time, ...) time
+#define TIME(func, ...)						\
+  if (TIME_time(__VA_ARGS__) &&				\
+      TIME_time(__VA_ARGS__)->action->func) {			\
+    return TIME_time(__VA_ARGS__)->action->func(__VA_ARGS__);	\
+  }									\
+  return -ENOSYS;
+
 int labcomm2014_time_free(struct labcomm2014_time *s)
 {
-  if (s && s->action->free)
-    return s->action->free(s);
-  return -ENOSYS;
+  TIME(free, s);
 }
 
 int labcomm2014_time_add_usec(struct labcomm2014_time *s, uint32_t usec)
 {
-  if (s && s->action->add_usec)
-    return s->action->add_usec(s, usec);
-  return -ENOSYS;
+  TIME(add_usec, s, usec);
 }
 
-- 
GitLab