freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft-devel] Re: freetype-2.3.7 -- ftconfig.h for biarch systems


From: mpsuzuki
Subject: Re: [ft-devel] Re: freetype-2.3.7 -- ftconfig.h for biarch systems
Date: Thu, 11 Sep 2008 01:37:29 +0900

Hi all,

As I receive few comments on previous patch, I revised
my patch for more smooth migration.

1. The cpp computation of bit length of int & long
   was duplicated from original ftconfig.h designed
   for non-autoconf-systems:
   freetype-2.3.7/include/freetype/config/ftconfig.h.
   Its computation does not require C99 at all.

   I postpone the introduction of new header file to
   separate the cpp computation for easier maintenance.

2. Add a check to guarantee the cpp computation results
   is compatible with the results detected by autoconf.
   If there's any difference, the results detected by
   autoconf is prioritized by the definition of
   USE_AUTOCONF_SIZEOF_TYPES. However, we can set this
   macro manually by "--{enable|disable}-biarch-header",
   regardless with the result of the comparison.
   
   Because the check must parse unconfigured ftconfig.in,
   the sh script to compare them is ugly. When I can
   separate the cpp computation to individual file,
   the comparison would be more simple (maybe existing
   autoconf macro will help).

By the comparison by configure.raw, I think this patch
does not introduce any difference in single architecture
platforms.


Index: ChangeLog
===================================================================
RCS file: /sources/freetype/freetype2/ChangeLog,v
retrieving revision 1.1789
diff -u -r1.1789 ChangeLog
--- ChangeLog   5 Sep 2008 03:21:20 -0000       1.1789
+++ ChangeLog   10 Sep 2008 13:57:06 -0000
@@ -1,3 +1,15 @@
+2008-09-10  suzuki toshiya <address@hidden>
+
+       * builds/unix/ftconfig.in: Duplicate the cpp computation of
+       FT_SIZEOF_{INT|LONG} from include/freetype/config/ftconfig.h.
+       If USE_AUTOCONF_SIZEOF_TYPES is defined, the cpp computation
+       is ignored and the statically configured sizes are used.
+       * builds/unix/configure.raw: Add the checks to compare the
+       cpp computation result versus the sizes detected by configure.
+       If the results are different, USE_AUTOCONF_SIZEOF_TYPES is
+       defined. New option --{enable|disable}-biarch-header is added
+       to override USE_AUTOCONF_SIZEOF_TYPES manually.
+
 2008-09-05  suzuki toshiya <address@hidden>
 
        * builds/unix/configure.raw: Clear FT2_EXTRA_LIBS when Carbon
Index: builds/unix/ftconfig.in
===================================================================
RCS file: /sources/freetype/freetype2/builds/unix/ftconfig.in,v
retrieving revision 1.23
diff -u -r1.23 ftconfig.in
--- builds/unix/ftconfig.in     2 Sep 2008 02:21:56 -0000       1.23
+++ builds/unix/ftconfig.in     10 Sep 2008 13:57:16 -0000
@@ -59,15 +59,54 @@
 
 #undef HAVE_UNISTD_H
 #undef HAVE_FCNTL_H
+#undef HAVE_STDINT_H
 
+
+  /* There are systems (like the Texas Instruments 'C54x) where a `char' */
+  /* has 16 bits.  ANSI C says that sizeof(char) is always 1.  Since an  */
+  /* `int' has 16 bits also for this system, sizeof(int) gives 1 which   */
+  /* is probably unexpected.                                             */
+  /*                                                                     */
+  /* `CHAR_BIT' (defined in limits.h) gives the number of bits in a      */
+  /* `char' type.                                                        */
+
+#ifndef FT_CHAR_BIT
+#define FT_CHAR_BIT  CHAR_BIT
+#endif
+
+
+#undef USE_AUTOCONF_SIZEOF_TYPES
+#ifdef USE_AUTOCONF_SIZEOF_TYPES
 #undef SIZEOF_INT
 #undef SIZEOF_LONG
+#define FT_SIZEOF_INT  SIZEOF_INT
+#define FT_SIZEOF_LONG SIZEOF_LONG
+#else
 
+  /* The size of an `int' type.  */
+#if                                 FT_UINT_MAX == 0xFFFFUL
+#define FT_SIZEOF_INT  (16 / FT_CHAR_BIT)
+#elif                               FT_UINT_MAX == 0xFFFFFFFFUL
+#define FT_SIZEOF_INT  (32 / FT_CHAR_BIT)
+#elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL
+#define FT_SIZEOF_INT  (64 / FT_CHAR_BIT)
+#else
+#error "Unsupported size of `int' type!"
+#endif
 
