8000 tools/codeformat.py: Eliminate need for sizeof fixup. · yazici/micropython@8a4ce6b · GitHub
[go: up one dir, main page]

Skip to content

Commit 8a4ce6b

Browse files
dlechdpgeorge
authored andcommitted
tools/codeformat.py: Eliminate need for sizeof fixup.
This eliminates the need for the sizeof regex fixup by rearranging things a bit. All other bitfields already use the parentheses around expressions with sizeof, so one case is fixed by following this convention. VM_MAX_STATE_ON_STACK is the only remaining problem and it can be worked around by changing the order of the operands.
1 parent fccf175 commit 8a4ce6b

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed

py/mpz.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ typedef int8_t mpz_dbl_dig_signed_t;
9393
typedef struct _mpz_t {
9494
size_t neg : 1;
9595
size_t fixed_dig : 1;
96-
size_t alloc : 8 * sizeof(size_t) - 2;
96+
size_t alloc : (8 * sizeof(size_t) - 2);
9797
size_t len;
9898
mpz_dig_t *dig;
9999
} mpz_t;

py/objfun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ STATIC void dump_args(const mp_obj_t *a, size_t sz) {
188188
// With this macro you can tune the maximum number of function state bytes
189189
// that will be allocated on the stack. Any function that needs more
190190
// than this will try to use the heap, with fallback to stack allocation.
191-
#define VM_MAX_STATE_ON_STACK (11 * sizeof(mp_uint_t))
191+
#define VM_MAX_STATE_ON_STACK (sizeof(mp_uint_t) * 11)
192192

193193
#define DECODE_CODESTATE_SIZE(bytecode, n_state_out_var, state_size_out_var) \
194194
{ \

tools/codeformat.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@
7070
PY_EXTS = (".py",)
7171

7272

73-
FIXUP_REPLACEMENTS = (
74-
(re.compile("sizeof\(([a-z_]+)\) \*\(([a-z_]+)\)"), r"sizeof(\1) * (\2)"),
75-
(re.compile("([0-9]+) \*sizeof"), r"\1 * sizeof"),
76-
)
73+
FIXUP_REPLACEMENTS = ((re.compile("sizeof\(([a-z_]+)\) \*\(([a-z_]+)\)"), r"sizeof(\1) * (\2)"),)
7774

7875

7976
def list_files(paths, exclusions=None, prefix=""):

0 commit comments

Comments
 (0)
0