Hi all,

Attached is a patch to support multiple architechtures that
use different sized integers (e.g. LP32 i386 and LP64 amd64).
At present, the patch is only for Unix-like platforms that
configure script proves the sizes for single architechture
and causes biarch problems (Savannah bug #21250, Mac OS X
issues). I have to note this patch is NOT the migration of
C99 that requires inttypes.h. I want to schedule the task
after the checking of 64bit support in FreeType2.

BTW, I want to ask a few questions to polish the patch...

Q1. the cpp computation of sizes of int and long should be
    separated to another file (e.g. include/freetype/config/ftsiztyp.h)?

Apparently, the cpp computation of size of int and long is
very long. There is another static ftconfig.h (include/freetype/
config/ftconfig.h) and  non-Unix platforms can have their own
ftconfig.h (like builds/vms/ftconfig.h). Although it's little
needed to apply my patch to them, keeping their difference
small is important for the code maintenance. If moving the
part added by my patch to new file, it is easy for all ftconfig.h
to refer it (if needed). Also if it is separated, it is easy
for configure script to check cpp-computation results are
same with the results proven by configure script.

Q2. ftconfig.h should be bi-arch by default?

Today, most binaries of FreeType2 on Unix platformts are
configured for single architechture, by running configure
script, or by ftconfig.h written/modified manually. I don't
know their maintenance style in detail, but I don't want to
confuse them. The safest way would be the restriction of
the cpp computation of size of int and long for special
case (e.g. configure --enable-biarch-ftconfig).

Regards,
mpsuzuki
? root
Index: ChangeLog
===================================================================
RCS file: /sources/freetype/freetype2/ChangeLog,v
retrieving revision 1.1780
diff -u -r1.1780 ChangeLog
--- ChangeLog	18 Aug 2008 06:02:06 -0000	1.1780
+++ ChangeLog	18 Aug 2008 11:19:21 -0000
@@ -1,5 +1,12 @@
 2008-08-18  suzuki toshiya <[EMAIL PROTECTED]>
 
+	* builds/unix/ftconfig.in: Add a configure-less computation of
+	FT_SIZEOF_INT and FT_SIZEOF_LONG from limits.h. It can support
+	multiple and incompatible architechtures by single ftconfig.h.
+	This fixes Savannah bug #21250.
+
+2008-08-18  suzuki toshiya <[EMAIL PROTECTED]>
+
 	* src/base/ftmac.c: Add a fallback to suppose the availability
 	of ResourceIndex type. It is used when built without configure
 	(e.g. build by Jam).
Index: builds/unix/ftconfig.in
===================================================================
RCS file: /sources/freetype/freetype2/builds/unix/ftconfig.in,v
retrieving revision 1.22
diff -u -r1.22 ftconfig.in
--- builds/unix/ftconfig.in	28 Mar 2007 21:17:10 -0000	1.22
+++ builds/unix/ftconfig.in	18 Aug 2008 11:19:22 -0000
@@ -60,15 +60,135 @@
 #undef HAVE_UNISTD_H
 #undef HAVE_FCNTL_H
 
-#undef SIZEOF_INT
-#undef SIZEOF_LONG
-
-
-#define FT_SIZEOF_INT   SIZEOF_INT
-#define FT_SIZEOF_LONG  SIZEOF_LONG
-
 #define FT_CHAR_BIT  CHAR_BIT
 
