This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Enhancement to mathconf.h for VAX
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- To: gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Fri, 30 Nov 2001 22:09:42 -2900 (EST)
- Subject: Enhancement to mathconf.h for VAX
This patch revises mathconf.h to allow it to handle the VAX floating
point data. I have been successfully able to build libstdc++ with
this patch installed. Test results are close to other machines without
weak support (eg., the PA under HPUX).
Please review.
Thanks,
Dave
--
J. David Anglin dave.anglin@nrc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)
2001-11-30 John David Anglin <dave@hiauly1.hia.nrc.ca>
* mathconf.h (vax_double_shape_type, vax_float_shape_type,
vax_long_double_shape_type, vax_quad_double_shape_type): New typedefs.
(GET_HIGH_WORD, GET_FLOAT_WORD, GET_LDOUBLE_EXP, GET_LDOUBLE_MSW64):
Revise for VAX.
--- mathconf.h.orig Tue Aug 21 13:46:30 2001
+++ mathconf.h Thu Aug 23 13:58:20 2001
@@ -70,6 +70,7 @@
# endif
#endif
+typedef unsigned int U_int16_t __attribute ((mode (HI)));
typedef unsigned int U_int32_t __attribute ((mode (SI)));
typedef int Int32_t __attribute ((mode (SI)));
typedef unsigned int U_int64_t __attribute ((mode (DI)));
@@ -171,27 +172,62 @@
} parts;
} ieee_double_shape_type;
#endif
+typedef union
+{
+ double value;
+ struct
+ {
+ U_int16_t w0, w1, w2, w3;
+ } parts;
+} vax_double_shape_type;
/* Get the more significant 32 bit int from a double. */
+#ifndef __vax
#define GET_HIGH_WORD(i,d) \
do { \
ieee_double_shape_type gh_u; \
gh_u.value = (d); \
(i) = gh_u.parts.msw; \
} while (0)
-
+#else
+#define GET_HIGH_WORD(i,d) \
+do { \
+ vax_double_shape_type gh_u; \
+ gh_u.value = (d); \
+ (i) = gh_u.parts.w0; \
+ (i) = ((i) << 16) | gh_u.parts.w1; \
+} while (0)
+#endif
typedef union
{
float value;
U_int32_t word;
} ieee_float_shape_type;
+typedef union
+{
+ float value;
+ struct
+ {
+ U_int16_t w0, w1;
+ } parts;
+} vax_float_shape_type;
/* Get a 32 bit int from a float. */
+#ifndef __vax
#define GET_FLOAT_WORD(i,d) \
do { \
ieee_float_shape_type gf_u; \
gf_u.value = (d); \
(i) = gf_u.word; \
} while (0)
+#else
+#define GET_FLOAT_WORD(i,d) \
+do { \
+ vax_double_shape_type gf_u; \
+ gf_u.value = (d); \
+ (i) = gf_u.parts.w0; \
+ (i) = ((i) << 16) | gf_u.parts.w1; \
+} while (0)
+#endif
#if BYTE_ORDER == BIG_ENDIAN
@@ -220,13 +256,23 @@
} parts;
} ieee_long_double_shape_type;
#endif
+typedef vax_double_shape_type vax_long_double_shape_type;
/* Get int from the exponent of a long double. */
+#ifndef __vax
#define GET_LDOUBLE_EXP(exp,d) \
do { \
ieee_long_double_shape_type ge_u; \
ge_u.value = (d); \
(exp) = ge_u.parts.sign_exponent; \
} while (0)
+#else
+#define GET_LDOUBLE_EXP(exp,d) \
+do { \
+ vax_long_double_shape_type ge_u; \
+ ge_u.value = (d); \
+ (exp) = ge_u.parts.w0 & 0xff80; \
+} while (0)
+#endif
#if BYTE_ORDER == BIG_ENDIAN
typedef union
@@ -258,13 +304,26 @@
} parts32;
} ieee_quad_double_shape_type;
#endif
+typedef vax_double_shape_type vax_quad_double_shape_type;
/* Get most significant 64 bit int from a quad long double. */
+#ifndef __vax
#define GET_LDOUBLE_MSW64(msw,d) \
do { \
ieee_quad_double_shape_type qw_u; \
qw_u.value = (d); \
(msw) = qw_u.parts64.msw; \
} while (0)
+#else
+#define GET_LDOUBLE_MSW64(msw,d) \
+do { \
+ vax_quad_double_shape_type qw_u; \
+ qw_u.value = (d); \
+ (msw) = qw_u.parts.w0; \
+ (msw) = ((msw) << 16) | qw_u.parts.w1; \
+ (msw) = ((msw) << 16) | qw_u.parts.w2; \
+ (msw) = ((msw) << 16) | qw_u.parts.w3; \
+} while (0)
+#endif
/* Replacement for non-existing float functions. */