This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, quadmath] PR 46625: Prefix internal libquadmath functions by __quadmath_


As there is no libquadmath maintainer yes, this needs the approval of a global maintainer.

As suggested by Jakub: This patch prefixes all functions of libquadmath, which are not part of the interface (cf. *.map file and quadmath.h) with __quadmath_ to avoid symbol space pollution.

As MinGW seemingly also uses internally gdtoa (also not mangled, cf. PR), one gets without this patch linkage errors on MinGW (and on older versions of MinGW64).

Build and regtested on x86-64-linux.
OK for the trunk?

Tobias
2010-12-11  Tobias Burnus  <burnus@net-b.de>

	PR fortran/46625
	* gdtoa/gdtoaimp.h: Mangle internal functions by
	prefixing them with __quadmath. Don't use gdtoa's strcp(y).
	* gdtoa/g_Qfmt.c (g_Qfmt): Use strcpy instead of strcp.
	* gdtoa/misc.c (strcpy): Renamed from strcp and only use
	if NO_STRING_H is set.
	* quadmath-imp.h (__quadmath_rem_pio2q, __quadmath_kernel_sincosq
	__quadmath_kernel_sinq, __quadmath_kernel_cosq): Added
	__quadmath prefix to internal functions.
	* math/cosq.c (cosq): Ditto.
	* math/sinq.c (cosq): Ditto.
	* math/tanq.c (tanq,__quadmath_kernel_tanq): Ditto.
	* math/rem_pio2q.c (rem_pio2, __quadmath_kernel_rem_pio2): Ditto.
	* math/sinq_kernel.c (__quadmath_kernel_sinq): Ditto.
	* math/cosq_kernel.c (__quadmath_kernel_cosq): Ditto.

