/
mrbconf.h
161 lines (132 loc) · 3.65 KB
/
mrbconf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
** mrbconf.h - mruby core configuration
**
** See Copyright Notice in mruby.h
*/
#ifndef MRUBYCONF_H
#define MRUBYCONF_H
#include <stdint.h>
#include <stddef.h>
/* configuration options: */
/* add -DMRB_USE_FLOAT to use float instead of double for floating point numbers */
//#define MRB_USE_FLOAT
/* add -DMRB_INT16 to use 16bit integer for mrb_int; conflict with MRB_INT64 */
//#define MRB_INT16
/* add -DMRB_INT64 to use 64bit integer for mrb_int; conflict with MRB_INT16 */
//#define MRB_INT64
/* represent mrb_value in boxed double; conflict with MRB_USE_FLOAT */
//#define MRB_NAN_BOXING
/* define on big endian machines; used by MRB_NAN_BOXING */
//#define MRB_ENDIAN_BIG
/* argv max size in mrb_funcall */
//#define MRB_FUNCALL_ARGC_MAX 16
/* number of object per heap page */
//#define MRB_HEAP_PAGE_SIZE 1024
/* use segmented list for IV table */
//#define MRB_USE_IV_SEGLIST
/* initial size for IV khash; ignored when MRB_USE_IV_SEGLIST is set */
//#define MRB_IVHASH_INIT_SIZE 8
/* initial size for IREP array */
//#define MRB_IREP_ARRAY_INIT_SIZE (256u)
/* default size of khash table bucket */
//#define KHASH_DEFAULT_SIZE 32
/* allocated memory address alignment */
//#define POOL_ALIGNMENT 4
/* page size of memory pool */
//#define POOL_PAGE_SIZE 16000
/* initial minimum size for string buffer */
//#define MRB_STR_BUF_MIN_SIZE 128
/* array size for parser buffer */
//#define MRB_PARSER_BUF_SIZE 1024
/* -DDISABLE_XXXX to drop following features */
//#define DISABLE_STDIO /* use of stdio */
/* -DENABLE_XXXX to enable following features */
//#define ENABLE_DEBUG /* hooks for debugger */
/* end of configuration */
#ifdef MRB_USE_FLOAT
typedef float mrb_float;
# define mrb_float_to_str(buf, i) sprintf(buf, "%.7e", i)
# define str_to_mrb_float(buf) strtof(buf, NULL)
#else
typedef double mrb_float;
# define mrb_float_to_str(buf, i) sprintf(buf, "%.16e", i)
# define str_to_mrb_float(buf) strtod(buf, NULL)
#endif
#if defined(MRB_INT16) && defined(MRB_INT64)
# error "You can't define MRB_INT16 and MRB_INT64 at the same time."
#endif
#if defined(MRB_INT64)
# ifdef MRB_NAN_BOXING
# error Cannot use NaN boxing when mrb_int is 64bit
# else
typedef int64_t mrb_int;
# define MRB_INT_MIN INT64_MIN
# define MRB_INT_MAX INT64_MAX
# define PRIdMRB_INT PRId64
# define PRIiMRB_INT PRIi64
# define PRIoMRB_INT PRIo64
# define PRIxMRB_INT PRIx64
# define PRIXMRB_INT PRIX64
# endif
#elif defined(MRB_INT16)
typedef int16_t mrb_int;
# define MRB_INT_MIN INT16_MIN
# define MRB_INT_MAX INT16_MAX
#else
typedef int32_t mrb_int;
# define MRB_INT_MIN INT32_MIN
# define MRB_INT_MAX INT32_MAX
# define PRIdMRB_INT PRId32
# define PRIiMRB_INT PRIi32
# define PRIoMRB_INT PRIo32
# define PRIxMRB_INT PRIx32
# define PRIXMRB_INT PRIX32
#endif
typedef short mrb_sym;
/* define ENABLE_XXXX from DISABLE_XXX */
#ifndef DISABLE_STDIO
#define ENABLE_STDIO
#endif
#ifndef ENABLE_DEBUG
#define DISABLE_DEBUG
#endif
#ifdef _MSC_VER
# include <float.h>
# define inline __inline
# define snprintf _snprintf
# define isnan _isnan
# define isinf(n) (!_finite(n) && !_isnan(n))
# define strtoll _strtoi64
# define PRId32 "I32d"
# define PRIi32 "I32i"
# define PRIo32 "I32o"
# define PRIx32 "I32x"
# define PRIX32 "I32X"
# define PRId64 "I64d"
# define PRIi64 "I64i"
# define PRIo64 "I64o"
# define PRIx64 "I64x"
# define PRIX64 "I64X"
# ifdef __cplusplus
typedef bool mrb_bool;
# else
typedef unsigned int mrb_bool;
# endif
#else
# include <inttypes.h>
# ifdef __cplusplus
typedef bool mrb_bool;
# else
typedef _Bool mrb_bool;
# endif
#endif
#ifdef ENABLE_STDIO
# include <stdio.h>
#endif
#ifndef FALSE
# define FALSE 0
#endif
#ifndef TRUE
# define TRUE 1
#endif
#endif /* MRUBYCONF_H */