Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Jan 2003 21:12:11 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Marcel Moolenaar <marcel@xcllnt.net>
Cc:        Jake Burkholder <jake@locore.ca>, sparc@FreeBSD.ORG, current@FreeBSD.ORG
Subject:   Re: [PATCH] Re: fpsetmask on sparc64
Message-ID:  <3E224AAA.11792616@mindspring.com>
References:  <20030112031626.GA15783@rot13.obsecurity.org> <20030112015221.G212@locore.ca> <3E212670.41627B9F@mindspring.com> <20030112032908.H212@locore.ca> <3E216911.B7AFC39F@mindspring.com> <20030112134948.I212@locore.ca> <3E21FDAC.1FD36F5C@mindspring.com> <3E2223F4.5554718E@mindspring.com> <20030113034638.GA2310@dhcp01.pn.xcllnt.net>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------B8AE5B3A0FF5EB7A07DC7E4B
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Marcel Moolenaar wrote:
> On Sun, Jan 12, 2003 at 06:27:00PM -0800, Terry Lambert wrote:
> > Therefore, it seems to me, that the correct place to put them is in
> > the <machine/floatingpoint.h> header (the other alternative was the
> > <machine/ieeefp.h> header; this seemed wrong to me, but I'm willing
> > to reroll the patch, if there's a lot of disagreement over this point).
> 
> I would like to see it in <machine/ieeefp.h>:

Here is the patch, made this way instead.  It's about 4 times
larger.

Pick which one you like, and commit it to make Kris happy.

-- Terry
--------------B8AE5B3A0FF5EB7A07DC7E4B
Content-Type: text/plain; charset=us-ascii;
 name="fixfp2.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="fixfp2.diff"

Index: include/ieeefp.h
===================================================================
RCS file: /cvs/src/include/ieeefp.h,v
retrieving revision 1.6
diff -c -r1.6 ieeefp.h
*** include/ieeefp.h	23 Mar 2002 17:24:53 -0000	1.6
--- include/ieeefp.h	13 Jan 2003 00:59:42 -0000
***************
*** 9,28 ****
  #ifndef _IEEEFP_H_
  #define _IEEEFP_H_
  
- #include <sys/cdefs.h>
  #include <machine/ieeefp.h>
- 
- #ifdef __i386__
- #include <machine/floatingpoint.h>
- #else /* !__i386__ */
- __BEGIN_DECLS
- extern fp_rnd_t    fpgetround(void);
- extern fp_rnd_t    fpsetround(fp_rnd_t);
- extern fp_except_t fpgetmask(void);
- extern fp_except_t fpsetmask(fp_except_t);
- extern fp_except_t fpgetsticky(void);
- extern fp_except_t fpsetsticky(fp_except_t);
- __END_DECLS
- #endif /* __i386__ */
  
  #endif /* _IEEEFP_H_ */
--- 9,14 ----
Index: sys/alpha/include/ieeefp.h
===================================================================
RCS file: /cvs/src/sys/alpha/include/ieeefp.h,v
retrieving revision 1.5
diff -c -r1.5 ieeefp.h
*** sys/alpha/include/ieeefp.h	10 May 2000 19:41:40 -0000	1.5
--- sys/alpha/include/ieeefp.h	13 Jan 2003 01:02:21 -0000
***************
*** 9,14 ****
--- 9,16 ----
  #ifndef _ALPHA_IEEEFP_H_
  #define _ALPHA_IEEEFP_H_
  
+ #include <sys/cdefs.h>
+ 
  typedef int fp_except_t;
  #define	FP_X_INV	(1LL << 1)	/* invalid operation exception */
  #define	FP_X_DZ		(1LL << 2)	/* divide-by-zero exception */
***************
*** 25,29 ****
--- 27,43 ----
      FP_RN=2,			/* round to nearest representable number */
      FP_RP=3			/* round toward positive infinity */
  } fp_rnd_t;
