summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-27 02:42:16 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-27 02:42:16 +0000
commitf933f9d3a5e5d71bcebc5d0a3206149870c412e0 (patch)
tree045c16c6de9011cf95261b5bc71aaed28be07835 /gc.c
parentd68e049c5f5ec5a0f2c1c7f2ebb0b08e735ef959 (diff)
* gc.c (id2ref): must not assign pointers to long int. use
LONG_LONG instead if SIZEOF_LONG < SIZEOF_VOIDP. [ruby-talk:149645] * ruby.h: use LONG_LONG to simplify the change. [ruby-talk:149645] * eval.c (rb_f_throw): replace all '0x%lx' by '%p'. [ruby-talk:149553] * missing/vsnprintf.c (BSD_vfprintf): '%p' need to handle 64bit size pointer. [ruby-talk:149553] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@8845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/gc.c b/gc.c
index 7a2ae7d..586e9b0 100644
--- a/gc.c
+++ b/gc.c
@@ -990,7 +990,7 @@ gc_mark_children(ptr, lev)
break;
default:
- rb_bug("rb_gc_mark(): unknown data type 0x%lx(0x%lx) %s",
+ rb_bug("rb_gc_mark(): unknown data type %p(%p) %s",
obj->as.basic.flags & T_MASK, obj,
is_pointer_to_heap(obj) ? "corrupted object" : "non object");
}
@@ -1256,7 +1256,7 @@ obj_free(obj)
break;
default:
- rb_bug("gc_sweep(): unknown data type 0x%lx(%ld)", obj,
+ rb_bug("gc_sweep(): unknown data type %p(%ld)", obj,
RANY(obj)->as.basic.flags & T_MASK);
}
}
@@ -1883,10 +1883,18 @@ static VALUE
id2ref(obj, id)
VALUE obj, id;
{
- unsigned long ptr, p0;
+#if SIZEOF_LONG == SIZEOF_VOIDP
+#define NUM2PTR(x) NUM2ULONG(x)
+#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
+#define NUM2PTR(x) NUM2ULL(x)
+#endif
+ VALUE ptr;
+ void *p0;
rb_secure(4);
- p0 = ptr = NUM2ULONG(id);
+ ptr = NUM2PTR(id);
+ p0 = (void *)ptr;
+
if (ptr == Qtrue) return Qtrue;
if (ptr == Qfalse) return Qfalse;
if (ptr == Qnil) return Qnil;
@@ -1897,10 +1905,10 @@ id2ref(obj, id)
ptr = id ^ FIXNUM_FLAG; /* unset FIXNUM_FLAG */
if (!is_pointer_to_heap((void *)ptr)|| BUILTIN_TYPE(ptr) >= T_BLKTAG) {
- rb_raise(rb_eRangeError, "0x%lx is not id value", p0);
+ rb_raise(rb_eRangeError, "%p is not id value", p0);
}
if (BUILTIN_TYPE(ptr) == 0 || RBASIC(ptr)->klass == 0) {
- rb_raise(rb_eRangeError, "0x%lx is recycled object", p0);
+ rb_raise(rb_eRangeError, "%p is recycled object", p0);
}
return (VALUE)ptr;
}