summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c41
1 files changed, 30 insertions, 11 deletions
diff --git a/win32/win32.c b/win32/win32.c
index d7f12d3f0b7..e07d0086dff 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -155,17 +155,6 @@ flock(int fd, int oper)
//#undef const
//FILE *fdopen(int, const char *);
-#if 0
-void
-sleep(unsigned int len)
-{
- time_t end;
-
- end = time((time_t *)0) + len;
- while (time((time_t *)0) < end)
- ;
-}
-#endif
//
// Initialization stuff
@@ -2480,3 +2469,33 @@ done:
return res;
}
+
+static long
+filetime_to_clock(FILETIME *ft)
+{
+ __int64 qw = ft->dwHighDateTime;
+ qw <<= 32;
+ qw |= ft->dwLowDateTime;
+ qw /= 10000; /* File time ticks at 0.1uS, clock at 1mS */
+ return (long) qw;
+}
+
+int
+mytimes(struct tms *tmbuf)
+{
+ FILETIME create, exit, kernel, user;
+
+ if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) {
+ tmbuf->tms_utime = filetime_to_clock(&user);
+ tmbuf->tms_stime = filetime_to_clock(&kernel);
+ tmbuf->cutime = 0;
+ tmbuf->cstime = 0;
+ }
+ else {
+ tmbuf->utime = clock();
+ tmbuf->stime = 0;
+ tmbuf->cutime = 0;
+ tmbuf->cstime = 0;
+ }
+ return 0;
+}