title: Ruby Global Interpreter Lock (GIL) - rb_thread_call_without_gvl
body: <p>I am struggling to pass arguments to <code>rb_thread_call_without_gvl</code>. This is the simple code I am using.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;ruby.h&gt;
  #include &lt;ruby/thread.h&gt;
  
  VALUE summa(VALUE self, VALUE x)
  {
      double result;
      result = NUM2DBL(x) + NUM2DBL(x);
  
      printf("The sum in C is %f\n", result);
      return DBL2NUM(result);
  }
  
  
  VALUE no_gvl(VALUE self)
  {
      double arg = 3.0;
      double *ptr = &amp;arg;
      rb_thread_call_without_gvl(summa, ptr, NULL, NULL);
      return Qnil;
  }
  
  void Init_csum()
  {
      VALUE myModule = rb_define_module("MyModule");
      VALUE myClass = rb_define_class_under(myModule, "MyClass", rb_cObject);
      rb_define_method(myClass, "summa", summa, 1);
      rb_define_method(myClass, "no_gvl", no_gvl, 0);
  }
  </code></pre>
  
  <p>I then try to call the extension from Ruby with the script <code>client.rb</code>:</p>
  
  <pre><code>require './csum'
  obj = MyModule::MyClass.new # MyClass is defined in C
  puts "The sum in R is " + obj.summa(7.0).to_s
  puts obj.no_gvl
  </code></pre>
  
  <p>And finally my <code>extconf.rb</code>:</p>
  
  <pre><code>require 'mkmf'
  extension_name = 'csum'
  create_makefile(extension_name)
  </code></pre>
  
  <p>I am a beginner in C, but I need to create an extension that can use a library without the limitation of one single thread. See my <a href="https://stackoverflow.com/questions/37019643/ruby-fiddle-and-global-interpreter-lock-gil">other question</a>.</p>
  
  <p>When I <code>make</code> the extension I receive a warning saying</p>
  
  <pre><code>warning: incompatible pointer types passing 'VALUE (VALUE, VALUE)' to parameter of type 'void *(*)(void *)'
  </code></pre>
  
  <p>Although I understand what it says, I cannot see how to fix it. Should I just ignore it?
  Also when I run <code>client.rb</code> I have a segmentation fault when it calls <code>obj.no_gvl</code>.</p>
  
  <p>I am on Mac OSX 10.10.5 and I am using Ruby 2.0.0-p247 through <code>rbenv</code>.</p>