Skip to contentSkip to conversation

No localtime_r in windows

Qemu-devel consul 2 participants 2 messages Apr 15, 2008 – Apr 17, 2008

lore
Share & tools
lore

consul

author
#0 lore raw

I don't pretend it is the correct patch, but at least it fixes the compile time error on windows and seems to work. I'm not sure if the thread-safety mechanism is needed here, or if this is the proper place to define the function.

Alex.

$ svn diff hw/twl92230.c
Index: hw/twl92230.c
===================================================================
--- hw/twl92230.c       (revision 4215)
+++ hw/twl92230.c       (working copy)
@@ -29,6 +29,14 @@

#define VERBOSE 1

+#ifdef _WIN32
+inline struct tm* localtime_r (const time_t *clock, struct tm *result) {

+       if (!clock || !result) return NULL;
+       memcpy(result,localtime(clock),sizeof(*result));
+       return result;
+}
+#endif
+
 struct menelaus_s {
     i2c_slave i2c;
     qemu_irq irq;
#1 lore raw

Hi,

Quoted 4 lines · consul

I don't pretend it is the correct patch, but at least it fixes the compile
time error on windows and seems to work. I'm not sure if the thread-safety mechanism is needed here, or if this is the proper place to define the function.

Thanks for spotting that (also thanks to Herve Poussineau). I converted the TWL92230 RTC to use qemu's own time/date functions and there should be no localtime_r uses left there.

Regards

Signature · 2 lines
Please do not print this email unless absolutely necessary. Spread
environmental awareness.