From 59c675a64c1d9757d50ad4627da67a6f996a99fb Mon Sep 17 00:00:00 2001
From: Paul Sokolovsky <pfalcon@users.sourceforge.net>
Date: Sat, 21 Jun 2014 22:43:22 +0300
Subject: [PATCH] py: Include mpconfig.h before all other includes.

It defines types used by all other headers.

Fixes #691.
---
 py/asmthumb.c        | 2 +-
 py/asmx64.c          | 2 +-
 py/binary.c          | 2 +-
 py/builtintables.c   | 2 +-
 py/compile.c         | 2 +-
 py/emitbc.c          | 2 +-
 py/emitcommon.c      | 2 +-
 py/emitcpy.c         | 2 +-
 py/emitglue.c        | 2 +-
 py/emitinlinethumb.c | 2 +-
 py/emitnative.c      | 2 +-
 py/emitpass1.c       | 2 +-
 py/gc.c              | 1 -
 py/lexer.c           | 2 +-
 py/lexerstr.c        | 2 +-
 py/lexerunix.c       | 2 +-
 py/malloc.c          | 2 +-
 py/map.c             | 2 +-
 py/modarray.c        | 2 +-
 py/modcmath.c        | 2 +-
 py/modcollections.c  | 2 +-
 py/modgc.c           | 2 +-
 py/modio.c           | 2 +-
 py/modmath.c         | 2 +-
 py/modmicropython.c  | 2 +-
 py/modstruct.c       | 2 +-
 py/modsys.c          | 2 +-
 py/mpz.c             | 2 +-
 py/objenumerate.c    | 2 +-
 py/parse.c           | 2 +-
 py/parsehelper.c     | 2 +-
 py/parsenum.c        | 2 +-
 py/parsenumbase.c    | 2 +-
 py/pfenv.c           | 2 +-
 py/qstr.c            | 2 +-
 py/repl.c            | 2 +-
 py/scope.c           | 2 +-
 py/smallint.c        | 2 +-
 py/unicode.c         | 2 +-
 py/vstr.c            | 2 +-
 40 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/py/asmthumb.c b/py/asmthumb.c
index 891947567..03752ed93 100644
--- a/py/asmthumb.c
+++ b/py/asmthumb.c
@@ -28,8 +28,8 @@
 #include <assert.h>
 #include <string.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "asmthumb.h"
 
 // wrapper around everything in this file
diff --git a/py/asmx64.c b/py/asmx64.c
index 6c22ea25d..4695bdc73 100644
--- a/py/asmx64.c
+++ b/py/asmx64.c
@@ -29,8 +29,8 @@
 #include <assert.h>
 #include <string.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 
 // wrapper around everything in this file
 #if MICROPY_EMIT_X64
diff --git a/py/binary.c b/py/binary.c
index 833d9c85a..9eab01c4e 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -29,8 +29,8 @@
 #include <string.h>
 #include <assert.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "binary.h"
diff --git a/py/builtintables.c b/py/builtintables.c
index 66ea4ea44..8b4df9317 100644
--- a/py/builtintables.c
+++ b/py/builtintables.c
@@ -26,8 +26,8 @@
 
 #include <stdlib.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "builtin.h"
diff --git a/py/compile.c b/py/compile.c
index b9979af14..d49edd6ef 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -31,8 +31,8 @@
 #include <assert.h>
 #include <math.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "lexer.h"
 #include "parse.h"
diff --git a/py/emitbc.c b/py/emitbc.c
index 841dd4aab..3eb0d575b 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -30,8 +30,8 @@
 #include <string.h>
 #include <assert.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "lexer.h"
 #include "parse.h"
diff --git a/py/emitcommon.c b/py/emitcommon.c
index ea6518362..464979313 100644
--- a/py/emitcommon.c
+++ b/py/emitcommon.c
@@ -28,8 +28,8 @@
 #include <stdint.h>
 #include <assert.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "lexer.h"
 #include "parse.h"
diff --git a/py/emitcpy.c b/py/emitcpy.c
index a8a6265b8..fbca3805b 100644
--- a/py/emitcpy.c
+++ b/py/emitcpy.c
@@ -30,8 +30,8 @@
 #include <string.h>
 #include <assert.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "lexer.h"
 #include "parse.h"
