updated FT_Div64by32

This commit is contained in:
David Turner 2001-10-18 09:51:09 +00:00
parent ea5a981c7d
commit 1c5802a4b2
3 changed files with 68 additions and 1 deletions

View File

@ -1,5 +1,15 @@
2001-10-18 David Turner <david@freetype.org>
* src/base/ftcalc.c (FT_Div64by32): changed the implementation
slightly since the original code was mis-compiled on Mac machines
using the MPW C compiler..
2001-10-17 David Turner >david@freetype.org>
* Version 2.0.4 released.
=========================
* include/freetype/freetype.h, include/internal/ftobjs.h,
src/base/ftobjs.c, src/sfnt/sfdriver.c, type1/t1driver.c,
cid/cidriver.c: Adding a new function named 'FT_Get_Postscript_Name' to
@ -8,6 +18,7 @@
* README, docs/CHANGES: updated for 2.0.5 release
2001-10-08 David Turner <david@freetype.org>
Fixed a bug in `glnames.py' that prevented it from generating

View File

@ -171,7 +171,7 @@ FT_BEGIN_HEADER
/* file "ftconfig.h" either statically, or through Autoconf */
/* on platforms that support it. */
/* */
#define FT_CONFIG_OPTION_FORCE_INT64
#undef FT_CONFIG_OPTION_FORCE_INT64
/*************************************************************************/

View File

@ -496,6 +496,61 @@
/* documentation is in ftcalc.h */
/* apparently, the second version of this code is not compiled correctly */
/* on Mac machines with the MPW C compiler.. tsss, tsss, tss... */
#if 1
FT_EXPORT_DEF( FT_Int32 )
FT_Div64by32( FT_Int64* x,
FT_Int32 y )
{
FT_Int32 s;
FT_UInt32 q, r, i, lo;
s = x->hi;
if ( s < 0 )
{
x->lo = (FT_UInt32)-(FT_Int32)x->lo;
x->hi = ~x->hi + !( x->lo );
}
s ^= y; y = ABS( y );
/* Shortcut */
if ( x->hi == 0 )
{
if ( y > 0 )
q = x->lo / y;
else
q = 0x7FFFFFFFL;
return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
}
r = x->hi;
lo = x->lo;
if ( r >= (FT_UInt32)y ) /* we know y is to be treated as unsigned here */
return ( s < 0 ? 0x80000001UL : 0x7FFFFFFFUL );
/* Return Max/Min Int32 if division overflow. */
/* This includes division by zero! */
q = 0;
for ( i = 0; i < 32; i++ )
{
r <<= 1;
q <<= 1;
r |= lo >> 31;
if ( r >= (FT_UInt32)y )
{
r -= y;
q |= 1;
}
lo <<= 1;
}
return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
}
#else
FT_EXPORT_DEF( FT_Int32 )
FT_Div64by32( FT_Int64* x,
FT_Int32 y )
@ -527,6 +582,7 @@
return ( s < 0 ? -(FT_Int32)q : (FT_Int32)q );
}
#endif
#ifdef FT_CONFIG_OPTION_OLD_CALCS