summaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog17
-rw-r--r--eval.c22
-rw-r--r--gc.c20
-rw-r--r--missing/vsnprintf.c9
-rw-r--r--object.c6
-rw-r--r--ruby.h7
-rw-r--r--sprintf.c7
-rw-r--r--variable.c2
8 files changed, 62 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 6591a69..5e3494e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,25 @@
+Wed Jul 27 10:43:14 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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]
+
Wed Jul 27 10:59:02 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* dir.c (dir_each): rewinddir(3) before iteration.
[ruby-talk:149628]
+Wed Jul 27 02:34:58 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * 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]
+
Tue Jul 26 18:11:33 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* ruby.h: support LLP64 model. [ruby-talk:149524]
diff --git a/eval.c b/eval.c
index f802f07..ef32c78 100644
--- a/eval.c
+++ b/eval.c
@@ -5848,7 +5848,7 @@ rb_call(klass, recv, mid, argc, argv, scope)
struct cache_entry *ent;
if (!klass) {
- rb_raise(rb_eNotImpError, "method `%s' called on terminated object (0x%lx)",
+ rb_raise(rb_eNotImpError, "method `%s' called on terminated object (%p)",
rb_id2name(mid), recv);
}
/* is it in the method cache? */
@@ -8502,7 +8502,7 @@ proc_to_s(self)
struct BLOCK *data;
NODE *node;
char *cname = rb_obj_classname(self);
- const int w = (SIZEOF_LONG * CHAR_BIT) / 4;
+ const int w = (sizeof(VALUE) * CHAR_BIT) / 4;
long len = strlen(cname)+6+w; /* 6:tags 16:addr */
VALUE str;
@@ -8511,13 +8511,13 @@ proc_to_s(self)
len += strlen(node->nd_file) + 2 + (SIZEOF_LONG*CHAR_BIT-NODE_LSHIFT)/3;
str = rb_str_new(0, len);
snprintf(RSTRING(str)->ptr, len+1,
- "#<%s:0x%.*lx@%s:%d>", cname, w, (VALUE)data->body,
+ "#<%s:%p@%s:%d>", cname, (VALUE)data->body,
node->nd_file, nd_line(node));
}
else {
str = rb_str_new(0, len);
snprintf(RSTRING(str)->ptr, len+1,
- "#<%s:0x%.*lx>", cname, w, (VALUE)data->body);
+ "#<%s:%p>", cname, (VALUE)data->body);
}
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
if (OBJ_TAINTED(self)) OBJ_TAINT(str);
@@ -10229,7 +10229,7 @@ rb_thread_deadlock()
char msg[21+SIZEOF_LONG*2];
VALUE e;
- sprintf(msg, "Thread(0x%lx): deadlock", curr_thread->thread);
+ sprintf(msg, "Thread(%p): deadlock", curr_thread->thread);
e = rb_exc_new2(rb_eFatal, msg);
if (curr_thread == main_thread) {
rb_exc_raise(e);
@@ -10509,13 +10509,13 @@ rb_thread_schedule()
TRAP_END;
}
FOREACH_THREAD_FROM(curr, th) {
- warn_printf("deadlock 0x%lx: %s:",
+ warn_printf("deadlock %p: %s:",
th->thread, thread_status_name(th->status));
if (th->wait_for & WAIT_FD) warn_printf("F(%d)", th->fd);
if (th->wait_for & WAIT_SELECT) warn_printf("S");
if (th->wait_for & WAIT_TIME) warn_printf("T(%f)", th->delay);
if (th->wait_for & WAIT_JOIN)
- warn_printf("J(0x%lx)", th->join ? th->join->thread : 0);
+ warn_printf("J(%p)", th->join ? th->join->thread : 0);
if (th->wait_for & WAIT_PID) warn_printf("P");
if (!th->wait_for) warn_printf("-");
warn_printf(" %s - %s:%d\n",
@@ -10752,10 +10752,10 @@ rb_thread_join(th, limit)
if (rb_thread_critical) rb_thread_deadlock();
if (!rb_thread_dead(th)) {
if (th == curr_thread)
- rb_raise(rb_eThreadError, "thread 0x%lx tried to join itself",
+ rb_raise(rb_eThreadError, "thread %p tried to join itself",
th->thread);
if ((th->wait_for & WAIT_JOIN) && th->join == curr_thread)
- rb_raise(rb_eThreadError, "Thread#join: deadlock 0x%lx - mutual join(0x%lx)",
+ rb_raise(rb_eThreadError, "Thread#join: deadlock %p - mutual join(%p)",
curr_thread->thread, th->thread);
if (curr_thread->status == THREAD_TO_KILL)
last_status = THREAD_TO_KILL;
@@ -12269,7 +12269,7 @@ rb_thread_inspect(thread)
size_t len = strlen(cname)+7+16+9+1;
str = rb_str_new(0, len); /* 7:tags 16:addr 9:status 1:nul */
- snprintf(RSTRING(str)->ptr, len, "#<%s:0x%lx %s>", cname, thread, status);
+ snprintf(RSTRING(str)->ptr, len, "#<%s:%p %s>", cname, thread, status);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
OBJ_INFECT(str, thread);
@@ -12803,7 +12803,7 @@ rb_f_throw(argc, argv)
break;
}
if (tt->tag == PROT_THREAD) {
- rb_raise(rb_eThreadError, "uncaught throw `%s' in thread 0x%lx",
+ rb_raise(rb_eThreadError, "uncaught throw `%s' in thread %p",
rb_id2name(SYM2ID(tag)),
curr_thread);
}
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;
}
diff --git a/missing/vsnprintf.c b/missing/vsnprintf.c
index e3362a9..d7d9e0b 100644
--- a/missing/vsnprintf.c
+++ b/missing/vsnprintf.c
@@ -781,14 +781,19 @@ fp_begin: _double = va_arg(ap, double);
* defined manner.''
* -- ANSI X3J11
*/
+#ifdef _HAVE_LLP64_
+ uqval = (u_long)va_arg(ap, void *);
+ flags = (flags) | QUADINT | HEXPREFIX;
+#else
ulval = (u_long)va_arg(ap, void *);
- base = 16;
- xdigs = "0123456789abcdef";
#ifdef _HAVE_SANE_QUAD_
flags = (flags & ~QUADINT) | HEXPREFIX;
#else /* _HAVE_SANE_QUAD_ */
flags = (flags) | HEXPREFIX;
#endif /* _HAVE_SANE_QUAD_ */
+#endif
+ base = 16;
+ xdigs = "0123456789abcdef";
ch = 'x';
goto nosign;
case 's':
diff --git a/object.c b/object.c
index b87a1d3..150c69d 100644
--- a/object.c
+++ b/object.c
@@ -359,7 +359,7 @@ rb_any_to_s(obj)
len = strlen(cname)+6+16;
str = rb_str_new(0, len); /* 6:tags 16:addr */
- snprintf(RSTRING(str)->ptr, len+1, "#<%s:0x%lx>", cname, obj);
+ snprintf(RSTRING(str)->ptr, len+1, "#<%s:%p>", cname, obj);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
if (OBJ_TAINTED(obj)) OBJ_TAINT(str);
@@ -442,13 +442,13 @@ rb_obj_inspect(obj)
if (rb_inspecting_p(obj)) {
len = strlen(c)+10+16+1;
str = rb_str_new(0, len); /* 10:tags 16:addr 1:nul */
- snprintf(RSTRING(str)->ptr, len, "#<%s:0x%lx ...>", c, obj);
+ snprintf(RSTRING(str)->ptr, len, "#<%s:%p ...>", c, obj);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
return str;
}
len = strlen(c)+6+16+1;
str = rb_str_new(0, len); /* 6:tags 16:addr 1:nul */
- snprintf(RSTRING(str)->ptr, len, "-<%s:0x%lx", c, obj);
+ snprintf(RSTRING(str)->ptr, len, "-<%s:%p", c, obj);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
return rb_protect_inspect(inspect_obj, obj, str);
}
diff --git a/ruby.h b/ruby.h
index 91d01d5..b613329 100644
--- a/ruby.h
+++ b/ruby.h
@@ -74,11 +74,8 @@ extern "C" {
typedef unsigned long VALUE;
typedef unsigned long ID;
#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP
-typedef unsigned long long VALUE;
-typedef unsigned long long ID;
-#elif SIZEOF___INT64 == SIZEOF_VOIDP
-typedef unsigned __int64 VALUE;
-typedef unsigned __int64 ID;
+typedef unsigned LONG_LONG VALUE;
+typedef unsigned LONG_LONG ID;
#else
# error ---->> ruby requires sizeof(void*) == sizeof(long) to be compiled. <<----
#endif
diff --git a/sprintf.c b/sprintf.c
index acfbf64..ad24cbd 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -809,3 +809,10 @@ fmt_setup(buf, c, flags, width, prec)
*buf++ = c;
*buf = '\0';
}
+#if SIZEOF_LONG < SIZEOF_VOIDP
+# if SIZEOF_LONG_LONG == SIZEOF_VOIDP
+# define _HAVE_SANE_QUAD_
+# define _HAVE_LLP64_
+# define u_quad_t unsigned LONG_LONG
+# endif
+#endif
diff --git a/variable.c b/variable.c
index 34a978f..14c5131 100644
--- a/variable.c
+++ b/variable.c
@@ -208,7 +208,7 @@ rb_class_path(klass)
}
len = 2 + strlen(s) + 3 + 2 * SIZEOF_LONG + 1;
path = rb_str_new(0, len);
- snprintf(RSTRING(path)->ptr, len+1, "#<%s:0x%lx>", s, klass);
+ snprintf(RSTRING(path)->ptr, len+1, "#<%s:%p>", s, klass);
RSTRING(path)->len = strlen(RSTRING(path)->ptr);
rb_ivar_set(klass, tmp_classpath, path);