Skip to content

Commit

Permalink
bugfix: fix cairo-wideint.c uint64_t usage and const return qualifiers
Browse files Browse the repository at this point in the history
These patches were sent to the cairo mailing list by Mathieu Lacage
<Mathieu.Lacage@sophia.inria.fr>:

http://lists.freedesktop.org/archives/cairo/2006-December/008741.html

  _cairo_uint_96by64_32x64_divrem(): fixes misuse of the uint64_t type
  and cairo-wideint-private.h functions.

http://lists.freedesktop.org/archives/cairo/2006-December/008742.html

  Remove const qualifiers from return types from cairo-wideint.c functions.

http://lists.freedesktop.org/archives/cairo/2006-December/008747.html

  Fixes a typo in cairo-wideint-private.h: _cairo_uint128_to_int128_
  had an extra trailing underscore.
  • Loading branch information
Mathieu Lacage authored and M Joonas Pihlaja committed Dec 5, 2006
1 parent 94e086b commit a4f5463
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/cairo-wideint-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ cairo_uint128_t I _cairo_uint128_negate (cairo_uint128_t a);
#define _cairo_uint128_negative(a) (_cairo_uint64_negative(a.hi))
cairo_uint128_t I _cairo_uint128_not (cairo_uint128_t a);

#define _cairo_uint128_to_int128_(i) (i)
#define _cairo_uint128_to_int128(i) (i)
#define _cairo_int128_to_uint128(i) (i)

cairo_int128_t I _cairo_int32_to_int128 (int32_t i);
Expand Down
14 changes: 7 additions & 7 deletions src/cairo-wideint.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ _cairo_int32_to_int64 (int32_t i)
return q;
}

static const cairo_uint64_t
static cairo_uint64_t
_cairo_uint32s_to_uint64 (uint32_t h, uint32_t l)
{
cairo_uint64_t q;
Expand Down Expand Up @@ -407,7 +407,7 @@ _cairo_uint128_sub (cairo_uint128_t a, cairo_uint128_t b)
#define uint64_lo32(i) ((i).lo)
#define uint64_hi32(i) ((i).hi)

static const cairo_uint64_t
static cairo_uint64_t
uint64_lo (cairo_uint64_t i)
{
cairo_uint64_t s;
Expand All @@ -417,7 +417,7 @@ uint64_lo (cairo_uint64_t i)
return s;
}

static const cairo_uint64_t
static cairo_uint64_t
uint64_hi (cairo_uint64_t i)
{
cairo_uint64_t s;
Expand All @@ -427,7 +427,7 @@ uint64_hi (cairo_uint64_t i)
return s;
}

static const cairo_uint64_t
static cairo_uint64_t
uint64_shift32 (cairo_uint64_t i)
{
cairo_uint64_t s;
Expand Down Expand Up @@ -671,7 +671,7 @@ _cairo_uint_96by64_32x64_divrem (cairo_uint128_t num,
cairo_uint64_t den)
{
cairo_uquorem64_t result;
uint64_t B = _cairo_uint32s_to_uint64 (1, 0);
cairo_uint64_t B = _cairo_uint32s_to_uint64 (1, 0);

/* These are the high 64 bits of the *96* bit numerator. We're
* going to represent the numerator as xB + y, where x is a 64,
Expand Down Expand Up @@ -701,7 +701,7 @@ _cairo_uint_96by64_32x64_divrem (cairo_uint128_t num,
* den = uB + v u, v : 32 bits
*/
uint32_t y = _cairo_uint128_to_uint32 (num);
uint32_t u = uint64_hi (den);
uint32_t u = uint64_hi32 (den);
uint32_t v = _cairo_uint64_to_uint32 (den);

/* Compute a lower bound approximate quotient of num/den
Expand Down Expand Up @@ -738,7 +738,7 @@ _cairo_uint_96by64_32x64_divrem (cairo_uint128_t num,
r = _cairo_uint64_to_uint32 (quorem.rem);
}
else {
q = uint64_hi (x);
q = uint64_hi32 (x);
r = _cairo_uint64_to_uint32 (x);
}
quotient = q;
Expand Down

0 comments on commit a4f5463

Please sign in to comment.