Skip to content

Commit

Permalink
fix truncation issues when dealing with unsigned long long types
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Sansonetti committed Mar 29, 2011
1 parent e2c7307 commit 01965bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,12 @@ rval_to_long_long(VALUE rval)
return NUM2LL(rb_Integer(bool_to_fix(rval)));
}

static inline unsigned long long
rval_to_ulong_long(VALUE rval)
{
return NUM2ULL(rb_Integer(bool_to_fix(rval)));
}

static inline double
rval_to_double(VALUE rval)
{
Expand Down Expand Up @@ -849,13 +855,13 @@ vm_rval_to_ulong(VALUE rval, unsigned long *ocval)
PRIMITIVE void
vm_rval_to_long_long(VALUE rval, long long *ocval)
{
*ocval = (long long)rval_to_long_long(rval);
*ocval = rval_to_long_long(rval);
}

PRIMITIVE void
vm_rval_to_ulong_long(VALUE rval, unsigned long long *ocval)
{
*ocval = (unsigned long long)rval_to_long_long(rval);
*ocval = rval_to_ulong_long(rval);
}

PRIMITIVE void
Expand Down
2 changes: 1 addition & 1 deletion objc.m
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@
else {
long v = 0;
assert(CFNumberGetValue((CFNumberRef)obj, kCFNumberLongType, &v));
return LONG2FIX(v);
return LONG2NUM(v);
}
}
else if (k == (Class)rb_cNSDate) {
Expand Down

0 comments on commit 01965bc

Please sign in to comment.