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]

[m68k] Fix PR c/12148


Hello,

this patch was attached to PR12148.  IMHO, it's quite safe.
I've mildly tested it by building m68k-uclinux toolchain,
kernel and userland with it.

Richard, may I install it on mainline?

I'd also like to commit these m68k-linux patches by
Richard Zidlicky:

 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02172.html
 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02173.html

If you approve it, I'll add the missing ChangeLog entries
before committing.

Finally, if you wish to pre-approve it, I'd like to clean
longlong.h a bit by removing usless tests for non-ANSI
predefines, as discussed here:

http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02184.html


2003-09-17 Markus F.X.J. Oberhumer <markus@oberhumer.com>


	PR c/12148
	* config/m68k/fpgnulib.c: Fix `-mshort' bugs: Use `long' instead of
	`int' in a number of places to make sure we always have a SImode
	(and not a HImode). Added a 'L' suffix to a number of constants.

diff -c -3 -p -r1.2 fpgnulib.c
*** gcc-3.4.orig/gcc/config/m68k/fpgnulib.c 16 Dec 1998 21:06:34 -0000 1.2
--- gcc-3.4/gcc/config/m68k/fpgnulib.c 17 Sep 2003 23:31:04 -0000
***************
*** 59,82 ****
#define PACK(s,e,m) ((s) | ((e) << 23L) | (m))
/* the following deal with IEEE double-precision numbers */
! #define EXCESSD 1022
#define HIDDEND (1L << 20L)
#define EXPDBITS 11
! #define EXPDMASK 0x7FF
#define EXPD(fp) (((fp.l.upper) >> 20L) & 0x7FFL)
#define SIGND(fp) ((fp.l.upper) & SIGNBIT)
#define MANTD(fp) (((((fp.l.upper) & 0xFFFFF) | HIDDEND) << 10) | \
(fp.l.lower >> 22))
! #define MANTDMASK 0xFFFFF /* mask of upper part */
/* the following deal with IEEE extended-precision numbers */
! #define EXCESSX 16382
#define HIDDENX (1L << 31L)
#define EXPXBITS 15
#define EXPXMASK 0x7FFF
#define EXPX(fp) (((fp.l.upper) >> 16) & EXPXMASK)
#define SIGNX(fp) ((fp.l.upper) & SIGNBIT)
! #define MANTXMASK 0x7FFFFFFF /* mask of upper part */
union double_long {
--- 59,82 ----
#define PACK(s,e,m) ((s) | ((e) << 23L) | (m))
/* the following deal with IEEE double-precision numbers */
! #define EXCESSD 1022L
#define HIDDEND (1L << 20L)
#define EXPDBITS 11
! #define EXPDMASK 0x7FFL
#define EXPD(fp) (((fp.l.upper) >> 20L) & 0x7FFL)
#define SIGND(fp) ((fp.l.upper) & SIGNBIT)
#define MANTD(fp) (((((fp.l.upper) & 0xFFFFF) | HIDDEND) << 10) | \
(fp.l.lower >> 22))
! #define MANTDMASK 0xFFFFFL /* mask of upper part */
/* the following deal with IEEE extended-precision numbers */
! #define EXCESSX 16382L
#define HIDDENX (1L << 31L)
#define EXPXBITS 15
#define EXPXMASK 0x7FFF
#define EXPX(fp) (((fp.l.upper) >> 16) & EXPXMASK)
#define SIGNX(fp) ((fp.l.upper) & SIGNBIT)
! #define MANTXMASK 0x7FFFFFFFL /* mask of upper part */
union double_long {
*************** union long_double_long
*** 107,113 ****
/* convert int to double */
double
! __floatsidf (int a1)
{
long sign = 0, exp = 31 + EXCESSD;
union double_long dl;
--- 107,113 ----
/* convert int to double */
double
! __floatsidf (long a1)
{
long sign = 0, exp = 31 + EXCESSD;
union double_long dl;
*************** __floatsidf (int a1)
*** 130,142 ****
}
}
! while (a1 < 0x1000000)
{
a1 <<= 4;
exp -= 4;
}
! while (a1 < 0x40000000)
{
a1 <<= 1;
exp--;
--- 130,142 ----
}
}
! while (a1 < 0x1000000L)
{
a1 <<= 4;
exp -= 4;
}
! while (a1 < 0x40000000L)
{
a1 <<= 1;
exp--;
*************** __floatsidf (int a1)
*** 153,159 ****
/* convert int to float */
float
! __floatsisf (int l)
{
double foo = __floatsidf (l);
return foo;
--- 153,159 ----
/* convert int to float */
float
! __floatsisf (long l)
{
double foo = __floatsidf (l);
return foo;
*************** __truncdfsf2 (double a1)
*** 208,214 ****
mant >>= 1;
/* did the round overflow? */
! if (mant & 0xFF000000)
{
mant >>= 1;
exp++;
--- 208,214 ----
mant >>= 1;
/* did the round overflow? */
! if (mant & 0xFF000000L)
{
mant >>= 1;
exp++;
*************** __truncdfsf2 (double a1)
*** 222,228 ****
}
/* convert double to int */
! int
__fixdfsi (double a1)
{
register union double_long dl1;
--- 222,228 ----
}
/* convert double to int */
! long
__fixdfsi (double a1)
{
register union double_long dl1;
*************** __fixdfsi (double a1)
*** 240,246 ****
if (exp > 0) {
/* Return largest integer. */
! return SIGND (dl1) ? 0x80000000 : 0x7fffffff;
}
if (exp <= -32)
--- 240,246 ----
if (exp > 0) {
/* Return largest integer. */
! return SIGND (dl1) ? 0x80000000L : 0x7fffffffL;
}
if (exp <= -32)
*************** __fixdfsi (double a1)
*** 254,260 ****
}
/* convert float to int */
! int
__fixsfsi (float a1)
{
double foo = a1;
--- 254,260 ----
}
/* convert float to int */
! long
__fixsfsi (float a1)
{
double foo = a1;
*************** __fixsfsi (float a1)
*** 268,279 ****
We assume all numbers are normalized, don't do any rounding, etc. */
/* Prototypes for the above in case we use them. */
! double __floatsidf (int);
! float __floatsisf (int);
double __extendsfdf2 (float);
float __truncdfsf2 (double);
! int __fixdfsi (double);
! int __fixsfsi (float);
/* convert double to long double */
long double
--- 268,279 ----
We assume all numbers are normalized, don't do any rounding, etc. */
/* Prototypes for the above in case we use them. */
! double __floatsidf (long);
! float __floatsisf (long);
double __extendsfdf2 (float);
float __truncdfsf2 (double);
! long __fixdfsi (double);
! long __fixsfsi (float);
/* convert double to long double */
long double
*************** __truncxfsf2 (long double ld)
*** 351,367 ****
/* convert an int to a long double */
long double
! __floatsixf (int l)
{
double foo = __floatsidf (l);
return foo;
}
/* convert a long double to an int */
! int
__fixxfsi (long double ld)
{
! int foo = __fixdfsi ((double) ld);
return foo;
}
--- 351,367 ----
/* convert an int to a long double */
long double
! __floatsixf (long l)
{
double foo = __floatsidf (l);
return foo;
}
/* convert a long double to an int */
! long
__fixxfsi (long double ld)
{
! long foo = __fixdfsi ((double) ld);
return foo;
}
--
// Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/ http://www.develer.com/




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