This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] sysdeps/*/fpu/bits/mathinline.h fixes


Hi!

Compiling a C++ program like this:
#include <math.h>
int main(void) { return 0; }

fails with current glibc if -I/usr/include is given to g++.
(both egcs 1.1.x and gcc 2.96 behave the same way, they don't like the same
function used once with throw() and once without).
This patch tries to deal with it (tested only on i386, sparc and sparc64):

2000-06-01  Jakub Jelinek  <jakub@redhat.com>

	* libc/sysdeps/alpha/fpu/bits/mathinline.h: Add __THROW to all
	inlines to match prototypes in mathcalls.h.
	* libc/sysdeps/i386/fpu/bits/mathinline.h: Likewise. 
	* libc/sysdeps/m68k/fpu/bits/mathinline.h: Likewise.
	* libc/sysdeps/powerpc/fpu/bits/mathinline.h: Likewise.
	* libc/sysdeps/sparc/fpu/bits/mathinline.h: Likewise.

--- libc/sysdeps/alpha/fpu/bits/mathinline.h.jj	Fri Nov 12 16:30:30 1999
+++ libc/sysdeps/alpha/fpu/bits/mathinline.h	Wed May 31 23:16:05 2000
@@ -1,5 +1,5 @@
 /* Inline math functions for Alpha.
-   Copyright (C) 1996, 1997, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by David Mosberger-Tang.
 
@@ -60,7 +60,7 @@
 
 #define __inline_copysign(NAME, TYPE)					\
 __MATH_INLINE TYPE							\
-NAME (TYPE __x, TYPE __y)						\
+NAME (TYPE __x, TYPE __y) __THROW					\
 {									\
   TYPE __z;								\
   __asm ("cpys %1, %2, %0" : "=f" (__z) : "f" (__y), "f" (__x));	\
@@ -76,14 +76,14 @@ __inline_copysign(copysign, double)
 
 
 #if __GNUC_PREREQ (2, 8)
-__MATH_INLINE float __fabsf (float __x) { return __builtin_fabsf (__x); }
-__MATH_INLINE float fabsf (float __x) { return __builtin_fabsf (__x); }
-__MATH_INLINE double __fabs (double __x) { return __builtin_fabs (__x); }
-__MATH_INLINE double fabs (double __x) { return __builtin_fabs (__x); }
+__MATH_INLINE float __fabsf (float __x) __THROW { return __builtin_fabsf (__x); }
+__MATH_INLINE float fabsf (float __x) __THROW { return __builtin_fabsf (__x); }
+__MATH_INLINE double __fabs (double __x) __THROW { return __builtin_fabs (__x); }
+__MATH_INLINE double fabs (double __x) __THROW { return __builtin_fabs (__x); }
 #else
 #define __inline_fabs(NAME, TYPE)			\
 __MATH_INLINE TYPE					\
-NAME (TYPE __x)						\
+NAME (TYPE __x) __THROW					\
 {							\
   TYPE __z;						\
   __asm ("cpys $f31, %1, %0" : "=f" (__z) : "f" (__x));	\
@@ -104,7 +104,7 @@ __inline_fabs(fabs, double)
    must be integral, as this avoids unpleasant integer overflows.  */
 
 __MATH_INLINE float
-__floorf (float __x)
+__floorf (float __x) __THROW
 {
   /* Check not zero since floor(-0) == -0.  */
   if (__x != 0 && fabsf (__x) < 16777216.0f)  /* 1 << FLT_MANT_DIG */
@@ -130,7 +130,7 @@ __floorf (float __x)
 }
 
 __MATH_INLINE double