+ 
+ /*
+  * SysV/386 FP control interface for platforms with library implementations
+  */
+ __BEGIN_DECLS
+ extern fp_rnd_t    fpgetround(void);
+ extern fp_rnd_t    fpsetround(fp_rnd_t);
+ extern fp_except_t fpgetmask(void);
+ extern fp_except_t fpsetmask(fp_except_t);
+ extern fp_except_t fpgetsticky(void);
+ extern fp_except_t fpsetsticky(fp_except_t);
+ __END_DECLS
  
  #endif /* _ALPHA_IEEEFP_H_ */
Index: sys/alpha/include/floatingpoint.h
===================================================================
RCS file: /cvs/src/sys/alpha/include/floatingpoint.h,v
retrieving revision 1.3
diff -c -r1.3 floatingpoint.h
*** sys/alpha/include/floatingpoint.h	1 May 2000 20:17:49 -0000	1.3
--- sys/alpha/include/floatingpoint.h	13 Jan 2003 01:10:07 -0000
***************
*** 32,35 ****
--- 32,40 ----
   * $FreeBSD: src/sys/alpha/include/floatingpoint.h,v 1.3 2000/05/01 20:17:49 peter Exp $
   */
  
+ #ifndef _FLOATINGPOINT_H_
+ #define _FLOATINGPOINT_H_
+ 
  #include <machine/ieeefp.h>
+ 
+ #endif /* !_FLOATINGPOINT_H_ */
Index: sys/i386/include/ieeefp.h
===================================================================
RCS file: /cvs/src/sys/i386/include/ieeefp.h,v
retrieving revision 1.7
diff -c -r1.7 ieeefp.h
*** sys/i386/include/ieeefp.h	28 Aug 1999 00:44:15 -0000	1.7
--- sys/i386/include/ieeefp.h	13 Jan 2003 01:06:06 -0000
***************
*** 41,46 ****
--- 41,48 ----
  #ifndef _MACHINE_IEEEFP_H_
  #define _MACHINE_IEEEFP_H_
  
+ #include <sys/cdefs.h>
+ 
  /*
   * FP rounding modes
   */
***************
*** 97,101 ****
--- 99,186 ----
  #define FP_PRC_OFF	8	/* precision control offset */
  #define FP_RND_OFF	10	/* round control offset */
  #define FP_STKY_OFF	0	/* sticky flags offset */
