Skip to content

Commit 4c307bf

Browse files
committed
all: Move BYTES_PER_WORD definition from ports to py/mpconfig.h
It can still be overwritten by a port in mpconfigport.h but for almost all cases one can use the provided default.
1 parent 64d0051 commit 4c307bf

File tree

16 files changed

+5
-28
lines changed

16 files changed

+5
-28
lines changed

bare-arm/mpconfigport.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@
4646

4747
// type definitions for the specific machine
4848

49-
#define BYTES_PER_WORD (4)
50-
5149
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1))
5250

5351
#define UINT_FMT "%lu"

cc3200/mpconfigport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ extern const struct _mp_obj_module_t mp_module_ussl;
200200

201201

202202
// type definitions for the specific machine
203-
#define BYTES_PER_WORD (4)
204203
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1))
205204
#define MP_SSIZE_MAX (0x7FFFFFFF)
206205

esp8266/mpconfigport.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@
118118

119119
// type definitions for the specific machine
120120

121-
#define BYTES_PER_WORD (4)
122-
123121
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p)))
124122

125123
#define MP_SSIZE_MAX (0x7fffffff)

examples/embedding/mpconfigport_minimal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,6 @@ typedef int mp_int_t; // must be pointer size
119119
typedef unsigned int mp_uint_t; // must be pointer size
120120
#endif
121121

122-
#define BYTES_PER_WORD sizeof(mp_int_t)
123-
124122
// Cannot include <sys/types.h>, as it may lead to symbol name clashes
125123
#if _FILE_OFFSET_BITS == 64 && !defined(__LP64__)
126124
typedef long long mp_off_t;

minimal/mpconfigport.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757

5858
// type definitions for the specific machine
5959

60-
#define BYTES_PER_WORD (4)
61-
6260
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1))
6361

6462
// This port is intended to be 32-bit, but unfortunately, int32_t for

mpy-cross/mpconfigport.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ typedef int mp_int_t; // must be pointer size
100100
typedef unsigned int mp_uint_t; // must be pointer size
101101
#endif
102102

103-
#define BYTES_PER_WORD sizeof(mp_int_t)
104-
105103
// Cannot include <sys/types.h>, as it may lead to symbol name clashes
106104
#if _FILE_OFFSET_BITS == 64 && !defined(__LP64__)
107105
typedef long long mp_off_t;

pic16bit/mpconfigport.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
// type definitions for the specific machine
6969

7070
#define MP_ENDIANNESS_LITTLE (1)
71-
#define BYTES_PER_WORD (2)
7271
#define MPZ_DIG_SIZE (8)
7372

7473
// The xc16 compiler doesn't seem to respect alignment (!!) so we

py/mpconfig.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,11 @@ typedef double mp_float_t;
11051105
#define STATIC static
11061106
#endif
11071107

1108+
// Number of bytes in a word
1109+
#ifndef BYTES_PER_WORD
1110+
#define BYTES_PER_WORD (sizeof(mp_uint_t))
1111+
#endif
1112+
11081113
#define BITS_PER_BYTE (8)
11091114
#define BITS_PER_WORD (BITS_PER_BYTE * BYTES_PER_WORD)
11101115
// mp_int_t value with most significant bit set

qemu-arm/mpconfigport.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939

4040
// type definitions for the specific machine
4141

42-
#define BYTES_PER_WORD (4)
43-
4442
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1))
4543

4644
#define MP_SSIZE_MAX (0x7fffffff)

stmhal/mpconfigport.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,6 @@ extern const struct _mp_obj_module_t mp_module_network;
264264

265265
// type definitions for the specific machine
266266

267-
#define BYTES_PER_WORD (4)
268-
269267
#define MICROPY_MAKE_POINTER_CALLABLE(p) ((void*)((mp_uint_t)(p) | 1))
270268

271269
#define MP_SSIZE_MAX (0x7fffffff)

0 commit comments

Comments
 (0)