ref: 6f325c26cf3df4e4c7ad97b8bccfdcc096b6637e
parent: 1f377f0d50a6a4bdf2a4985a010af0403925681f
author: Werner Lemberg <[email protected]>
date: Mon Feb 16 06:31:32 EST 2015
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.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2015-02-16 Werner Lemberg <[email protected]>
+ 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 <[email protected]>
+
* src/base/ftsystem.c: Use casts in standard C function wrappers.
(ft_alloc, ft_realloc, ft_ansi_stream_io, FT_Stream_Open): Do it.
--- a/builds/unix/ftconfig.in
+++ b/builds/unix/ftconfig.in
@@ -89,7 +89,7 @@
/* 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,9 +349,27 @@
#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
--- a/builds/vms/ftconfig.h
+++ b/builds/vms/ftconfig.h
@@ -292,9 +292,27 @@
#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
--- a/include/config/ftconfig.h
+++ b/include/config/ftconfig.h
@@ -319,9 +319,27 @@
#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
--- a/include/internal/ftobjs.h
+++ b/include/internal/ftobjs.h
@@ -83,11 +83,12 @@
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 )
--- a/src/autofit/afwarp.h
+++ b/src/autofit/afwarp.h
@@ -25,7 +25,7 @@
#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 )