From 95e295c418527555f8000f87f0d0e5eafdb9f40d Mon Sep 17 00:00:00 2001 From: Misty De Meo Date: Wed, 5 Feb 2014 22:32:58 -0800 Subject: [PATCH] ruby: fix build on < 10.6 --- Formula/ruby.rb | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Formula/ruby.rb b/Formula/ruby.rb index dbd44e5c2734c..cc5b800ab78cc 100644 --- a/Formula/ruby.rb +++ b/Formula/ruby.rb @@ -28,6 +28,10 @@ class Ruby < Formula build 2326 end + # pthread_setname_np() is unavailable before Snow Leopard + # Reported upstream: https://bugs.ruby-lang.org/issues/9492 + def patches; DATA; end if MacOS.version < :snow_leopard + def install system "autoconf" if build.head? @@ -76,3 +80,36 @@ def caveats; <<-EOS.undent EOS end end + +__END__ +diff --git a/thread_pthread.c b/thread_pthread.c +index 3911f8f..74d1ab7 100644 +--- a/thread_pthread.c ++++ b/thread_pthread.c +@@ -1416,15 +1416,6 @@ timer_thread_sleep(rb_global_vm_lock_t* unused) + } + #endif /* USE_SLEEPY_TIMER_THREAD */ + +-#if defined(__linux__) && defined(PR_SET_NAME) +-# define SET_THREAD_NAME(name) prctl(PR_SET_NAME, name) +-#elif defined(__APPLE__) +-/* pthread_setname_np() on Darwin does not have target thread argument */ +-# define SET_THREAD_NAME(name) pthread_setname_np(name) +-#else +-# define SET_THREAD_NAME(name) (void)0 +-#endif +- + static void * + thread_timer(void *p) + { +@@ -1432,7 +1423,9 @@ thread_timer(void *p) + + if (TT_DEBUG) WRITE_CONST(2, "start timer thread\n"); + +- SET_THREAD_NAME("ruby-timer-thr"); ++#if defined(__linux__) && defined(PR_SET_NAME) ++ prctl(PR_SET_NAME, "ruby-timer-thr"); ++#endif + + #if !USE_SLEEPY_TIMER_THREAD + native_mutex_initialize(&timer_thread_lock);