-__floor (double __x)
+__floor (double __x) __THROW
 {
   if (__x != 0 && fabs (__x) < 9007199254740992.0)  /* 1 << DBL_MANT_DIG */
     {
@@ -148,26 +148,26 @@ __floor (double __x)
   return __x;
 }
 
-__MATH_INLINE float floorf (float __x) { return __floorf(__x); }
-__MATH_INLINE double floor (double __x) { return __floor(__x); }
+__MATH_INLINE float floorf (float __x) __THROW { return __floorf(__x); }
+__MATH_INLINE double floor (double __x) __THROW { return __floor(__x); }
 
 
-__MATH_INLINE float __fdimf (float __x, float __y)
+__MATH_INLINE float __fdimf (float __x, float __y) __THROW
 {
   return __x < __y ? 0.0f : __x - __y;
 }
 
-__MATH_INLINE float fdimf (float __x, float __y)
+__MATH_INLINE float fdimf (float __x, float __y) __THROW
 {
   return __x < __y ? 0.0f : __x - __y;
 }
 
-__MATH_INLINE double __fdim (double __x, double __y)
+__MATH_INLINE double __fdim (double __x, double __y) __THROW
 {
   return __x < __y ? 0.0 : __x - __y;
 }
 
-__MATH_INLINE double fdim (double __x, double __y)
+__MATH_INLINE double fdim (double __x, double __y) __THROW
 {
   return __x < __y ? 0.0 : __x - __y;
 }
--- libc/sysdeps/i386/fpu/bits/mathinline.h.jj	Wed May 31 23:02:51 2000
+++ libc/sysdeps/i386/fpu/bits/mathinline.h	Wed May 31 23:28:03 2000
@@ -115,19 +115,19 @@
 # if __GNUC_PREREQ (2, 8)
 /* Test for negative number.  Used in the signbit() macro.  */
 __MATH_INLINE int
-__signbitf (float __x)
+__signbitf (float __x) __THROW
 {
   __extension__ union { float __f; int __i; } __u = { __f: __x };
   return __u.__i < 0;
 }
 __MATH_INLINE int
-__signbit (double __x)
+__signbit (double __x) __THROW
 {
   __extension__ union { double __d; int __i[2]; } __u = { __d: __x };
   return __u.__i[1] < 0;
 }
 __MATH_INLINE int
-__signbitl (long double __x)
+__signbitl (long double __x) __THROW
 {
   __extension__ union { long double __l; int __i[3]; } __u = { __l: __x };
   return (__u.__i[2] & 0x8000) != 0;
@@ -189,11 +189,11 @@ __signbitl (long double __x)
 #endif
 
 #define __inline_mathop_decl_(float_type, func, op, params...) \
-  __MATH_INLINE float_type func (float_type);				      \
+  __MATH_INLINE float_type func (float_type) __THROW;			      \
   __inline_mathop_declNP_ (float_type, func, op, params)
 
 #define __inline_mathop_declNP_(float_type, func, op, params...) \
-  __MATH_INLINE float_type func (float_type __x)			      \
+  __MATH_INLINE float_type func (float_type __x) __THROW		      \
   {									      \
     register float_type __result;					      \
     __asm __volatile__ (op : "=t" (__result) : params);			      \
@@ -242,33 +242,33 @@ __signbitl (long double __x)
 #endif
 
 #define __inline_mathcode_(float_type, func, arg, code) \
-  __MATH_INLINE float_type func (float_type);				      \
+  __MATH_INLINE float_type func (float_type) __THROW;			      \
   __inline_mathcodeNP_(float_type, func, arg, code)
 
 #define __inline_mathcodeNP_(float_type, func, arg, code) \
-  __MATH_INLINE float_type func (float_type arg)			      \
+  __MATH_INLINE float_type func (float_type arg) __THROW		      \
   {									      \
     code;								      \
   }
 
 
 #define __inline_mathcode2_(float_type, func, arg1, arg2, code) \
-  __MATH_INLINE float_type func (float_type, float_type);		      \
+  __MATH_INLINE float_type func (float_type, float_type) __THROW;	      \
   __inline_mathcodeNP2_ (float_type, func, arg1, arg2, code)
 
 #define __inline_mathcodeNP2_(float_type, func, arg1, arg2, code) \
-  __MATH_INLINE float_type func (float_type arg1, float_type arg2)	      \
+  __MATH_INLINE float_type func (float_type arg1, float_type arg2) __THROW    \
   {									      \
     code;								      \
   }
 
 #define __inline_mathcode3_(float_type, func, arg1, arg2, arg3, code) \
-  __MATH_INLINE float_type func (float_type, float_type, float_type);	      \
+  __MATH_INLINE float_type func (float_type, float_type, float_type) __THROW; \
   __inline_mathcodeNP3_(float_type, func, arg1, arg2, arg3, code)
 
 #define __inline_mathcodeNP3_(float_type, func, arg1, arg2, arg3, code) \
   __MATH_INLINE float_type func (float_type arg1, float_type arg2,	      \
-				 float_type arg3)			      \
+				 float_type arg3) __THROW		      \
   {									      \
     code;								      \
   }
@@ -331,19 +331,19 @@ __inline_mathcode (__pow2, __x, \
   *__cosx = __cosr
 
 __MATH_INLINE void
-__sincos (double __x, double *__sinx, double *__cosx)
+__sincos (double __x, double *__sinx, double *__cosx) __THROW
 {
   __sincos_code;
 }
 
 __MATH_INLINE void
-__sincosf (float __x, float *__sinx, float *__cosx)
+__sincosf (float __x, float *__sinx, float *__cosx) __THROW
 {
   __sincos_code;
 }
 
 __MATH_INLINE void
-__sincosl (long double __x, long double *__sinx, long double *__cosx)
+__sincosl (long double __x, long double *__sinx, long double *__cosx) __THROW
 {
   __sincos_code;
 }
@@ -557,7 +557,7 @@ __inline_mathcodeNP (ceil, __x, \
   return __value
 
 __MATH_INLINE double
-ldexp (double __x, int __y)
+ldexp (double __x, int __y) __THROW
 {
   __ldexp_code;
 }
@@ -619,13 +619,13 @@ __inline_mathop_declNP (log2, "fld1; fxc
 #endif /* __FAST_MATH__ */
 
 __MATH_INLINE float
-ldexpf (float __x, int __y)
+ldexpf (float __x, int __y) __THROW
 {
   __ldexp_code;
 }
 
 __MATH_INLINE long double
-ldexpl (long double __x, int __y)
+ldexpl (long double __x, int __y) __THROW
 {
   __ldexp_code;
 }
@@ -643,17 +643,17 @@ __inline_mathopNP (rint, "frndint")
      : "=m" (__lrintres) : "t" (__x) : "st");				      \
   return __lrintres
 __MATH_INLINE long int
-lrintf (float __x)
+lrintf (float __x) __THROW
 {
   __lrint_code;
 }
 __MATH_INLINE long int
-lrint (double __x)
+lrint (double __x) __THROW
 {
   __lrint_code;
 }
 __MATH_INLINE long int
-lrintl (long double __x)
+lrintl (long double __x) __THROW
 {
   __lrint_code;
 }
@@ -666,17 +666,17 @@ lrintl (long double __x)
      : "=m" (__llrintres) : "t" (__x) : "st");				      \
   return __llrintres
 __MATH_INLINE long long int
-llrintf (float __x)
+llrintf (float __x) __THROW
 {
   __llrint_code;
 }
 __MATH_INLINE long long int
-llrint (double __x)
+llrint (double __x) __THROW
 {
   __llrint_code;
 }
 __MATH_INLINE long long int
-llrintl (long double __x)
+llrintl (long double __x) __THROW
 {
   __llrint_code;
 }
@@ -701,7 +701,7 @@ __inline_mathcodeNP2 (drem, __x, __y, \
 
 /* This function is used in the `isfinite' macro.  */
 __MATH_INLINE int
-__finite (double __x)
+__finite (double __x) __THROW
 {
   return (__extension__
 	  (((((union { double __d; int __i[2]; }) {__d: __x}).__i[1]
--- libc/sysdeps/m68k/fpu/bits/mathinline.h.jj	Wed May 31 23:39:36 2000
+++ libc/sysdeps/m68k/fpu/bits/mathinline.h	Wed May 31 23:50:30 2000
@@ -1,5 +1,5 @@
 /* Definitions of inline math functions implemented by the m68881/2.
-   Copyright (C) 1991,92,93,94,96,97,98,99 Free Software Foundation, Inc.
+   Copyright (C) 1991,92,93,94,96,97,98,99,2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -109,7 +109,7 @@
 #endif
 
 #define __inline_mathop1(float_type,func, op)				      \
-  __m81_defun (float_type, func, (float_type __mathop_x))		      \
+  __m81_defun (float_type, func, (float_type __mathop_x)) __THROW	      \
   {									      \
     float_type __result;						      \
     __asm("f" __STRING(op) "%.x %1, %0" : "=f" (__result) : "f" (__mathop_x));\
@@ -169,7 +169,7 @@ __inline_mathop(trunc, intrz)
 
 #define __inline_functions(float_type, s)				  \
 __m81_inline float_type							  \
-__m81_u(__CONCAT(__frexp,s))(float_type __value, int *__expptr)		  \
+__m81_u(__CONCAT(__frexp,s))(float_type __value, int *__expptr)	__THROW	  \
 {									  \
   float_type __mantissa, __exponent;					  \
   int __iexponent;							  \
@@ -190,7 +190,7 @@ __m81_u(__CONCAT(__frexp,s))(float_type 
   return __mantissa;							  \
 }									  \
 									  \
-__m81_defun (float_type, __CONCAT(__floor,s), (float_type __x))		  \
+__m81_defun (float_type, __CONCAT(__floor,s), (float_type __x))	__THROW	  \
 {									  \
   float_type __result;							  \
   unsigned long int __ctrl_reg;						  \
@@ -206,7 +206,7 @@ __m81_defun (float_type, __CONCAT(__floo
   return __result;							  \
 }									  \
 									  \
-__m81_defun (float_type, __CONCAT(__ceil,s), (float_type __x))		  \
+__m81_defun (float_type, __CONCAT(__ceil,s), (float_type __x)) __THROW	  \
 {									  \
   float_type __result;							  \
   unsigned long int __ctrl_reg;						  \
@@ -232,7 +232,7 @@ __inline_functions(long double,l)
 #ifdef __USE_MISC
 
 # define __inline_functions(float_type, s)				  \
-__m81_defun (int, __CONCAT(__isinf,s), (float_type __value))		  \
+__m81_defun (int, __CONCAT(__isinf,s), (float_type __value)) __THROW	  \
 {									  \
   /* There is no branch-condition for infinity,				  \
      so we must extract and examine the condition codes manually.  */	  \
@@ -242,7 +242,7 @@ __m81_defun (int, __CONCAT(__isinf,s), (
   return (__fpsr & (2 << 24)) ? (__fpsr & (8 << 24) ? -1 : 1) : 0;	  \
 }									  \
 									  \
-__m81_defun (int, __CONCAT(__finite,s), (float_type __value))		  \
+__m81_defun (int, __CONCAT(__finite,s), (float_type __value)) __THROW	  \
 {									  \
   /* There is no branch-condition for infinity, so we must extract and	  \
      examine the condition codes manually.  */				  \
@@ -253,7 +253,7 @@ __m81_defun (int, __CONCAT(__finite,s), 
 }									  \
 									  \
 __m81_defun (float_type, __CONCAT(__scalbn,s),				  \
-	     (float_type __x, int __n))					  \
+	     (float_type __x, int __n))	__THROW				  \
 {									  \
   float_type __result;							  \
   __asm ("fscale%.l %1, %0" : "=f" (__result) : "dmi" (__n), "0" (__x));  \
@@ -270,7 +270,7 @@ __inline_functions(long double,l)
 #if defined __USE_MISC || defined __USE_XOPEN
 
 # define __inline_functions(float_type, s)				  \
-__m81_defun (int, __CONCAT(__isnan,s), (float_type __value))		  \
+__m81_defun (int, __CONCAT(__isnan,s), (float_type __value)) __THROW	  \
 {									  \
   char __result;							  \
   __asm("ftst%.x %1\n"							  \
@@ -290,7 +290,7 @@ __inline_functions(long double,l)
 #ifdef __USE_ISOC99
 
 # define __inline_functions(float_type, s)				  \
-__m81_defun (int, __CONCAT(__signbit,s), (float_type __value))		  \
+__m81_defun (int, __CONCAT(__signbit,s), (float_type __value)) __THROW	  \
 {									  \
   /* There is no branch-condition for the sign bit, so we must extract	  \
      and examine the condition codes manually.  */			  \
@@ -301,12 +301,12 @@ __m81_defun (int, __CONCAT(__signbit,s),
 }									  \
 									  \
 __m81_defun (float_type, __CONCAT(__scalbln,s),				  \
-	     (float_type __x, long int __n))				  \
+	     (float_type __x, long int __n)) __THROW			  \
 {									  \
   return __CONCAT(__scalbn,s) (__x, __n);				  \
 }									  \
 									  \
-__m81_defun (float_type, __CONCAT(__nearbyint,s), (float_type __x))	  \
+__m81_defun (float_type, __CONCAT(__nearbyint,s), (float_type __x)) __THROW \
 {									  \
   float_type __result;							  \
   unsigned long int __ctrl_reg;						  \
@@ -320,7 +320,7 @@ __m81_defun (float_type, __CONCAT(__near
   return __result;							  \
 }									  \
 									  \
-__m81_defun (long int, __CONCAT(__lrint,s), (float_type __x))		  \
+__m81_defun (long int, __CONCAT(__lrint,s), (float_type __x)) __THROW	  \
 {									  \
   long int __result;							  \
   __asm ("fmove%.l %1, %0" : "=dm" (__result) : "f" (__x));		  \
@@ -329,7 +329,7 @@ __m81_defun (long int, __CONCAT(__lrint,
 									  \
 __m81_inline float_type							  \
 __m81_u(__CONCAT(__fma,s))(float_type __x, float_type __y,		  \
-			   float_type __z)				  \
+			   float_type __z) __THROW			  \
 {									  \
   return (__x * __y) + __z;						  \
 }
@@ -346,7 +346,7 @@ __inline_functions (long double,l)
 # define __inline_functions(float_type, s)				\
 __m81_inline void							\
 __m81_u(__CONCAT(__sincos,s))(float_type __x, float_type *__sinx,	\
-			      float_type *__cosx)			\
+			      float_type *__cosx) __THROW		\
 {									\
   __asm ("fsincos%.x %2,%1:%0"						\
 	 : "=f" (*__sinx), "=f" (*__cosx) : "f" (__x));			\
@@ -367,13 +367,13 @@ __inline_functions (long double,l)
    NAME, to make token pasting work correctly with -traditional.  */
 # define __inline_forward_c(rettype, name, args1, args2)	\
 extern __inline rettype __attribute__((__const__))	\
-name args1						\
+name args1 __THROW					\
 {							\
   return __CONCAT(__,name) args2;			\
 }
 
 # define __inline_forward(rettype, name, args1, args2)	\
-extern __inline rettype name args1			\
+extern __inline rettype name args1 __THROW		\
 {							\
   return __CONCAT(__,name) args2;			\
 }
--- libc/sysdeps/powerpc/fpu/bits/mathinline.h.jj	Sun Oct 31 18:35:13 1999
+++ libc/sysdeps/powerpc/fpu/bits/mathinline.h	Wed May 31 23:50:48 2000
@@ -1,5 +1,6 @@
 /* Inline math functions for powerpc.
-   Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -45,9 +46,9 @@
 #endif  /* __cplusplus */
 
 #ifdef __USE_ISOC99
-__MATH_INLINE long int lrint (double __x);
+__MATH_INLINE long int lrint (double __x) __THROW;
 __MATH_INLINE long int
-lrint (double __x)
+lrint (double __x) __THROW
 {
   union {
     double __d;
@@ -57,9 +58,9 @@ lrint (double __x)
   return __u.__ll[1];
 }
 
-__MATH_INLINE long int lrintf (float __x);
+__MATH_INLINE long int lrintf (float __x) __THROW;
 __MATH_INLINE long int
-lrintf (float __x)
+lrintf (float __x) __THROW
 {
   union {
     double __d;
@@ -69,16 +70,16 @@ lrintf (float __x)
   return __u.__ll[1];
 }
 
-__MATH_INLINE double fdim (double __x, double __y);
+__MATH_INLINE double fdim (double __x, double __y) __THROW;
 __MATH_INLINE double
-fdim (double __x, double __y)
+fdim (double __x, double __y) __THROW
 {
   return __x < __y ? 0 : __x - __y;
 }
 
-__MATH_INLINE float fdimf (float __x, float __y);
+__MATH_INLINE float fdimf (float __x, float __y) __THROW;
 __MATH_INLINE float
-fdimf (float __x, float __y)
+fdimf (float __x, float __y) __THROW
 {
   return __x < __y ? 0 : __x - __y;
 }
--- libc/sysdeps/sparc/fpu/bits/mathinline.h.jj	Mon Jan  3 07:35:20 2000
+++ libc/sysdeps/sparc/fpu/bits/mathinline.h	Wed May 31 23:50:59 2000
@@ -1,5 +1,5 @@
 /* Inline math functions for SPARC.
-   Copyright (C) 1999 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Jakub Jelinek <jj@ultra.linux.cz>.
 
@@ -144,7 +144,7 @@ __signbitl (long double __x)
 #endif /* sparc64 */
 
 __MATH_INLINE double
-sqrt(double __x)
+sqrt(double __x) __THROW
 {
   register double __r;
   __asm ("fsqrtd %1,%0" : "=f" (__r) : "f" (__x));
@@ -152,7 +152,7 @@ sqrt(double __x)
 }
 
 __MATH_INLINE float
-sqrtf(float __x)
+sqrtf(float __x) __THROW
 {
   register float __r;
   __asm ("fsqrts %1,%0" : "=f" (__r) : "f" (__x));
@@ -161,7 +161,7 @@ sqrtf(float __x)
 
 #if __WORDSIZE == 64
 __MATH_INLINE long double
-sqrtl(long double __x)
+sqrtl(long double __x) __THROW
 {
   long double __r;
   extern void _Qp_sqrt(long double *, __const__ long double *);

	Jakub

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]