Skip to content

Commit

Permalink
Minor fixes for rbx compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Oct 19, 2009
1 parent 37bf73d commit 945eb1c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ext/em.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,19 @@ See the file COPYING for complete licensing information.
#include <ruby.h>
#define EmSelect rb_thread_select

#ifdef HAVE_RBTRAP
#if defined(HAVE_RBTRAP)
#include <rubysig.h>
#else
#elif defined(HAVE_RB_THREAD_CHECK_INTS)
extern "C" {
void rb_enable_interrupt(void);
void rb_disable_interrupt(void);
}

#define TRAP_BEG rb_enable_interrupt()
#define TRAP_END do { rb_disable_interrupt(); rb_thread_check_ints(); } while(0)
#else
#define TRAP_BEG
#define TRAP_END
#endif

// 1.9.0 compat
Expand Down
2 changes: 2 additions & 0 deletions ext/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def add_define(name)
add_define "HAVE_INOTIFY" if inotify = have_func('inotify_init', 'sys/inotify.h')
add_define "HAVE_OLD_INOTIFY" if !inotify && have_macro('__NR_inotify_init', 'sys/syscall.h')
add_define 'HAVE_WRITEV' if have_func('writev', 'sys/uio.h')
have_func('rb_thread_check_ints')
have_func('rb_time_new')

# Minor platform details between *nix and Windows:

Expand Down
9 changes: 9 additions & 0 deletions ext/rubymain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,8 +967,17 @@ t_get_loop_time

static VALUE t_get_loop_time (VALUE self)
{
#ifndef HAVE_RB_TIME_NEW
static VALUE cTime = rb_path2class("Time");
static ID at = rb_intern("at");
#endif

if (gCurrentLoopTime != 0) {
#ifndef HAVE_RB_TIME_NEW
return rb_funcall(cTime, at, 2, INT2NUM(gCurrentLoopTime / 1000000), INT2NUM(gCurrentLoopTime % 1000000));
#else
return rb_time_new(gCurrentLoopTime / 1000000, gCurrentLoopTime % 1000000);
#endif
}
return Qnil;
}
Expand Down

0 comments on commit 945eb1c

Please sign in to comment.