+#define FT_IS_GE_NBYTE( x, n ) \
+  ( ( SCHAR_MAX ) <= ( ( x ) >> ( FT_CHAR_BIT * ( n ) ) ) )
+#define FT_IS_LT_NBYTE( x, n ) \
+  ( ( SCHAR_MAX ) >  ( ( x ) >> ( FT_CHAR_BIT * ( n ) ) ) )
+#define FT_IS_IN_NBYTE_RANGE( x, n ) \
+  ( FT_IS_GE_NBYTE( x, n - 1 ) && FT_IS_LT_NBYTE( x, n ) )
+
+
+/* check cpp can handle 64bit constant */
+#if ( 0x7FFFFFFFUL < 0x7FFFFFFFFFFFFFFFUL ) && !defined( USE_PROVEN_SIZES )
+
+# if ( INT_MAX < 0x7FFF )
+#  error Non-standard C whose int cannot cover signed 16bit 
+# elif FT_IS_IN_NBYTE_RANGE( INT_MAX, 1 )
+#  define FT_SIZEOF_INT 1
+# elif FT_IS_IN_NBYTE_RANGE( INT_MAX, 2 )
+#  define FT_SIZEOF_INT 2
+# elif FT_IS_IN_NBYTE_RANGE( INT_MAX, 3 )
+#  define FT_SIZEOF_INT 3
+# elif FT_IS_IN_NBYTE_RANGE( INT_MAX, 4 )
+#  define FT_SIZEOF_INT 4
+# elif FT_IS_IN_NBYTE_RANGE( INT_MAX, 5 )
+#  define FT_SIZEOF_INT 5
+# elif FT_IS_IN_NBYTE_RANGE( INT_MAX, 6 )
+#  define FT_SIZEOF_INT 6
+# elif FT_IS_IN_NBYTE_RANGE( INT_MAX, 7 )
+#  define FT_SIZEOF_INT 7
+# elif FT_IS_IN_NBYTE_RANGE( INT_MAX, 8 )
+#  define FT_SIZEOF_INT 8
+# else
+#  define USE_PROVEN_SIZES
+# endif
+
+# if ( LONG_MAX < 0x7FFFFFFF )
+#  error Non-standard C whose int cannot cover signed 16bit 
+# elif FT_IS_IN_NBYTE_RANGE( LONG_MAX, 1 )
+#  define FT_SIZEOF_LONG 1
+# elif FT_IS_IN_NBYTE_RANGE( LONG_MAX, 2 )
+#  define FT_SIZEOF_LONG 2
+# elif FT_IS_IN_NBYTE_RANGE( LONG_MAX, 3 )
+#  define FT_SIZEOF_LONG 3
+# elif FT_IS_IN_NBYTE_RANGE( LONG_MAX, 4 )
+#  define FT_SIZEOF_LONG 4
+# elif FT_IS_IN_NBYTE_RANGE( LONG_MAX, 5 )
+#  define FT_SIZEOF_LONG 5
+# elif FT_IS_IN_NBYTE_RANGE( LONG_MAX, 6 )
+#  define FT_SIZEOF_LONG 6
+# elif FT_IS_IN_NBYTE_RANGE( LONG_MAX, 7 )
+#  define FT_SIZEOF_LONG 7
+# elif FT_IS_IN_NBYTE_RANGE( LONG_MAX, 8 )
+#  define FT_SIZEOF_LONG 8
+# else
+#  define USE_PROVEN_SIZES
+# endif
+
+
+
+#else /* cpp cannot handle 64bit constant */
+
+  /*
+   * Here we list the environment that can execute multiple ABIs
+   * with different bitsize (e.g. IRIX on mips64, AIX on ppc64)
+   * or build binary for multiple ABIs by single SDK (Mac OS X).
+   * The environment that use single ABIs or multiple ABIs but
+   * same bit-length should be prepared by configure.
+   */
+# if defined( linux ) || defined( __FreeBSD__ ) || defined( __NetBSD__ ) || defined( __OpenBSD__ )
+#  if   defined( __amd64 ) || defined( __ia64 ) || defined( __ppc64 ) || defined( __mips64 ) || defined( __sparc64 ) || defined( __sh64 )
+#   define __FT_LP64__ 1
+#  elif defined( __i386 )  || defined( __ppc )   || defined( __mips )   || defined( __sparc )   || defined( __sh )
+#   define __FT_LP32__ 1
+#  endif
+
+  /* AIX */
+# elif defined( _AIX ) /* See /usr/include/sys/limits.h */
+#  if   defined( __64BIT__ )
+#   define __FT_LP64__ 1
+#  else
+#   define __FT_LP32__ 1
+#  endif
+
+  /* HP-UX */
+# elif defined( __hpux )
+#  ifndef __FT_LP64__
+#   define __FT_LP32__ 1
+#  endif
+
+  /* IRIX */
+# elif defined( sgi )
+#  if defined( _MIPS_SZLONG ) && ( _MIPS_SZLONG == 64 )
+#   define __FT_LP64__
+#  else
+#   define __FT_LP32__
+#  endif
+
+  /* Solaris */
+# elif defined( sun )
+#  ifdef _LP64
+#   define __FT_LP64__
+#  else
+#   define __FT_LP32__
+#  endif
+
+# endif
+
+# if   defined( __LP32__ ) || defined( __FT_LP32__ ) || defined( __FT_LLP64__ )
+#  define FT_SIZEOF_INT  4
+#  define FT_SIZEOF_LONG 4
+# elif defined( __LP64__ ) || defined( __FT_LP64__ )
+#  define FT_SIZEOF_INT  4
+#  define FT_SIZEOF_LONG 8
+# elif defined( __ILP64__ )
+#  define FT_SIZEOF_INT  8
+#  define FT_SIZEOF_LONG 8
+# else
+#  define USE_PROVEN_SIZES
+# endif
+
+#endif
+
+#ifdef USE_PROVEN_SIZES
+# undef SIZEOF_INT
+# undef SIZEOF_LONG
+# define FT_SIZEOF_INT   SIZEOF_INT
+# define FT_SIZEOF_LONG  SIZEOF_LONG
+#endif
+
   /* Preferred alignment of data */
 #define FT_ALIGNMENT  8
 
_______________________________________________
Freetype-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/freetype-devel

Reply via email to