qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] supplement timegm function for Solaris in cutils.c
@ 2007-11-09 19:26 Ben Taylor
  2007-11-10  0:47 ` [Qemu-devel] " consul
  0 siblings, 1 reply; 2+ messages in thread
From: Ben Taylor @ 2007-11-09 19:26 UTC (permalink / raw)
  To: qemu-devel


Solaris doesn't have the timegm function, so I found a replacement and
wedge it into cutils.c.

I found the supplement for timegm in the opensync repository at:
http://www.opensync.org/changeset/1769

--- qemu.ORIG/cutils.c  2007-09-16 17:07:49.000000000 -0400
+++ qemu/cutils.c       2007-11-09 14:11:04.005353000 -0500
@@ -81,3 +81,38 @@
         *ptr = p;
     return 1;
 }
+
+#ifdef __sun__
+/*
+ * On solaris no timegm function exists,
+ * we must implement it here
+ */
+time_t timegm(struct tm *t)
+{
+    time_t tl, tb;
+    struct tm *tg;
+
+    tl = mktime (t);
+     if (tl == -1)
+    {
+        t->tm_hour--;
+        tl = mktime (t);
+        if (tl == -1)
+            return -1; /* can't deal with output from strptime */
+        tl += 3600;
+    }
+    tg = gmtime (&tl);
+    tg->tm_isdst = 0;
+    tb = mktime (tg);
+    if (tb == -1)
+    {
+        tg->tm_hour--;
+        tb = mktime (tg);
+        if (tb == -1)
+            return -1; /* can't deal with output from gmtime */
+        tb += 3600;
+    }
+    return (tl - (tb - tl));
+}
+#endif
+

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

* [Qemu-devel] Re: supplement timegm function for Solaris in cutils.c
  2007-11-09 19:26 [Qemu-devel] supplement timegm function for Solaris in cutils.c Ben Taylor
@ 2007-11-10  0:47 ` consul
  0 siblings, 0 replies; 2+ messages in thread
From: consul @ 2007-11-10  0:47 UTC (permalink / raw)
  To: qemu-devel

Windows does not seem to have this function either.
With your patch I was able to compile most of the targets from the current 
CVS tree (except arm), but at least i386-softmmu is broken.

It crashes immediately with the following error:

Starting program: c:\qemu-dist9/qemu.exe -L . -hda c:\qemu-img\wxp.q2 -boot 
c -localtime -m 512 -net nic,model=rtl8139 -net 
tap,ifname=TAP0 -kernel-kqemu

Program received signal SIGSEGV, Segmentation fault.
qcow_aio_read_cb (opaque=0x23dfcc70, ret=-22) at block-qcow2.c:840
840             acb->common.cb(acb->common.opaque, 0);

(gdb) q

Alex.

"Ben Taylor" <sol10x86@cox.net> wrote in message 
news:20071109142635.5NICO.161491.root@eastrmwml12...
>
> Solaris doesn't have the timegm function, so I found a replacement and
> wedge it into cutils.c.
>
> I found the supplement for timegm in the opensync repository at:
> http://www.opensync.org/changeset/1769
>
> --- qemu.ORIG/cutils.c  2007-09-16 17:07:49.000000000 -0400
> +++ qemu/cutils.c       2007-11-09 14:11:04.005353000 -0500
> @@ -81,3 +81,38 @@
>         *ptr = p;
>     return 1;
> }
> +
> +#ifdef __sun__
> +/*
> + * On solaris no timegm function exists,
> + * we must implement it here
> + */
> +time_t timegm(struct tm *t)
> +{
> +    time_t tl, tb;
> +    struct tm *tg;
> +
> +    tl = mktime (t);
> +     if (tl == -1)
> +    {
> +        t->tm_hour--;
> +        tl = mktime (t);
> +        if (tl == -1)
> +            return -1; /* can't deal with output from strptime */
> +        tl += 3600;
> +    }
> +    tg = gmtime (&tl);
> +    tg->tm_isdst = 0;
> +    tb = mktime (tg);
> +    if (tb == -1)
> +    {
> +        tg->tm_hour--;
> +        tb = mktime (tg);
> +        if (tb == -1)
> +            return -1; /* can't deal with output from gmtime */
> +        tb += 3600;
> +    }
> +    return (tl - (tb - tl));
> +}
> +#endif
> +
>
>
>
> 

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

end of thread, other threads:[~2007-11-10  0:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-09 19:26 [Qemu-devel] supplement timegm function for Solaris in cutils.c Ben Taylor
2007-11-10  0:47 ` [Qemu-devel] " consul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).