Hello,

You can use regular extconf.rb detection mechanisms to check whether
rb_thread_blocking_region is available, so that's definitely the
preferred way to go. You should check how various other projects to
method detection. You can use something very simple like the
following:

have_func('rb_thread_blocking_region')

If you use this in your extconf.rb, you get a Makefile that defines
the appropriate HAVE_RB_THREAD_BLOCKING_REGION define so it will also
work with MRI. Rubinius actually defines
HAVE_RB_THREAD_BLOCKING_REGION manually because it can't be linked as
a shared library, unlike MRI. The shared library linking is used by
extconf for checking whether methods are available.

If you find other methods to be missing in Rubinius, please report an
issue, we want the C-api to be as complete as possible. If you are
able to add specs and the missing method, that would of course be even
more awesome :).

-- 
Regards,

Dirkjan Bussink

On Mon, Sep 27, 2010 at 10:33, ngollan <[email protected]> wrote:
> On Sep 24, 9:42 pm, "Tim Felgentreff" <[email protected]>
> wrote:
>> The availability of rb_thread_blocking_region is announced by a #define 
>> HAVE_RB_THREAD_BLOCKING_REGION. At least on JRuby, supporting the TRAP_X 
>> macros would be a lot of work an it would be nice if pcap could run there, 
>> too, sometime, without forcing ruby version 1.9
>
> MRI 1.9.1 does not seem to define that flag, so that's not a one-stop
> solution either. My local version of the pcap gem now works on rbx, as
> well as 1.8.7 and 1.9.1 with a rather simple preprocessor trick and
> some more version magic in extconf.rbto work around an issue with
> rb_thread_fd_close() which does not exist in rbx, but in 1.9.x and
> 1.8.7. For now I'm just omitting that call where it doesn't exist, as
> that's compliant with the current "/* TODO: fix me */" implementation
> in MRI.
>
> Another nicety is that pcap uses SIZEOF_VOIDP which is not provided in
> rbx, but that looks like a rather icky design decision in pcap to
> ensure IPv4 addresses can be encoded in VALUE.
>
> If you are interested, you can look at the progress so far at
> http://github.com/ngollan/pcap-ruby-apis
>
> I am a total beginner at Ruby C API stuff, so I'm pretty much going
> from error to error until it compiles, and then doesn't break
> horribly. If anything I did is total bogus, please correct me ;-)
>
> --
> --- !ruby/object:MailingList
> name: rubinius-dev
> view: http://groups.google.com/group/rubinius-dev?hl=en
> post: [email protected]
> unsubscribe: [email protected]

-- 
--- !ruby/object:MailingList
name: rubinius-dev
view: http://groups.google.com/group/rubinius-dev?hl=en
post: [email protected]
unsubscribe: [email protected]

Reply via email to