summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authordearblue <[email protected]>2021-08-21 15:42:57 +0900
committerdearblue <[email protected]>2021-08-21 15:42:57 +0900
commit5a576028607c4bd7b46e8b1d2726329355d4bc03 (patch)
tree9c459b43e52d4421e66ff05a3955dc3f234854a6
parent886055b3fb047839abe13b03dd44d9e35c35d5b0 (diff)
downloadmruby-5a576028607c4bd7b46e8b1d2726329355d4bc03.tar.gz
mruby-5a576028607c4bd7b46e8b1d2726329355d4bc03.zip
Organize the include of header files
- `#include <math.h>` is done in `mruby.h`. Eliminate the need to worry about the `MRB_NO_FLOAT` macro. - Include mruby header files before standard header files. If the standard header file is already placed before `mruby.h`, the standard header file added in the future tends to be placed before `mruby.h`. This change should some reduce the chances of macros that must be defined becoming undefined in C++ or including problematic header files in a particular mruby build configuration.
-rw-r--r--include/mruby.h1
-rw-r--r--mrbgems/mruby-cmath/src/cmath.c1
-rw-r--r--mrbgems/mruby-compiler/core/codegen.c5
-rw-r--r--mrbgems/mruby-complex/src/complex.c1
-rw-r--r--mrbgems/mruby-math/src/math.c1
-rw-r--r--mrbgems/mruby-numeric-ext/src/numeric_ext.c1
-rw-r--r--mrbgems/mruby-range-ext/src/range.c1
-rw-r--r--mrbgems/mruby-rational/src/rational.c1
-rw-r--r--mrbgems/mruby-sprintf/src/sprintf.c5
-rw-r--r--mrbgems/mruby-time/src/time.c4
-rw-r--r--src/dump.c4
-rw-r--r--src/load.c4
-rw-r--r--src/numeric.c6
-rw-r--r--src/string.c3
-rw-r--r--src/vm.c3
15 files changed, 9 insertions, 32 deletions
diff --git a/include/mruby.h b/include/mruby.h
index 2a6bc7753..1cee5b7a6 100644
--- a/include/mruby.h
+++ b/include/mruby.h
@@ -99,6 +99,7 @@
#include <mruby/version.h>
#ifndef MRB_NO_FLOAT
+#include <math.h>
#include <float.h>
#ifndef FLT_EPSILON
#define FLT_EPSILON (1.19209290e-07f)
diff --git a/mrbgems/mruby-cmath/src/cmath.c b/mrbgems/mruby-cmath/src/cmath.c
index 03b181840..8b0c4d04a 100644
--- a/mrbgems/mruby-cmath/src/cmath.c
+++ b/mrbgems/mruby-cmath/src/cmath.c
@@ -15,7 +15,6 @@
# error CMath conflicts with 'MRB_NO_FLOAT' configuration
#endif
-#include <math.h>
#include <complex.h>
mrb_value mrb_complex_new(mrb_state *mrb, mrb_float real, mrb_float imag);
diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c
index 3f849b0f1..4546e6cc0 100644
--- a/mrbgems/mruby-compiler/core/codegen.c
+++ b/mrbgems/mruby-compiler/core/codegen.c
@@ -4,9 +4,6 @@
** See Copyright Notice in mruby.h
*/
-#include <ctype.h>
-#include <string.h>
-#include <math.h>
#include <mruby.h>
#include <mruby/compile.h>
#include <mruby/proc.h>
@@ -19,6 +16,8 @@
#include <mruby/opcode.h>
#include <mruby/re.h>
#include <mruby/throw.h>
+#include <ctype.h>
+#include <string.h>
#ifndef MRB_CODEGEN_LEVEL_MAX
#define MRB_CODEGEN_LEVEL_MAX 1024
diff --git a/mrbgems/mruby-complex/src/complex.c b/mrbgems/mruby-complex/src/complex.c
index 286e7e38e..66176c3c1 100644
--- a/mrbgems/mruby-complex/src/complex.c
+++ b/mrbgems/mruby-complex/src/complex.c
@@ -2,7 +2,6 @@
#include <mruby/class.h>
#include <mruby/numeric.h>
#include <mruby/presym.h>
-#include <math.h>
#ifdef MRB_NO_FLOAT
# error Complex conflicts with 'MRB_NO_FLOAT' configuration
diff --git a/mrbgems/mruby-math/src/math.c b/mrbgems/mruby-math/src/math.c
index 8eccc03e5..79fdb7c6f 100644
--- a/mrbgems/mruby-math/src/math.c
+++ b/mrbgems/mruby-math/src/math.c
@@ -12,7 +12,6 @@
#include <mruby/array.h>
#include <mruby/presym.h>
-#include <math.h>
static void
domain_error(mrb_state *mrb, const char *func)
diff --git a/mrbgems/mruby-numeric-ext/src/numeric_ext.c b/mrbgems/mruby-numeric-ext/src/numeric_ext.c
index 38d297374..2f2a6c755 100644
--- a/mrbgems/mruby-numeric-ext/src/numeric_ext.c
+++ b/mrbgems/mruby-numeric-ext/src/numeric_ext.c
@@ -1,7 +1,6 @@
#include <mruby.h>
#include <mruby/numeric.h>
#include <mruby/presym.h>
-#include <math.h>
/*
* call-seq:
diff --git a/mrbgems/mruby-range-ext/src/range.c b/mrbgems/mruby-range-ext/src/range.c
index 2d021f31f..633c97b73 100644
--- a/mrbgems/mruby-range-ext/src/range.c
+++ b/mrbgems/mruby-range-ext/src/range.c
@@ -1,6 +1,5 @@
#include <mruby.h>
#include <mruby/range.h>
-#include <math.h>
static mrb_bool
r_le(mrb_state *mrb, mrb_value a, mrb_value b)
diff --git a/mrbgems/mruby-rational/src/rational.c b/mrbgems/mruby-rational/src/rational.c
index 7d099b1e2..dacce53eb 100644
--- a/mrbgems/mruby-rational/src/rational.c
+++ b/mrbgems/mruby-rational/src/rational.c
@@ -155,7 +155,6 @@ rational_new_i(mrb_state *mrb, mrb_int n, mrb_int d)
}
#ifndef MRB_NO_FLOAT
-#include <math.h>
#if defined(MRB_INT32) || defined(MRB_USE_FLOAT32)
#define frexp_rat(x,exp) frexpf((float)x, exp)
diff --git a/mrbgems/mruby-sprintf/src/sprintf.c b/mrbgems/mruby-sprintf/src/sprintf.c
index 362d24651..ba5ba4cda 100644
--- a/mrbgems/mruby-sprintf/src/sprintf.c
+++ b/mrbgems/mruby-sprintf/src/sprintf.c
@@ -5,14 +5,11 @@
*/
#include <mruby.h>
-#include <string.h>
#include <mruby/string.h>
#include <mruby/hash.h>
#include <mruby/numeric.h>
#include <mruby/presym.h>
-#ifndef MRB_NO_FLOAT
-#include <math.h>
-#endif
+#include <string.h>
#include <ctype.h>
#define BIT_DIGITS(N) (((N)*146)/485 + 1) /* log2(10) =~ 146/485 */
diff --git a/mrbgems/mruby-time/src/time.c b/mrbgems/mruby-time/src/time.c
index 99dcb2bcf..6b9762acf 100644
--- a/mrbgems/mruby-time/src/time.c
+++ b/mrbgems/mruby-time/src/time.c
@@ -4,10 +4,6 @@
** See Copyright Notice in mruby.h
*/
-#ifndef MRB_NO_FLOAT
-#include <math.h>
-#endif
-
#include <mruby.h>
#include <mruby/class.h>
#include <mruby/data.h>
diff --git a/src/dump.c b/src/dump.c
index 94d5cf74d..4327cb375 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -4,12 +4,12 @@
** See Copyright Notice in mruby.h
*/
-#include <string.h>
-#include <math.h>
+#include <mruby.h>
#include <mruby/dump.h>
#include <mruby/string.h>
#include <mruby/irep.h>
#include <mruby/debug.h>
+#include <string.h>
#ifndef MRB_NO_FLOAT
#include <mruby/endian.h>
diff --git a/src/load.c b/src/load.c
index 83e06f1f8..b5b069fcf 100644
--- a/src/load.c
+++ b/src/load.c
@@ -4,8 +4,7 @@
** See Copyright Notice in mruby.h
*/
-#include <string.h>
-#include <math.h>
+#include <mruby.h>
#include <mruby/dump.h>
#include <mruby/irep.h>
#include <mruby/proc.h>
@@ -14,6 +13,7 @@
#include <mruby/error.h>
#include <mruby/data.h>
#include <mruby/endian.h>
+#include <string.h>
#if SIZE_MAX < UINT32_MAX
# error size_t must be at least 32 bits wide
diff --git a/src/numeric.c b/src/numeric.c
index 5fbf9c586..c159c717a 100644
--- a/src/numeric.c
+++ b/src/numeric.c
@@ -4,17 +4,13 @@
** See Copyright Notice in mruby.h
*/
-#ifndef MRB_NO_FLOAT
-#include <math.h>
-#endif
-#include <string.h>
-
#include <mruby.h>
#include <mruby/array.h>
#include <mruby/numeric.h>
#include <mruby/string.h>
#include <mruby/class.h>
#include <mruby/presym.h>
+#include <string.h>
#ifndef MRB_NO_FLOAT
#ifdef MRB_USE_FLOAT32
diff --git a/src/string.c b/src/string.c
index 97e115a19..30d1bcab3 100644
--- a/src/string.c
+++ b/src/string.c
@@ -15,9 +15,6 @@
#include <mruby/string.h>
#include <mruby/numeric.h>
#include <mruby/presym.h>
-#ifndef MRB_NO_FLOAT
-#include <math.h>
-#endif
#include <string.h>
typedef struct mrb_shared_string {
diff --git a/src/vm.c b/src/vm.c
index 57531797c..50ad3b31d 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -20,9 +20,6 @@
#include <mruby/throw.h>
#include <mruby/dump.h>
#include <mruby/presym.h>
-#ifndef MRB_NO_FLOAT
-#include <math.h>
-#endif
#ifdef MRB_NO_STDIO
#if defined(__cplusplus)