Hugo Frappier | 18 Apr 2013 22:01
Favicon
Gravatar

Cross-platform C code packaged in a gem

Was anyone able to package cross-platform C code in a gem and loading
it with FFI?

I'm having a hard time compiling and linking the code (especially on
Windows) using extconf.rb.  I looked at all the github FFI projects
(the one listed on the Wiki) and none of them seems to be doing
something similar.

Thanks

--

-- 

--- 
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe@...
For more options, visit https://groups.google.com/groups/opt_out.

Kim Burgestrand | 28 Mar 2013 19:34
Picon
Favicon
Gravatar

I wrote on advanced FFI usage

Might be interesting to you since you are subscribed to the FFI mailing list. The article is here: http://www.elabs.se/blog/61-advanced-topics-in-ruby-ffi


If you have any reactions to what I've written I'd love to hear them.



--
— Kim Burgestrand

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Maurizio De Santis | 26 Mar 2013 01:23
Picon
Gravatar

AutoPointer on an array of structs corrupts the structs values

Hello,

I have an issue using FFI::AutoPointer on an array of structs.

This is the C function declaration:

glibtop_map_entry * glibtop_get_proc_map (glibtop_proc_map *buf, pid_t pid);

The returned value is an array of glibtop_map_entry structs should be freed using g_free .

If I declare the pointer to the array of structs entries using FFI::Pointer, everything works fine, and the output of the structs is correct:


s = GTop::ProcessMemoryMaps.new
addr = GTop.process_memory_maps(s, Process.pid)
ss_pointer = FFI::Pointer.new(GTop::MemoryMapEntry, addr)
s[:number].times do |i|
  ssi = GTop::MemoryMapEntry.new(ss_pointer[i])
  p Hash[ ssi.members.map { |m| [ m, ssi[m].is_a?(FFI::StructLayout::CharArray) ? ssi[m].to_s.force_encoding('UTF-8') : ssi[m] ] } ]
end
GTop::GLib.g_free ss_pointer



This is a part the ouput:


{:flags=>8191, :start=>140496509870080, :end=>140496510115840, :offset=>0, :perm=>21, :inode=>2494196, :device=>2054, :size=>245760, :rss=>8192, :shared_clean=>8192, :shared_dirty=>0, :private_clean=>0, :private_dirty=>0, :filename=>"/lib/x86_64-linux-gnu/libpcre.so.3.13.1"}
{:flags=>8191, :start=>140496510115840, :end=>140496512208896, :offset=>245760, :perm=>16, :inode=>2494196, :device=>2054, :size=>2093056, :rss=>0, :shared_clean=>0, :shared_dirty=>0, :private_clean=>0, :private_dirty=>0, :filename=>"/lib/x86_64-linux-gnu/libpcre.so.3.13.1"}
{:flags=>8191, :start=>140496512208896, :end=>140496512212992, :offset=>241664, :perm=>17, :inode=>2494196, :device=>2054, :size=>4096, :rss=>4096, :shared_clean=>0, :shared_dirty=>0, :private_clean=>0, :private_dirty=>4096, :filename=>"/lib/x86_64-linux-gnu/libpcre.so.3.13.1"}
[...]
{:flags=>8191, :start=>140496599904256, :end=>140496620888064, :offset=>0, :perm=>19, :inode=>0, :device=>0, :size=>20983808, :rss=>20844544, :shared_clean=>0, :shared_dirty=>0, :private_clean=>0, :private_dirty=>20844544, :filename=>"[heap]"}
{:flags=>8191, :start=>140737331818496, :end=>140737331953664, :offset=>0, :perm=>19, :inode=>0, :device=>0, :size=>139264, :rss=>49152, :shared_clean=>0, :shared_dirty=>0, :private_clean=>0, :private_dirty=>49152, :filename=>"[stack]"}
{:flags=>8191, :start=>140737332150272, :end=>140737332154368, :offset=>0, :perm=>21, :inode=>0, :device=>0, :size=>4096, :rss=>4096, :shared_clean=>4096, :shared_dirty=>0, :private_clean=>0, :private_dirty=>0, :filename=>"[vdso]"}
{:flags=>8191, :start=>18446744073699065856, :end=>18446744073699069952, :offset=>0, :perm=>21, :inode=>0, :device=>0, :size=>4096, :rss=>0, :shared_clean=>0, :shared_dirty=>0, :private_clean=>0, :private_dirty=>0, :filename=>"[vsyscall]"}



However, when I use FFI::AutoPointer:


