Remove dependency on fiddle from test/ruby

Co-authored-by: "Nobuyoshi Nakada" <nobu@ruby-lang.org>
This commit is contained in:
Hiroshi SHIBATA 2024-06-04 17:53:49 +09:00
parent 8ff5458c2e
commit 892849ac98
3 changed files with 27 additions and 7 deletions

View file

@ -0,0 +1,3 @@
if have_func("gettid")
create_makefile("-test-/thread/id")
end

15
ext/-test-/thread/id/id.c Normal file
View file

@ -0,0 +1,15 @@
#include <ruby.h>
static VALUE
bug_gettid(VALUE self)
{
pid_t tid = gettid();
return PIDT2NUM(tid);
}
void
Init_id(void)
{
VALUE klass = rb_define_module_under(rb_define_module("Bug"), "ThreadID");
rb_define_module_function(klass, "gettid", bug_gettid, 0);
}