[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft-devel] freetype-2.3.7 -- ftconfig.h for biarch systems
From: |
mpsuzuki |
Subject: |
Re: [ft-devel] freetype-2.3.7 -- ftconfig.h for biarch systems |
Date: |
Wed, 9 Jul 2008 12:07:06 +0900 |
On Tue, 8 Jul 2008 22:39:58 +0200
Antoine Leca <address@hidden> wrote:
>On Monday, June 30th, 2008, mpsuzuki wrote:
>> So, I think, using traditional ANSI C header "limits.h"
>> is more generic than using modern headers "bits/wordsize.h", like...
>>
>> #ifdef HAVE_LIMITS_H
>>
>> # if ( UINT_MAX == 0xFFFFFFFFFFFFFFFF )
>> # define FT_SIZEOF_INT 8
>> # elif ( UINT_MAX == 0xFFFFFFFFFFFF )
>> # define FT_SIZEOF_INT 6
>> # elif ( UINT_MAX == 0xFFFFFFFF )
>> # define FT_SIZEOF_INT 4
>> # else
>> # error XXX
>> # endif
>
>There is a real defect with the above approach: imagine a conforming C90
>compiler with 32 bits being the widest type; on such a compiler, cpp would
>evaluate the quantities using 32-bit arithmetic; unsigned truncates, so
>0xFFFFFFFFFFFFFFFF would truncate to 0xFFFFFFFF, perhaps with a warning but
>this is not required; and the first test succeeds; of course, this is not
>what you want!
Thank you, I happened to find the defect you wrote, during
the tests of Tiny C compiler and Bruce's C compiler. So
my revised proposal has the check of cpp feature:
#if ( 0x7FFFFFFFUL < 0x7FFFFFFFFFFFFFFFUL )
# warning cpp can evaluate 64bit numerics
# if ( INT_MAX < 0x7FFF )
# error Non-standard C whose int cannot cover signed 16bit
# elif ( 0x7FFF <= INT_MAX ) && ( INT_MAX < 0x7FFFFFFFUL )
# define FT_SIZEOF_INT 2
# elif ( 0x7FFFFFFF <= INT_MAX ) && ( INT_MAX < 0x7FFFFFFFFFFFUL )
# define FT_SIZEOF_INT 4
# else
# define FT_SIZEOF_INT 8
# endif
(http://lists.gnu.org/archive/html/freetype-devel/2008-07/msg00010.html).
The truncation (as a string process from the beginning)
of too long numerical constant is de-jure behaviour in C90?
I was misunderstanding that too long numerical constant
causes some overflow in cpp. Considering the possibility
of the string truncation from the end to fit 32bit integer,
should I check another possibility like following?
# if ( 0x7FFFFFFFUL < 0x000000017FFFFFFFUL )
Regards,
mpsuzuki
- [ft-devel] bcc and FreeType2 (Re: freetype-2.3.7 -- ftconfig.h for biarch systems), (continued)
- Re: [ft-devel] freetype-2.3.7 -- ftconfig.h for biarch systems, mpsuzuki, 2008/07/10
- Re: [ft-devel] freetype-2.3.7 -- ftconfig.h for biarch systems, Werner LEMBERG, 2008/07/10
- Re: [ft-devel] freetype-2.3.7 -- ftconfig.h for biarch systems, mpsuzuki, 2008/07/10
- Re: [ft-devel] freetype-2.3.7 -- ftconfig.h for biarch systems, Werner LEMBERG, 2008/07/10
- Re: [ft-devel] freetype-2.3.7 -- ftconfig.h for biarch systems, Antoine Leca, 2008/07/09
- Re: [ft-devel] freetype-2.3.7 -- ftconfig.h for biarch systems, Antoine Leca, 2008/07/09
Re: [ft-devel] freetype-2.3.7 -- ftconfig.h for biarch systems, Antoine Leca, 2008/07/08
- Re: [ft-devel] freetype-2.3.7 -- ftconfig.h for biarch systems,
mpsuzuki <=
Re: [ft-devel] freetype-2.3.7 -- ftconfig.h for biarch systems, Antoine Leca, 2008/07/09
Re: [ft-devel] freetype-2.3.7 -- ftconfig.h for biarch systems, Peter Breitenlohner, 2008/07/09
Re: [ft-devel] freetype-2.3.7 -- ftconfig.h for biarch systems, Antoine Leca, 2008/07/09
Re: [ft-devel] freetype-2.3.7 -- ftconfig.h for biarch systems, David Turner, 2008/07/16