win32: implement missing timersub
Implement and wrap timersub() for Win32. Acked-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
		
							parent
							
								
									31d3c9b8c1
								
							
						
					
					
						commit
						ad620c29c2
					
				
							
								
								
									
										19
									
								
								osdep.h
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								osdep.h
									
									
									
									
									
								
							@ -8,9 +8,7 @@
 | 
				
			|||||||
#include <sys/signal.h>
 | 
					#include <sys/signal.h>
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef _WIN32
 | 
					 | 
				
			||||||
#include <sys/time.h>
 | 
					#include <sys/time.h>
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef glue
 | 
					#ifndef glue
 | 
				
			||||||
#define xglue(x, y) x ## y
 | 
					#define xglue(x, y) x ## y
 | 
				
			||||||
@ -131,4 +129,21 @@ int qemu_madvise(void *addr, size_t len, int advice);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
int qemu_create_pidfile(const char *filename);
 | 
					int qemu_create_pidfile(const char *filename);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef _WIN32
 | 
				
			||||||
 | 
					static inline void qemu_timersub(const struct timeval *val1,
 | 
				
			||||||
 | 
					                                 const struct timeval *val2,
 | 
				
			||||||
 | 
					                                 struct timeval *res)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    res->tv_sec = val1->tv_sec - val2->tv_sec;
 | 
				
			||||||
 | 
					    if (val1->tv_usec < val2->tv_usec) {
 | 
				
			||||||
 | 
					        res->tv_sec--;
 | 
				
			||||||
 | 
					        res->tv_usec = val1->tv_usec - val2->tv_usec + 1000 * 1000;
 | 
				
			||||||
 | 
					    } else {
 | 
				
			||||||
 | 
					        res->tv_usec = val1->tv_usec - val2->tv_usec;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#else
 | 
				
			||||||
 | 
					#define qemu_timersub timersub
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										6
									
								
								ui/vnc.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								ui/vnc.c
									
									
									
									
									
								
							@ -2302,7 +2302,7 @@ static int vnc_update_stats(VncDisplay *vd,  struct timeval * tv)
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    timersub(tv, &VNC_REFRESH_STATS, &res);
 | 
					    qemu_timersub(tv, &VNC_REFRESH_STATS, &res);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (timercmp(&vd->guest.last_freq_check, &res, >)) {
 | 
					    if (timercmp(&vd->guest.last_freq_check, &res, >)) {
 | 
				
			||||||
        return has_dirty;
 | 
					        return has_dirty;
 | 
				
			||||||
@ -2320,7 +2320,7 @@ static int vnc_update_stats(VncDisplay *vd,  struct timeval * tv)
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            max = rect->times[(rect->idx + count - 1) % count];
 | 
					            max = rect->times[(rect->idx + count - 1) % count];
 | 
				
			||||||
            timersub(tv, &max, &res);
 | 
					            qemu_timersub(tv, &max, &res);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (timercmp(&res, &VNC_REFRESH_LOSSY, >)) {
 | 
					            if (timercmp(&res, &VNC_REFRESH_LOSSY, >)) {
 | 
				
			||||||
                rect->freq = 0;
 | 
					                rect->freq = 0;
 | 
				
			||||||
@ -2331,7 +2331,7 @@ static int vnc_update_stats(VncDisplay *vd,  struct timeval * tv)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            min = rect->times[rect->idx];
 | 
					            min = rect->times[rect->idx];
 | 
				
			||||||
            max = rect->times[(rect->idx + count - 1) % count];
 | 
					            max = rect->times[(rect->idx + count - 1) % count];
 | 
				
			||||||
            timersub(&max, &min, &res);
 | 
					            qemu_timersub(&max, &min, &res);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            rect->freq = res.tv_sec + res.tv_usec / 1000000.;
 | 
					            rect->freq = res.tv_sec + res.tv_usec / 1000000.;
 | 
				
			||||||
            rect->freq /= count;
 | 
					            rect->freq /= count;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user