Skip to content

Commit 8a87549

Browse files
committed
Rename float configuration option names.
- `MRB_WITHOUT_FLOAT` => `MRB_NO_FLOAT` - `MRB_USE_FLOAT` => `MRB_USE_FLOAT32` The former is to use `USE_XXX` naming convention. The latter is to make sure `float` is 32bit float and not floating point number in general.
1 parent ef9df5d commit 8a87549

51 files changed

Lines changed: 223 additions & 202 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

doc/guides/mrbconf.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ You can use mrbconfs with following ways:
4646

4747
## Primitive type configuration.
4848

49-
`MRB_USE_FLOAT`
49+
`MRB_USE_FLOAT32`
5050
* When defined single precision floating point type(C type `float`) is used as `mrb_float`.
51-
* Else double precision floating point type(C type `double`) is used as `mrb_float`.
51+
* Otherwise double precision floating point type(C type `double`) is used as `mrb_float`.
5252

53-
`MRB_WITHOUT_FLOAT`
53+
`MRB_NO_FLOAT`
5454
* When defined removes floating point numbers from mruby.
5555
* It makes mruby easier to handle in "Microcontroller without FPU" and "Kernel Space".
5656

@@ -117,7 +117,7 @@ largest value of required alignment.
117117

118118
`MRB_NAN_BOXING`
119119
* If defined represent `mrb_value` in boxed `double`.
120-
* Conflicts with `MRB_USE_FLOAT` and `MRB_WITHOUT_FLOAT`.
120+
* Conflicts with `MRB_USE_FLOAT32` and `MRB_NO_FLOAT`.
121121

122122
`MRB_WORD_BOXING`
123123
* If defined represent `mrb_value` as a word.

doc/mruby3.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ pull-request.
5757

5858
Some configuration macro names are changed for consistency
5959

60+
== `MRB_NO_FLOAT`
61+
62+
Changed from `MRB_WITHOUT_FLOAT` to conform `USE_XXX` naming
63+
convention.
64+
65+
== `MRB_USE_FLOAT32`
66+
67+
Changed from `MRB_USE_FLOAT` to make sure `float` here means
68+
using single precision float, and not the opposite of
69+
`MRB_NO_FLOAT`.
70+
6071
== `MRB_USE_METHOD_T_STRUCT`
6172

6273
Changed from `MRB_METHOD_T_STRUCT`.

include/mrbconf.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,24 @@
2525
#endif
2626

2727
/* configuration options: */
28-
/* add -DMRB_USE_FLOAT to use float instead of double for floating point numbers */
29-
//#define MRB_USE_FLOAT
28+
/* add -DMRB_USE_FLOAT32 to use float instead of double for floating point numbers */
29+
//#define MRB_USE_FLOAT32
3030

3131
/* exclude floating point numbers */
32-
//#define MRB_WITHOUT_FLOAT
32+
//#define MRB_NO_FLOAT
3333

34-
#if defined(MRB_USE_FLOAT) && defined(MRB_WITHOUT_FLOAT)
35-
#error Cannot define MRB_USE_FLOAT and MRB_WITHOUT_FLOAT at the same time
34+
/* obsolete configuration */
35+
#if defined(MRB_USE_FLOAT)
36+
# define MRB_USE_FLOAT32
37+
#endif
38+
39+
/* obsolete configuration */
40+
#if defined(MRB_WITHOUT_FLOAT)
41+
# define MRB_NO_FLOAT
42+
#endif
43+
44+
#if defined(MRB_USE_FLOAT32) && defined(MRB_NO_FLOAT)
45+
#error Cannot define MRB_USE_FLOAT32 and MRB_NO_FLOAT at the same time
3646
#endif
3747

3848
/* stop inlining floating point numbers in mrb_value (effective only with MRB_WORD_BOXING)*/
@@ -65,7 +75,7 @@
6575
# endif
6676
#endif
6777

68-
/* represent mrb_value in boxed double; conflict with MRB_USE_FLOAT and MRB_WITHOUT_FLOAT */
78+
/* represent mrb_value in boxed double; conflict with MRB_USE_FLOAT32 and MRB_NO_FLOAT */
6979
//#define MRB_NAN_BOXING
7080

7181
/* represent mrb_value as a word (natural unit of data for the processor) */

include/mruby.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
#include <mruby/presym.h>
9393
#include <mruby/version.h>
9494

95-
#ifndef MRB_WITHOUT_FLOAT
95+
#ifndef MRB_NO_FLOAT
9696
#include <float.h>
9797
#ifndef FLT_EPSILON
9898
#define FLT_EPSILON (1.19209290e-07f)
@@ -104,7 +104,7 @@
104104
#define LDBL_EPSILON (1.08420217248550443401e-19L)
105105
#endif
106106

