Skip to content

Commit

Permalink
The rb_nativethread_lock functions need to be inlined as they take a …
Browse files Browse the repository at this point in the history
…pointer to a Ruby object variable
  • Loading branch information
chrisseaton committed Mar 30, 2017
1 parent b74c5ba commit e5bdde9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
28 changes: 24 additions & 4 deletions lib/cext/ruby.h
Original file line number Diff line number Diff line change
Expand Up @@ -1008,10 +1008,10 @@ typedef void *rb_nativethread_id_t;
typedef void *rb_nativethread_lock_t;

rb_nativethread_id_t rb_nativethread_self();
int rb_nativethread_lock_initialize(rb_nativethread_lock_t *lock);
int rb_nativethread_lock_destroy(rb_nativethread_lock_t *lock);
int rb_nativethread_lock_lock(rb_nativethread_lock_t *lock);
int rb_nativethread_lock_unlock(rb_nativethread_lock_t *lock);
MUST_INLINE int rb_nativethread_lock_initialize(rb_nativethread_lock_t *lock);
MUST_INLINE int rb_nativethread_lock_destroy(rb_nativethread_lock_t *lock);
MUST_INLINE int rb_nativethread_lock_lock(rb_nativethread_lock_t *lock);
MUST_INLINE int rb_nativethread_lock_unlock(rb_nativethread_lock_t *lock);

// IO

Expand Down Expand Up @@ -1149,6 +1149,26 @@ VALUE *rb_ruby_debug_ptr(void);

// Inline implementations

MUST_INLINE int rb_nativethread_lock_initialize(rb_nativethread_lock_t *lock) {
*lock = truffle_invoke(RUBY_CEXT, "rb_nativethread_lock_initialize");
return 0;
}

MUST_INLINE int rb_nativethread_lock_destroy(rb_nativethread_lock_t *lock) {
*lock = NULL;
return 0;
}

MUST_INLINE int rb_nativethread_lock_lock(rb_nativethread_lock_t *lock) {
truffle_invoke(*lock, "lock");
return 0;
}

MUST_INLINE int rb_nativethread_lock_unlock(rb_nativethread_lock_t *lock) {
truffle_invoke(*lock, "unlock");
return 0;
}

MUST_INLINE int rb_range_values(VALUE range, VALUE *begp, VALUE *endp, int *exclp) {
if (rb_obj_is_kind_of(range, rb_cRange)) {
*begp = (VALUE) truffle_invoke(range, "begin");
Expand Down
20 changes: 0 additions & 20 deletions truffleruby/src/main/c/cext/ruby.c
Original file line number Diff line number Diff line change
Expand Up @@ -2232,26 +2232,6 @@ rb_nativethread_id_t rb_nativethread_self() {
return (VALUE) truffle_invoke(RUBY_CEXT, "rb_nativethread_self");
}

int rb_nativethread_lock_initialize(rb_nativethread_lock_t *lock) {
*lock = truffle_invoke(RUBY_CEXT, "rb_nativethread_lock_initialize");
return 0;
}

int rb_nativethread_lock_destroy(rb_nativethread_lock_t *lock) {
*lock = NULL;
return 0;
}

int rb_nativethread_lock_lock(rb_nativethread_lock_t *lock) {
truffle_invoke(lock, "lock");
return 0;
}

int rb_nativethread_lock_unlock(rb_nativethread_lock_t *lock) {
truffle_invoke(lock, "unlock");
return 0;
}

// IO

void rb_io_check_writable(rb_io_t *io) {
Expand Down

0 comments on commit e5bdde9

Please sign in to comment.