Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType
Commits:
1 changed file:
Changes:
src/base/ftcalc.c
... |
... |
@@ -69,13 +69,15 @@ |
69
|
69
|
|
70
|
70
|
/* transfer sign, leaving a positive number; */
|
71
|
71
|
/* we need an unsigned value to safely negate INT_MIN (or LONG_MIN) */
|
72
|
|
-#define FT_MOVE_SIGN( x, x_unsigned, s ) \
|
73
|
|
- FT_BEGIN_STMNT \
|
74
|
|
- if ( x < 0 ) \
|
75
|
|
- { \
|
76
|
|
- x_unsigned = 0U - (x_unsigned); \
|
77
|
|
- s = -s; \
|
78
|
|
- } \
|
|
72
|
+#define FT_MOVE_SIGN( utype, x, x_unsigned, s ) \
|
|
73
|
+ FT_BEGIN_STMNT \
|
|
74
|
+ if ( x < 0 ) \
|
|
75
|
+ { \
|
|
76
|
+ x_unsigned = 0U - (utype)x; \
|
|
77
|
+ s = -s; \
|
|
78
|
+ } \
|
|
79
|
+ else \
|
|
80
|
+ x_unsigned = (utype)x; \
|
79
|
81
|
FT_END_STMNT
|
80
|
82
|
|
81
|
83
|
/* The following three functions are available regardless of whether */
|
... |
... |
@@ -179,13 +181,9 @@ |
179
|
181
|
FT_Long d_;
|
180
|
182
|
|
181
|
183
|
|
182
|
|
- a = (FT_UInt64)a_;
|
183
|
|
- b = (FT_UInt64)b_;
|
184
|
|
- c = (FT_UInt64)c_;
|
185
|
|
-
|
186
|
|
- FT_MOVE_SIGN( a_, a, s );
|
187
|
|
- FT_MOVE_SIGN( b_, b, s );
|
188
|
|
- FT_MOVE_SIGN( c_, c, s );
|
|
184
|
+ FT_MOVE_SIGN( FT_UInt64, a_, a, s );
|
|
185
|
+ FT_MOVE_SIGN( FT_UInt64, b_, b, s );
|
|
186
|
+ FT_MOVE_SIGN( FT_UInt64, c_, c, s );
|
189
|
187
|
|
190
|
188
|
d = c > 0 ? ( a * b + ( c >> 1 ) ) / c
|
191
|
189
|
: 0x7FFFFFFFUL;
|
... |
... |
@@ -208,13 +206,9 @@ |
208
|
206
|
FT_Long d_;
|
209
|
207
|
|
210
|
208
|
|
211
|
|
- a = (FT_UInt64)a_;
|
212
|
|
- b = (FT_UInt64)b_;
|
213
|
|
- c = (FT_UInt64)c_;
|
214
|
|
-
|
215
|
|
- FT_MOVE_SIGN( a_, a, s );
|
216
|
|
- FT_MOVE_SIGN( b_, b, s );
|
217
|
|
- FT_MOVE_SIGN( c_, c, s );
|
|
209
|
+ FT_MOVE_SIGN( FT_UInt64, a_, a, s );
|
|
210
|
+ FT_MOVE_SIGN( FT_UInt64, b_, b, s );
|
|
211
|
+ FT_MOVE_SIGN( FT_UInt64, c_, c, s );
|
218
|
212
|
|
219
|
213
|
d = c > 0 ? a * b / c
|
220
|
214
|
: 0x7FFFFFFFUL;
|
... |
... |
@@ -257,11 +251,8 @@ |
257
|
251
|
FT_Long q_;
|
258
|
252
|
|
259
|
253
|
|
260
|
|
- a = (FT_UInt64)a_;
|
261
|
|
- b = (FT_UInt64)b_;
|
262
|
|
-
|
263
|
|
- FT_MOVE_SIGN( a_, a, s );
|
264
|
|
- FT_MOVE_SIGN( b_, b, s );
|
|
254
|
+ FT_MOVE_SIGN( FT_UInt64, a_, a, s );
|
|
255
|
+ FT_MOVE_SIGN( FT_UInt64, b_, b, s );
|
265
|
256
|
|
266
|
257
|
q = b > 0 ? ( ( a << 16 ) + ( b >> 1 ) ) / b
|
267
|
258
|
: 0x7FFFFFFFUL;
|
... |
... |
@@ -422,13 +413,9 @@ |
422
|
413
|
|
423
|
414
|
/* XXX: this function does not allow 64-bit arguments */
|
424
|
415
|
|
425
|
|
- a = (FT_UInt32)a_;
|
426
|
|
- b = (FT_UInt32)b_;
|
427
|
|
- c = (FT_UInt32)c_;
|
428
|
|
-
|
429
|
|
- FT_MOVE_SIGN( a_, a, s );
|
430
|
|
- FT_MOVE_SIGN( b_, b, s );
|
431
|
|
- FT_MOVE_SIGN( c_, c, s );
|
|
416
|
+ FT_MOVE_SIGN( FT_UInt32, a_, a, s );
|
|
417
|
+ FT_MOVE_SIGN( FT_UInt32, b_, b, s );
|
|
418
|
+ FT_MOVE_SIGN( FT_UInt32, c_, c, s );
|
432
|
419
|
|
433
|
420
|
if ( c == 0 )
|
434
|
421
|
a = 0x7FFFFFFFUL;
|
... |
... |
@@ -470,13 +457,9 @@ |
470
|
457
|
|
471
|
458
|
/* XXX: this function does not allow 64-bit arguments */
|
472
|
459
|
|
473
|
|
- a = (FT_UInt32)a_;
|
474
|
|
- b = (FT_UInt32)b_;
|
475
|
|
- c = (FT_UInt32)c_;
|
476
|
|
-
|
477
|
|
- FT_MOVE_SIGN( a_, a, s );
|
478
|
|
- FT_MOVE_SIGN( b_, b, s );
|
479
|
|
- FT_MOVE_SIGN( c_, c, s );
|
|
460
|
+ FT_MOVE_SIGN( FT_UInt32, a_, a, s );
|
|
461
|
+ FT_MOVE_SIGN( FT_UInt32, b_, b, s );
|
|
462
|
+ FT_MOVE_SIGN( FT_UInt32, c_, c, s );
|
480
|
463
|
|
481
|
464
|
if ( c == 0 )
|
482
|
465
|
a = 0x7FFFFFFFUL;
|
... |
... |
@@ -575,11 +558,8 @@ |
575
|
558
|
|
576
|
559
|
/* XXX: this function does not allow 64-bit arguments */
|
577
|
560
|
|
578
|
|
- a = (FT_UInt32)a_;
|
579
|
|
- b = (FT_UInt32)b_;
|
580
|
|
-
|
581
|
|
- FT_MOVE_SIGN( a_, a, s );
|
582
|
|
- FT_MOVE_SIGN( b_, b, s );
|
|
561
|
+ FT_MOVE_SIGN( FT_UInt32, a_, a, s );
|
|
562
|
+ FT_MOVE_SIGN( FT_UInt32, b_, b, s );
|
583
|
563
|
|
584
|
564
|
if ( a + ( b >> 8 ) <= 8190UL )
|
585
|
565
|
a = ( a * b + 0x8000UL ) >> 16;
|
... |
... |
@@ -614,11 +594,8 @@ |
614
|
594
|
|
615
|
595
|
/* XXX: this function does not allow 64-bit arguments */
|
616
|
596
|
|
617
|
|
- a = (FT_UInt32)a_;
|
618
|
|
- b = (FT_UInt32)b_;
|
619
|
|
-
|
620
|
|
- FT_MOVE_SIGN( a_, a, s );
|
621
|
|
- FT_MOVE_SIGN( b_, b, s );
|
|
597
|
+ FT_MOVE_SIGN( FT_UInt32, a_, a, s );
|
|
598
|
+ FT_MOVE_SIGN( FT_UInt32, b_, b, s );
|
622
|
599
|
|
623
|
600
|
if ( b == 0 )
|
624
|
601
|
{
|
... |
... |
@@ -829,11 +806,8 @@ |
829
|
806
|
FT_Int sx = 1, sy = 1, shift;
|
830
|
807
|
|
831
|
808
|
|
832
|
|
- x = (FT_UInt32)x_;
|
833
|
|
- y = (FT_UInt32)y_;
|
834
|
|
-
|
835
|
|
- FT_MOVE_SIGN( x_, x, sx );
|
836
|
|
- FT_MOVE_SIGN( y_, y, sy );
|
|
809
|
+ FT_MOVE_SIGN( FT_UInt32, x_, x, sx );
|
|
810
|
+ FT_MOVE_SIGN( FT_UInt32, y_, y, sy );
|
837
|
811
|
|
838
|
812
|
/* trivial cases */
|
839
|
813
|
if ( x == 0 )
|
... |
... |
@@ -1122,11 +1096,8 @@ |
1122
|
1096
|
FT_UInt32 factor;
|
1123
|
1097
|
|
1124
|
1098
|
|
1125
|
|
- scalar = (FT_UInt32)s[i];
|
1126
|
|
- factor = (FT_UInt32)f[i];
|
1127
|
|
-
|
1128
|
|
- FT_MOVE_SIGN( s[i], scalar, sign );
|
1129
|
|
- FT_MOVE_SIGN( f[i], factor, sign );
|
|
1099
|
+ FT_MOVE_SIGN( FT_UInt32, s[i], scalar, sign );
|
|
1100
|
+ FT_MOVE_SIGN( FT_UInt32, f[i], factor, sign );
|
1130
|
1101
|
|
1131
|
1102
|
ft_multo64( scalar, factor, &multResult );
|
1132
|
1103
|
|
|