s = GTop::ProcessMemoryMaps.new
addr = GTop.process_memory_maps(s, Process.pid)
pre_ss_pointer = FFI::Pointer.new(GTop::MemoryMapEntry, addr)
ss_pointer = FFI::AutoPointer.new pre_ss_pointer, GTop::GLib.method(:g_free)
s[:number].times do |i|
  ssi = GTop::MemoryMapEntry.new(ss_pointer[i])
  p Hash[ ssi.members.map { |m| [ m, ssi[m].is_a?(FFI::StructLayout::CharArray) ? ssi[m].to_s.force_encoding('UTF-8') : ssi[m] ] } ]
end



the output is corrupted:


{:flags=>8191, :start=>140185021132800, :end=>140185021378560, :offset=>0, :perm=>21, :inode=>2494196, :device=>2054, :size=>245760, :rss=>8192, :shared_clean=>8192, :shared_dirty=>0, :private_clean=>0, :private_dirty=>0, :filename=>"/lib/x86_64-linux-gnu/libpcre.so.3.13.1"}
{:flags=>31, :start=>547597738800, :end=>547597739760, :offset=>1513209474796486656, :perm=>17582052945254416384, :inode=>432345564227577358, :device=>8, :size=>960, :rss=>32, :shared_clean=>32, :shared_dirty=>0, :private_clean=>0, :private_dirty=>3386706919782612992, :filename=>"lib/x86_64-linux-gnu/libpcre.so.3.13.1"}
[...]
{:flags=>0, :start=>1376256, :end=>163459629056, :offset=>134610944, :perm=>16106127360, :inode=>536870912, :device=>536870912, :size=>0, :rss=>0, :shared_clean=>0, :shared_dirty=>8660248813382860800, :private_clean=>7596496373740942904, :private_dirty=>3419760881481315694, :filename=>"libpcre.so.3.13.1"}
{:flags=>0, :start=>5376, :end=>638514176, :offset=>525824, :perm=>62914560, :inode=>2097152, :device=>2097152, :size=>0, :rss=>0, :shared_clean=>0, :shared_dirty=>4069054363051241216, :private_clean=>7956009158131998518, :private_dirty=>7795578597039503477, :filename=>"ibpcre.so.3.13.1"}
{:flags=>0, :start=>21, :end=>2494196, :offset=>2054, :perm=>245760, :inode=>8192, :device=>8192, :size=>0, :rss=>0, :shared_clean=>0, :shared_dirty=>3907004821653777455, :private_clean=>8461816663211521631, :private_dirty=>7596498852877118840, :filename=>"bpcre.so.3.13.1"}
[...]
{:flags=>3543826231318490725, :start=>3223091, :end=>0, :offset=>0, :perm=>0, :inode=>0, :device=>0, :size=>0, :rss=>0, :shared_clean=>0, :shared_dirty=>0, :private_clean=>0, :private_dirty=>0, :filename=>""}
{:flags=>3688780367150412590, :start=>12590, :end=>0, :offset=>0, :perm=>0, :inode=>0, :device=>0, :size=>0, :rss=>0, :shared_clean=>0, :shared_dirty=>0, :private_clean=>0, :private_dirty=>0, :filename=>""}
{:flags=>3329058624053866355, :start=>49, :end=>0, :offset=>0, :perm=>0, :inode=>0, :device=>0, :size=>0, :rss=>0, :shared_clean=>0, :shared_dirty=>0, :private_clean=>0, :private_dirty=>0, :filename=>""}
{:flags=>3543826243108679279, :start=>0, :end=>0, :offset=>0, :perm=>0, :inode=>0, :device=>0, :size=>0, :rss=>0, :shared_clean=>0, :shared_dirty=>0, :private_clean=>0, :private_dirty=>0, :filename=>""}
{:flags=>13843071262143278, :start=>0, :end=>0, :offset=>0, :perm=>0, :inode=>0, :device=>0, :size=>0, :rss=>0, :shared_clean=>0, :shared_dirty=>0, :private_clean=>0, :private_dirty=>0, :filename=>""}
{:flags=>54074497117747, :start=>0, :end=>0, :offset=>0, :perm=>0, :inode=>0, :device=>0, :size=>0, :rss=>0, :shared_clean=>0, :shared_dirty=>0, :private_clean=>0, :private_dirty=>0, :filename=>""}
{:flags=>211228504366, :start=>0, :end=>0, :offset=>0, :perm=>0, :inode=>0, :device=>0, :size=>0, :rss=>0, :shared_clean=>0, :shared_dirty=>0, :private_clean=>0, :private_dirty=>0, :filename=>""}
{:flags=>825111345, :start=>0, :end=>0, :offset=>0, :perm=>0, :inode=>0, :device=>0, :size=>0, :rss=>0, :shared_clean=>0, :shared_dirty=>0, :private_clean=>0, :private_dirty=>0, :filename=>""}
{:flags=>3223091, :start=>0, :end=>0, :offset=>0, :perm=>0, :inode=>0, :device=>0, :size=>0, :rss=>0, :shared_clean=>0, :shared_dirty=>0, :private_clean=>0, :private_dirty=>0, :filename=>""}
{:flags=>12590, :start=>0, :end=>0, :offset=>0, :perm=>0, :inode=>0, :device=>0, :size=>0, :rss=>0, :shared_clean=>0, :shared_dirty=>0, :private_clean=>0, :private_dirty=>0, :filename=>""}


