* [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-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
0 siblings, 1 reply; 6+ messages in thread
From: Robert Millan @ 2009-02-21 23:25 UTC (permalink / raw)
To: The development of GRUB 2
On Sun, Feb 15, 2009 at 07:49:38PM +0100, Felix Zielcke wrote:
> --- 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>
I'm not sure this is garanteed to work unless it's defined before any
header is included. Did it compile without warnings?
--
Robert Millan
The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all."
^ 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
* Re: [PATCH] implement grub_millisleep in util/misc.c for grub-emu
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
0 siblings, 2 replies; 6+ messages in thread
From: Christian Franke @ 2009-02-28 20:51 UTC (permalink / raw)
To: The development of GRUB 2
Robert Millan wrote:
> On Sun, Feb 15, 2009 at 07:49:38PM +0100, Felix Zielcke wrote:
>
>> --- 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>
>>
>
> I'm not sure this is garanteed to work unless it's defined before any
> header is included. Did it compile without warnings?
>
>
At least with glibc headers, the #define from the patch has no effect,
because at least unistd.h has already included features.h which handles
these settings. There is no warning, because none of the headers define
_POSIX_C_SOURCE.
From features.h:
/* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
(and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined). */
#if (...!defined (_POSIX_C_SOURCE)...)
# define _POSIX_SOURCE 1
# if defined _XOPEN_SOURCE ...
# ...
# else
# define _POSIX_C_SOURCE 200112L
# endif
#endif
I would suggest to remove the #define and commit the patch.
BTW: compiles fine on Cygwin, with or without the #define.
--
Christian Franke
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] implement grub_millisleep in util/misc.c for grub-emu
2009-02-28 20:51 ` Christian Franke
@ 2009-02-28 20:56 ` Christian Franke
2009-03-04 10:26 ` Felix Zielcke
1 sibling, 0 replies; 6+ messages in thread
From: Christian Franke @ 2009-02-28 20:56 UTC (permalink / raw)
To: The development of GRUB 2
Christian Franke wrote:
> There is no warning, because none of the headers define _POSIX_C_SOURCE.
This should read: There is a warning, because features.h defines
_POSIX_C_SOURCE :-)
--
Christian Franke
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] implement grub_millisleep in util/misc.c for grub-emu
2009-02-28 20:51 ` Christian Franke
2009-02-28 20:56 ` Christian Franke
@ 2009-03-04 10:26 ` Felix Zielcke
1 sibling, 0 replies; 6+ messages in thread
From: Felix Zielcke @ 2009-03-04 10:26 UTC (permalink / raw)
To: The development of GRUB 2
Am Samstag, den 28.02.2009, 21:51 +0100 schrieb Christian Franke:
> I would suggest to remove the #define and commit the patch.
>
Ok commited.
--
Felix Zielcke
^ 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.