New `TYPEOF' macro. This helps suppress signedness warnings, avoiding issues with implicit conversion changes. * include/config/ftconfig.h, builds/unix/ftconfig.in, builds/vms/ftconfig.h (TYPEOF): Define. * include/internal/ftobjs.h (FT_PAD_FLOOR, FT_PIX_FLOOR), src/autofit/afwarp.h (AF_WARPER_FLOOR): Use it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
diff --git a/ChangeLog b/ChangeLog
index fa69973..982b928 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2015-02-16 Werner Lemberg <wl@gnu.org>
+ New `TYPEOF' macro.
+
+ This helps suppress signedness warnings, avoiding issues with
+ implicit conversion changes.
+
+ * include/config/ftconfig.h, builds/unix/ftconfig.in,
+ builds/vms/ftconfig.h (TYPEOF): Define.
+
+ * include/internal/ftobjs.h (FT_PAD_FLOOR, FT_PIX_FLOOR),
+ src/autofit/afwarp.h (AF_WARPER_FLOOR): Use it.
+
+2015-02-16 Werner Lemberg <wl@gnu.org>
+
* src/base/ftsystem.c: Use casts in standard C function wrappers.
(ft_alloc, ft_realloc, ft_ansi_stream_io, FT_Stream_Open): Do it.
diff --git a/builds/unix/ftconfig.in b/builds/unix/ftconfig.in
index 6d28b61..47ca2da 100644
--- a/builds/unix/ftconfig.in
+++ b/builds/unix/ftconfig.in
@@ -89,7 +89,7 @@ FT_BEGIN_HEADER
/* is copied from default include/config/ftconfig.h. */
/* If any improvement is required for this file, it should be */
/* applied to the original header file for the builders that */
- /* does not use configure script. */
+ /* do not use configure script. */
/* The size of an `int' type. */
#if FT_UINT_MAX == 0xFFFFUL
@@ -349,11 +349,29 @@ FT_BEGIN_HEADER
#endif
+ /*************************************************************************/
+ /* */
+ /* <Section> */
+ /* miscellaneous */
+ /* */
+ /*************************************************************************/
+
+
#define FT_BEGIN_STMNT do {
#define FT_END_STMNT } while ( 0 )
#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
+ /* typeof condition taken from gnulib's `intprops.h' header file */
+#if ( __GNUC__ >= 2 || \
+ defined( __IBM__TYPEOF__ ) || \
+ ( __SUNPRO_C >= 0x5110 && !__STDC__ ) )
+#define TYPEOF( type, x ) (__typeof__ (type))(x)
+#else
+#define TYPEOF( type, x ) (x)
+#endif
+
+
#ifdef FT_MAKE_OPTION_SINGLE_OBJECT
#define FT_LOCAL( x ) static x
diff --git a/builds/vms/ftconfig.h b/builds/vms/ftconfig.h
index 0e05028..571c3e5 100644
--- a/builds/vms/ftconfig.h
+++ b/builds/vms/ftconfig.h
@@ -292,11 +292,29 @@ FT_BEGIN_HEADER
#endif
+ /*************************************************************************/
+ /* */
+ /* <Section> */
+ /* miscellaneous */
+ /* */
+ /*************************************************************************/
+
+
#define FT_BEGIN_STMNT do {
#define FT_END_STMNT } while ( 0 )
#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
+ /* typeof condition taken from gnulib's `intprops.h' header file */
+#if ( __GNUC__ >= 2 || \
+ defined( __IBM__TYPEOF__ ) || \
+ ( __SUNPRO_C >= 0x5110 && !__STDC__ ) )
+#define TYPEOF( type, x ) (__typeof__ (type))(x)
+#else
+#define TYPEOF( type, x ) (x)
+#endif
+
+
#ifdef FT_MAKE_OPTION_SINGLE_OBJECT
#define FT_LOCAL( x ) static x
diff --git a/include/config/ftconfig.h b/include/config/ftconfig.h
index c165fa5..b9fbfe2 100644
--- a/include/config/ftconfig.h
+++ b/include/config/ftconfig.h
@@ -319,11 +319,29 @@ FT_BEGIN_HEADER
#endif
+ /*************************************************************************/
+ /* */
+ /* <Section> */
+ /* miscellaneous */
+ /* */
+ /*************************************************************************/
+
+
#define FT_BEGIN_STMNT do {
#define FT_END_STMNT } while ( 0 )
#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT
+ /* typeof condition taken from gnulib's `intprops.h' header file */
+#if ( __GNUC__ >= 2 || \
+ defined( __IBM__TYPEOF__ ) || \
+ ( __SUNPRO_C >= 0x5110 && !__STDC__ ) )
+#define TYPEOF( type, x ) (__typeof__ (type))(x)
+#else
+#define TYPEOF( type, x ) (x)
+#endif
+
+
#ifdef FT_MAKE_OPTION_SINGLE_OBJECT
#define FT_LOCAL( x ) static x
diff --git a/include/internal/ftobjs.h b/include/internal/ftobjs.h
index f08b8fa..80c12b3 100644
--- a/include/internal/ftobjs.h
+++ b/include/internal/ftobjs.h
@@ -83,11 +83,12 @@ FT_BEGIN_HEADER
x > y ? x + ( 3 * y >> 3 ) \
: y + ( 3 * x >> 3 ) )
-#define FT_PAD_FLOOR( x, n ) ( (x) & ~((n)-1) )
+ /* we use the TYPEOF macro to suppress signedness compilation warnings */
+#define FT_PAD_FLOOR( x, n ) ( (x) & ~TYPEOF( x, (n)-1 ) )
#define FT_PAD_ROUND( x, n ) FT_PAD_FLOOR( (x) + ((n)/2), n )
#define FT_PAD_CEIL( x, n ) FT_PAD_FLOOR( (x) + ((n)-1), n )
-#define FT_PIX_FLOOR( x ) ( (x) & ~63 )
+#define FT_PIX_FLOOR( x ) ( (x) & ~TYPEOF( x, 63 ) )
#define FT_PIX_ROUND( x ) FT_PIX_FLOOR( (x) + 32 )
#define FT_PIX_CEIL( x ) FT_PIX_FLOOR( (x) + 63 )
diff --git a/src/autofit/afwarp.h b/src/autofit/afwarp.h
index 3b1c87a..a2c5f77 100644
--- a/src/autofit/afwarp.h
+++ b/src/autofit/afwarp.h
@@ -25,7 +25,7 @@ FT_BEGIN_HEADER
#define AF_WARPER_SCALE
-#define AF_WARPER_FLOOR( x ) ( (x) & ~63 )
+#define AF_WARPER_FLOOR( x ) ( (x) & ~TYPEOF( x, 63 ) )
#define AF_WARPER_CEIL( x ) AF_WARPER_FLOOR( (x) + 63 )