gcl-devel
[Top][All Lists]
Advanced

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

Re: [Gcl-devel] [Maxima] Out of range floating point number determinatio


From: Camm Maguire
Subject: Re: [Gcl-devel] [Maxima] Out of range floating point number determination
Date: Sat, 03 Nov 2012 09:41:00 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Greetings, and thanks!

Raymond Toy <address@hidden> writes:

>>>>>> "Camm" == Camm Maguire <address@hidden> writes:
>
>     Camm> I've got something working for the x87, but as far as I can see, 
> there
>     Camm> is no pertinent sse information passed in ucontext_t to the 
> sighandler
>     Camm> (e.g. like the fpregs for the x87).  Furthermore, the chip does not 
> set
>     Camm> the fop or fooff regs at point of sse exception.  Yet the sigaction
>     Camm> wipes the xmm registers before proceeding to the handler.  All that
>     Camm> appears left in the handler is the fault address, from which one 
> might
>     Camm> decode the faulting instruction.  Even the si_code field does not 
> appear
>     Camm> set consistently with the x87 FPU case.
>
> Did I ever answer this?  If not, sorry for the delay!
>
> Anyway, it seems that on my Ubuntu system, the ucontext must contain
> the xmm registers because that's how cmucl grabs the values to print
> when handling an arithmetic-error, and the values are correctly
> printed, as far as I know.
>

Thanks so much for this!  Casting the pointer to (struct _fpstate *)
indeed revealed the xmm register contents.


> Don't know about the value fop or foff regs.  But as I understand it,
> the sse instructions signal exceptions at the offending instruction,
> unlike x87 where the exception is signaled at the *next* x87
> instruction.  Hence, you need the fop and fooff regs to tell you what
> the offending instruction actually is.  I think; I haven't looked at
> that stuff in decades, probably.

Exactly.  The code needs to look at the instruction pointer contents in
case of SSE.  fop is not zeroed out in this case, so I suppose either
differentially examining the status words for the two fpus, or decoding
the instruction pointer and defaulting to fop if an x87 instruction,
would suffice.

All of this is identical on i386 and amd64, to my understanding.

Thanks so much!  I'll post something shortly.

>
> In any case, here is how cmucl grabs the sse values:
>
> unsigned char *
> os_sigcontext_fpu_reg(ucontext_t *scp, int offset)
> {
>     fpregset_t fpregs = scp->uc_mcontext.fpregs;
>     unsigned char *reg = NULL;
>     
>     if (fpregs) {
>         if (offset < 8) {
>             reg = (unsigned char *) &fpregs->_st[offset];
>         }
> #ifdef FEATURE_SSE2
>         else {
>             struct _fpstate *fpstate;
>             fpstate = (struct _fpstate*) scp->uc_mcontext.fpregs;
>             if (fpstate->magic != 0xffff) {
>                 reg = (unsigned char *) &fpstate->_xmm[offset - 8];
>             }
>         }
> #endif
>     }
>     return reg;
> }
>
> Note that on cmucl, the offset arg above is 0-7 for the x87 registers
> and 8+ for the xmm registers.  8 corresponds to xmm0.
>
> Hope this helps a little,
>
> Ray
>
>
> _______________________________________________
> Gcl-devel mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/gcl-devel
>
>
>
>

-- 
Camm Maguire                                        address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah



reply via email to

[Prev in Thread] Current Thread [Next in Thread]