From 7aeee3c50f2656b65f7dc207aa2020bb1398da98 Mon Sep 17 00:00:00 2001 From: Werner Lemberg Date: Sat, 18 Mar 2017 17:30:42 +0100 Subject: [PATCH] Introduce FT_UINT_TO_POINTER macro (#50560). We have to make a separate case for Windows 64's LLP64 data model. * builds/unix/ftconfig.in, builds/vms/ftconfig.h, include/freetype/config/ftconfig.h (FT_UINT_TO_POINTER): New macro. * src/truetype/ttgload.c (load_truetype_glyph): Use it. --- ChangeLog | 11 +++++++++++ builds/unix/ftconfig.in | 9 +++++++++ builds/vms/ftconfig.h | 9 +++++++++ include/freetype/config/ftconfig.h | 9 +++++++++ src/truetype/ttgload.c | 6 +++--- 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea14f23c7..6a6351868 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2017-03-18 Werner Lemberg + + Introduce FT_UINT_TO_POINTER macro (#50560). + + We have to make a separate case for Windows 64's LLP64 data model. + + * builds/unix/ftconfig.in, builds/vms/ftconfig.h, + include/freetype/config/ftconfig.h (FT_UINT_TO_POINTER): New macro. + + * src/truetype/ttgload.c (load_truetype_glyph): Use it. + 2017-03-18 Werner Lemberg * src/truetype/ttinterp.c (TT_RunIns): Adjust loop counter (#50573). diff --git a/builds/unix/ftconfig.in b/builds/unix/ftconfig.in index 0bc93f19a..b0ef313a8 100644 --- a/builds/unix/ftconfig.in +++ b/builds/unix/ftconfig.in @@ -365,6 +365,15 @@ FT_BEGIN_HEADER #endif +#ifdef _WIN64 + /* only 64bit Windows uses the LLP64 data model, i.e., */ + /* 32bit integers, 64bit pointers */ +#define FT_UINT_TO_POINTER( x ) (void*)(FT_UInt64)(x) +#else +#define FT_UINT_TO_POINTER( x ) (void*)(unsigned long)(x) +#endif + + /*************************************************************************/ /* */ /* miscellaneous */ diff --git a/builds/vms/ftconfig.h b/builds/vms/ftconfig.h index c959ff19f..8fbb0f4b7 100644 --- a/builds/vms/ftconfig.h +++ b/builds/vms/ftconfig.h @@ -306,6 +306,15 @@ FT_BEGIN_HEADER #endif +#ifdef _WIN64 + /* only 64bit Windows uses the LLP64 data model, i.e., */ + /* 32bit integers, 64bit pointers */ +#define FT_UINT_TO_POINTER( x ) (void*)(FT_UInt64)(x) +#else +#define FT_UINT_TO_POINTER( x ) (void*)(unsigned long)(x) +#endif + + /*************************************************************************/ /* */ /* miscellaneous */ diff --git a/include/freetype/config/ftconfig.h b/include/freetype/config/ftconfig.h index 9d7f8839b..0a1e4db8e 100644 --- a/include/freetype/config/ftconfig.h +++ b/include/freetype/config/ftconfig.h @@ -333,6 +333,15 @@ FT_BEGIN_HEADER #endif +#ifdef _WIN64 + /* only 64bit Windows uses the LLP64 data model, i.e., */ + /* 32bit integers, 64bit pointers */ +#define FT_UINT_TO_POINTER( x ) (void*)(FT_UInt64)(x) +#else +#define FT_UINT_TO_POINTER( x ) (void*)(unsigned long)(x) +#endif + + /*************************************************************************/ /* */ /* miscellaneous */ diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c index eecf7afdd..cd4634faa 100644 --- a/src/truetype/ttgload.c +++ b/src/truetype/ttgload.c @@ -1711,7 +1711,7 @@ /* check whether we already have a composite glyph with this index */ if ( FT_List_Find( &loader->composites, - (void*)(unsigned long)glyph_index ) ) + FT_UINT_TO_POINTER( glyph_index ) ) ) { FT_TRACE1(( "TT_Load_Composite_Glyph:" " infinite recursion detected\n" )); @@ -1720,13 +1720,13 @@ } else if ( node ) - node->data = (void*)(unsigned long)glyph_index; + node->data = FT_UINT_TO_POINTER( glyph_index ); else { if ( FT_NEW( node ) ) goto Exit; - node->data = (void*)(unsigned long)glyph_index; + node->data = FT_UINT_TO_POINTER( glyph_index ); FT_List_Add( &loader->composites, node ); }