1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

sizes.c.tmpl: autogenerate

* template/sizes.c.tmpl: generate automatically by extracting
  RUBY_CHECK_SIZEOF from configure.in.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-08-26 03:37:15 +00:00
parent c3ab2dc6ae
commit 21d7cd3988
6 changed files with 49 additions and 57 deletions

1
.gitignore vendored
View file

@ -82,6 +82,7 @@ y.tab.c
/rubicon /rubicon
/ruby /ruby
/ruby-man.rd.gz /ruby-man.rd.gz
/sizes.c
/test.rb /test.rb
/tmp /tmp
/transdb.h /transdb.h

View file

@ -1,3 +1,8 @@
Mon Aug 26 12:37:10 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* template/sizes.c.tmpl: generate automatically by extracting
RUBY_CHECK_SIZEOF from configure.in.
Mon Aug 26 10:16:59 2013 Kazuhiro NISHIYAMA <zn@mbf.nifty.com> Mon Aug 26 10:16:59 2013 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* process.c (gcd_timetick_int): Renamed from gcd_timtick_int. * process.c (gcd_timetick_int): Renamed from gcd_timtick_int.

View file

@ -95,7 +95,6 @@ COMMONOBJS = array.$(OBJEXT) \
vm_trace.$(OBJEXT) \ vm_trace.$(OBJEXT) \
thread.$(OBJEXT) \ thread.$(OBJEXT) \
cont.$(OBJEXT) \ cont.$(OBJEXT) \
sizes.$(OBJEXT) \
$(BUILTIN_ENCOBJS) \ $(BUILTIN_ENCOBJS) \
$(BUILTIN_TRANSOBJS) \ $(BUILTIN_TRANSOBJS) \
$(MISSING) $(MISSING)
@ -103,6 +102,7 @@ COMMONOBJS = array.$(OBJEXT) \
EXPORTOBJS = $(DLNOBJ) \ EXPORTOBJS = $(DLNOBJ) \
localeinit.$(OBJEXT) \ localeinit.$(OBJEXT) \
loadpath.$(OBJEXT) \ loadpath.$(OBJEXT) \
sizes.$(OBJEXT) \
$(COMMONOBJS) $(COMMONOBJS)
OBJS = $(EXPORTOBJS) prelude.$(OBJEXT) OBJS = $(EXPORTOBJS) prelude.$(OBJEXT)
@ -883,7 +883,7 @@ INSNS2VMOPT = --srcdir="$(srcdir)"
{$(VPATH)}vm.inc: $(srcdir)/template/vm.inc.tmpl {$(VPATH)}vm.inc: $(srcdir)/template/vm.inc.tmpl
srcs: {$(VPATH)}parse.c {$(VPATH)}lex.c {$(VPATH)}newline.c {$(VPATH)}id.c srcs-ext srcs-enc srcs: {$(VPATH)}parse.c {$(VPATH)}lex.c {$(VPATH)}newline.c {$(VPATH)}id.c {$(VPATH)}sizes.c srcs-ext srcs-enc
EXT_SRCS = $(srcdir)/ext/ripper/ripper.c $(srcdir)/ext/json/parser/parser.c \ EXT_SRCS = $(srcdir)/ext/ripper/ripper.c $(srcdir)/ext/json/parser/parser.c \
$(srcdir)/ext/dl/callback/callback.c $(srcdir)/ext/dl/callback/callback.c
@ -910,6 +910,11 @@ id.c: $(srcdir)/tool/generic_erb.rb $(srcdir)/template/id.c.tmpl $(srcdir)/defs/
$(Q) $(BASERUBY) $(srcdir)/tool/generic_erb.rb --output=$@ \ $(Q) $(BASERUBY) $(srcdir)/tool/generic_erb.rb --output=$@ \
$(srcdir)/template/id.c.tmpl $(srcdir)/template/id.c.tmpl
sizes.c: $(srcdir)/tool/generic_erb.rb $(srcdir)/template/sizes.c.tmpl $(srcdir)/configure.in
$(ECHO) generating $@
$(Q) $(BASERUBY) $(srcdir)/tool/generic_erb.rb --output=$@ \
$(srcdir)/template/sizes.c.tmpl $(srcdir)/configure.in
node_name.inc: {$(VPATH)}node.h node_name.inc: {$(VPATH)}node.h
$(ECHO) generating $@ $(ECHO) generating $@
$(Q) $(BASERUBY) -n $(srcdir)/tool/node_name.rb < $? > $@ $(Q) $(BASERUBY) -n $(srcdir)/tool/node_name.rb < $? > $@

