mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/dl/mkcallback.rb: split callback.h to callback-[0-9].c to reduce
memory consumption on compilation. [ruby-dev:31898] * ext/dl/depend: add dependency for callback-[0-9].[co]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c4eb738b74
commit
3deee712f5
4 changed files with 69 additions and 28 deletions
|
@ -1,3 +1,10 @@
|
|||
Sun Aug 31 01:53:31 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/dl/mkcallback.rb: split callback.h to callback-[0-9].c to reduce
|
||||
memory consumption on compilation. [ruby-dev:31898]
|
||||
|
||||
* ext/dl/depend: add dependency for callback-[0-9].[co].
|
||||
|
||||
Sun Aug 31 01:27:46 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/dl/mkcallback.rb (foreach_proc_entry): extracted.
|
||||
|
|
|
@ -6,6 +6,19 @@ handle.o: handle.c dl.h $(hdrdir)/ruby.h
|
|||
|
||||
dl.o: dl.c dl.h callback.h $(hdrdir)/ruby.h $(hdrdir)/io.h
|
||||
|
||||
callback-0.o: callback-0.c $(hdrdir)/ruby.h
|
||||
callback-1.o: callback-1.c $(hdrdir)/ruby.h
|
||||
callback-2.o: callback-2.c $(hdrdir)/ruby.h
|
||||
callback-3.o: callback-3.c $(hdrdir)/ruby.h
|
||||
callback-4.o: callback-4.c $(hdrdir)/ruby.h
|
||||
callback-5.o: callback-5.c $(hdrdir)/ruby.h
|
||||
callback-6.o: callback-6.c $(hdrdir)/ruby.h
|
||||
callback-7.o: callback-7.c $(hdrdir)/ruby.h
|
||||
callback-8.o: callback-8.c $(hdrdir)/ruby.h
|
||||
|
||||
callback-0.c callback-1.c callback-2.c \
|
||||
callback-3.c callback-4.c callback-5.c \
|
||||
callback-6.c callback-7.c callback-8.c \
|
||||
callback.h: $(srcdir)/mkcallback.rb dl.h
|
||||
@echo "generating callback.h"
|
||||
@$(RUBY) $(srcdir)/mkcallback.rb $(srcdir)/dl.h > $@
|
||||
@$(RUBY) $(srcdir)/mkcallback.rb $(srcdir)/dl.h
|
||||
|
|
|
@ -25,6 +25,13 @@ else
|
|||
check = false
|
||||
end
|
||||
|
||||
$objs = %w[
|
||||
cfunc.o dl.o cptr.o handle.o
|
||||
callback-0.o callback-1.o callback-2.o callback-3.o
|
||||
callback-4.o callback-5.o callback-6.o callback-7.o
|
||||
callback-8.o
|
||||
]
|
||||
|
||||
if check
|
||||
$defs << %[-DRUBY_VERSION=\\"#{RUBY_VERSION}\\"]
|
||||
create_makefile("dl")
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
$out ||= $stdout
|
||||
$out = open("callback.h", "w")
|
||||
|
||||
$dl_h = ARGV[0] || "dl.h"
|
||||
|
||||
# import DLSTACK_SIZE, DLSTACK_ARGS and so on
|
||||
|
@ -94,7 +95,7 @@ VALUE rb_DLCdeclCallbackAddrs, rb_DLCdeclCallbackProcs;
|
|||
VALUE rb_DLStdcallCallbackAddrs, rb_DLStdcallCallbackProcs;
|
||||
/*static void *cdecl_callbacks[MAX_DLTYPE][MAX_CALLBACK];*/
|
||||
/*static void *stdcall_callbacks[MAX_DLTYPE][MAX_CALLBACK];*/
|
||||
static ID cb_call;
|
||||
ID rb_dl_cb_call;
|
||||
EOS
|
||||
|
||||
def foreach_proc_entry
|
||||
|
@ -124,7 +125,7 @@ FUNC_#{calltype.upcase}(#{func_name(ty,argc,n,calltype)})(#{(0...argc).collect{|
|
|||
}.join("\n")
|
||||
}
|
||||
cb = rb_ary_entry(rb_ary_entry(#{proc_entry}, #{ty}), #{(n * DLSTACK_SIZE) + argc});
|
||||
ret = rb_funcall2(cb, cb_call, #{argc}, #{argc > 0 ? 'args' : 'NULL'});
|
||||
ret = rb_funcall2(cb, rb_dl_cb_call, #{argc}, #{argc > 0 ? 'args' : 'NULL'});
|
||||
return #{DLTYPE[ty][:conv] ? DLTYPE[ty][:conv] % "ret" : ""};
|
||||
}
|
||||
|
||||
|
@ -149,14 +150,42 @@ def gen_push_addr_ary(ty, aryname, calltype)
|
|||
}.join(","))
|
||||
end
|
||||
|
||||
foreach_proc_entry do |calltype, proc_entry|
|
||||
for ty in 0..(MAX_DLTYPE-1)
|
||||
for argc in 0..(DLSTACK_SIZE-1)
|
||||
for n in 0..(MAX_CALLBACK-1)
|
||||
$out << gencallback(ty, calltype, proc_entry, argc, n)
|
||||
def gen_callback_file(ty)
|
||||
filename = "callback-#{ty}.c"
|
||||
initname = "rb_dl_init_callbacks_#{ty}"
|
||||
open(filename, "w") {|f|
|
||||
f.puts <<-EOS
|
||||
#include "dl.h"
|
||||
extern VALUE rb_DLCdeclCallbackAddrs, rb_DLCdeclCallbackProcs;
|
||||
extern VALUE rb_DLStdcallCallbackAddrs, rb_DLStdcallCallbackProcs;
|
||||
extern ID rb_dl_cb_call;
|
||||
EOS
|
||||
yield f
|
||||
f.puts <<-EOS
|
||||
void
|
||||
#{initname}()
|
||||
{
|
||||
#{gen_push_proc_ary(ty, "rb_DLCdeclCallbackProcs")}
|
||||
#{gen_push_addr_ary(ty, "rb_DLCdeclCallbackAddrs", CDECL)}
|
||||
#{gen_push_proc_ary(ty, "rb_DLStdcallCallbackProcs")}
|
||||
#{gen_push_addr_ary(ty, "rb_DLStdcallCallbackAddrs", STDCALL)}
|
||||
}
|
||||
EOS
|
||||
}
|
||||
initname
|
||||
end
|
||||
|
||||
for ty in 0...MAX_DLTYPE
|
||||
initname = gen_callback_file(ty) {|f|
|
||||
foreach_proc_entry do |calltype, proc_entry|
|
||||
for argc in 0...DLSTACK_SIZE
|
||||
for n in 0...MAX_CALLBACK
|
||||
f << gencallback(ty, calltype, proc_entry, argc, n)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
$out << "void #{initname}();\n"
|
||||
end
|
||||
|
||||
$out << (<<EOS)
|
||||
|
@ -164,7 +193,7 @@ static void
|
|||
rb_dl_init_callbacks()
|
||||
{
|
||||
VALUE tmp;
|
||||
cb_call = rb_intern("call");
|
||||
rb_dl_cb_call = rb_intern("call");
|
||||
|
||||
tmp = rb_DLCdeclCallbackProcs = rb_ary_new();
|
||||
rb_define_const(rb_mDL, "CdeclCallbackProcs", tmp);
|
||||
|
@ -180,23 +209,8 @@ rb_dl_init_callbacks()
|
|||
|
||||
#{
|
||||
(0...MAX_DLTYPE).collect{|ty|
|
||||
gen_push_proc_ary(ty, "rb_DLCdeclCallbackProcs")
|
||||
}.join("\n")
|
||||
}
|
||||
#{
|
||||
(0...MAX_DLTYPE).collect{|ty|
|
||||
gen_push_addr_ary(ty, "rb_DLCdeclCallbackAddrs", CDECL)
|
||||
}.join("\n")
|
||||
}
|
||||
#{
|
||||
(0...MAX_DLTYPE).collect{|ty|
|
||||
gen_push_proc_ary(ty, "rb_DLStdcallCallbackProcs")
|
||||
}.join("\n")
|
||||
}
|
||||
#{
|
||||
(0...MAX_DLTYPE).collect{|ty|
|
||||
gen_push_addr_ary(ty, "rb_DLStdcallCallbackAddrs", STDCALL)
|
||||
}.join("\n")
|
||||
"rb_dl_init_callbacks_#{ty}();\n"
|
||||
}.join("")
|
||||
}
|
||||
}
|
||||
EOS
|
||||
|
|
Loading…
Reference in a new issue