From 7429c585c92f395f5f2ad8f66b9da7462f342156 Mon Sep 17 00:00:00 2001 From: borutr Date: Tue, 2 Oct 2007 17:31:50 +0000 Subject: [PATCH] * src/SDCCval.h: unified double2ul macro for all platforms git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4925 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 4 ++++ src/SDCCval.h | 19 +++++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index f72eef0a..ec342a2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-10-02 Borut Razem + + * src/SDCCval.h: unified double2ul macro for all platforms + 2007-09-30 Borut Razem * src/SDCCval.h: fixed bug #1739860 - sdcc does not work correctly on some diff --git a/src/SDCCval.h b/src/SDCCval.h index 5348ec98..98a1a7eb 100644 --- a/src/SDCCval.h +++ b/src/SDCCval.h @@ -6,16 +6,16 @@ under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - + In other words, you are welcome to use, share and improve this program. You are forbidden to forbid anyone else to use, share and improve what you give them. Help stamp out software-hoarding! @@ -30,13 +30,13 @@ /* * See ISO/IEC 9899, chapter 6.3.1.4 Real floating and integer: * If the value of the integral part cannot be represented by the integer type, the behavior is undefined. - * This shows up on Mac OS X i386 platform + * This shows up on Mac OS X i386 platform which useus SSE unit instead of the x87 FPU for floating-point operations */ -#if defined(__APPLE__) && defined(__i386__) -#define double2ul(val) (((val) < 0) ? (unsigned long) -((long) -(val)) : (unsigned long) (val)) -#else -#define double2ul(val) ((unsigned long) (val)) -#endif +/* + * on Mac OS X ppc (long) 2147483648.0 equals to 2147483647, so we explicitely convert it to 0x80000000 + * on other known platforms (long) 2147483648.0 equals to -2147483648 + */ +#define double2ul(val) (((val) < 0) ? (((val) < -2147483647.0) ? 0x80000000UL : (unsigned long) -((long) -(val))) : (unsigned long) (val)) /* value wrapper */ typedef struct value @@ -58,7 +58,6 @@ typedef struct literalList struct literalList *next; } literalList; - enum { INIT_NODE, -- 2.30.2