2013-07-29 09:55:29 -04:00
|
|
|
#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));
|
|
|
|
|
2013-07-29 19:22:25 -04:00
|
|
|
#if SIZEOF_INT != 0
|
2013-07-29 09:55:29 -04:00
|
|
|
DEFINE(int, INT);
|
|
|
|
#endif
|
2013-07-29 19:22:25 -04:00
|
|
|
#if SIZEOF_SHORT != 0
|
2013-07-29 09:55:29 -04:00
|
|
|
DEFINE(short, SHORT);
|
|
|
|
#endif
|
2013-07-29 19:22:25 -04:00
|
|
|
#if SIZEOF_LONG != 0
|
2013-07-29 09:55:29 -04:00
|
|
|
DEFINE(long, LONG);
|
|
|
|
#endif
|
2013-07-29 19:22:25 -04:00
|
|
|
#if SIZEOF_LONG_LONG != 0 && defined(HAVE_TRUE_LONG_LONG)
|
2013-07-29 09:55:29 -04:00
|
|
|
DEFINE(long long, LONG_LONG);
|
|
|
|
#endif
|
2013-07-29 19:22:25 -04:00
|
|
|
#if SIZEOF___INT64 != 0
|
2013-07-29 09:55:29 -04:00
|
|
|
DEFINE(__int64, __INT64);
|
|
|
|
#endif
|
2013-07-29 19:22:25 -04:00
|
|
|
#if SIZEOF___INT128 != 0
|
2013-07-29 09:55:29 -04:00
|
|
|
DEFINE(__int128, __INT128);
|
|
|
|
#endif
|
2013-07-29 19:22:25 -04:00
|
|
|
#if SIZEOF_OFF_T != 0
|
2013-07-29 09:55:29 -04:00
|
|
|
DEFINE(off_t, OFF_T);
|
|
|
|
#endif
|
2013-07-29 19:22:25 -04:00
|
|
|
#if SIZEOF_VOIDP != 0
|
2013-07-29 09:55:29 -04:00
|
|
|
DEFINE(void*, VOIDP);
|
|
|
|
#endif
|
2013-07-29 19:22:25 -04:00
|
|
|
#if SIZEOF_FLOAT != 0
|
2013-07-29 09:55:29 -04:00
|
|
|
DEFINE(float, FLOAT);
|
|
|
|
#endif
|
2013-07-29 19:22:25 -04:00
|
|
|
#if SIZEOF_DOUBLE != 0
|
2013-07-29 09:55:29 -04:00
|
|
|
DEFINE(double, DOUBLE);
|
|
|
|
#endif
|
2013-07-29 19:22:25 -04:00
|
|
|
#if SIZEOF_TIME_T != 0
|
2013-07-29 09:55:29 -04:00
|
|
|
DEFINE(time_t, TIME_T);
|
|
|
|
#endif
|
2013-07-29 19:22:25 -04:00
|
|
|
#if SIZEOF_SIZE_T != 0
|
2013-07-29 09:55:29 -04:00
|
|
|
DEFINE(size_t, SIZE_T);
|
|
|
|
#endif
|
2013-07-29 19:22:25 -04:00
|
|
|
#if SIZEOF_PTRDIFF_T != 0
|
2013-07-29 09:55:29 -04:00
|
|
|
DEFINE(ptrdiff_t, PTRDIFF_T);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#undef DEFINE
|
|
|
|
}
|