View file

@ -28,3 +28,9 @@ Init_enc_set_filesystem_encoding(void)
{ {
return rb_enc_to_index(rb_default_external_encoding()); return rb_enc_to_index(rb_default_external_encoding());
} }
/* sizes.c */
void
Init_sizes(void)
{
}

55
sizes.c
View file

@ -1,55 +0,0 @@
#include "ruby/ruby.h"
void
Init_sizes(void)
{
VALUE s = rb_hash_new();
rb_define_const(rb_define_module("RbConfig"), "SIZEOF", s);
#define DEFINE(type, size) rb_hash_aset(s, rb_str_new_cstr(#type), INT2FIX(SIZEOF_##size));
#if SIZEOF_INT != 0
DEFINE(int, INT);
#endif
#if SIZEOF_SHORT != 0
DEFINE(short, SHORT);
#endif
#if SIZEOF_LONG != 0
DEFINE(long, LONG);
#endif
#if SIZEOF_LONG_LONG != 0 && defined(HAVE_TRUE_LONG_LONG)
DEFINE(long long, LONG_LONG);
#endif
#if SIZEOF___INT64 != 0
DEFINE(__int64, __INT64);
#endif
#if SIZEOF___INT128 != 0
DEFINE(__int128, __INT128);
#endif
#if SIZEOF_OFF_T != 0
DEFINE(off_t, OFF_T);
#endif
#if SIZEOF_VOIDP != 0
DEFINE(void*, VOIDP);
#endif
#if SIZEOF_FLOAT != 0
DEFINE(float, FLOAT);
#endif
#if SIZEOF_DOUBLE != 0
DEFINE(double, DOUBLE);
#endif
#if SIZEOF_TIME_T != 0
DEFINE(time_t, TIME_T);
#endif
#if SIZEOF_CLOCK_T != 0
DEFINE(clock_t, CLOCK_T);
#endif
#if SIZEOF_SIZE_T != 0
DEFINE(size_t, SIZE_T);
#endif
#if SIZEOF_PTRDIFF_T != 0
DEFINE(ptrdiff_t, PTRDIFF_T);
#endif
#undef DEFINE
}

30
template/sizes.c.tmpl Normal file
View file

@ -0,0 +1,30 @@
%# -*- c -*-
#include "ruby/ruby.h"
<%
class String
def tr_cpp
strip.upcase.tr_s("^A-Z0-9_*", "_").tr_s("*", "P")
end
end
types = ARGF.grep(/^\s*RUBY_CHECK_SIZEOF\((\w[^\[\],#]*)[^#]*\)/) {$1}
conditions = {
"long long" => 'defined(HAVE_TRUE_LONG_LONG)',
}
%>
void
Init_sizes(void)
{
VALUE s = rb_hash_new();
rb_define_const(rb_define_module("RbConfig"), "SIZEOF", s);
#define DEFINE(type, size) rb_hash_aset(s, rb_str_new_cstr(#type), INT2FIX(SIZEOF_##size));
% types.each do |type|
% cond = conditions[type]
#if SIZEOF_<%= type.tr_cpp %> != 0<%= " && #{cond}" if cond %>
DEFINE(<%= type %>, <%= type.tr_cpp %>);
#endif
% end
#undef DEFINE
}