summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2013-07-04 16:46:30 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2013-07-04 16:46:30 +0200
commitb9ce6027dde8b3c6fd002d38e3cee07e7711d73c (patch)
tree3adf5e718ffc28f300f2449f115f628162fe96f2
parent67d068f7c843e980141cbabad9560154024a1366 (diff)
downloadufodecode-b9ce6027dde8b3c6fd002d38e3cee07e7711d73c.tar.gz
ufodecode-b9ce6027dde8b3c6fd002d38e3cee07e7711d73c.tar.bz2
ufodecode-b9ce6027dde8b3c6fd002d38e3cee07e7711d73c.tar.xz
ufodecode-b9ce6027dde8b3c6fd002d38e3cee07e7711d73c.zip
Move timer functions into timer.{c,h}
-rw-r--r--test/CMakeLists.txt13
-rw-r--r--test/ipedec.c37
-rw-r--r--test/timer.c33
-rw-r--r--test/timer.h17
4 files changed, 63 insertions, 37 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index aea7b7d..7539c19 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,9 +1,20 @@
# --- Build test executable -------------------------------------------------
+include(CheckIncludeFile)
+
+check_include_file("sys/time.h" HAVE_SYS_TIME_H)
+
+if (NOT HAVE_SYS_TIME_H)
+ message(FATAL_ERROR "sys/time.h not found")
+endif()
+
include_directories(
${CMAKE_SOURCE_DIR}/src
)
-add_executable(ipedec ipedec.c)
+add_executable(ipedec
+ ipedec.c
+ timer.c)
+
target_link_libraries(ipedec ufodecode)
install(TARGETS ipedec DESTINATION ${BIN_INSTALL_DIR})
diff --git a/test/ipedec.c b/test/ipedec.c
index 6e48c14..52aebb0 100644
--- a/test/ipedec.c
+++ b/test/ipedec.c
@@ -4,9 +4,9 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
-#include <sys/time.h>
#include <getopt.h>
#include <ufodecode.h>
+#include "timer.h"
static const int MAX_ROWS = 2048;
@@ -103,41 +103,6 @@ print_meta_data (UfoDecoderMeta *meta)
printf("\n");
}
-typedef struct {
- struct timeval start;
- long seconds;
- long useconds;
-} Timer;
-
-static Timer *
-timer_new (void)
-{
- Timer *t = (Timer *) malloc (sizeof (Timer));
- t->seconds = t->useconds = 0L;
- return t;
-}
-
-static void
-timer_destroy (Timer *t)
-{
- free (t);
-}
-
-static void
-timer_start (Timer *t)
-{
- gettimeofday(&t->start, NULL);
-}
-
-static void
-timer_stop (Timer *t)
-{
- struct timeval end;
-
- gettimeofday(&end, NULL);
- t->seconds += end.tv_sec - t->start.tv_sec;
- t->useconds += end.tv_usec - t->start.tv_usec;
-}
static int
process_file(const char *filename, Options *opts)
diff --git a/test/timer.c b/test/timer.c
new file mode 100644
index 0000000..43aff84
--- /dev/null
+++ b/test/timer.c
@@ -0,0 +1,33 @@
+#include <stdlib.h>
+#include "timer.h"
+
+
+Timer *
+timer_new (void)
+{
+ Timer *t = (Timer *) malloc (sizeof (Timer));
+ t->seconds = t->useconds = 0L;
+ return t;
+}
+
+void
+timer_destroy (Timer *t)
+{
+ free (t);
+}
+
+void
+timer_start (Timer *t)
+{
+ gettimeofday(&t->start, NULL);
+}
+
+void
+timer_stop (Timer *t)
+{
+ struct timeval end;
+
+ gettimeofday(&end, NULL);
+ t->seconds += end.tv_sec - t->start.tv_sec;
+ t->useconds += end.tv_usec - t->start.tv_usec;
+}
diff --git a/test/timer.h b/test/timer.h
new file mode 100644
index 0000000..272f69d
--- /dev/null
+++ b/test/timer.h
@@ -0,0 +1,17 @@
+#ifndef TIMER_H
+#define TIMER_H
+
+#include <sys/time.h>
+
+typedef struct {
+ struct timeval start;
+ long seconds;
+ long useconds;
+} Timer;
+
+Timer * timer_new (void);
+void timer_destroy (Timer *t);
+void timer_start (Timer *t);
+void timer_stop (Timer *t);
+
+#endif