Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 30 Apr 2000 10:00:12 -0400 (EDT)
From:      Daniel Eischen <eischen@vigrid.com>
To:        Marco van de Voort <marcov@stack.nl>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: fp statusword in sigcontext
Message-ID:  <Pine.SUN.3.91.1000430095431.7649A-100000@pcnet1.pcnet.com>
In-Reply-To: <20000430134619.C29D82E806@hermes.tue.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 30 Apr 2000, Marco van de Voort wrote:

> I want a signalhandler, which splits out sigfpe to the different copro 
> signals. I found a linux example, which is based on the statusword field of the
> sigcontext structure passed to the signalhandler set 
> 
> Problem is that the linux sigcontext has a field for the floatingpoint statusword,
> while the BSD sigcontext (machine/signal.h) has only two arrays of int's:
> 
> (FPU part struct sigcontext
>      * XXX FPU state is 27 * 4 bytes h/w, 1 * 4 bytes s/w (probably not
>          * needed here), or that + 16 * 4 bytes for emulators (probably all
>          * needed here).  The "spare" bytes are mostly not spare.
>          */
>         int     sc_fpregs[28];          /* machine state (FPU): */
>         int     sc_spare[17];
> };
> 
> Does somebody know how to distille the FP statusword from this struct?

See <machine/reg.h> and <machine/npx.h>.

struct fpreg {
	/*
	 * XXX should get struct from npx.h.  Here we give a slightly
	 * simplified struct.  This may be too much detail.  Perhaps
	 * an array of unsigned longs is best.
	 */
	unsigned long	fpr_env[7];
	unsigned char	fpr_acc[8][10];
	unsigned long	fpr_ex_sw;
	unsigned char	fpr_pad[64];
};

fpr_env should correspond to struct env87 in npx.h:

/* Environment information of floating point unit */
struct	env87 {
	long	en_cw;		/* control word (16bits) */
	long	en_sw;		/* status word (16bits) */
	long	en_tw;		/* tag word (16bits) */
	long	en_fip;		/* floating point instruction pointer */
	u_short	en_fcs;		/* floating code segment selector */
	u_short	en_opcode;	/* opcode last executed (11 bits ) */
	long	en_foo;		/* floating operand offset */
	long	en_fos;		/* floating operand segment selector */
};

So your status word should be in sc_fpregs[1].

-- 
Dan Eischen



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.SUN.3.91.1000430095431.7649A-100000>