Ruby 2.1.5p273(2014-11-13revision48405)

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

sizes.c
Go to the documentation of this file.
1 #include "ruby/ruby.h"
2
3 void
4 Init_sizeof(void)
5 {
6 VALUE s = rb_hash_new();
7 rb_define_const(rb_define_module("RbConfig"), "SIZEOF", s);
8
9 #define DEFINE(type, size) rb_hash_aset(s, rb_str_new_cstr(#type), INT2FIX(SIZEOF_##size));
10
11 #if SIZEOF_INT != 0
12 DEFINE(int, INT);
13 #endif
14 #if SIZEOF_SHORT != 0
15 DEFINE(short, SHORT);
16 #endif
17 #if SIZEOF_LONG != 0
18 DEFINE(long, LONG);
19 #endif
20 #if SIZEOF_LONG_LONG != 0 && defined(HAVE_TRUE_LONG_LONG)
21 DEFINE(long long, LONG_LONG);
22 #endif
23 #if SIZEOF___INT64 != 0
24 DEFINE(__int64, __INT64);
25 #endif
26 #if SIZEOF___INT128 != 0
27 DEFINE(__int128, __INT128);
28 #endif
29 #if SIZEOF_OFF_T != 0
30 DEFINE(off_t, OFF_T);
31 #endif
32 #if SIZEOF_VOIDP != 0
33 DEFINE(void*, VOIDP);
34 #endif
35 #if SIZEOF_FLOAT != 0
36 DEFINE(float, FLOAT);
37 #endif
38 #if SIZEOF_DOUBLE != 0
39 DEFINE(double, DOUBLE);
40 #endif
41 #if SIZEOF_TIME_T != 0
42 DEFINE(time_t, TIME_T);
43 #endif
44 #if SIZEOF_CLOCK_T != 0
45 DEFINE(clock_t, CLOCK_T);
46 #endif
47 #if SIZEOF_SIZE_T != 0
48 DEFINE(size_t, SIZE_T);
49 #endif
50 #if SIZEOF_PTRDIFF_T != 0
51 DEFINE(ptrdiff_t, PTRDIFF_T);
52 #endif
53
54 #undef DEFINE
55 }
ruby.h
rb_define_const
void rb_define_const(VALUE, const char *, VALUE)
Definition: variable.c:2225
Init_sizeof
void Init_sizeof(void)
Definition: sizes.c:4
off_t
#define off_t
Definition: io.c:65
rb_hash_new
VALUE rb_hash_new(void)
Definition: hash.c:298
DEFINE
#define DEFINE(type, size)
VALUE
unsigned long VALUE
Definition: ruby.h:88
rb_define_module
VALUE rb_define_module(const char *name)
Definition: class.c:746