107-
#ifdef MRB_USE_FLOAT
107+
#ifdef MRB_USE_FLOAT32
108108
#define MRB_FLOAT_EPSILON FLT_EPSILON
109109
#else
110110
#define MRB_FLOAT_EPSILON DBL_EPSILON
@@ -245,7 +245,7 @@ typedef struct mrb_state {
245245
struct RClass *hash_class;
246246
struct RClass *range_class;
247247

248-
#ifndef MRB_WITHOUT_FLOAT
248+
#ifndef MRB_NO_FLOAT
249249
struct RClass *float_class;
250250
#endif
251251
struct RClass *fixnum_class;
@@ -1211,7 +1211,7 @@ MRB_API mrb_bool mrb_obj_equal(mrb_state *mrb, mrb_value a, mrb_value b);
12111211
MRB_API mrb_bool mrb_equal(mrb_state *mrb, mrb_value obj1, mrb_value obj2);
12121212
MRB_API mrb_value mrb_convert_to_integer(mrb_state *mrb, mrb_value val, mrb_int base);
12131213
MRB_API mrb_value mrb_Integer(mrb_state *mrb, mrb_value val);
1214-
#ifndef MRB_WITHOUT_FLOAT
1214+
#ifndef MRB_NO_FLOAT
12151215
MRB_API mrb_value mrb_Float(mrb_state *mrb, mrb_value val);
12161216
#endif
12171217
MRB_API mrb_value mrb_inspect(mrb_state *mrb, mrb_value obj);
@@ -1304,7 +1304,7 @@ MRB_API mrb_value mrb_vformat(mrb_state *mrb, const char *format, va_list ap);
13041304
#define E_FROZEN_ERROR (mrb_exc_get_id(mrb, MRB_SYM(FrozenError)))
13051305

13061306
#define E_NOTIMP_ERROR (mrb_exc_get_id(mrb, MRB_SYM(NotImplementedError)))
1307-
#ifndef MRB_WITHOUT_FLOAT
1307+
#ifndef MRB_NO_FLOAT
13081308
#define E_FLOATDOMAIN_ERROR (mrb_exc_get_id(mrb, MRB_SYM(FloatDomainError)))
13091309
#endif
13101310

include/mruby/boxing_nan.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
#ifndef MRUBY_BOXING_NAN_H
88
#define MRUBY_BOXING_NAN_H
99

10-
#ifdef MRB_USE_FLOAT
11-
# error ---->> MRB_NAN_BOXING and MRB_USE_FLOAT conflict <<----
10+
#ifdef MRB_USE_FLOAT32
11+
# error ---->> MRB_NAN_BOXING and MRB_USE_FLOAT32 conflict <<----
1212
#endif
1313

14-
#ifdef MRB_WITHOUT_FLOAT
15-
# error ---->> MRB_NAN_BOXING and MRB_WITHOUT_FLOAT conflict <<----
14+
#ifdef MRB_NO_FLOAT
15+
# error ---->> MRB_NAN_BOXING and MRB_NO_FLOAT conflict <<----
1616
#endif
1717

1818
#ifdef MRB_INT64

include/mruby/boxing_no.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define MRB_SYMBOL_SHIFT 0
1212

1313
union mrb_value_union {
14-
#ifndef MRB_WITHOUT_FLOAT
14+
#ifndef MRB_NO_FLOAT
1515
mrb_float f;
1616
#endif
1717
void *p;
@@ -26,7 +26,7 @@ typedef struct mrb_value {
2626

2727
#define mrb_ptr(o) (o).value.p
2828
#define mrb_cptr(o) mrb_ptr(o)
29-
#ifndef MRB_WITHOUT_FLOAT
29+
#ifndef MRB_NO_FLOAT
3030
#define mrb_float(o) (o).value.f
3131
#endif
3232
#define mrb_fixnum(o) (o).value.i
@@ -43,7 +43,7 @@ typedef struct mrb_value {
4343
#define SET_TRUE_VALUE(r) BOXNIX_SET_VALUE(r, MRB_TT_TRUE, value.i, 1)
4444
#define SET_BOOL_VALUE(r,b) BOXNIX_SET_VALUE(r, b ? MRB_TT_TRUE : MRB_TT_FALSE, value.i, 1)
4545
#define SET_INT_VALUE(r,n) BOXNIX_SET_VALUE(r, MRB_TT_FIXNUM, value.i, (n))
46-
#ifndef MRB_WITHOUT_FLOAT
46+
#ifndef MRB_NO_FLOAT
4747
#define SET_FLOAT_VALUE(mrb,r,v) BOXNIX_SET_VALUE(r, MRB_TT_FLOAT, value.f, (v))
4848
#endif
4949
#define SET_SYM_VALUE(r,v) BOXNIX_SET_VALUE(r, MRB_TT_SYMBOL, value.sym, (v))

include/mruby/boxing_word.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#error MRB_INT64 cannot be used with MRB_WORD_BOXING in 32-bit mode.
1212
#endif
1313

14-
#if !defined(MRB_WITHOUT_FLOAT) || defined(MRB_NO_FLOAT_INLINE)
14+
#if !defined(MRB_NO_FLOAT) || defined(MRB_NO_FLOAT_INLINE)
1515
struct RFloat {
1616
MRB_OBJECT_HEADER;
1717
mrb_float f;
@@ -80,7 +80,7 @@ union mrb_value_ {
8080
};
8181
#endif
8282
struct RBasic *bp;
83-
#ifndef MRB_WITHOUT_FLOAT
83+
#ifndef MRB_NO_FLOAT
8484
struct RFloat *fp;
8585
#endif
8686
struct RCptr *vp;
@@ -96,13 +96,13 @@ mrb_val_union(mrb_value v)
9696
}
9797

9898
MRB_API mrb_value mrb_word_boxing_cptr_value(struct mrb_state*, void*);
99-
#ifndef MRB_WITHOUT_FLOAT
99+
#ifndef MRB_NO_FLOAT
100100
MRB_API mrb_value mrb_word_boxing_float_value(struct mrb_state*, mrb_float);
101101
#endif
102102

103103
#define mrb_ptr(o) mrb_val_union(o).p
104104
#define mrb_cptr(o) mrb_val_union(o).vp->p
105-
#ifndef MRB_WITHOUT_FLOAT
105+
#ifndef MRB_NO_FLOAT
106106
#define mrb_float(o) mrb_val_union(o).fp->f
107107
#endif
108108
#define mrb_fixnum(o) BOXWORD_SHIFT_VALUE(o, FIXNUM, mrb_int)
@@ -124,7 +124,7 @@ MRB_API mrb_value mrb_word_boxing_float_value(struct mrb_state*, mrb_float);
124124
#define mrb_nil_p(o) ((o) == MRB_Qnil)
125125
#define mrb_false_p(o) ((o) == MRB_Qfalse)
126126
#define mrb_true_p(o) ((o) == MRB_Qtrue)
127-
#ifndef MRB_WITHOUT_FLOAT
127+
#ifndef MRB_NO_FLOAT
128128
#define mrb_float_p(o) BOXWORD_OBJ_TYPE_P(o, FLOAT)
129129
#endif
130130
#define mrb_array_p(o) BOXWORD_OBJ_TYPE_P(o, ARRAY)
@@ -146,7 +146,7 @@ MRB_API mrb_value mrb_word_boxing_float_value(struct mrb_state*, mrb_float);
146146
#define mrb_istruct_p(o) BOXWORD_OBJ_TYPE_P(o, ISTRUCT)
147147
#define mrb_break_p(o) BOXWORD_OBJ_TYPE_P(o, BREAK)
148148

149-
#ifndef MRB_WITHOUT_FLOAT
149+
#ifndef MRB_NO_FLOAT
150150
#define SET_FLOAT_VALUE(mrb,r,v) ((r) = mrb_word_boxing_float_value(mrb, v))
151151
#endif
152152
#define SET_CPTR_VALUE(mrb,r,v) ((r) = mrb_word_boxing_cptr_value(mrb, v))

include/mruby/class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ mrb_class(mrb_state *mrb, mrb_value v)
3737
return mrb->symbol_class;
3838
case MRB_TT_FIXNUM:
3939
return mrb->fixnum_class;
40-
#ifndef MRB_WITHOUT_FLOAT
40+
#ifndef MRB_NO_FLOAT
4141
case MRB_TT_FLOAT:
4242
return mrb->float_class;
4343
#endif

include/mruby/error.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ MRB_API mrb_noreturn void mrb_no_method_error(mrb_state *mrb, mrb_sym id, mrb_va
3232
/* declaration for `fail` method */
3333
MRB_API mrb_value mrb_f_raise(mrb_state*, mrb_value);
3434

35-
#if defined(MRB_64BIT) || defined(MRB_USE_FLOAT) || defined(MRB_NAN_BOXING) || defined(MRB_WORD_BOXING)
35+
#if defined(MRB_64BIT) || defined(MRB_USE_FLOAT32) || defined(MRB_NAN_BOXING) || defined(MRB_WORD_BOXING)
3636
struct RBreak {
3737
MRB_OBJECT_HEADER;
3838
const struct RProc *proc;
@@ -62,7 +62,7 @@ mrb_break_value_set(struct RBreak *brk, mrb_value val)
6262
brk->flags &= ~RBREAK_VALUE_TT_MASK;
6363
brk->flags |= val.tt;
6464
}
65-
#endif /* MRB_64BIT || MRB_USE_FLOAT || MRB_NAN_BOXING || MRB_WORD_BOXING */
65+
#endif /* MRB_64BIT || MRB_USE_FLOAT32 || MRB_NAN_BOXING || MRB_WORD_BOXING */
6666
#define mrb_break_proc_get(brk) ((brk)->proc)
6767
#define mrb_break_proc_set(brk, p) ((brk)->proc = p)
6868

include/mruby/numeric.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,20 @@ MRB_BEGIN_DECL
2222
#define POSFIXABLE(f) TYPED_POSFIXABLE(f,mrb_int)
2323
#define NEGFIXABLE(f) TYPED_NEGFIXABLE(f,mrb_int)
2424
#define FIXABLE(f) TYPED_FIXABLE(f,mrb_int)
25-
#ifndef MRB_WITHOUT_FLOAT
25+
#ifndef MRB_NO_FLOAT
2626
#ifdef MRB_INT64
2727
#define FIXABLE_FLOAT(f) ((f)>=-9223372036854775808.0 && (f)<9223372036854775808.0)
2828
#else
2929
#define FIXABLE_FLOAT(f) TYPED_FIXABLE(f,mrb_float)
3030
#endif
3131
#endif
3232

33-
#ifndef MRB_WITHOUT_FLOAT
33+
#ifndef MRB_NO_FLOAT
3434
MRB_API mrb_value mrb_flo_to_fixnum(mrb_state *mrb, mrb_value val);
3535
#endif
3636
MRB_API mrb_value mrb_fixnum_to_str(mrb_state *mrb, mrb_value x, mrb_int base);
3737
/* ArgumentError if format string doesn't match /%(\.[0-9]+)?[aAeEfFgG]/ */
38-
#ifndef MRB_WITHOUT_FLOAT
38+
#ifndef MRB_NO_FLOAT
3939
MRB_API mrb_value mrb_float_to_str(mrb_state *mrb, mrb_value x, const char *fmt);
4040
MRB_API int mrb_float_to_cstr(mrb_state *mrb, char *buf, size_t len, const char *fmt, mrb_float f);
4141
MRB_API mrb_float mrb_to_flo(mrb_state *mrb, mrb_value x);
@@ -161,13 +161,13 @@ mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
161161

162162
#endif
163163

164-
#ifndef MRB_WITHOUT_FLOAT
164+
#ifndef MRB_NO_FLOAT
165165
# include <stdint.h>
166166
# include <float.h>
167167

168168
# define MRB_FLT_RADIX FLT_RADIX
169169

170-
# ifdef MRB_USE_FLOAT
170+
# ifdef MRB_USE_FLOAT32
171171
# define MRB_FLT_MANT_DIG FLT_MANT_DIG
172172
# define MRB_FLT_EPSILON FLT_EPSILON
173173
# define MRB_FLT_DIG FLT_DIG
@@ -178,7 +178,7 @@ mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
178178
# define MRB_FLT_MAX FLT_MAX
179179
# define MRB_FLT_MAX_10_EXP FLT_MAX_10_EXP
180180

181-
# else /* not MRB_USE_FLOAT */
181+
# else /* not MRB_USE_FLOAT32 */
182182
# define MRB_FLT_MANT_DIG DBL_MANT_DIG
183183
# define MRB_FLT_EPSILON DBL_EPSILON
184184
# define MRB_FLT_DIG DBL_DIG
@@ -188,8 +188,8 @@ mrb_int_mul_overflow(mrb_int multiplier, mrb_int multiplicand, mrb_int *product)
188188
# define MRB_FLT_MAX_EXP DBL_MAX_EXP
189189
# define MRB_FLT_MAX DBL_MAX
190190
# define MRB_FLT_MAX_10_EXP DBL_MAX_10_EXP
191-
# endif /* MRB_USE_FLOAT */
192-
#endif /* MRB_WITHOUT_FLOAT */
191+
# endif /* MRB_USE_FLOAT32 */
192+
#endif /* MRB_NO_FLOAT */
193193

194194
MRB_END_DECL
195195

0 commit comments

Comments
 (0)