summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--m68k-semi.c10
-rw-r--r--osdep.c24
-rw-r--r--osdep.h11
3 files changed, 43 insertions, 2 deletions
diff --git a/m68k-semi.c b/m68k-semi.c
index 27bdce8e2f..73224f181a 100644
--- a/m68k-semi.c
+++ b/m68k-semi.c
@@ -116,8 +116,14 @@ static void translate_stat(CPUState *env, target_ulong addr, struct stat *s)
p->gdb_st_gid = cpu_to_be32(s->st_gid);
p->gdb_st_rdev = cpu_to_be32(s->st_rdev);
p->gdb_st_size = cpu_to_be64(s->st_size);
+#ifdef _WIN32
+ /* Windows stat is missing some fields. */
+ p->gdb_st_blksize = 0;
+ p->gdb_st_blocks = 0;
+#else
p->gdb_st_blksize = cpu_to_be64(s->st_blksize);
p->gdb_st_blocks = cpu_to_be64(s->st_blocks);
+#endif
p->gdb_st_atime = cpu_to_be32(s->st_atime);
p->gdb_st_mtime = cpu_to_be32(s->st_mtime);
p->gdb_st_ctime = cpu_to_be32(s->st_ctime);
@@ -281,9 +287,9 @@ void do_m68k_semihosting(CPUM68KState *env, int nr)
ARG(0), ARG(1));
return;
} else {
- struct timeval tv;
+ qemu_timeval tv;
struct gdb_timeval *p;
- result = gettimeofday(&tv, NULL);
+ result = qemu_gettimeofday(&tv);
if (result != 0) {
p = lock_user(ARG(0), sizeof(struct gdb_timeval), 0);
p->tv_sec = cpu_to_be32(tv.tv_sec);
diff --git a/osdep.c b/osdep.c
index ccc1d70bbc..c24906c99a 100644
--- a/osdep.c
+++ b/osdep.c
@@ -264,3 +264,27 @@ int qemu_create_pidfile(const char *filename)
#endif
return 0;
}
+
+#ifdef _WIN32
+
+/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
+#define _W32_FT_OFFSET (116444736000000000ULL)
+
+int qemu_gettimeofday(qemu_timeval *tp)
+{
+ union {
+ unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */
+ FILETIME ft;
+ } _now;
+
+ if(tp)
+ {
+ GetSystemTimeAsFileTime (&_now.ft);
+ tp->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL );
+ tp->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL);
+ }
+ /* Always return 0 as per Open Group Base Specifications Issue 6.
+ Do not set errno on error. */
+ return 0;
+}
+#endif /* _WIN32 */
diff --git a/osdep.h b/osdep.h
index 68d29d74e3..50686d5935 100644
--- a/osdep.h
+++ b/osdep.h
@@ -17,4 +17,15 @@ void *get_mmap_addr(unsigned long size);
int qemu_create_pidfile(const char *filename);
+#ifdef _WIN32
+typedef struct {
+ long tv_sec;
+ long tv_usec;
+} qemu_timeval;
+int qemu_gettimeofday(qemu_timeval *tp);
+#else
+typedef struct timeval qemu_timeval;
+#define qemu_gettimeofday(tp) gettimeofday(tp, NULL);
+#endif /* !_WIN32 */
+
#endif