summaryrefslogtreecommitdiffstats
path: root/libiberty/copysign.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>1997-08-21 22:57:35 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>1997-08-21 22:57:35 +0000
commit28e9041cc224267271fbcd8db22bea115912365b (patch)
treea3b19970338bdae580faff126a716e1d5520400c /libiberty/copysign.c
parent5000a677980ebfb439f5349c5e269f7447dbab41 (diff)
downloadppe42-gcc-28e9041cc224267271fbcd8db22bea115912365b.tar.gz
ppe42-gcc-28e9041cc224267271fbcd8db22bea115912365b.zip
Initial revision
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@14877 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libiberty/copysign.c')
-rw-r--r--libiberty/copysign.c140
1 files changed, 140 insertions, 0 deletions
diff --git a/libiberty/copysign.c b/libiberty/copysign.c
new file mode 100644
index 00000000000..0b5f8c3d9df
--- /dev/null
+++ b/libiberty/copysign.c
@@ -0,0 +1,140 @@
+#include <ansidecl.h>
+
+#ifdef __IEEE_BIG_ENDIAN
+
+typedef union
+{
+ double value;
+ struct
+ {
+ unsigned int sign : 1;
+ unsigned int exponent: 11;
+ unsigned int fraction0:4;
+ unsigned int fraction1:16;
+ unsigned int fraction2:16;
+ unsigned int fraction3:16;
+
+ } number;
+ struct
+ {
+ unsigned int sign : 1;
+ unsigned int exponent: 11;
+ unsigned int quiet:1;
+ unsigned int function0:3;
+ unsigned int function1:16;
+ unsigned int function2:16;
+ unsigned int function3:16;
+ } nan;
+ struct
+ {
+ unsigned long msw;
+ unsigned long lsw;
+ } parts;
+ long aslong[2];
+} __ieee_double_shape_type;
+
+#endif
+
+#ifdef __IEEE_LITTLE_ENDIAN
+
+typedef union
+{
+ double value;
+ struct
+ {
+#ifdef __SMALL_BITFIELDS
+ unsigned int fraction3:16;
+ unsigned int fraction2:16;
+ unsigned int fraction1:16;
+ unsigned int fraction0: 4;
+#else
+ unsigned int fraction1:32;
+ unsigned int fraction0:20;
+#endif
+ unsigned int exponent :11;
+ unsigned int sign : 1;
+ } number;
+ struct
+ {
+#ifdef __SMALL_BITFIELDS
+ unsigned int function3:16;
+ unsigned int function2:16;
+ unsigned int function1:16;
+ unsigned int function0:3;
+#else
+ unsigned int function1:32;
+ unsigned int function0:19;
+#endif
+ unsigned int quiet:1;
+ unsigned int exponent: 11;
+ unsigned int sign : 1;
+ } nan;
+ struct
+ {
+ unsigned long lsw;
+ unsigned long msw;
+ } parts;
+
+ long aslong[2];
+
+} __ieee_double_shape_type;
+
+#endif
+
+#ifdef __IEEE_BIG_ENDIAN
+typedef union
+{
+ float value;
+ struct
+ {
+ unsigned int sign : 1;
+ unsigned int exponent: 8;
+ unsigned int fraction0: 7;
+ unsigned int fraction1: 16;
+ } number;
+ struct
+ {
+ unsigned int sign:1;
+ unsigned int exponent:8;
+ unsigned int quiet:1;
+ unsigned int function0:6;
+ unsigned int function1:16;
+ } nan;
+ long p1;
+
+} __ieee_float_shape_type;
+#endif
+
+#ifdef __IEEE_LITTLE_ENDIAN
+typedef union
+{
+ float value;
+ struct
+ {
+ unsigned int fraction0: 7;
+ unsigned int fraction1: 16;
+ unsigned int exponent: 8;
+ unsigned int sign : 1;
+ } number;
+ struct
+ {
+ unsigned int function1:16;
+ unsigned int function0:6;
+ unsigned int quiet:1;
+ unsigned int exponent:8;
+ unsigned int sign:1;
+ } nan;
+ long p1;
+
+} __ieee_float_shape_type;
+#endif
+
+
+double DEFUN(copysign, (x, y), double x AND double y)
+{
+ __ieee_double_shape_type a,b;
+ b.value = y;
+ a.value = x;
+ a.number.sign =b.number.sign;
+ return a.value;
+}
OpenPOWER on IntegriCloud