Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Jan 2003 18:27:00 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Jake Burkholder <jake@locore.ca>, sparc@FreeBSD.ORG, current@FreeBSD.ORG
Subject:   [PATCH] Re: fpsetmask on sparc64
Message-ID:  <3E2223F4.5554718E@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>

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

This patch also affects the IA64 and Alpha, as well as just the SPARC.

It took a lot of discussion, but it seems to me that the problem is
that the prototypes in scope aren't in scope when the wrong include
file is included.

This is partially a problem with the FreeBSD code, because it's really
not healthy to have "#ifdef i386" in /usr/include/*, since these are
(supposedly) machine independent files that should not change behaviour
based on which platform you are using to compile them.

That basically means that the machine dependent behaviour should be
in <machine/XXX.h> headers.  This is actually how it works for the
i386 in -current, where the symbols come into scope as macros whose
definitions reference inline functions.  But this layering is broken
for the other platforms, where the symbols are supposed to come into
scope by means of prototypes.

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).

So I've basically gotten rid of the #ifdef, and pushed the function
prototypes down.


This will incidently work around the improper inclusion of machine
dependent files by ports.  I can't really fix that, without the ports
that do it being fixed.  For code wher this isn't an issue, though,
it actually fixes, rather than works around, the problem, in what I
thing is the correct way.

Context diff attached.

-- Terry
--------------C36EAE74A9FB2FE61C3D5D7B
Content-Type: text/plain; charset=us-ascii;
 name="fixfp.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="fixfp.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	12 Jan 2003 22:04:26 -0000
***************
*** 11,28 ****
  
  #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_ */
--- 11,16 ----
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	12 Jan 2003 22:10:33 -0000
***************
*** 32,35 ****
--- 32,63 ----
   * $FreeBSD: src/sys/alpha/include/floatingpoint.h,v 1.3 2000/05/01 20:17:49 peter Exp $
   */
  
+ #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>
+ 
+ /*
+  * SysV/386 FP control interface for platforms with library implemetnations
+  */
+ __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 /* !_FLOATINGPOINT_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	12 Jan 2003 22:10:50 -0000
***************
*** 32,35 ****
--- 32,63 ----
   * $FreeBSD: src/sys/ia64/include/floatingpoint.h,v 1.1 2000/09/29 13:46:05 dfr Exp $
   */
  
+ #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>
+ 
+ /*
+  * SysV/386 FP control interface for platforms with library implemetnations
+  */
+ __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 /* !_FLOATINGPOINT_H_ */
Index: sys/sparc64/include/floatingpoint.h
===================================================================
RCS file: /cvs/src/sys/sparc64/include/floatingpoint.h,v
retrieving revision 1.1
diff -c -r1.1 floatingpoint.h
*** sys/sparc64/include/floatingpoint.h	10 Feb 2002 14:27:20 -0000	1.1
--- sys/sparc64/include/floatingpoint.h	12 Jan 2003 22:11:14 -0000
***************
*** 32,37 ****
--- 32,60 ----
  #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>
+ 
+ /*
+  * SysV/386 FP control interface for platforms with library implemetnations
+  */
+ __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 /* !_FLOATINGPOINT_H_ */

--------------C36EAE74A9FB2FE61C3D5D7B--


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?3E2223F4.5554718E>