ruby/template/extinit.c.tmpl
Hiroshi SHIBATA 0a67190735 merge revision(s) 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.
	---
	 ext/extmk.rb            | 16 +++++++++++++++-
	 template/extinit.c.tmpl |  2 +-
	 2 files changed, 16 insertions(+), 2 deletions(-)
2024-05-23 14:12:53 +09:00

17 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
}