ruby/template/extinit.c.tmpl
Nobuyoshi Nakada ae8990aef0
Alias init functions
The extension library has each initialization function named "Init_" +
basename. If multiple extensions have the same base name (such as
cgi/escape and erb/escape), the same function will be registered for
both names.

To fix this conflict, rename the initialization functions under sub
directories using using parent names, when statically linking.
2024-02-04 16:43:09 +09:00

18 lines
336 B
C

%# -*- C -*-
% extinits = ARGV.map {|n| [n.tr('/', '_'), n]}
#include "ruby/ruby.h"
#define init(func, name) { \
extern void func(void); \
ruby_init_ext(name".so", func); \
}
void ruby_init_ext(const char *name, void (*init)(void));
void Init_ext(void)
{
% extinits.each do |f, n|
init(Init_<%=f%>, <%=n.dump%>);
% end
}