+ 
+ /*-
+  * XXX the following undocumented pollution is exported:
+  *	fpsetsticky().
+  *	FP*FLD, FP*OFF and FP*REG from <machine/ieeefp.h>
+  */
+ 
+ #ifdef __GNUC__
+ 
+ #define __fldenv(addr)	__asm __volatile("fldenv %0" : : "m" (*(addr)))
+ #define __fnstenv(addr)	__asm __volatile("fnstenv %0" : "=m" (*(addr)))
+ #define __fnstcw(addr)	__asm __volatile("fnstcw %0" : "=m" (*(addr)))
+ #define __fnstsw(addr)	__asm __volatile("fnstsw %0" : "=m" (*(addr)))
+ 
+ /*
+  * return the contents of a FP register
+  */
+ static __inline__ int
+ __fpgetreg(int _reg)
+ {
+ 	unsigned short _mem;
+ 
+ 	/*-
+ 	 * This is more efficient than it looks.  The switch gets optimized
+ 	 * away if _reg is constant.
+ 	 *
+ 	 * The default case only supports _reg == 0.  We could handle more
+ 	 * registers (e.g., tags) using fnstenv, but the interface doesn't
+ 	 * support more.
+ 	 */
+ 	switch(_reg) {
+ 	default:
+ 		__fnstcw(&_mem);
+ 		break;
+ 	case FP_STKY_REG:
+ 		__fnstsw(&_mem);
+ 		break;
+ 	}
+ 	return _mem;
+ }
+ 
+ /*
+  * set a FP mode; return previous mode
+  */
+ static __inline__ int
+ __fpsetreg(int _m, int _reg, int _fld, int _off)
+ {
+ 	unsigned _env[7];
+ 	unsigned _p;
+ 
+ 	/*
+ 	 * _reg == 0 could be handled better using fnstcw/fldcw.
+ 	 */
+ 	__fnstenv(_env);
+ 	_p =  (_env[_reg] & _fld) >> _off;
+ 	_env[_reg] = (_env[_reg] & ~_fld) | (_m << _off & _fld);
+ 	__fldenv(_env);
+ 	return _p;
+ }
+ 
+ #endif /* __GNUC__ */
+ 
+ /*
+  * SysV/386 FP control interface
+  */
+ #define	fpgetround()	((fp_rnd_t)					\
+ 	((__fpgetreg(FP_RND_REG) & FP_RND_FLD) >> FP_RND_OFF))
+ #define	fpsetround(m)	((fp_rnd_t)					\
+ 	__fpsetreg((m), FP_RND_REG, FP_RND_FLD, FP_RND_OFF))
+ #define	fpgetprec()	((fp_prec_t)					\
+ 	((__fpgetreg(FP_PRC_REG) & FP_PRC_FLD) >> FP_PRC_OFF))
+ #define	fpsetprec(m)	((fp_prec_t)					\
+ 	__fpsetreg((m), FP_PRC_REG, FP_PRC_FLD, FP_PRC_OFF))
+ #define	fpgetmask()	((fp_except_t)					\
+ 	((~__fpgetreg(FP_MSKS_REG) & FP_MSKS_FLD) >> FP_MSKS_OFF))
+ #define	fpsetmask(m)	((fp_except_t)					\
+ 	(~__fpsetreg(~(m), FP_MSKS_REG, FP_MSKS_FLD, FP_MSKS_OFF)) &	\
+ 	    (FP_MSKS_FLD >> FP_MSKS_OFF))
+ #define	fpgetsticky()	((fp_except_t)					\
+ 	((__fpgetreg(FP_STKY_REG) & FP_STKY_FLD) >> FP_STKY_OFF))
+ #define	fpresetsticky(m) ((fp_except_t)					\
+ 	__fpsetreg(0, FP_STKY_REG, (m), FP_STKY_OFF))
+ #define	fpsetsticky(m)	fpresetsticky(m)
  
  #endif /* !_MACHINE_IEEEFP_H_ */
Index: sys/i386/include/floatingpoint.h
===================================================================
RCS file: /cvs/src/sys/i386/include/floatingpoint.h,v
retrieving revision 1.12
diff -c -r1.12 floatingpoint.h
*** sys/i386/include/floatingpoint.h	1 Jun 2002 17:39:46 -0000	1.12
--- sys/i386/include/floatingpoint.h	13 Jan 2003 01:10:33 -0000
***************
*** 37,130 ****
  #ifndef _FLOATINGPOINT_H_
  #define _FLOATINGPOINT_H_
  
- /*
-  * IEEE floating point structure and function definitions
-  */
- 
- /*-
-  * XXX the following undocumented pollution is exported:
-  *	fpsetsticky().
-  *	FP*FLD, FP*OFF and FP*REG from <machine/ieeefp.h>
-  */
- 
- #include <sys/cdefs.h>
  #include <machine/ieeefp.h>
