* include/ruby/intern.h (rb_strerrno): declared.
* template/known_errors.inc.tmpl: generate defined_error() and undefined_error() instead of set_syserr. * error.c (Init_syserr): define defined_error() and undefined_error() to follow the above change. (rb_strerrno): defined. * thread_pthread.c: show error message and errno macro name with rb_bug. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25893 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
a80eb26a18
commit
3302b8fff5
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
|||||||
|
Tue Nov 24 09:18:33 2009 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* include/ruby/intern.h (rb_strerrno): declared.
|
||||||
|
|
||||||
|
* template/known_errors.inc.tmpl: generate defined_error() and
|
||||||
|
undefined_error() instead of set_syserr.
|
||||||
|
|
||||||
|
* error.c (Init_syserr): define defined_error() and undefined_error()
|
||||||
|
to follow the above change.
|
||||||
|
(rb_strerrno): defined.
|
||||||
|
|
||||||
|
* thread_pthread.c: show error message and errno macro name with
|
||||||
|
rb_bug.
|
||||||
|
|
||||||
Mon Nov 23 16:06:53 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Mon Nov 23 16:06:53 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* thread_pthread.c (RUBY_STACK_MIN, RUBY_STACK_SPACE): delay for
|
* thread_pthread.c (RUBY_STACK_MIN, RUBY_STACK_SPACE): delay for
|
||||||
|
18
error.c
18
error.c
@ -1247,10 +1247,26 @@ rb_check_frozen(VALUE obj)
|
|||||||
if (OBJ_FROZEN(obj)) rb_error_frozen(rb_obj_classname(obj));
|
if (OBJ_FROZEN(obj)) rb_error_frozen(rb_obj_classname(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init_syserr(void)
|
void
|
||||||
|
Init_syserr(void)
|
||||||
{
|
{
|
||||||
rb_eNOERROR = set_syserr(0, "NOERROR");
|
rb_eNOERROR = set_syserr(0, "NOERROR");
|
||||||
|
#define defined_error(name, num) set_syserr(num, name);
|
||||||
|
#define undefined_error(name) set_syserr(0, name);
|
||||||
#include "known_errors.inc"
|
#include "known_errors.inc"
|
||||||
|
#undef defined_error
|
||||||
|
#undef undefined_error
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
rb_strerrno(int err)
|
||||||
|
{
|
||||||
|
#define defined_error(name, num) if (err == num) return name;
|
||||||
|
#define undefined_error(name)
|
||||||
|
#include "known_errors.inc"
|
||||||
|
#undef defined_error
|
||||||
|
#undef undefined_error
|
||||||
|
return "NOERROR";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -200,6 +200,7 @@ PRINTF_ARGS(void rb_compile_error_append(const char*, ...), 1, 2);
|
|||||||
NORETURN(void rb_load_fail(const char*));
|
NORETURN(void rb_load_fail(const char*));
|
||||||
NORETURN(void rb_error_frozen(const char*));
|
NORETURN(void rb_error_frozen(const char*));
|
||||||
void rb_check_frozen(VALUE);
|
void rb_check_frozen(VALUE);
|
||||||
|
char *rb_strerrno(int);
|
||||||
/* eval.c */
|
/* eval.c */
|
||||||
int rb_sourceline(void);
|
int rb_sourceline(void);
|
||||||
const char *rb_sourcefile(void);
|
const char *rb_sourcefile(void);
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
% error_names = ARGF.read.split(/\s+/)
|
% error_names = ARGF.read.split(/\s+/)
|
||||||
% error_names.each do |name|
|
% error_names.each do |name|
|
||||||
#ifdef <%=name%>
|
#ifdef <%=name%>
|
||||||
set_syserr(<%=name%>, "<%=name%>");
|
defined_error("<%=name%>", <%=name%>)
|
||||||
#else
|
#else
|
||||||
set_syserr(0, "<%=name%>");
|
undefined_error("<%=name%>")
|
||||||
#endif
|
#endif
|
||||||
% end
|
% end
|
||||||
|
@ -34,7 +34,7 @@ native_mutex_lock(pthread_mutex_t *lock)
|
|||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
if ((r = pthread_mutex_lock(lock)) != 0) {
|
if ((r = pthread_mutex_lock(lock)) != 0) {
|
||||||
rb_bug("pthread_mutex_lock: %d", r);
|
rb_bug("pthread_mutex_lock: %s (%s)", strerror(r), rb_strerrno(r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ native_mutex_unlock(pthread_mutex_t *lock)
|
|||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
if ((r = pthread_mutex_unlock(lock)) != 0) {
|
if ((r = pthread_mutex_unlock(lock)) != 0) {
|
||||||
rb_bug("native_mutex_unlock return non-zero: %d", r);
|
rb_bug("pthread_mutex_unlock: %s (%s)", strerror(r), rb_strerrno(r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ native_mutex_trylock(pthread_mutex_t *lock)
|
|||||||
return EBUSY;
|
return EBUSY;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_bug("native_mutex_trylock return non-zero: %d", r);
|
rb_bug("pthread_mutex_trylock: %s (%s)", strerror(r), rb_strerrno(r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -67,7 +67,7 @@ native_mutex_initialize(pthread_mutex_t *lock)
|
|||||||
{
|
{
|
||||||
int r = pthread_mutex_init(lock, 0);
|
int r = pthread_mutex_init(lock, 0);
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
rb_bug("native_mutex_initialize return non-zero: %d", r);
|
rb_bug("pthread_mutex_init: %s (%s)", strerror(r), rb_strerrno(r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ native_mutex_destroy(pthread_mutex_t *lock)
|
|||||||
{
|
{
|
||||||
int r = pthread_mutex_destroy(lock);
|
int r = pthread_mutex_destroy(lock);
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
rb_bug("native_mutex_destroy return non-zero: %d", r);
|
rb_bug("pthread_mutex_destroy: %s (%s)", strerror(r), rb_strerrno(r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ native_cond_initialize(pthread_cond_t *cond)
|
|||||||
{
|
{
|
||||||
int r = pthread_cond_init(cond, 0);
|
int r = pthread_cond_init(cond, 0);
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
rb_bug("native_cond_initialize return non-zero: %d", r);
|
rb_bug("pthread_cond_init: %s (%s)", strerror(r), rb_strerrno(r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ native_cond_destroy(pthread_cond_t *cond)
|
|||||||
{
|
{
|
||||||
int r = pthread_cond_destroy(cond);
|
int r = pthread_cond_destroy(cond);
|
||||||
if (r != 0) {
|
if (r != 0) {
|
||||||
rb_bug("native_cond_destroy return non-zero: %d", r);
|
rb_bug("pthread_cond_destroy: %s (%s)", strerror(r), rb_strerrno(r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ ruby_init_stack(volatile VALUE *addr
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_ERR(expr) \
|
#define CHECK_ERR(expr) \
|
||||||
{int err = (expr); if (err) {rb_bug("err: %d - %s", err, #expr);}}
|
{int err = (expr); if (err) {rb_bug("%s: %s (%s)", #expr, strerror(err), rb_strerrno(err));}}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
native_thread_init_stack(rb_thread_t *th)
|
native_thread_init_stack(rb_thread_t *th)
|
||||||
@ -621,7 +621,7 @@ native_sleep(rb_thread_t *th, struct timeval *tv)
|
|||||||
thread_debug("native_sleep: pthread_cond_wait start\n");
|
thread_debug("native_sleep: pthread_cond_wait start\n");
|
||||||
r = pthread_cond_wait(&th->native_thread_data.sleep_cond,
|
r = pthread_cond_wait(&th->native_thread_data.sleep_cond,
|
||||||
&th->interrupt_lock);
|
&th->interrupt_lock);
|
||||||
if (r) rb_bug("pthread_cond_wait: %d", r);
|
if (r) rb_bug("pthread_cond_wait: %s (%s)", strerror(r), rb_strerrno(r));
|
||||||
thread_debug("native_sleep: pthread_cond_wait end\n");
|
thread_debug("native_sleep: pthread_cond_wait end\n");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -630,7 +630,7 @@ native_sleep(rb_thread_t *th, struct timeval *tv)
|
|||||||
(unsigned long)ts.tv_sec, ts.tv_nsec);
|
(unsigned long)ts.tv_sec, ts.tv_nsec);
|
||||||
r = pthread_cond_timedwait(&th->native_thread_data.sleep_cond,
|
r = pthread_cond_timedwait(&th->native_thread_data.sleep_cond,
|
||||||
&th->interrupt_lock, &ts);
|
&th->interrupt_lock, &ts);
|
||||||
if (r && r != ETIMEDOUT) rb_bug("pthread_cond_timedwait: %d", r);
|
if (r && r != ETIMEDOUT) rb_bug("pthread_cond_timedwait: %s (%s)", strerror(r), rb_strerrno(r));
|
||||||
|
|
||||||
thread_debug("native_sleep: pthread_cond_timedwait end (%d)\n", r);
|
thread_debug("native_sleep: pthread_cond_timedwait end (%d)\n", r);
|
||||||
}
|
}
|
||||||
@ -763,7 +763,7 @@ thread_timer(void *dummy)
|
|||||||
else if (err == 0 || err == EINTR) {
|
else if (err == 0 || err == EINTR) {
|
||||||
if (rb_signal_buff_size() == 0) break;
|
if (rb_signal_buff_size() == 0) break;
|
||||||
}
|
}
|
||||||
else rb_bug("thread_timer/timedwait: %d", err);
|
else rb_bug("thread_timer/timedwait: %s (%s)", strerror(err), rb_strerrno(err));
|
||||||
|
|
||||||
#if !defined(__CYGWIN__) && !defined(__SYMBIAN32__)
|
#if !defined(__CYGWIN__) && !defined(__SYMBIAN32__)
|
||||||
if (signal_thread_list_anchor.next) {
|
if (signal_thread_list_anchor.next) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user