aboutsummaryrefslogtreecommitdiffstats
path: root/modules/timer/posix_rt
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-28 15:34:09 +0000
committerlloyd <[email protected]>2008-09-28 15:34:09 +0000
commitea32d18231b9c6c5c84b3754c4249170d3b4e4c0 (patch)
treecc179337d0594ed105768011722b9dbae105e07a /modules/timer/posix_rt
parentb841401e095cfc1aa0708689d7920eb95ece71af (diff)
This is the first checkin to net.randombit.botan.modularized, which
has the intent of modularizing Botan's source code, and making it much easier to add or remove various things at compile time. In this first checkin: Add support for nested directories in modules/ and move all the modules into grouped directories like entropy/ or compression/ Currently this is not ideal, it will _only_ find code in modules/*/*/modinfo.txt, while it would be much better to allow for arbitrary nestings under modules (find modules -name modinfo.txt) for more complicated setups. This 'new' (OMG I've found directories!) structure allows for a more free naming convention (no need for leading es_, ml_, etc to group names, though some keep it for lack of a more meaningful name being obvious to me right at the moment).
Diffstat (limited to 'modules/timer/posix_rt')
-rw-r--r--modules/timer/posix_rt/modinfo.txt23
-rw-r--r--modules/timer/posix_rt/tm_posix.cpp31
-rw-r--r--modules/timer/posix_rt/tm_posix.h24
3 files changed, 78 insertions, 0 deletions
diff --git a/modules/timer/posix_rt/modinfo.txt b/modules/timer/posix_rt/modinfo.txt
new file mode 100644
index 000000000..e9298a81c
--- /dev/null
+++ b/modules/timer/posix_rt/modinfo.txt
@@ -0,0 +1,23 @@
+realname "POSIX Timer"
+
+define TIMER_POSIX
+
+load_on auto
+
+<add>
+tm_posix.cpp
+tm_posix.h
+</add>
+
+<libs>
+linux -> rt
+</libs>
+
+# The *BSDs put clock_gettime in sys/time.h, not time.h like POSIX says
+<os>
+cygwin
+linux
+#freebsd
+#netbsd
+#openbsd
+</os>
diff --git a/modules/timer/posix_rt/tm_posix.cpp b/modules/timer/posix_rt/tm_posix.cpp
new file mode 100644
index 000000000..601b2b43d
--- /dev/null
+++ b/modules/timer/posix_rt/tm_posix.cpp
@@ -0,0 +1,31 @@
+/*************************************************
+* POSIX Timer Source File *
+* (C) 1999-2007 Jack Lloyd *
+*************************************************/
+
+#include <botan/tm_posix.h>
+#include <botan/util.h>
+
+#ifndef _POSIX_C_SOURCE
+ #define _POSIX_C_SOURCE 199309
+#endif
+
+#include <time.h>
+
+#ifndef CLOCK_REALTIME
+ #define CLOCK_REALTIME 0
+#endif
+
+namespace Botan {
+
+/*************************************************
+* Get the timestamp *
+*************************************************/
+u64bit POSIX_Timer::clock() const
+ {
+ struct ::timespec tv;
+ ::clock_gettime(CLOCK_REALTIME, &tv);
+ return combine_timers(tv.tv_sec, tv.tv_nsec, 1000000000);
+ }
+
+}
diff --git a/modules/timer/posix_rt/tm_posix.h b/modules/timer/posix_rt/tm_posix.h
new file mode 100644
index 000000000..60fa8f844
--- /dev/null
+++ b/modules/timer/posix_rt/tm_posix.h
@@ -0,0 +1,24 @@
+/*************************************************
+* POSIX Timer Header File *
+* (C) 1999-2007 Jack Lloyd *
+*************************************************/
+
+#ifndef BOTAN_EXT_TIMER_POSIX_H__
+#define BOTAN_EXT_TIMER_POSIX_H__
+
+#include <botan/timers.h>
+
+namespace Botan {
+
+/*************************************************
+* POSIX Timer *
+*************************************************/
+class POSIX_Timer : public Timer
+ {
+ public:
+ u64bit clock() const;
+ };
+
+}
+
+#endif