Index: libquadmath/gdtoa/gdtoaimp.h
===================================================================
--- libquadmath/gdtoa/gdtoaimp.h	(Revision 167702)
+++ libquadmath/gdtoa/gdtoaimp.h	(Arbeitskopie)
@@ -472,51 +472,54 @@ extern void memcpy_D2A ANSI((void*, cons
 #define Bcopy(x,y) memcpy(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int))
 #endif /* NO_STRING_H */
 
-#define Balloc Balloc_D2A
-#define Bfree Bfree_D2A
-#define ULtoQ ULtoQ_D2A
-#define ULtof ULtof_D2A
-#define ULtod ULtod_D2A
-#define ULtodd ULtodd_D2A
-#define ULtox ULtox_D2A
-#define ULtoxL ULtoxL_D2A
-#define any_on any_on_D2A
-#define b2d b2d_D2A
-#define bigtens bigtens_D2A
-#define cmp cmp_D2A
-#define copybits copybits_D2A
-#define d2b d2b_D2A
-#define decrement decrement_D2A
-#define diff diff_D2A
-#define dtoa_result dtoa_result_D2A
-#define g__fmt g__fmt_D2A
-#define gethex gethex_D2A
-#define hexdig hexdig_D2A
-#define hexnan hexnan_D2A
-#define hi0bits(x) hi0bits_D2A((ULong)(x))
-#define i2b i2b_D2A
-#define increment increment_D2A
-#define lo0bits lo0bits_D2A
-#define lshift lshift_D2A
-#define match match_D2A
-#define mult mult_D2A
-#define multadd multadd_D2A
-#define nrv_alloc nrv_alloc_D2A
-#define pow5mult pow5mult_D2A
-#define quorem quorem_D2A
-#define ratio ratio_D2A
-#define rshift rshift_D2A
-#define rv_alloc rv_alloc_D2A
-#define s2b s2b_D2A
-#define set_ones set_ones_D2A
-#define strcp strcp_D2A
-#define strtoIg strtoIg_D2A
-#define sum sum_D2A
-#define tens tens_D2A
-#define tinytens tinytens_D2A
-#define tinytens tinytens_D2A
-#define trailz trailz_D2A
-#define ulp ulp_D2A
+#define Balloc __quadmath_Balloc_D2A
+#define Bfree __quadmath_Bfree_D2A
+#define ULtoQ __quadmath_ULtoQ_D2A
+#define ULtof __quadmath_ULtof_D2A
+#define ULtod __quadmath_ULtod_D2A
+#define ULtodd __quadmath_ULtodd_D2A
+#define ULtox __quadmath_ULtox_D2A
+#define ULtoxL __quadmath_ULtoxL_D2A
+#define any_on __quadmath_any_on_D2A
+#define b2d __quadmath_b2d_D2A
+#define bigtens __quadmath_bigtens_D2A
+#define cmp __quadmath_cmp_D2A
+#define copybits __quadmath_copybits_D2A
+#define d2b __quadmath_d2b_D2A
+#define decrement __quadmath_decrement_D2A
+#define diff __quadmath_diff_D2A
+#define dtoa_result __quadmath_dtoa_result_D2A
+#define g__fmt __quadmath_g__fmt_D2A
+#define gethex __quadmath_gethex_D2A
+#define hexdig __quadmath_hexdig_D2A
+#define hexnan __quadmath_hexnan_D2A
+#define hi0bits_D2A __quadmath_hi0bits_D2A
+#define hi0bits(x) __quadmath_hi0bits_D2A((ULong)(x))
+#define i2b __quadmath_i2b_D2A
+#define increment __quadmath_increment_D2A
+#define lo0bits __quadmath_lo0bits_D2A
+#define lshift __quadmath_lshift_D2A
+#define match __quadmath_match_D2A
+#define mult __quadmath_mult_D2A
+#define multadd __quadmath_multadd_D2A
+#define nrv_alloc __quadmath_nrv_alloc_D2A
+#define pow5mult __quadmath_pow5mult_D2A
+#define quorem __quadmath_quorem_D2A
+#define ratio __quadmath_ratio_D2A
+#define rshift __quadmath_rshift_D2A
+#define rv_alloc __quadmath_rv_alloc_D2A
+#define s2b __quadmath_s2b_D2A
+#define set_ones __quadmath_set_ones_D2A
+#ifdef NO_STRING_H
+#define strcp __quadmath_strcp_D2A
+#endif
+#define strtoIg __quadmath_strtoIg_D2A
+#define sum __quadmath_sum_D2A
+#define tens __quadmath_tens_D2A
+#define tinytens __quadmath_tinytens_D2A
+#define tinytens __quadmath_tinytens_D2A
+#define trailz __quadmath_trailz_D2A
+#define ulp __quadmath_ulp_D2A
 
  extern char *dtoa_result;
  extern CONST double bigtens[], tens[], tinytens[];
@@ -559,7 +562,9 @@ extern void memcpy_D2A ANSI((void*, cons
  extern char *rv_alloc ANSI((int));
  extern Bigint *s2b ANSI((CONST char*, int, int, ULong, int));
  extern Bigint *set_ones ANSI((Bigint*, int));
- extern char *strcp ANSI((char*, const char*));
+#ifdef NO_STRING_H
+ extern char *strcpy ANSI((char*, const char*));
+#endif
  extern int strtoIg ANSI((CONST char*, char**, FPI*, Long*, Bigint**, int*));
  extern Bigint *sum ANSI((Bigint*, Bigint*));
  extern int trailz ANSI((Bigint*));
Index: libquadmath/gdtoa/g_Qfmt.c
===================================================================
--- libquadmath/gdtoa/g_Qfmt.c	(Revision 167702)
+++ libquadmath/gdtoa/g_Qfmt.c	(Arbeitskopie)
@@ -82,12 +82,12 @@ g_Qfmt(char *buf, void *V, int ndig, siz
 		if (ex == 0x7fff) {
 			/* Infinity or NaN */
 			if (bits[0] | bits[1] | bits[2] | bits[3])
-				b = strcp(b, "NaN");
+				b = strcpy(b, "NaN");
 			else {
 				b = buf;
 				if (sign)
 					*b++ = '-';
-				b = strcp(b, "Infinity");
+				b = strcpy(b, "Infinity");
 				}
 			return b;
 			}
Index: libquadmath/gdtoa/misc.c
===================================================================
--- libquadmath/gdtoa/misc.c	(Revision 167702)
+++ libquadmath/gdtoa/misc.c	(Arbeitskopie)
@@ -844,11 +844,12 @@ tens[] = {
 #endif
 		};
 
+#ifdef NO_STRING_H
  char *
 #ifdef KR_headers
-strcp_D2A(a, b) char *a; char *b;
+strcpy_D2A(a, b) char *a; char *b;
 #else
-strcp_D2A(char *a, CONST char *b)
+strcpy_D2A(char *a, CONST char *b)
 #endif
 {
 	while((*a = *b++))
@@ -856,7 +857,6 @@ strcp_D2A(char *a, CONST char *b)
 	return a;
 	}
 
-#ifdef NO_STRING_H
 
  Char *
 #ifdef KR_headers
Index: libquadmath/quadmath-imp.h
===================================================================
--- libquadmath/quadmath-imp.h	(Revision 167702)
+++ libquadmath/quadmath-imp.h	(Arbeitskopie)
@@ -27,10 +27,11 @@ Boston, MA 02110-1301, USA.  */
 
 
 // Prototypes for internal functions
-extern int32_t rem_pio2q (__float128, __float128 *);
-extern void __kernel_sincosq (__float128, __float128, __float128 *, __float128 *, int);
-extern __float128 __kernel_sinq (__float128, __float128, int);
-extern __float128 __kernel_cosq (__float128, __float128);
+extern int32_t __quadmath_rem_pio2q (__float128, __float128 *);
+extern void __quadmath_kernel_sincosq (__float128, __float128, __float128 *,
+				       __float128 *, int);
+extern __float128 __quadmath_kernel_sinq (__float128, __float128, int);
+extern __float128 __quadmath_kernel_cosq (__float128, __float128);
 
 
 
Index: libquadmath/math/tanq.c
===================================================================
--- libquadmath/math/tanq.c	(Revision 167702)
+++ libquadmath/math/tanq.c	(Arbeitskopie)
@@ -31,7 +31,7 @@
     License along with this library; if not, write to the Free Software
     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA */
 
-/* __kernel_tanq( x, y, k )
+/* __quadmath_kernel_tanq( x, y, k )
  * kernel tan function on [-pi/4, pi/4], pi/4 ~ 0.7854
  * Input x is assumed to be bounded by ~pi/4 in magnitude.
  * Input y is the tail of x.
@@ -84,7 +84,7 @@ static const __float128
 
 
 static __float128
-__kernel_tanq (__float128 x, __float128 y, int iy)
+__quadmath_kernel_tanq (__float128 x, __float128 y, int iy)
 {
   __float128 z, r, v, w, s;
   int32_t ix, sign = 1;
@@ -218,7 +218,7 @@ tanq (__float128 x)
 
     /* |x| ~< pi/4 */
 	ix &= 0x7fffffffffffffffLL;
-	if(ix <= 0x3ffe921fb54442d1LL) return __kernel_tanq(x,z,1);
+	if(ix <= 0x3ffe921fb54442d1LL) return __quadmath_kernel_tanq(x,z,1);
 
     /* tanl(Inf or NaN) is NaN */
 	else if (ix>=0x7fff000000000000LL) {
@@ -230,8 +230,8 @@ tanq (__float128 x)
 
     /* argument reduction needed */
 	else {
-	    n = rem_pio2q(x,y);
-	    return __kernel_tanq(y[0],y[1],1-((n&1)<<1)); /*   1 -- n even
-							-1 -- n odd */
+	    n = __quadmath_rem_pio2q(x,y);
+					/*   1 -- n even, -1 -- n odd */
+	    return __quadmath_kernel_tanq(y[0],y[1],1-((n&1)<<1));
 	}
 }
Index: libquadmath/math/cosq.c
===================================================================
--- libquadmath/math/cosq.c	(Revision 167702)
+++ libquadmath/math/cosq.c	(Arbeitskopie)
@@ -58,7 +58,7 @@ cosq (__float128 x)
     /* |x| ~< pi/4 */
 	ix &= 0x7fffffffffffffffLL;
 	if(ix <= 0x3ffe921fb54442d1LL)
-	  return __kernel_cosq(x,z);
+	  return __quadmath_kernel_cosq(x,z);
 
     /* cos(Inf or NaN) is NaN */
 	else if (ix>=0x7fff000000000000LL) {
@@ -70,13 +70,13 @@ cosq (__float128 x)
 
     /* argument reduction needed */
 	else {
-	    n = rem_pio2q(x,y);
+	    n = __quadmath_rem_pio2q(x,y);
 	    switch(n&3) {
-		case 0: return  __kernel_cosq(y[0],y[1]);
-		case 1: return -__kernel_sinq(y[0],y[1],1);
-		case 2: return -__kernel_cosq(y[0],y[1]);
+		case 0: return  __quadmath_kernel_cosq(y[0],y[1]);
+		case 1: return -__quadmath_kernel_sinq(y[0],y[1],1);
+		case 2: return -__quadmath_kernel_cosq(y[0],y[1]);
 		default:
-		        return  __kernel_sinq(y[0],y[1],1);
+		        return  __quadmath_kernel_sinq(y[0],y[1],1);
 	    }
 	}
 }
Index: libquadmath/math/sincosq_kernel.c
===================================================================
--- libquadmath/math/sincosq_kernel.c	(Revision 167702)
+++ libquadmath/math/sincosq_kernel.c	(Arbeitskopie)
@@ -96,7 +96,8 @@ static const __float128 c[] = {
 extern const __float128 __sincosq_table[];
 
 void
-__kernel_sincosq(__float128 x, __float128 y, __float128 *sinx, __float128 *cosx, int iy)
+__quadmath_kernel_sincosq(__float128 x, __float128 y, __float128 *sinx,
+			  __float128 *cosx, int iy)
 {
   __float128 h, l, z, sin_l, cos_l_m1;
   int64_t ix;
Index: libquadmath/math/cosq_kernel.c
===================================================================
--- libquadmath/math/cosq_kernel.c	(Revision 167702)
+++ libquadmath/math/cosq_kernel.c	(Arbeitskopie)
@@ -77,7 +77,7 @@ static const __float128 c[] = {
 extern const __float128 __sincosq_table[];
 
 __float128
-__kernel_cosq (__float128 x, __float128 y)
+__quadmath_kernel_cosq (__float128 x, __float128 y)
 {
   __float128 h, l, z, sin_l, cos_l_m1;
   int64_t ix;
Index: libquadmath/math/sinq.c
===================================================================
--- libquadmath/math/sinq.c	(Revision 167702)
+++ libquadmath/math/sinq.c	(Arbeitskopie)
@@ -58,7 +58,7 @@ sinq (__float128 x)
     /* |x| ~< pi/4 */
 	ix &= 0x7fffffffffffffffLL;
 	if(ix <= 0x3ffe921fb54442d1LL)
-	  return __kernel_sinq(x,z,0);
+	  return __quadmath_kernel_sinq(x,z,0);
 
     /* sin(Inf or NaN) is NaN */
 	else if (ix>=0x7fff000000000000LL) {
@@ -70,13 +70,13 @@ sinq (__float128 x)
 
     /* argument reduction needed */
 	else {
-	    n = rem_pio2q(x,y);
+	    n = __quadmath_rem_pio2q(x,y);
 	    switch(n&3) {
-		case 0: return  __kernel_sinq(y[0],y[1],1);
-		case 1: return  __kernel_cosq(y[0],y[1]);
-		case 2: return -__kernel_sinq(y[0],y[1],1);
+		case 0: return  __quadmath_kernel_sinq(y[0],y[1],1);
+		case 1: return  __quadmath_kernel_cosq(y[0],y[1]);
+		case 2: return -__quadmath_kernel_sinq(y[0],y[1],1);
 		default:
-			return -__kernel_cosq(y[0],y[1]);
+			return -__quadmath_kernel_cosq(y[0],y[1]);
 	    }
 	}
 }
Index: libquadmath/math/sinq_kernel.c
===================================================================
--- libquadmath/math/sinq_kernel.c	(Revision 167702)
+++ libquadmath/math/sinq_kernel.c	(Arbeitskopie)
@@ -77,7 +77,7 @@ static const __float128 c[] = {
 extern const __float128 __sincosq_table[];
 
 __float128
-__kernel_sinq (__float128 x, __float128 y, int iy)
+__quadmath_kernel_sinq (__float128 x, __float128 y, int iy)
 {
   __float128 h, l, z, sin_l, cos_l_m1;
   int64_t ix;
Index: libquadmath/math/sincosq.c
===================================================================
--- libquadmath/math/sincosq.c	(Revision 167702)
+++ libquadmath/math/sincosq.c	(Arbeitskopie)
@@ -32,7 +32,7 @@ sincosq (__float128 x, __float128 *sinx,
   /* |x| ~< pi/4 */
   ix &= 0x7fffffffffffffffLL;
   if (ix <= 0x3ffe921fb54442d1LL)
-    __kernel_sincosq (x, 0.0Q, sinx, cosx, 0);
+    __quadmath_kernel_sincosq (x, 0.0Q, sinx, cosx, 0);
   else if (ix >= 0x7fff000000000000LL)
     {
       /* sin(Inf or NaN) is NaN */
@@ -44,23 +44,23 @@ sincosq (__float128 x, __float128 *sinx,
       __float128 y[2];
       int n;
 
-      n = rem_pio2q (x, y);
+      n = __quadmath_rem_pio2q (x, y);
       switch (n & 3)
 	{
 	case 0:
-	  __kernel_sincosq (y[0], y[1], sinx, cosx, 1);
+	  __quadmath_kernel_sincosq (y[0], y[1], sinx, cosx, 1);
 	  break;
 	case 1:
-	  __kernel_sincosq (y[0], y[1], cosx, sinx, 1);
+	  __quadmath_kernel_sincosq (y[0], y[1], cosx, sinx, 1);
 	  *cosx = -*cosx;
 	  break;
 	case 2:
-	  __kernel_sincosq (y[0], y[1], sinx, cosx, 1);
+	  __quadmath_kernel_sincosq (y[0], y[1], sinx, cosx, 1);
 	  *sinx = -*sinx;
 	  *cosx = -*cosx;
 	  break;
 	default:
-	  __kernel_sincosq (y[0], y[1], cosx, sinx, 1);
+	  __quadmath_kernel_sincosq (y[0], y[1], cosx, sinx, 1);
 	  *sinx = -*sinx;
 	  break;
 	}
Index: libquadmath/math/rem_pio2q.c
===================================================================
--- libquadmath/math/rem_pio2q.c	(Revision 167702)
+++ libquadmath/math/rem_pio2q.c	(Arbeitskopie)
@@ -151,7 +151,7 @@ static const double
 
 
 static int
-__kernel_rem_pio2 (double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2)
+__quadmath_kernel_rem_pio2 (double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2)
 {
 	int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
 	double z,fw,f[20],fq[20],q[20];
@@ -500,7 +500,7 @@ static const __float128 c[] = {
 
 
 int32_t
-rem_pio2q (__float128 x, __float128 *y)
+__quadmath_rem_pio2q (__float128 x, __float128 *y)
 {
   __float128 z, w, t;
   double tx[8];
@@ -557,8 +557,9 @@ rem_pio2q (__float128 x, __float128 *y)
   tx [3] = (double)((lx >> 17) & 0xffffff);
   tx [4] = (double)((lx << 7) & 0xffffff);
 
-  n = __kernel_rem_pio2 (tx, tx + 5, exp, ((lx << 7) & 0xffffff) ? 5 : 4,
-			 3, two_over_pi);
+  n = __quadmath_kernel_rem_pio2 (tx, tx + 5, exp,
+				  ((lx << 7) & 0xffffff) ? 5 : 4,
+				  3, two_over_pi);
 
   /* The result is now stored in 3 double values, we need to convert it into
      two __float128 values.  */

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