ruby-changes:6455
From: nobu <ko1@a...>
Date: Wed, 9 Jul 2008 20:19:08 +0900 (JST)
Subject: [ruby-changes:6455] Ruby:r17971 (trunk): * configure.in (rb_cv_va_args_macro): check for __VA_ARGS__.
nobu 2008-07-09 20:18:52 +0900 (Wed, 09 Jul 2008) New Revision: 17971 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=17971 Log: * configure.in (rb_cv_va_args_macro): check for __VA_ARGS__. * thread.c (thread_debug): show source name and line if possible. Modified files: trunk/ChangeLog trunk/configure.in trunk/thread.c Index: configure.in =================================================================== --- configure.in (revision 17970) +++ configure.in (revision 17971) @@ -395,6 +395,15 @@ AC_DEFINE(HAVE_STDARG_PROTOTYPES) fi +AC_CACHE_CHECK(for variable length macro, rb_cv_va_args_macro, + [AC_TRY_COMPILE([@%:@define FOO(a, ...) foo(a, @%:@@%:@__VA_ARGS__)], + [FOO(1);FOO(1,2);FOO(1,2,3);], + rb_cv_va_args_macro=yes, + rb_cv_va_args_macro=no)]) +if test "$rb_cv_va_args_macro" = yes; then + AC_DEFINE(HAVE_VA_ARGS_MACRO) +fi + AC_DEFUN([RUBY_FUNC_ATTRIBUTE], [dnl m4_ifval([$2], dnl [AS_VAR_PUSHDEF([attrib],[$2])], dnl Index: ChangeLog =================================================================== --- ChangeLog (revision 17970) +++ ChangeLog (revision 17971) @@ -1,5 +1,9 @@ -Wed Jul 9 18:17:06 2008 Nobuyoshi Nakada <nobu@r...> +Wed Jul 9 20:18:50 2008 Nobuyoshi Nakada <nobu@r...> + * configure.in (rb_cv_va_args_macro): check for __VA_ARGS__. + + * thread.c (thread_debug): show source name and line if possible. + * thread_{pthread,win32}.c (rb_thread_create_timer_thread): needs more stack for debug. Index: thread.c =================================================================== --- thread.c (revision 17970) +++ thread.c (revision 17971) @@ -121,7 +121,17 @@ } while(0) #if THREAD_DEBUG +#ifdef HAVE_VA_ARGS_MACRO +void rb_thread_debug(const char *file, int line, const char *fmt, ...); +#define thread_debug(fmt, ...) rb_thread_debug(__FILE__, __LINE__, fmt, ##__VA_ARGS__) +#define POSITION_FORMAT "%s:%d:" +#define POSITION_ARGS ,file, line +#else void rb_thread_debug(const char *fmt, ...); +#define thread_debug rb_thread_debug +#define POSITION_FORMAT +#define POSITION_ARGS +#endif # if THREAD_DEBUG < 0 static int rb_thread_debug_enabled; @@ -141,7 +151,6 @@ # else # define rb_thread_debug_enabled THREAD_DEBUG # endif -#define thread_debug rb_thread_debug #else #define thread_debug if(0)printf #endif @@ -158,7 +167,7 @@ #define DEBUG_OUT() \ WaitForSingleObject(&debug_mutex, INFINITE); \ - printf("%p - %s", GetCurrentThreadId(), buf); \ + printf(POSITION_FORMAT"%p - %s" POSITION_ARGS, GetCurrentThreadId(), buf); \ fflush(stdout); \ ReleaseMutex(&debug_mutex); @@ -167,7 +176,7 @@ #define DEBUG_OUT() \ pthread_mutex_lock(&debug_mutex); \ - printf("%#"PRIxVALUE" - %s", (VALUE)pthread_self(), buf); \ + printf(POSITION_FORMAT"%#"PRIxVALUE" - %s" POSITION_ARGS, (VALUE)pthread_self(), buf); \ fflush(stdout); \ pthread_mutex_unlock(&debug_mutex); @@ -180,7 +189,11 @@ static rb_thread_lock_t debug_mutex; void -rb_thread_debug(const char *fmt, ...) +rb_thread_debug( +#ifdef HAVE_VA_ARGS_MACRO + const char *file, int line, +#endif + const char *fmt, ...) { va_list args; char buf[BUFSIZ]; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/