aboutsummaryrefslogtreecommitdiffstats
path: root/modules/tm_posix
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-05-18 18:33:19 +0000
committerlloyd <[email protected]>2006-05-18 18:33:19 +0000
commita2c99d3270eb73ef2db5704fc54356c6b75096f8 (patch)
treead3d6c4fcc8dd0f403f8105598943616246fe172 /modules/tm_posix
Initial checkin1.5.6
Diffstat (limited to 'modules/tm_posix')
-rw-r--r--modules/tm_posix/modinfo.txt19
-rw-r--r--modules/tm_posix/tm_posix.cpp31
-rw-r--r--modules/tm_posix/tm_posix.h24
3 files changed, 74 insertions, 0 deletions
diff --git a/modules/tm_posix/modinfo.txt b/modules/tm_posix/modinfo.txt
new file mode 100644
index 000000000..df8d63122
--- /dev/null
+++ b/modules/tm_posix/modinfo.txt
@@ -0,0 +1,19 @@
+realname "POSIX Timer"
+
+define TIMER_POSIX
+
+add_file tm_posix.cpp
+add_file tm_posix.h
+
+<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/tm_posix/tm_posix.cpp b/modules/tm_posix/tm_posix.cpp
new file mode 100644
index 000000000..bec82bc41
--- /dev/null
+++ b/modules/tm_posix/tm_posix.cpp
@@ -0,0 +1,31 @@
+/*************************************************
+* POSIX Timer Source File *
+* (C) 1999-2006 The Botan Project *
+*************************************************/
+
+#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/tm_posix/tm_posix.h b/modules/tm_posix/tm_posix.h
new file mode 100644
index 000000000..9a921ab3e
--- /dev/null
+++ b/modules/tm_posix/tm_posix.h
@@ -0,0 +1,24 @@
+/*************************************************
+* POSIX Timer Header File *
+* (C) 1999-2006 The Botan Project *
+*************************************************/
+
+#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