As you can see, the struct values "get chewed" from entry to entry.

Is it a known issue?

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Kim Burgestrand | 21 Mar 2013 08:47
Picon
Favicon
Gravatar

Wiki list of projects using FFI

See here: https://github.com/ffi/ffi/wiki/Projects-Using-FFI


The libspotify-ruby project has moved to https://github.com/Burgestrand/spotify and is now just called `spotify`. Still heavily using FFI.

I’d update the list myself, but it appears to be closed from modification from non-collaborators.

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Jon | 4 Mar 2013 20:12
Picon
Gravatar

XNI and FFI summary?

Hi Wayne,

I recently cloned the XNI repo but haven't done much more than spelunking why the download took a bit

  PS xni-git> du .\jruby-ext -B mb
  .\jruby-ext: 19.17 MiB

and discovering that XNI leverages FFI.

When you get a free moment, please provide a quick summary of:

  * XNI's main reason(s) for being
  * when should one prefer XNI over FFI?
  * will XNI always utilize FFI?

Thanks.

Jon

---
Fail fast. Fail often. Fail publicly. Learn. Adapt. Repeat.
http://thecodeshop.github.com | http://jonforums.github.com/
twitter:  <at> jonforums

--

-- 

--- 
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe@...
For more options, visit https://groups.google.com/groups/opt_out.

Maurizio De Santis | 3 Mar 2013 03:06
Picon
Gravatar

Passing a struct by value, and typedef

I am writing a libgtop2 wrapper using ffi in order to learn how to use ffi; I am new to ffi, so I have a lot of doubts.

libgtop2 lets get system and processes informations (cpu usage, memory usage, ...).

Here some informations about glibtop_get_cpu:

Library function `glibtop_get_cpu':

     void glibtop_get_cpu (glibtop_cpu *buf);
     void glibtop_get_cpu_l (glibtop *server, glibtop_cpu *buf);

   Declaration of `glibtop_cpu' in `<glibtop/cpu.h>':

     typedef struct _glibtop_cpu     glibtop_cpu;

     struct _glibtop_cpu
     {
         guint64   flags,
             total,
             user,
             nice,
             sys,
             idle,
             iowait,
             irq,
             softirq,
             frequency,
             xcpu_total [GLIBTOP_NCPU],
             xcpu_user [GLIBTOP_NCPU],
             xcpu_nice [GLIBTOP_NCPU],
             xcpu_sys  [GLIBTOP_NCPU],
             xcpu_idle [GLIBTOP_NCPU],
             xcpu_iowait [GLIBTOP_NCPU],
             xcpu_irq [GLIBTOP_NCPU],
             xcpu_softirq [GLIBTOP_NCPU],
             xcpu_flags;
     };

...



Here is what I wrote:

require 'ffi'

class GlibtopCpu < FFI::Struct
  layout :flags,        :guint64,
         :total,        :guint64,
         :user,         :guint64,
         :nice,         :guint64,
         :sys,          :guint64,
         :idle,         :guint64,
         :iowait,       :guint64,
         :irq,          :guint64,
         :softirq,      :guint64,
         :frequency,    :guint64,
         :xcpu_total,   :guint64,
         :xcpu_user,    :guint64,
         :xcpu_nice,    :guint64,
         :xcpu_sys,     :guint64,
         :xcpu_idle,    :guint64,
         :xcpu_iowait,  :guint64,
         :xcpu_irq,     :guint64,
         :xcpu_softirq, :guint64,
         :xcpu_flags,   :guint64
end

module LibGtop
 
  extend FFI::Library
  ffi_lib 'libgtop-2.0'
  attach_function :glibtop_get_cpu, [:pointer], :void

end