diff --git a/py/emitglue.c b/py/emitglue.c
index f9b946083..17dc8f867 100644
--- a/py/emitglue.c
+++ b/py/emitglue.c
@@ -30,8 +30,8 @@
 #include <string.h>
 #include <assert.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "runtime0.h"
diff --git a/py/emitinlinethumb.c b/py/emitinlinethumb.c
index 8acee6c3e..435e1b64d 100644
--- a/py/emitinlinethumb.c
+++ b/py/emitinlinethumb.c
@@ -30,8 +30,8 @@
 #include <stdarg.h>
 #include <assert.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "lexer.h"
 #include "parse.h"
diff --git a/py/emitnative.c b/py/emitnative.c
index 4dac5ffb0..49acc0bb1 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -48,8 +48,8 @@
 #include <string.h>
 #include <assert.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "lexer.h"
 #include "parse.h"
diff --git a/py/emitpass1.c b/py/emitpass1.c
index 2e76420a2..bea1af4db 100644
--- a/py/emitpass1.c
+++ b/py/emitpass1.c
@@ -28,8 +28,8 @@
 #include <stdint.h>
 #include <assert.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "lexer.h"
 #include "parse.h"
diff --git a/py/gc.c b/py/gc.c
index 90b7b89e5..65bfea0b3 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -33,7 +33,6 @@
 #include "misc.h"
 #include "gc.h"
 
-#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "runtime.h"
diff --git a/py/lexer.c b/py/lexer.c
index f69c395e7..5d1113fb3 100644
--- a/py/lexer.c
+++ b/py/lexer.c
@@ -32,8 +32,8 @@
 #include <stdio.h>
 #include <assert.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "lexer.h"
 
diff --git a/py/lexerstr.c b/py/lexerstr.c
index 76e90671b..666dbfa37 100644
--- a/py/lexerstr.c
+++ b/py/lexerstr.c
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "lexer.h"
 
diff --git a/py/lexerunix.c b/py/lexerunix.c
index 89dc80b00..51bc915b2 100644
--- a/py/lexerunix.c
+++ b/py/lexerunix.c
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 
 #if MICROPY_HELPER_LEXER_UNIX
 
diff --git a/py/malloc.c b/py/malloc.c
index b180ddf6b..8e90849e9 100644
--- a/py/malloc.c
+++ b/py/malloc.c
@@ -28,8 +28,8 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 
 #if 0 // print debugging info
 #define DEBUG_printf DEBUG_printf
diff --git a/py/map.c b/py/map.c
index 402040162..dcc13c52c 100644
--- a/py/map.c
+++ b/py/map.c
@@ -27,8 +27,8 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "runtime0.h"
diff --git a/py/modarray.c b/py/modarray.c
index 2b9f531f9..3ff567f1d 100644
--- a/py/modarray.c
+++ b/py/modarray.c
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "builtin.h"
diff --git a/py/modcmath.c b/py/modcmath.c
index 14f204b8b..ddd8abf71 100644
--- a/py/modcmath.c
+++ b/py/modcmath.c
@@ -26,8 +26,8 @@
 
 #include <math.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "builtin.h"
diff --git a/py/modcollections.c b/py/modcollections.c
index 2f732085f..5cd0b317a 100644
--- a/py/modcollections.c
+++ b/py/modcollections.c
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "builtin.h"
diff --git a/py/modgc.c b/py/modgc.c
index a82a7a0eb..f136ce733 100644
--- a/py/modgc.c
+++ b/py/modgc.c
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "builtin.h"
diff --git a/py/modio.c b/py/modio.c
index e2ebc990b..ef3b29b53 100644
--- a/py/modio.c
+++ b/py/modio.c
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "builtin.h"
diff --git a/py/modmath.c b/py/modmath.c
index ff6129c5b..0d0d13b4e 100644
--- a/py/modmath.c
+++ b/py/modmath.c
@@ -26,8 +26,8 @@
 
 #include <math.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "builtin.h"
