gpm/gpm-1.20.1-aligned-sleep.patch
2006-10-10 18:37:26 +00:00

30 lines
900 B
Diff

--- gpm-1.20.1/src/console.c.org 2006-09-03 10:11:17.000000000 +0200
+++ gpm-1.20.1/src/console.c 2006-09-03 10:14:34.000000000 +0200
@@ -30,6 +30,7 @@
#include <time.h> /* time() */
#include <sys/fcntl.h> /* O_RDONLY */
#include <sys/stat.h> /* mkdir() */
+#include <sys/time.h>
#include <asm/types.h> /* __u32 */
#include <linux/vt.h> /* VT_GETSTATE */
@@ -102,8 +103,17 @@ int is_text_console(void)
/*-------------------------------------------------------------------*/
void wait_text_console(void)
{
+ struct timeval now;
+ int usecs;
do {
- sleep(2);
+ /* sleep to the top of the seconds about 2 seconds from now */
+ gettimeofday(&now, NULL);
+ usecs = 2000000;
+ if (now.tv_usec <= 250000)
+ usecs -= 1000000;
+ usecs += 1000000 - now.tv_usec;
+
+ usleep(usecs);
} while (!is_text_console());
}