summaryrefslogtreecommitdiff
path: root/otherlibs/win32unix/times.c
diff options
context:
space:
mode:
authorAlain Frisch <alain@frisch.fr>2012-01-18 08:31:11 +0000
committerAlain Frisch <alain@frisch.fr>2012-01-18 08:31:11 +0000
commitc45bcb892d78f3182acb2805aef7ec6e23cce42a (patch)
treeb92b5d6becb9e67a198bc2e070d748eeef62bc3d /otherlibs/win32unix/times.c
parentcdbb84ec682704379bac21a633cbd2b9e93b35a8 (diff)
parent869feeb00704e0640c45ffe6aee6cc13e4077f79 (diff)
downloadocaml-unused_declarations.tar.gz
Synchronize with trunk.unused_declarations
git-svn-id: http://caml.inria.fr/svn/ocaml/branches/unused_declarations@12034 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/win32unix/times.c')
-rw-r--r--otherlibs/win32unix/times.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/otherlibs/win32unix/times.c b/otherlibs/win32unix/times.c
new file mode 100644
index 0000000000..725895ec15
--- /dev/null
+++ b/otherlibs/win32unix/times.c
@@ -0,0 +1,35 @@
+#include <windows.h>
+#include <mlvalues.h>
+#include "unixsupport.h"
+
+
+double to_sec(FILETIME ft) {
+ ULARGE_INTEGER tmp;
+
+ tmp.u.LowPart = ft.dwLowDateTime;
+ tmp.u.HighPart = ft.dwHighDateTime;
+
+ /* convert to seconds:
+ GetProcessTimes returns number of 100-nanosecond intervals */
+ return tmp.QuadPart / 1e7;
+}
+
+
+value unix_times(value unit) {
+
+ value res;
+ FILETIME creation, exit, stime, utime;
+
+ if (!(GetProcessTimes(GetCurrentProcess(), &creation, &exit, &stime, &utime))) {
+ win32_maperr(GetLastError());
+ uerror("times", Nothing);
+ }
+
+ res = alloc_small(4 * Double_wosize, Double_array_tag);
+ Store_double_field(res, 0, to_sec(utime));
+ Store_double_field(res, 1, to_sec(stime));
+ Store_double_field(res, 2, 0);
+ Store_double_field(res, 3, 0);
+ return res;
+
+}