diff --git a/py/modmicropython.c b/py/modmicropython.c
index c1a293a53..bbb315189 100644
--- a/py/modmicropython.c
+++ b/py/modmicropython.c
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "builtin.h"
diff --git a/py/modstruct.c b/py/modstruct.c
index ae6cb9eb9..2e40264e8 100644
--- a/py/modstruct.c
+++ b/py/modstruct.c
@@ -27,8 +27,8 @@
 
 #include <assert.h>
 #include <string.h>
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "builtin.h"
diff --git a/py/modsys.c b/py/modsys.c
index 519d470b0..1e7f7eff7 100644
--- a/py/modsys.c
+++ b/py/modsys.c
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "builtin.h"
diff --git a/py/mpz.c b/py/mpz.c
index ab300b91d..3f1e859fc 100644
--- a/py/mpz.c
+++ b/py/mpz.c
@@ -30,8 +30,8 @@
 #include <string.h>
 #include <assert.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "mpz.h"
 
 #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ
diff --git a/py/objenumerate.c b/py/objenumerate.c
index 2fdf30b23..37414464d 100644
--- a/py/objenumerate.c
+++ b/py/objenumerate.c
@@ -27,8 +27,8 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "runtime.h"
diff --git a/py/parse.c b/py/parse.c
index af09c335f..492c1678b 100644
--- a/py/parse.c
+++ b/py/parse.c
@@ -30,8 +30,8 @@
 #include <assert.h>
 #include <string.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "lexer.h"
 #include "parsenumbase.h"
diff --git a/py/parsehelper.c b/py/parsehelper.c
index 3ead5a303..105afe711 100644
--- a/py/parsehelper.c
+++ b/py/parsehelper.c
@@ -29,8 +29,8 @@
 #include <stdint.h>
 #include <stdio.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "lexer.h"
 #include "parse.h"
diff --git a/py/parsenum.c b/py/parsenum.c
index 36b069050..b9801ab6a 100644
--- a/py/parsenum.c
+++ b/py/parsenum.c
@@ -27,8 +27,8 @@
 #include <stdbool.h>
 #include <stdlib.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "nlr.h"
 #include "obj.h"
diff --git a/py/parsenumbase.c b/py/parsenumbase.c
index ce140655b..4fddac9c3 100644
--- a/py/parsenumbase.c
+++ b/py/parsenumbase.c
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "parsenumbase.h"
 
 // find real radix base, and strip preceding '0x', '0o' and '0b'
diff --git a/py/pfenv.c b/py/pfenv.c
index e631f8654..ca1e3e919 100644
--- a/py/pfenv.c
+++ b/py/pfenv.c
@@ -27,8 +27,8 @@
 #include <stdint.h>
 #include <string.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "mpz.h"
diff --git a/py/qstr.c b/py/qstr.c
index 7ccb34f1c..10bc20ecb 100644
--- a/py/qstr.c
+++ b/py/qstr.c
@@ -27,8 +27,8 @@
 #include <assert.h>
 #include <string.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 
 // NOTE: we are using linear arrays to store and search for qstr's (unique strings, interned strings)
diff --git a/py/repl.c b/py/repl.c
index 457ce165b..2c3dfbd4d 100644
--- a/py/repl.c
+++ b/py/repl.c
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "repl.h"
 
 #if MICROPY_HELPER_REPL
diff --git a/py/scope.c b/py/scope.c
index 839e8216c..83c2b6e07 100644
--- a/py/scope.c
+++ b/py/scope.c
@@ -29,8 +29,8 @@
 #include <stdio.h>
 #include <assert.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "parse.h"
diff --git a/py/smallint.c b/py/smallint.c
index 5543f126c..c57f364e3 100644
--- a/py/smallint.c
+++ b/py/smallint.c
@@ -24,8 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 #include "qstr.h"
 #include "obj.h"
 #include "smallint.h"
diff --git a/py/unicode.c b/py/unicode.c
index c8faa5700..88f835131 100644
--- a/py/unicode.c
+++ b/py/unicode.c
@@ -26,8 +26,8 @@
 
 #include <stdint.h>
 
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 
 // attribute flags
 #define FL_PRINT (0x01)
diff --git a/py/vstr.c b/py/vstr.c
index ea6a1c937..f8b7e4dab 100644
--- a/py/vstr.c
+++ b/py/vstr.c
@@ -29,8 +29,8 @@
 #include <stdarg.h>
 #include <string.h>
 #include <assert.h>
-#include "misc.h"
 #include "mpconfig.h"
+#include "misc.h"
 
 // returned value is always at least 1 greater than argument
 #define ROUND_ALLOC(a) (((a) & ((~0) - 7)) + 8)
-- 
GitLab