# taken from https://github.com/ffi/ffi/wiki/Structs
pointer = FFI::MemoryPointer.new :byte, GlibtopCpu.size, false
a = GlibtopCpu.new pointer
p LibGtop.glibtop_get_cpu(a)


Executing this gives (unsurprisingly) an error:

$ ruby lib/lib_gtop.rb
/home/izietto/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/ffi-1.4.0/lib/ffi/types.rb:57:in `find_type': unable to resolve type 'guint64' (TypeError)
    from /home/izietto/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/ffi-1.4.0/lib/ffi/struct.rb:316:in `find_type'
    from /home/izietto/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/ffi-1.4.0/lib/ffi/struct.rb:309:in `find_field_type'
    from /home/izietto/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/ffi-1.4.0/lib/ffi/struct.rb:351:in `array_layout'
    from /home/izietto/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/ffi-1.4.0/lib/ffi/struct.rb:261:in `layout'
    from lib/lib_gtop.rb:4:in `<class:GlibtopCpu>'
    from lib/lib_gtop.rb:3:in `<main>'


It doesn't find the guint64 type; how should I declare it?

Also: xcpu_total, xcpu_user are arrays... how should I declare them?

Finally... if someone could give me an explanation and an example of how to implement the bind to glibtop_get_cpu, I would appreciate it very much :)

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Maurizio De Santis | 2 Mar 2013 20:02
Picon
Gravatar

[BEGINNER]

Hola!

I am writing a libgtop2 wrapper using ffi in order to learn how to use ffi; I am new to ffi, so I have a lot of doubts :)

libgtop2 lets get system and processes informations (cpu usage, memory usage, ...).

Here some informations about glibtop_get_cpu:

Library function `glibtop_get_cpu':

     void glibtop_get_cpu (glibtop_cpu *buf);
     void glibtop_get_cpu_l (glibtop *server, glibtop_cpu *buf);

   Declaration of `glibtop_cpu' in `<glibtop/cpu.h>':

     typedef struct _glibtop_cpu     glibtop_cpu;

     struct _glibtop_cpu
     {
         guint64   flags,
             total,
             user,
             nice,
             sys,
             idle,
             iowait,
             irq,
             softirq,
             frequency,
             xcpu_total [GLIBTOP_NCPU],
             xcpu_user [GLIBTOP_NCPU],
             xcpu_nice [GLIBTOP_NCPU],
             xcpu_sys  [GLIBTOP_NCPU],
             xcpu_idle [GLIBTOP_NCPU],
             xcpu_iowait [GLIBTOP_NCPU],
             xcpu_irq [GLIBTOP_NCPU],
             xcpu_softirq [GLIBTOP_NCPU],
             xcpu_flags;
     };

...



Here is what I wrote:

require 'ffi'

class GlibtopCpu < FFI::Struct
  layout :flags,        :guint64,
         :total,        :guint64,
         :user,         :guint64,
         :nice,         :guint64,
         :sys,          :guint64,
         :idle,         :guint64,
         :iowait,       :guint64,
         :irq,          :guint64,
         :softirq,      :guint64,
         :frequency,    :guint64,
         :xcpu_total,   :guint64,
         :xcpu_user,    :guint64,
         :xcpu_nice,    :guint64,
         :xcpu_sys,     :guint64,
         :xcpu_idle,    :guint64,
         :xcpu_iowait,  :guint64,
         :xcpu_irq,     :guint64,
         :xcpu_softirq, :guint64,
         :xcpu_flags,   :guint64
end

module LibGtop
 
  extend FFI::Library
  ffi_lib 'libgtop-2.0'
  attach_function :glibtop_get_cpu, [:pointer], :void

end

# taken from https://github.com/ffi/ffi/wiki/Structs
pointer = FFI::MemoryPointer.new :byte, GlibtopCpu.size, false
a = GlibtopCpu.new pointer
p LibGtop.glibtop_get_cpu(a)


Executing this gives (unsurprisingly) an error:

$ ruby lib/lib_gtop.rb
/home/izietto/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/ffi-1.4.0/lib/ffi/types.rb:57:in `find_type': unable to resolve type 'byte' (TypeError)
    from /home/izietto/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/ffi-1.4.0/lib/ffi/types.rb:160:in `type_size'
    from lib/lib_gtop.rb:33:in `initialize'
    from lib/lib_gtop.rb:33:in `new'
    from lib/lib_gtop.rb:33:in `<main>'
izietto <at> shino:~/sys-proc-info$ ruby lib/lib_gtop.rb
/home/izietto/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/ffi-1.4.0/lib/ffi/types.rb:57:in `find_type': unable to resolve type 'guint64' (TypeError)
    from /home/izietto/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/ffi-1.4.0/lib/ffi/struct.rb:316:in `find_type'
    from /home/izietto/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/ffi-1.4.0/lib/ffi/struct.rb:309:in `find_field_type'
    from /home/izietto/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/ffi-1.4.0/lib/ffi/struct.rb:351:in `array_layout'
    from /home/izietto/.rbenv/versions/2.0.0-p0/lib/ruby/gems/2.0.0/gems/ffi-1.4.0/lib/ffi/struct.rb:261:in `layout'
    from lib/lib_gtop.rb:4:in `<class:GlibtopCpu>'
    from lib/lib_gtop.rb:3:in `<main>'


It doesn't find the guint64 type; how should I declare it?

Also: xcpu_total, xcpu_user are arrays... how should I declare them?

Finally... if someone could give me an explanation and an example of how to implement the bind to glibtop_get_cpu, I would appreciate it very much :)

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 
codehacker | 2 Mar 2013 14:51
Picon

Need help to understand FFI 1.4 installation failure

I'm a bit out of my depth here. Any insight would be appreciated.


Installing FFI 1.4 with bundler I see:

** [out :: pa491.railsplayground.net] Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
 ** [out :: pa491.railsplayground.net] 
 ** [out :: pa491.railsplayground.net] /usr/local/bin/ruby extconf.rb
 ** [out :: pa491.railsplayground.net] checking for ffi.h... no
 ** [out :: pa491.railsplayground.net] checking for ffi.h in /usr/local/include,/usr/include/ffi... no
 ** [out :: pa491.railsplayground.net] checking for rb_thread_blocking_region()... yes
 ** [out :: pa491.railsplayground.net] checking for rb_thread_call_with_gvl()... yes
 ** [out :: pa491.railsplayground.net] checking for rb_thread_call_without_gvl()... yes
 ** [out :: pa491.railsplayground.net] checking for ffi_prep_cif_var()... no
 ** [out :: pa491.railsplayground.net] creating extconf.h
 ** [out :: pa491.railsplayground.net] creating Makefile
 ** [out :: pa491.railsplayground.net] 
 ** [out :: pa491.railsplayground.net] make
 ** [out :: pa491.railsplayground.net] make: *** No rule to make target `/include/i686-linux/ruby/config.h', needed by `MemoryPointer.o'.  Stop.

any suggestions for how to proceed would be greatly appreciated

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Ryan Pavlik | 25 Feb 2013 17:41
Picon

[ANN] c2ffi-ruby

For anyone interested, I've recently been working on c2ffi (https://github.com/rpav/c2ffi), which uses Clang to parse C into JSON, and I have just posted c2ffi-ruby, which transforms the JSON into a file for ruby-ffi:

    https://github.com/rpav/c2ffi-ruby

This should produce more accurate input than SWIG.

Apologies for ugly code; this was done as a bit of a test for c2ffi, and I haven't written much ruby in awhile.  Nor has it been extensively tested, but it does parse the included Cairo bindings.

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Kim Burgestrand | 24 Feb 2013 15:24
Picon
Favicon
Gravatar

Possible issues with Ruby FFI on ARM processor (Raspberry PI)

I’ve been having some issues running one of my gems (http://rubygems.org/gems/spotify) successfully on Raspberry PI, using the soft float debian “weezy” OS, downloadable from http://www.raspberrypi.org/downloads on cruby 1.9.3 (ruby 1.9.3p385 (2013-02-06 revision 39114) [armv6l-linux-eabi]).


I’ve been troubleshooting some, and created one example written in C, and one equivalent example written in Ruby using FFI. My suspicion was that they would behave identically, but the ruby code will sometimes segfault on exit, while the C code does not.

Now, I’m not entirely certain that the two examples are completely equivalent, so I’d be grateful for any pair of critical eyes on the two code samples: https://gist.github.com/Burgestrand/7b691591af20c29d6849

My questions are:

1. Are the two (C vs. Ruby) samples really equivalent?
2. Any ideas for further troubleshooting?

— Kim

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Ole Olson | 12 Feb 2013 23:49

Callback Function with varargs

Hi,

I have to use a callback function with varargs (I already red issue #161).
I cannot avoid this because I cannot change the interface of the C Library.

Do you have any idea, how to solve this problem ?

Maybe define va_list as an parameter and split the elements in the implementation of the callback ?

Thanks for help.

--
 
---
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Gmane