- 
- #ifdef __GNUC__
- 
- #define __fldenv(addr)	__asm __volatile("fldenv %0" : : "m" (*(addr)))
- #define __fnstenv(addr)	__asm __volatile("fnstenv %0" : "=m" (*(addr)))
- #define __fnstcw(addr)	__asm __volatile("fnstcw %0" : "=m" (*(addr)))
- #define __fnstsw(addr)	__asm __volatile("fnstsw %0" : "=m" (*(addr)))
- 
- /*
-  * return the contents of a FP register
-  */
- static __inline__ int
- __fpgetreg(int _reg)
- {
- 	unsigned short _mem;
- 
- 	/*-
- 	 * This is more efficient than it looks.  The switch gets optimized
- 	 * away if _reg is constant.
- 	 *
- 	 * The default case only supports _reg == 0.  We could handle more
- 	 * registers (e.g., tags) using fnstenv, but the interface doesn't
- 	 * support more.
- 	 */
- 	switch(_reg) {
- 	default:
- 		__fnstcw(&_mem);
- 		break;
- 	case FP_STKY_REG:
- 		__fnstsw(&_mem);
- 		break;
- 	}
- 	return _mem;
- }
- 
- /*
-  * set a FP mode; return previous mode
-  */
- static __inline__ int
- __fpsetreg(int _m, int _reg, int _fld, int _off)
- {
- 	unsigned _env[7];
- 	unsigned _p;
- 
- 	/*
- 	 * _reg == 0 could be handled better using fnstcw/fldcw.
- 	 */
- 	__fnstenv(_env);
- 	_p =  (_env[_reg] & _fld) >> _off;
- 	_env[_reg] = (_env[_reg] & ~_fld) | (_m << _off & _fld);
- 	__fldenv(_env);
- 	return _p;
- }
- 
- #endif /* __GNUC__ */
- 
- /*
-  * SysV/386 FP control interface
-  */
- #define	fpgetround()	((fp_rnd_t)					\
- 	((__fpgetreg(FP_RND_REG) & FP_RND_FLD) >> FP_RND_OFF))
- #define	fpsetround(m)	((fp_rnd_t)					\
- 	__fpsetreg((m), FP_RND_REG, FP_RND_FLD, FP_RND_OFF))
- #define	fpgetprec()	((fp_prec_t)					\
- 	((__fpgetreg(FP_PRC_REG) & FP_PRC_FLD) >> FP_PRC_OFF))
- #define	fpsetprec(m)	((fp_prec_t)					\
- 	__fpsetreg((m), FP_PRC_REG, FP_PRC_FLD, FP_PRC_OFF))
- #define	fpgetmask()	((fp_except_t)					\
- 	((~__fpgetreg(FP_MSKS_REG) & FP_MSKS_FLD) >> FP_MSKS_OFF))
- #define	fpsetmask(m)	((fp_except_t)					\
- 	(~__fpsetreg(~(m), FP_MSKS_REG, FP_MSKS_FLD, FP_MSKS_OFF)) &	\
- 	    (FP_MSKS_FLD >> FP_MSKS_OFF))
- #define	fpgetsticky()	((fp_except_t)					\
- 	((__fpgetreg(FP_STKY_REG) & FP_STKY_FLD) >> FP_STKY_OFF))
- #define	fpresetsticky(m) ((fp_except_t)					\
- 	__fpsetreg(0, FP_STKY_REG, (m), FP_STKY_OFF))
- #define	fpsetsticky(m)	fpresetsticky(m)
  
  #endif /* !_FLOATINGPOINT_H_ */
--- 37,42 ----
Index: sys/ia64/include/ieeefp.h
===================================================================
RCS file: /cvs/src/sys/ia64/include/ieeefp.h,v
retrieving revision 1.3
diff -c -r1.3 ieeefp.h
*** sys/ia64/include/ieeefp.h	13 May 2002 05:01:05 -0000	1.3
--- sys/ia64/include/ieeefp.h	13 Jan 2003 01:03:01 -0000
***************
*** 29,34 ****
--- 29,35 ----
  #ifndef _MACHINE_IEEEFP_H_
  #define _MACHINE_IEEEFP_H_
  
+ #include <sys/cdefs.h>
  #include <machine/fpu.h>
  
  typedef int fp_except_t;
***************
*** 47,51 ****
--- 48,64 ----
      FP_RN=2,			/* round to nearest representable number */
      FP_RP=3			/* round toward positive infinity */
  } fp_rnd_t;
+ 
+ /*
+  * SysV/386 FP control interface for platforms with library implementations
+  */
+ __BEGIN_DECLS
+ extern fp_rnd_t    fpgetround(void);
+ extern fp_rnd_t    fpsetround(fp_rnd_t);
+ extern fp_except_t fpgetmask(void);
+ extern fp_except_t fpsetmask(fp_except_t);
+ extern fp_except_t fpgetsticky(void);
+ extern fp_except_t fpsetsticky(fp_except_t);
+ __END_DECLS
  
  #endif /* _MACHINE_IEEEFP_H_ */
