summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-29 13:55:29 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-29 13:55:29 +0000
commit9f06167a265a2a117ffbf714e2632bbf746e5b46 (patch)
treedf7a7707acfe88fab752aa9aadadf8add1474d22
parent654c3cdec6c9f1bdb13ae90f1243909b9208532d (diff)
sizes.c: RbConfig::SIZEOF
* sizes.c (Init_sizes): define RbConfig::SIZEOF. [Feature #8568] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42244 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--common.mk3
-rw-r--r--inits.c1
-rw-r--r--sizes.c52
4 files changed, 60 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 43b9f77..4e6398b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Mon Jul 29 22:55:26 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * sizes.c (Init_sizes): define RbConfig::SIZEOF. [Feature #8568]
+
Mon Jul 29 22:25:20 2013 Zachary Scott <e@zzak.io>
* ext/curses/curses.c: [DOC] Update location of samples
diff --git a/common.mk b/common.mk
index ae2804e..27ddafe 100644
--- a/common.mk
+++ b/common.mk
@@ -95,6 +95,7 @@ COMMONOBJS = array.$(OBJEXT) \
vm_trace.$(OBJEXT) \
thread.$(OBJEXT) \
cont.$(OBJEXT) \
+ sizes.$(OBJEXT) \
$(BUILTIN_ENCOBJS) \
$(BUILTIN_TRANSOBJS) \
$(MISSING)
@@ -818,6 +819,8 @@ golf_prelude.$(OBJEXT): {$(VPATH)}golf_prelude.c $(RUBY_H_INCLUDES) \
goruby.$(OBJEXT): {$(VPATH)}goruby.c {$(VPATH)}main.c $(RUBY_H_INCLUDES) \
{$(VPATH)}vm_debug.h {$(VPATH)}node.h $(hdrdir)/ruby.h
+sizes.$(OBJEXT): {$(VPATH)}sizes.c $(RUBY_H_INCLUDES)
+
ascii.$(OBJEXT): {$(VPATH)}ascii.c {$(VPATH)}regenc.h {$(VPATH)}config.h \
{$(VPATH)}oniguruma.h {$(VPATH)}missing.h $(RUBY_H_INCLUDES)
us_ascii.$(OBJEXT): {$(VPATH)}us_ascii.c {$(VPATH)}regenc.h \
diff --git a/inits.c b/inits.c
index fe0aade..f6611a0 100644
--- a/inits.c
+++ b/inits.c
@@ -61,5 +61,6 @@ rb_call_inits(void)
CALL(Complex);
CALL(version);
CALL(vm_trace);
+ CALL(sizes);
}
#undef CALL
diff --git a/sizes.c b/sizes.c
new file mode 100644
index 0000000..398ee95
--- /dev/null
+++ b/sizes.c
@@ -0,0 +1,52 @@
+#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));
+
+#ifdef SIZEOF_INT
+ DEFINE(int, INT);
+#endif
+#ifdef SIZEOF_SHORT
+ DEFINE(short, SHORT);
+#endif
+#ifdef SIZEOF_LONG
+ DEFINE(long, LONG);
+#endif
+#ifdef SIZEOF_LONG_LONG
+ DEFINE(long long, LONG_LONG);
+#endif
+#ifdef SIZEOF___INT64
+ DEFINE(__int64, __INT64);
+#endif
+#ifdef SIZEOF___INT128
+ DEFINE(__int128, __INT128);
+#endif
+#ifdef SIZEOF_OFF_T
+ DEFINE(off_t, OFF_T);
+#endif
+#ifdef SIZEOF_VOIDP
+ DEFINE(void*, VOIDP);
+#endif
+#ifdef SIZEOF_FLOAT
+ DEFINE(float, FLOAT);
+#endif
+#ifdef SIZEOF_DOUBLE
+ DEFINE(double, DOUBLE);
+#endif
+#ifdef SIZEOF_TIME_T
+ DEFINE(time_t, TIME_T);
+#endif
+#ifdef SIZEOF_SIZE_T
+ DEFINE(size_t, SIZE_T);
+#endif
+#ifdef SIZEOF_PTRDIFF_T
+ DEFINE(ptrdiff_t, PTRDIFF_T);
+#endif
+
+#undef DEFINE
+}