Subject: lib/5142: setjmp(3) does not save fpu environment (at least on i386)
To: None <>
From: None <wennmach@geo.Uni-Koeln.DE>
List: netbsd-bugs
Date: 03/10/1998 14:36:39
>Number:         5142
>Category:       lib
>Synopsis:       setjmp(3) does not save fpu environment (at least on i386)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people (Library Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 10 05:50:00 1998
>Originator:     Dr. Lex Wennmacher
Institute of Geophysics
University of Cologne

Murphey's law:  "Anything that can go wr
/bin/mail: Segmentation violation -- Core dumped
>Release:        <NetBSD-current source date> NetBSD-1.3
System: NetBSD hal 1.3 NetBSD 1.3 (HAL) #1: Sat Jan 24 20:17:18 MET 1998 wennmach@hal:/usr/src/sys/arch/i386/compile/HAL i386

>From the setjmp(3) manual page:
"    The sigsetjmp(), setjmp(), and _setjmp() functions save their calling en-
     vironment in env. Each of these functions returns 0.

     The corresponding longjmp() functions restore the environment saved by
     their most recent respective invocations of the setjmp() function.  They
     then return so that program execution continues as if the corresponding
     invocation of the setjmp() call had just returned  the value specified by
     val, instead of 0."

To my understanding, the floating point registers belong to the "calling 
environment". However, they are not saved by the sigsetjmp(), setjmp(), and
_setjmp() functions (at least this is the case in the i386 port). This should
be changed. Siglongjmp(), longjmp(), and _longjmp() should restore the floating
point environment.

I need floating point-aware setjmp()/longjmp() functions to implement my
checkpointing library. Currently, I have to save the FPU myself using 
(non-portable) assembler routines.
Probably non-trivial. On i386, change the definition of jmp_buf such that
it is capable to hold the additional 108 bytes of FPU environment. Add
appropriate fnsave and frstor instructions to

However, I don't know what happens on machines without FPU with these changes.