summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-08-15 06:22:49 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-08-15 06:22:49 +0000
commitc345257ff6c1e913125739545a40cc1b60b62611 (patch)
tree410afef9741dff97642c267ece942d7cfeeab0f6 /win32
parent37282fa5b083375cab6780824a8941c459b59ebe (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/config.h.in2
-rw-r--r--win32/win32.c41
-rw-r--r--win32/win32.h12
3 files changed, 43 insertions, 12 deletions
diff --git a/win32/config.h.in b/win32/config.h.in
index a850388..57dcea2 100644
--- a/win32/config.h.in
+++ b/win32/config.h.in
@@ -28,7 +28,7 @@
#define HAVE_GETCWD 1
/* #define HAVE_TRUNCATE 1 */
#define HAVE_CHSIZE 1
-/* #define HAVE_TIMES 1 */
+#define HAVE_TIMES 1
/* #define HAVE_UTIMES 1 */
/* #define HAVE_FCNTL 1 */
/* #define HAVE_SETITIMER 1 */
diff --git a/win32/win32.c b/win32/win32.c
index d7f12d3..e07d008 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;
+}
diff --git a/win32/win32.h b/win32/win32.h
index 9e6e153..0435e0c 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -414,4 +414,16 @@ extern char *mystrerror(int);
#endif
#define rename myrename
+struct tms {
+ long tms_utime;
+ long tms_stime;
+ long tms_cutime;
+ long tms_cstime;
+};
+
+#ifdef times
+#undef times
+#endif
+#define times mytimes
+
#endif