summaryrefslogtreecommitdiff
path: root/lang/perl5/patches/patch-ad
blob: d115dce9356cfc2a81f71fdf2bd3f8e584b6c918 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
$NetBSD: patch-ad,v 1.9 2001/09/05 17:13:41 jlam Exp $

--- pp.c.orig	Sat Apr  7 23:09:16 2001
+++ pp.c	Sat Sep  1 03:57:59 2001
@@ -1900,6 +1900,28 @@
     }
 }
 
+/*
+ * There are strange code-generation bugs caused on sparc64 by gcc-2.95.2.
+ * These need to be revisited when a newer toolchain becomes available.
+ */
+#if defined(__sparc64__) && defined(__GNUC__)
+#if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
+#undef SPARC64_WORKAROUND
+#define SPARC64_WORKAROUND 1
+#endif
+#endif
+
+#if defined(SPARC64_WORKAROUND)
+double
+sparc64_workaround_modf(double theVal, double *theIntRes)
+{
+    double res, ret;
+    ret = modf(theVal, &res);
+    *theIntRes = res;
+    return ret;
+}
+#endif
+
 PP(pp_int)
 {
     dSP; dTARGET;
@@ -1913,6 +1935,9 @@
       }
       else {
 	  if (value >= 0.0) {
+#if defined(SPARC64_WORKAROUND)
+	      (void)sparc64_workaround_modf(value, &value);
+#else
 #if defined(HAS_MODFL) || defined(LONG_DOUBLE_EQUALS_DOUBLE)
 	      (void)Perl_modf(value, &value);
 #else
@@ -1920,6 +1945,7 @@
 	      (void)Perl_modf(tmp, &tmp);
 	      value = (NV)tmp;
 #endif
+#endif /* SPARC64_WORKAROUND */
 	  }
 	else {
 #if defined(HAS_MODFL) || defined(LONG_DOUBLE_EQUALS_DOUBLE)