Commit 29b3a6627e57585a156fb753c7781b4b1646a934
1 parent
0fa7f157
Windows build fixes.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2959 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
43 additions
and
2 deletions
m68k-semi.c
@@ -116,8 +116,14 @@ static void translate_stat(CPUState *env, target_ulong addr, struct stat *s) | @@ -116,8 +116,14 @@ static void translate_stat(CPUState *env, target_ulong addr, struct stat *s) | ||
116 | p->gdb_st_gid = cpu_to_be32(s->st_gid); | 116 | p->gdb_st_gid = cpu_to_be32(s->st_gid); |
117 | p->gdb_st_rdev = cpu_to_be32(s->st_rdev); | 117 | p->gdb_st_rdev = cpu_to_be32(s->st_rdev); |
118 | p->gdb_st_size = cpu_to_be64(s->st_size); | 118 | p->gdb_st_size = cpu_to_be64(s->st_size); |
119 | +#ifdef _WIN32 | ||
120 | + /* Windows stat is missing some fields. */ | ||
121 | + p->gdb_st_blksize = 0; | ||
122 | + p->gdb_st_blocks = 0; | ||
123 | +#else | ||
119 | p->gdb_st_blksize = cpu_to_be64(s->st_blksize); | 124 | p->gdb_st_blksize = cpu_to_be64(s->st_blksize); |
120 | p->gdb_st_blocks = cpu_to_be64(s->st_blocks); | 125 | p->gdb_st_blocks = cpu_to_be64(s->st_blocks); |
126 | +#endif | ||
121 | p->gdb_st_atime = cpu_to_be32(s->st_atime); | 127 | p->gdb_st_atime = cpu_to_be32(s->st_atime); |
122 | p->gdb_st_mtime = cpu_to_be32(s->st_mtime); | 128 | p->gdb_st_mtime = cpu_to_be32(s->st_mtime); |
123 | p->gdb_st_ctime = cpu_to_be32(s->st_ctime); | 129 | p->gdb_st_ctime = cpu_to_be32(s->st_ctime); |
@@ -281,9 +287,9 @@ void do_m68k_semihosting(CPUM68KState *env, int nr) | @@ -281,9 +287,9 @@ void do_m68k_semihosting(CPUM68KState *env, int nr) | ||
281 | ARG(0), ARG(1)); | 287 | ARG(0), ARG(1)); |
282 | return; | 288 | return; |
283 | } else { | 289 | } else { |
284 | - struct timeval tv; | 290 | + qemu_timeval tv; |
285 | struct gdb_timeval *p; | 291 | struct gdb_timeval *p; |
286 | - result = gettimeofday(&tv, NULL); | 292 | + result = qemu_gettimeofday(&tv); |
287 | if (result != 0) { | 293 | if (result != 0) { |
288 | p = lock_user(ARG(0), sizeof(struct gdb_timeval), 0); | 294 | p = lock_user(ARG(0), sizeof(struct gdb_timeval), 0); |
289 | p->tv_sec = cpu_to_be32(tv.tv_sec); | 295 | p->tv_sec = cpu_to_be32(tv.tv_sec); |
osdep.c
@@ -264,3 +264,27 @@ int qemu_create_pidfile(const char *filename) | @@ -264,3 +264,27 @@ int qemu_create_pidfile(const char *filename) | ||
264 | #endif | 264 | #endif |
265 | return 0; | 265 | return 0; |
266 | } | 266 | } |
267 | + | ||
268 | +#ifdef _WIN32 | ||
269 | + | ||
270 | +/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */ | ||
271 | +#define _W32_FT_OFFSET (116444736000000000ULL) | ||
272 | + | ||
273 | +int qemu_gettimeofday(qemu_timeval *tp) | ||
274 | +{ | ||
275 | + union { | ||
276 | + unsigned long long ns100; /*time since 1 Jan 1601 in 100ns units */ | ||
277 | + FILETIME ft; | ||
278 | + } _now; | ||
279 | + | ||
280 | + if(tp) | ||
281 | + { | ||
282 | + GetSystemTimeAsFileTime (&_now.ft); | ||
283 | + tp->tv_usec=(long)((_now.ns100 / 10ULL) % 1000000ULL ); | ||
284 | + tp->tv_sec= (long)((_now.ns100 - _W32_FT_OFFSET) / 10000000ULL); | ||
285 | + } | ||
286 | + /* Always return 0 as per Open Group Base Specifications Issue 6. | ||
287 | + Do not set errno on error. */ | ||
288 | + return 0; | ||
289 | +} | ||
290 | +#endif /* _WIN32 */ |
osdep.h
@@ -17,4 +17,15 @@ void *get_mmap_addr(unsigned long size); | @@ -17,4 +17,15 @@ void *get_mmap_addr(unsigned long size); | ||
17 | 17 | ||
18 | int qemu_create_pidfile(const char *filename); | 18 | int qemu_create_pidfile(const char *filename); |
19 | 19 | ||
20 | +#ifdef _WIN32 | ||
21 | +typedef struct { | ||
22 | + long tv_sec; | ||
23 | + long tv_usec; | ||
24 | +} qemu_timeval; | ||
25 | +int qemu_gettimeofday(qemu_timeval *tp); | ||
26 | +#else | ||
27 | +typedef struct timeval qemu_timeval; | ||
28 | +#define qemu_gettimeofday(tp) gettimeofday(tp, NULL); | ||
29 | +#endif /* !_WIN32 */ | ||
30 | + | ||
20 | #endif | 31 | #endif |