Skip to content

Commit 51dfcb4

Browse files
committed
py: Move to guarded includes, everywhere in py/ core.
Addresses issue adafruit#1022.
1 parent db1ac36 commit 51dfcb4

128 files changed

Lines changed: 529 additions & 818 deletions

Some content is hidden

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

py/argcheck.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,8 @@
2727
#include <stdlib.h>
2828
#include <assert.h>
2929

30-
#include "mpconfig.h"
31-
#include "nlr.h"
32-
#include "misc.h"
33-
#include "qstr.h"
34-
#include "obj.h"
35-
#include "runtime.h"
30+
#include "py/nlr.h"
31+
#include "py/runtime.h"
3632

3733
void mp_arg_check_num(mp_uint_t n_args, mp_uint_t n_kw, mp_uint_t n_args_min, mp_uint_t n_args_max, bool takes_kw) {
3834
// TODO maybe take the function name as an argument so we can print nicer error messages

py/asmarm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
#include <assert.h>
3030
#include <string.h>
3131

32-
#include "mpconfig.h"
33-
#include "misc.h"
34-
#include "asmarm.h"
32+
#include "py/mpconfig.h"
3533

3634
// wrapper around everything in this file
3735
#if MICROPY_EMIT_ARM
3836

37+
#include "py/asmarm.h"
38+
3939
#define SIGNED_FIT24(x) (((x) & 0xff800000) == 0) || (((x) & 0xff000000) == 0xff000000)
4040

4141
struct _asm_arm_t {

py/asmthumb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
#include <assert.h>
2929
#include <string.h>
3030

31-
#include "mpconfig.h"
32-
#include "misc.h"
33-
#include "asmthumb.h"
31+
#include "py/mpconfig.h"
3432

3533
// wrapper around everything in this file
3634
#if MICROPY_EMIT_THUMB || MICROPY_EMIT_INLINE_THUMB
3735

36+
#include "py/asmthumb.h"
37+
3838
#define UNSIGNED_FIT8(x) (((x) & 0xffffff00) == 0)
3939
#define UNSIGNED_FIT16(x) (((x) & 0xffff0000) == 0)
4040
#define SIGNED_FIT8(x) (((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80)

py/asmx64.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@
2929
#include <assert.h>
3030
#include <string.h>
3131

32-
#include "mpconfig.h"
33-
#include "misc.h"
32+
#include "py/mpconfig.h"
3433

3534
// wrapper around everything in this file
3635
#if MICROPY_EMIT_X64
3736

38-
#include "asmx64.h"
37+
#include "py/asmx64.h"
3938

4039
/* all offsets are measured in multiples of 8 bytes */
4140
#define WORD_SIZE (8)

py/asmx86.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@
2929
#include <assert.h>
3030
#include <string.h>
3131

32-
#include "mpconfig.h"
33-
#include "misc.h"
32+
#include "py/mpconfig.h"
3433

3534
// wrapper around everything in this file
3635
#if MICROPY_EMIT_X86
3736

38-
#include "asmx86.h"
37+
#include "py/asmx86.h"
3938

4039
/* all offsets are measured in multiples of 4 bytes */
4140
#define WORD_SIZE (4)

py/bc.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,9 @@
2929
#include <string.h>
3030
#include <assert.h>
3131

32-
#include "mpconfig.h"
33-
#include "nlr.h"
34-
#include "misc.h"
35-
#include "qstr.h"
36-
#include "obj.h"
37-
#include "objtuple.h"
38-
#include "objfun.h"
39-
#include "runtime0.h"
40-
#include "runtime.h"
41-
#include "bc.h"
42-
#include "stackctrl.h"
32+
#include "py/nlr.h"
33+
#include "py/objfun.h"
34+
#include "py/bc.h"
4335

4436
#if 0 // print debugging info
4537
#define DEBUG_PRINT (1)

py/bc.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26+
#ifndef __MICROPY_INCLUDED_PY_BC_H__
27+
#define __MICROPY_INCLUDED_PY_BC_H__
28+
29+
#include "py/runtime.h"
30+
#include "py/obj.h"
2631

2732
// Exception stack entry
2833
typedef struct _mp_exc_stack {
@@ -61,3 +66,5 @@ const byte *mp_bytecode_print_str(const byte *ip);
6166
#define MP_TAGPTR_TAG0(x) ((mp_uint_t)(x) & 1)
6267
#define MP_TAGPTR_TAG1(x) ((mp_uint_t)(x) & 2)
6368
#define MP_TAGPTR_MAKE(ptr, tag) ((void*)((mp_uint_t)(ptr) | (tag)))
69+
70+
#endif // __MICROPY_INCLUDED_PY_BC_H__

py/bc0.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26+
#ifndef __MICROPY_INCLUDED_PY_BC0_H__
27+
#define __MICROPY_INCLUDED_PY_BC0_H__
2628

2729
// Micro Python byte-codes.
2830
// The comment at the end of the line (if it exists) tells the arguments to the byte-code.
@@ -118,3 +120,5 @@
118120
#define MP_BC_STORE_FAST_MULTI (0xc0) // + N(16)
119121
#define MP_BC_UNARY_OP_MULTI (0xd0) // + op(5)
120122
#define MP_BC_BINARY_OP_MULTI (0xd5) // + op(35)
123+
124+
#endif // __MICROPY_INCLUDED_PY_BC0_H__

py/binary.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,8 @@
3030
#include <string.h>
3131
#include <assert.h>
3232

33-
#include "mpconfig.h"
34-
#include "misc.h"
35-
#include "qstr.h"
36-
#include "obj.h"
37-
#include "smallint.h"
38-
#include "binary.h"
33+
#include "py/binary.h"
34+
#include "py/smallint.h"
3935

4036
// Helpers to work with binary-encoded data
4137

py/binary.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26+
#ifndef __MICROPY_INCLUDED_PY_BINARY_H__
27+
#define __MICROPY_INCLUDED_PY_BINARY_H__
28+
29+
#include "py/obj.h"
2630

2731
// Use special typecode to differentiate repr() of bytearray vs array.array('B')
2832
// (underlyingly they're same).
@@ -36,3 +40,5 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr);
3640
void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr);
3741
long long mp_binary_get_int(mp_uint_t size, bool is_signed, bool big_endian, const byte *src);
3842
void mp_binary_set_int(mp_uint_t val_sz, bool big_endian, byte *dest, mp_uint_t val);
43+
44+
#endif // __MICROPY_INCLUDED_PY_BINARY_H__

0 commit comments

Comments
 (0)