summaryrefslogtreecommitdiffstats
path: root/core/timer.h
diff options
context:
space:
mode:
authorGravatar Christof Arnosti <charno@charno.ch>2020-03-10 22:58:24 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-03-10 17:42:54 -0700
commitcb28158b9abe10f08142f12f11ddbb5d23686fd5 (patch)
tree1d3aec604dfe116accf10326a3f4fe2cca3bf975 /core/timer.h
parentb6163804fd56acf23bf6156a84cad02bc6f6eb08 (diff)
downloadsubsurface-cb28158b9abe10f08142f12f11ddbb5d23686fd5.tar.gz
Add timestamps to libdivecomputer.log
Since I learned while trying to implement this that getting sub-second resolution time in portable C99 is hard (especially for someone who is used to the comfort of std::chrono and Howard Hinnants date library) the timer-implemetation from libdivecomputer is now copied to the subsurface source. Signed-off-by: Christof Arnosti <charno@charno.ch>
Diffstat (limited to 'core/timer.h')
-rw-r--r--core/timer.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/core/timer.h b/core/timer.h
new file mode 100644
index 000000000..651991ff9
--- /dev/null
+++ b/core/timer.h
@@ -0,0 +1,51 @@
+/*
+ * libdivecomputer
+ *
+ * Copyright (C) 2018 Jef Driesen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301 USA
+ */
+
+#ifndef DC_TIMER_H
+#define DC_TIMER_H
+
+#include <libdivecomputer/common.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#if defined (_WIN32) && !defined (__GNUC__)
+typedef unsigned __int64 dc_usecs_t;
+#else
+typedef unsigned long long dc_usecs_t;
+#endif
+
+typedef struct dc_timer_t dc_timer_t;
+
+dc_status_t
+dc_timer_new (dc_timer_t **timer);
+
+dc_status_t
+dc_timer_now (dc_timer_t *timer, dc_usecs_t *usecs);
+
+dc_status_t
+dc_timer_free (dc_timer_t *timer);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* DC_TIMER_H */