All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] implement grub_millisleep in util/misc.c for grub-emu
@ 2009-02-15 18:49 Felix Zielcke
  2009-02-21 23:25 ` Robert Millan
  0 siblings, 1 reply; 6+ messages in thread
From: Felix Zielcke @ 2009-02-15 18:49 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 132 bytes --]

Here's a small patch which implements grub_millisleep () using nanosleep
() in util/misc.c.
I hope it's correct.

-- 
Felix Zielcke

[-- Attachment #2: millisleep.diff --]
[-- Type: text/x-patch, Size: 881 bytes --]

2009-02-15  Felix Zielcke  <fzielcke@z-51.de>

	* util/misc.c: Define _POSIX_C_SOURCE 199309L.
	Include <time.h>.
	(grub_millisleep): New function.

Index: util/misc.c
===================================================================
--- util/misc.c	(revision 1996)
+++ util/misc.c	(working copy)
@@ -27,6 +27,9 @@
 #include <sys/time.h>
 #include <unistd.h>
 
+#define _POSIX_C_SOURCE 199309L
+#include <time.h>
+
 #include <grub/kernel.h>
 #include <grub/misc.h>
 #include <grub/cache.h>
@@ -310,6 +313,16 @@ grub_get_time_ms (void)
   return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
 }
 
+void
+grub_millisleep (grub_uint32_t ms)
+{
+  struct timespec ts;
+
+  ts.tv_sec = ms / 1000;
+  ts.tv_nsec = (ms % 1000) * 1000000;
+  nanosleep (&ts, NULL);
+}
+
 void 
 grub_arch_sync_caches (void *address __attribute__ ((unused)),
 		       grub_size_t len __attribute__ ((unused)))

^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [PATCH] implement grub_millisleep in util/misc.c for grub-emu
@ 2009-02-22  1:29 Kalamatee
  0 siblings, 0 replies; 6+ messages in thread
From: Kalamatee @ 2009-02-22  1:29 UTC (permalink / raw)
  To: grub-devel

Robert Millan wrote ..
>I'm not sure this is garanteed to work unless it's defined before any
>header is included.  Did it compile without warnings?

Compiles perfectly with the patch here.

Without the patch grub fails to compile when configured with
"--enable-grub-emu --enable-grub-fstest"



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-03-04 10:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-15 18:49 [PATCH] implement grub_millisleep in util/misc.c for grub-emu Felix Zielcke
2009-02-21 23:25 ` Robert Millan
2009-02-28 20:51   ` Christian Franke
2009-02-28 20:56     ` Christian Franke
2009-03-04 10:26     ` Felix Zielcke
  -- strict thread matches above, loose matches on Subject: below --
2009-02-22  1:29 Kalamatee

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.