DragonFly BSD
DragonFly users List (threaded) for 2013-04
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

SBCL and FP state restoration when returning from signal handler


From: vasily postnicov <shamaz.mazum@xxxxxxxxx>
Date: Sun, 21 Apr 2013 13:56:22 +0400

--bcaec5171f9df36f7c04dadbf652
Content-Type: text/plain; charset=ISO-8859-1

There is a function in SBCL, which restores FP state when SBCL returns from
signal handler:

> void
> os_restore_fp_control(os_context_t *context)
> {
>   struct envxmm *ex = (struct envxmm*)(&context->uc_mcontext.mc_fpregs);
>    /* reset exception flags and restore control flags on SSE2 FPU */
>    unsigned int temp = (ex->en_mxcsr) & ~0x3F;
>    asm ("ldmxcsr %0" : : "m" (temp));
>    /* same for x87 FPU. */
>    asm ("fldcw %0" : : "m" (ex->en_cw));
>}

As you can see, it restores both mxcsr and x87 FPU control word. Do we
still need it after this commit?

http://gitweb.dragonflybsd.org/dragonfly.git/commit/e6e019a801e99ba7888ed009c5c3b3c7b047af1e

P.S. It is curious, what my old SBCL build stopped working after I rebuild
recent DragonFly. git bisect says that this commit was the cause. But after
I rebuild it with clisp it began to work again. It seems that some kind of
binary incompatibility has place.

--bcaec5171f9df36f7c04dadbf652
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

There is a function in SBCL, which restores FP state when SBCL returns from=
 signal handler:<br><br>&gt; void<br>&gt; os_restore_fp_control(os_context_=
t *context)<br>&gt; {<br>&gt; =A0 struct envxmm *ex =3D (struct envxmm*)(&a=
mp;context-&gt;uc_mcontext.mc_fpregs);<br>
&gt; =A0=A0 /* reset exception flags and restore control flags on SSE2 FPU =
*/<br>&gt;=A0=A0=A0 unsigned int temp =3D (ex-&gt;en_mxcsr) &amp; ~0x3F;<br=
>&gt;=A0=A0=A0 asm (&quot;ldmxcsr %0&quot; : : &quot;m&quot; (temp));<br>&g=
t;=A0 =A0 /* same for x87 FPU. */<br>
&gt;=A0=A0=A0 asm (&quot;fldcw %0&quot; : : &quot;m&quot; (ex-&gt;en_cw));<=
br>&gt;}<br><br>As you can see, it restores both mxcsr and x87 FPU control =
word. Do we still need it after this commit?<br><br><a href=3D"http://gitwe=
b.dragonflybsd.org/dragonfly.git/commit/e6e019a801e99ba7888ed009c5c3b3c7b04=
7af1e">http://gitweb.dragonflybsd.org/dragonfly.git/commit/e6e019a801e99ba7=
888ed009c5c3b3c7b047af1e</a><br>
<br>P.S. It is curious, what my old SBCL build stopped working after I rebu=
ild recent DragonFly. git bisect says that this commit was the cause. But a=
fter I rebuild it with clisp it began to work again. It seems that some kin=
d of binary incompatibility has place.<br>

--bcaec5171f9df36f7c04dadbf652--



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]