summaryrefslogtreecommitdiff
path: root/pp_pack.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2016-06-25 22:14:41 -0400
committerJarkko Hietaniemi <jhi@iki.fi>2016-07-01 20:43:12 -0400
commita7157111fed730f765c2c281a61bcde95bacc9ed (patch)
tree56c9a564cc9164b9c045fcdbbbc91ed4e92e9177 /pp_pack.c
parentc183cd86045c09fcbba056a606ae50f11c9c5b5a (diff)
downloadperl-a7157111fed730f765c2c281a61bcde95bacc9ed.tar.gz
VAX: code changes for VAX floats
Mainly to avoid Inf and NaN, which VAX does does not have. There is something like Inf called "excess" but that is a deadly exception, seems to manifest itself in vax-netbsd either as a SIGFPE or SIGSEGV (pretty much untrappable at least from Perl level). The range of VAX floats is different from IEEE. There is positive zero, but no negative zero.
Diffstat (limited to 'pp_pack.c')
-rw-r--r--pp_pack.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/pp_pack.c b/pp_pack.c
index f6964c3f30..891d2e2d42 100644
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -2674,7 +2674,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist )
NV anv;
fromstr = NEXTFROM;
anv = SvNV(fromstr);
-# if defined(VMS) && !defined(_IEEE_FP)
+# if (defined(VMS) && !defined(_IEEE_FP)) || defined(DOUBLE_IS_VAX_FLOAT)
/* IEEE fp overflow shenanigans are unavailable on VAX and optional
* on Alpha; fake it if we don't have them.
*/
@@ -2684,15 +2684,17 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist )
afloat = -FLT_MAX;
else afloat = (float)anv;
# else
-#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
+# if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
if(Perl_isnan(anv))
afloat = (float)NV_NAN;
else
-#endif
+# endif
+# ifdef NV_INF
/* a simple cast to float is undefined if outside
* the range of values that can be represented */
afloat = (float)(anv > FLT_MAX ? NV_INF :
anv < -FLT_MAX ? -NV_INF : anv);
+# endif
# endif
PUSH_VAR(utf8, cur, afloat, needs_swap);
}
@@ -2703,7 +2705,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist )
NV anv;
fromstr = NEXTFROM;
anv = SvNV(fromstr);
-# if defined(VMS) && !defined(_IEEE_FP)
+# if (defined(VMS) && !defined(_IEEE_FP)) || defined(DOUBLE_IS_VAX_FLOAT)
/* IEEE fp overflow shenanigans are unavailable on VAX and optional
* on Alpha; fake it if we don't have them.
*/