-#define FT_SIZEOF_INT   SIZEOF_INT
-#define FT_SIZEOF_LONG  SIZEOF_LONG
+  /* The size of a `long' type.  A five-byte `long' (as used e.g. on the */
+  /* DM642) is recognized but avoided.                                   */
+#if                                  FT_ULONG_MAX == 0xFFFFFFFFUL
+#define FT_SIZEOF_LONG  (32 / FT_CHAR_BIT)
+#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL
+#define FT_SIZEOF_LONG  (32 / FT_CHAR_BIT)
+#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL
+#define FT_SIZEOF_LONG  (64 / FT_CHAR_BIT)
+#else
+#error "Unsupported size of `long' type!"
+#endif
 
-#define FT_CHAR_BIT  CHAR_BIT
+#endif /* ! USE_AUTOCONF_SIZEOF_TYPES */
 
   /* Preferred alignment of data */
 #define FT_ALIGNMENT  8
Index: builds/unix/configure.raw
===================================================================
RCS file: /sources/freetype/freetype2/builds/unix/configure.raw,v
retrieving revision 1.33
diff -u -r1.33 configure.raw
--- builds/unix/configure.raw   5 Sep 2008 03:21:21 -0000       1.33
+++ builds/unix/configure.raw   10 Sep 2008 13:57:08 -0000
@@ -126,6 +126,65 @@
 AC_CHECK_SIZEOF([long])
 
 
+# checks for cpp computation of size of int and long ftconfig.in works
+
+AC_MSG_CHECKING([cpp computation of bit length in ftconfig.in works])
+orig_CPPFLAGS="${CPPFLAGS}"
+CPPFLAGS="-I${srcdir} -I. ${CPPFLAGS}"
+ac_clean_files="ft2build.h ftoption.h ftstdlib.h"
+touch ft2build.h ftoption.h ftstdlib.h
+cat > conftest.c <<\_ACEOF
+#include <limits.h>
+#define FT_CONFIG_OPTIONS_H "ftoption.h"
+#define FT_CONFIG_STANDARD_LIBRARY_H "ftstdlib.h"
+#define FT_UINT_MAX  UINT_MAX
+#define FT_ULONG_MAX ULONG_MAX
+#include "ftconfig.in"
+_ACEOF
+echo >> conftest.c "#if FT_SIZEOF_INT == "${ac_cv_sizeof_int}
+echo >> conftest.c "ac_cpp_ft_sizeof_int="${ac_cv_sizeof_int}
+echo >> conftest.c "#endif"
+echo >> conftest.c "#if FT_SIZEOF_LONG == "${ac_cv_sizeof_long}
+echo >> conftest.c "ac_cpp_ft_sizeof_long="${ac_cv_sizeof_long}
+echo >> conftest.c "#endif"
+${CPP} ${CPPFLAGS} conftest.c | ${GREP} ac_cpp_ft > conftest.sh
+eval `cat conftest.sh`
+${RMF} conftest.c conftest.sh confft2build.h ftoption.h ftstdlib.h
+if test x != "x${ac_cpp_ft_sizeof_int}" -a x != x"${ac_cpp_ft_sizeof_long}"
+then
+  unset use_autoconf_sizeof_types
+else
+  use_autoconf_sizeof_types="yes"
+fi
+AC_ARG_ENABLE(biarch-config,
+[  --enable-biarch-config  install biarch ftconfig.h to support multiple
+                          architechtures by single file], [], [])
+
+case :${use_autoconf_sizeof_types}:${enable_biarch_config}: in
+  :yes:yes: )
+    AC_MSG_RESULT([broken but use])
+    unset use_autoconf_sizeof_types
+    ;;
+  ::no: )
+    AC_MSG_RESULT([works but ignore])
+    use_autoconf_sizeof_types="yes"
+    ;;
+  ::yes: | ::: )
+    AC_MSG_RESULT([yes])
+    unset use_autoconf_sizeof_types
+    ;;
+  * )
+    AC_MSG_RESULT([no])
+    use_autoconf_sizeof_types="yes"
+    ;;
+esac
+if test xyes = x"${use_autoconf_sizeof_types}"
+then
+  AC_DEFINE([USE_AUTOCONF_SIZEOF_TYPES])
+fi
+CPPFLAGS="${orig_CPPFLAGS}"
+
+
 # checks for library functions
 
 # Here we check whether we can use our mmap file component.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]