diff options
author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-05-17 02:48:59 +0000 |
---|---|---|
committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-05-17 02:48:59 +0000 |
commit | 76bc2d1ed7f13fb329c33f48756ea3c24c59a6ea (patch) | |
tree | 3ec93c5eb45d0bc6e6eb53d2efebd2f8c0c8ee3d /thread_pthread.c | |
parent | 0a7aada5d18441b437f5e406a991d963b3613d9a (diff) | |
download | ruby-76bc2d1ed7f13fb329c33f48756ea3c24c59a6ea.tar.gz |
Imports Ruby's port to NativeClient (a.k.a NaCl).
Patch by Google Inc. [ruby-core:45073].
* configure.in (RUBY_NACL): New M4 func to configure variables for
NaCl.
(RUBY_NACL_CHECK_PEPPER_TYPES): New M4 func to check the old names
of Pepper interface types.
(BTESTRUBY): New variable to specify which ruby should be run on
"make btest". NaCl can run the built binary by sel_ldr, but it need
rbconfig.rb. So this variable is distinguished from $MINIRUBY.
* thread_pthread.c: Disabled some features on NaCl.
* io.c: ditto.
* process.c: ditto.
* signal.c: ditto.
* file.c: ditto.
* missing/flock.c: ditto.
* nacl/pepper_main.c: An example implementation of Pepper application
that embeds Ruby.
* nacl/example.html: An example of web page that uses the Pepper
application.
* nacl/nacl-config.rb: Detects variants of NaCl SDK.
* nacl/GNUmakefile.in: Makefile template for NaCl specific build
process.
* nacl/package.rb: script for packaging a NaCl-Ruby embedding
application.
* nacl/reate_nmf.rb: Wrapper script of create_nmf.py
* dln.c (dln_load): Added a hack to call on NaCl.
* util.c (ruby_getcwd): Path to the current directort is not available
on NaCl.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r-- | thread_pthread.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/thread_pthread.c b/thread_pthread.c index de8325e087..61b93e1edf 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -27,6 +27,9 @@ #if HAVE_SYS_PRCTL_H #include <sys/prctl.h> #endif +#if defined(__native_client__) && defined(NACL_NEWLIB) +# include "nacl/select.h" +#endif static void native_mutex_lock(pthread_mutex_t *lock); static void native_mutex_unlock(pthread_mutex_t *lock); @@ -137,9 +140,11 @@ static void gvl_init(rb_vm_t *vm) { native_mutex_initialize(&vm->gvl.lock); +#ifdef HAVE_PTHREAD_CONDATTR_INIT native_cond_initialize(&vm->gvl.cond, RB_CONDATTR_CLOCK_MONOTONIC); native_cond_initialize(&vm->gvl.switch_cond, RB_CONDATTR_CLOCK_MONOTONIC); native_cond_initialize(&vm->gvl.switch_wait_cond, RB_CONDATTR_CLOCK_MONOTONIC); +#endif vm->gvl.acquired = 0; vm->gvl.waiting = 0; vm->gvl.need_yield = 0; @@ -148,9 +153,11 @@ gvl_init(rb_vm_t *vm) static void gvl_destroy(rb_vm_t *vm) { +#ifdef HAVE_PTHREAD_CONDATTR_INIT native_cond_destroy(&vm->gvl.switch_wait_cond); native_cond_destroy(&vm->gvl.switch_cond); native_cond_destroy(&vm->gvl.cond); +#endif native_mutex_destroy(&vm->gvl.lock); } @@ -232,6 +239,9 @@ native_mutex_destroy(pthread_mutex_t *lock) } } +#ifdef HAVE_PTHREAD_CONDATTR_INIT +int pthread_condattr_init(pthread_condattr_t *attr); + static void native_cond_initialize(rb_thread_cond_t *cond, int flags) { @@ -266,6 +276,7 @@ native_cond_destroy(rb_thread_cond_t *cond) rb_bug_errno("pthread_cond_destroy", r); } } +#endif /* * In OS X 10.7 (Lion), pthread_cond_signal and pthread_cond_broadcast return @@ -439,20 +450,26 @@ Init_native_thread(void) #ifdef USE_SIGNAL_THREAD_LIST native_mutex_initialize(&signal_thread_list_lock); #endif +#ifndef __native_client__ posix_signal(SIGVTALRM, null_func); +#endif } static void native_thread_init(rb_thread_t *th) { +#ifdef HAVE_PTHREAD_CONDATTR_INIT native_cond_initialize(&th->native_thread_data.sleep_cond, RB_CONDATTR_CLOCK_MONOTONIC); +#endif ruby_thread_set_native(th); } static void native_thread_destroy(rb_thread_t *th) { +#ifdef HAVE_PTHREAD_CONDATTR_INIT native_cond_destroy(&th->native_thread_data.sleep_cond); +#endif } #define USE_THREAD_CACHE 0 @@ -1197,6 +1214,7 @@ thread_timer(void *p) static void rb_thread_create_timer_thread(void) { +#ifndef __native_client__ if (!timer_thread_id) { pthread_attr_t attr; int err; @@ -1256,6 +1274,7 @@ rb_thread_create_timer_thread(void) } pthread_attr_destroy(&attr); } +#endif } static int |