Index: sys/ia64/include/floatingpoint.h
===================================================================
RCS file: /cvs/src/sys/ia64/include/floatingpoint.h,v
retrieving revision 1.1
diff -c -r1.1 floatingpoint.h
*** sys/ia64/include/floatingpoint.h	29 Sep 2000 13:46:05 -0000	1.1
--- sys/ia64/include/floatingpoint.h	13 Jan 2003 01:10:53 -0000
***************
*** 32,35 ****
--- 32,40 ----
   * $FreeBSD: src/sys/ia64/include/floatingpoint.h,v 1.1 2000/09/29 13:46:05 dfr Exp $
   */
  
+ #ifndef _FLOATINGPOINT_H_
+ #define _FLOATINGPOINT_H_
+ 
  #include <machine/ieeefp.h>
+ 
+ #endif /* !_FLOATINGPOINT_H_ */
Index: sys/powerpc/include/ieeefp.h
===================================================================
RCS file: /cvs/src/sys/powerpc/include/ieeefp.h,v
retrieving revision 1.1
diff -c -r1.1 ieeefp.h
*** sys/powerpc/include/ieeefp.h	13 May 2002 07:44:42 -0000	1.1
--- sys/powerpc/include/ieeefp.h	13 Jan 2003 01:03:26 -0000
***************
*** 8,13 ****
--- 8,15 ----
  #ifndef _MACHINE_IEEEFP_H_
  #define _MACHINE_IEEEFP_H_
  
+ #include <sys/cdefs.h>
+ 
  typedef int fp_except_t;
  #define FP_X_IMP	0x01	/* imprecise (loss of precision) */
  #define FP_X_DZ		0x02	/* divide-by-zero exception */
***************
*** 21,25 ****
--- 23,39 ----
      FP_RP=2,			/* round toward positive infinity */
      FP_RM=3			/* round toward negative infinity */
  } fp_rnd_t;
+ 
+ /*
+  * SysV/386 FP control interface for platforms with library implementations
+  */
+ __BEGIN_DECLS
+ extern fp_rnd_t    fpgetround(void);
+ extern fp_rnd_t    fpsetround(fp_rnd_t);
+ extern fp_except_t fpgetmask(void);
+ extern fp_except_t fpsetmask(fp_except_t);
+ extern fp_except_t fpgetsticky(void);
+ extern fp_except_t fpsetsticky(fp_except_t);
+ __END_DECLS
  
  #endif /* _MACHINE_IEEEFP_H_ */
Index: sys/sparc64/include/ieeefp.h
===================================================================
RCS file: /cvs/src/sys/sparc64/include/ieeefp.h,v
retrieving revision 1.3
diff -c -r1.3 ieeefp.h
*** sys/sparc64/include/ieeefp.h	14 Sep 2002 18:00:44 -0000	1.3
--- sys/sparc64/include/ieeefp.h	13 Jan 2003 01:03:41 -0000
***************
*** 7,12 ****
--- 7,13 ----
  #ifndef _MACHINE_IEEEFP_H_
  #define _MACHINE_IEEEFP_H_
  
+ #include <sys/cdefs.h>
  #include <machine/fsr.h>
  
  typedef int fp_except_t;
***************
*** 22,26 ****
--- 23,39 ----
  	FP_RP = FSR_RD_PINF,	/* round toward positive infinity */
  	FP_RM = FSR_RD_NINF	/* round toward negative infinity */
  } fp_rnd_t;
+ 
+ /*
+  * SysV/386 FP control interface for platforms with library implementations
+  */
+ __BEGIN_DECLS
+ extern fp_rnd_t    fpgetround(void);
+ extern fp_rnd_t    fpsetround(fp_rnd_t);
+ extern fp_except_t fpgetmask(void);
+ extern fp_except_t fpsetmask(fp_except_t);
+ extern fp_except_t fpgetsticky(void);
+ extern fp_except_t fpsetsticky(fp_except_t);
+ __END_DECLS
  
  #endif /* _MACHINE_IEEEFP_H_ */

--------------B8AE5B3A0FF5EB7A07DC7E4B--


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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3E224AAA.11792616>