Skip to content

Commit fe0e2f1

Browse files
committed
wip; fix qstr processing
1 parent 0dca530 commit fe0e2f1

File tree

41 files changed

+149
-119
lines changed

Some content is hidden

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

41 files changed

+149
-119
lines changed

devices/ble_hci/common-hal/_bleio/PacketBuffer.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void common_hal_bleio_packet_buffer_construct(
101101
}
102102

103103
if (incoming) {
104-
if (!ringbuf_alloc(&self->ringbuf, buffer_size * (sizeof(uint16_t) + max_packet_size), false)) {
104+
if (!ringbuf_alloc(&self->ringbuf, buffer_size * (sizeof(uint16_t) + max_packet_size))) {
105105
mp_raise_ValueError(translate("Buffer too large and unable to allocate"));
106106
}
107107
}
@@ -110,8 +110,8 @@ void common_hal_bleio_packet_buffer_construct(
110110
self->packet_queued = false;
111111
self->pending_index = 0;
112112
self->pending_size = 0;
113-
self->outgoing[0] = m_malloc(max_packet_size, false);
114-
self->outgoing[1] = m_malloc(max_packet_size, false);
113+
self->outgoing[0] = m_malloc(max_packet_size);
114+
self->outgoing[1] = m_malloc(max_packet_size);
115115
} else {
116116
self->outgoing[0] = NULL;
117117
self->outgoing[1] = NULL;

extmod/moduselect.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,6 @@ STATIC const mp_obj_type_t mp_type_poll = {
347347
{ &mp_type_type },
348348
.flags = MP_TYPE_FLAG_EXTENDED,
349349
.name = MP_QSTR_poll,
350-
.getiter = mp_identity_getiter,
351-
.iternext = poll_iternext,
352350
.locals_dict = (void *)&poll_locals_dict,
353351
MP_TYPE_EXTENDED_FIELDS(
354352
.getiter = mp_identity_getiter,

mpy-cross/mpy-cross.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,6 @@ endif
7878
OBJ = $(PY_CORE_O)
7979
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
8080

81-
$(BUILD)/supervisor/shared/translate/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/compression.generated.h
81+
$(BUILD)/supervisor/shared/translate/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/compressed_translations.generated.h
8282

8383
include $(TOP)/py/mkrules.mk

ports/atmel-samd/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ endif
171171
# we know is ok. It's not clear how to give the compiler the info it needs so
172172
# disable the checks for now.
173173
# See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578
174+
GCCVERSIONGTEQ11 := $(shell expr `$(CC) -dumpversion` \>= 11)
175+
ifeq ($(GCC_VERSION_GTEQ_11),1)
174176
CFLAGS += -Wno-stringop-overread -Wno-stringop-overflow
177+
endif
175178

176179
LDFLAGS = $(CFLAGS) -nostartfiles -Wl,-nostdlib -Wl,-T,$(GENERATED_LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections -specs=nano.specs
177180

@@ -350,10 +353,12 @@ OBJ += $(addprefix $(BUILD)/, $(SRC_S:.s=.o))
350353
OBJ += $(addprefix $(BUILD)/, $(SRC_MOD:.c=.o))
351354

352355
SRC_QSTR += $(HEADER_BUILD)/sdiodata.h
356+
OBJ_EXTRA_ORDER_DEPS += $(HEADER_BUILD)/sioddata.h
353357
$(HEADER_BUILD)/sdiodata.h: tools/mksdiodata.py | $(HEADER_BUILD)
354358
$(Q)$(PYTHON) $< > $@
355359

356360
SRC_QSTR += $(HEADER_BUILD)/candata.h
361+
OBJ_EXTRA_ORDER_DEPS += $(HEADER_BUILD)/candata.h
357362
$(HEADER_BUILD)/candata.h: tools/mkcandata.py | $(HEADER_BUILD)
358363
$(Q)$(PYTHON) $< > $@
359364

ports/atmel-samd/common-hal/pulseio/PulseIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ void common_hal_pulseio_pulsein_construct(pulseio_pulsein_obj_t *self,
159159
mp_raise_RuntimeError(translate("EXTINT channel already in use"));
160160
}
161161

162-
self->buffer = (uint16_t *)m_malloc(maxlen * sizeof(uint16_t), false);
162+
self->buffer = (uint16_t *)m_malloc(maxlen * sizeof(uint16_t));
163163
if (self->buffer == NULL) {
164164
m_malloc_fail(maxlen * sizeof(uint16_t));
165165
}

ports/unix/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,3 +366,5 @@ install: $(PROG)
366366

367367
uninstall:
368368
-rm $(BINDIR)/$(PROG)
369+
370+
$(BUILD)/supervisor/shared/translate/translate.o: $(HEADER_BUILD)/qstrdefs.generated.h $(HEADER_BUILD)/compressed_translations.generated.h

py/circuitpy_defns.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ SRC_MOD += $(addprefix lib/mp3/src/, \
713713
subband.c \
714714
trigtabs.c \
715715
)
716-
$(BUILD)/lib/mp3/src/buffers.o: CFLAGS += -include "py/misc.h" -D'MPDEC_ALLOCATOR(x)=m_malloc(x,0)' -D'MPDEC_FREE(x)=m_free(x)'
716+
$(BUILD)/lib/mp3/src/buffers.o: CFLAGS += -include "py/misc.h" -D'MPDEC_ALLOCATOR(x)=m_malloc(x)' -D'MPDEC_FREE(x)=m_free(x)'
717717
endif
718718
ifeq ($(CIRCUITPY_RGBMATRIX),1)
719719
SRC_MOD += $(addprefix lib/protomatter/src/, \

py/makeqstrdata.py

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@
249249
"zip",
250250
]
251251

252-
253252
# this must match the equivalent function in qstr.c
254253
def compute_hash(qstr, bytes_hash):
255254
hash = 5381
@@ -351,13 +350,12 @@ def parse_input_headers(infiles):
351350
return qcfgs, qstrs, i18ns
352351

353352

354-
def escape_bytes(qstr):
353+
def escape_bytes(qstr, qbytes):
355354
if all(32 <= ord(c) <= 126 and c != "\\" and c != '"' for c in qstr):
356355
# qstr is all printable ASCII so render it as-is (for easier debugging)
357356
return qstr
358357
else:
359358
# qstr contains non-printable codes so render entire thing as hex pairs
360-
qbytes = bytes_cons(qstr, "utf8")
361359
return "".join(("\\x%02x" % b) for b in qbytes)
362360

363361

@@ -368,7 +366,7 @@ def make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr):
368366
if qlen >= (1 << (8 * cfg_bytes_len)):
369367
print("qstr is too long:", qstr)
370368
assert False
371-
qdata = escape_bytes(qstr)
369+
qdata = escape_bytes(qstr, qbytes)
372370
return '%d, %d, "%s"' % (qhash, qlen, qdata)
373371

374372

@@ -402,18 +400,10 @@ def print_qstr_data(qcfgs, qstrs, i18ns):
402400
print("// {} bytes worth of qstr".format(total_qstr_size))
403401

404402

405-
def print_qstr_enums(qstrs):
406-
# print out the starter of the generated C header file
407-
print("// This file was automatically generated by makeqstrdata.py")
408-
print("")
409-
410-
# add NULL qstr with no hash or data
411-
print("QENUM(MP_QSTRnull)")
412-
413-
# go through each qstr and print it out
414-
for order, ident, qstr in sorted(qstrs.values(), key=lambda x: x[0]):
415-
print("QENUM(MP_QSTR_%s)" % (ident,))
416403

404+
def do_work(infiles):
405+
qcfgs, qstrs, i18ns = parse_input_headers(infiles)
406+
print_qstr_data(qcfgs, qstrs, i18ns)
417407

418408
if __name__ == "__main__":
419409
import argparse
@@ -424,19 +414,7 @@ def print_qstr_enums(qstrs):
424414
parser.add_argument(
425415
"infiles", metavar="N", type=str, nargs="+", help="an integer for the accumulator"
426416
)
427-
parser.add_argument(
428-
"--output_type",
429-
default="enums",
430-
type=str,
431-
help="output definitions",
432-
choices=("enums", "data"),
433-
)
434417

435418
args = parser.parse_args()
436419

437-
qcfgs, qstrs, i18ns = parse_input_headers(args.infiles)
438-
if args.output_type == "data":
439-
i18ns = sorted(i18ns)
440-
print_qstr_data(qcfgs, qstrs, i18ns)
441-
else:
442-
print_qstr_enums(qstrs)
420+
do_work(args.infiles)

py/mkenv.mk

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ifeq ("$(origin V)", "command line")
2020
BUILD_VERBOSE=$(V)
2121
endif
2222
ifndef BUILD_VERBOSE
23-
$(info Use make V=1, make V=2 or set BUILD_VERBOSE similarly in your environment to increase build verbosity.)
23+
$(info Use make V={1,2,3} or set BUILD_VERBOSE similarly in your environment to increase build verbosity.)
2424
BUILD_VERBOSE = 0
2525
endif
2626
ifeq ($(BUILD_VERBOSE),0)
@@ -30,10 +30,19 @@ else ifeq ($(BUILD_VERBOSE),1)
3030
Q = @
3131
STEPECHO = @echo
3232
else
33+
# BUILD_VERBOSE not 0 or 1
3334
Q =
3435
STEPECHO = @echo
3536
endif
3637

38+
ifeq ($(BUILD_VERBOSE),3)
39+
# This clever shell redefinition will print out the makefile line that is causing an action.
40+
# Note that -j can cause the order to be confusing.
41+
# https://www.cmcrossroads.com/article/tracing-rule-execution-gnu-make
42+
OLD_SHELL := $(SHELL)
43+
SHELL = $(warning BUILDING $@)$(OLD_SHELL)
44+
endif
45+
3746
# default settings; can be overridden in main Makefile
3847

3948
PY_SRC ?= $(TOP)/py

py/mkrules.mk

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,25 +75,14 @@ $(Q)$(CXX) $(CXXFLAGS) -c -MD -o $@ $<
7575
$(RM) -f $(@:.o=.d)
7676
endef
7777

78-
vpath %.c . $(TOP) $(USER_C_MODULES)
78+
vpath %.c . $(TOP) $(USER_C_MODULES) $(DEVICES_MODULES)
7979
$(BUILD)/%.o: %.c
8080
$(call compile_c)
8181

8282
vpath %.cpp . $(TOP) $(USER_C_MODULES)
8383
$(BUILD)/%.o: %.cpp
8484
$(call compile_cxx)
8585

86-
QSTR_GEN_EXTRA_CFLAGS += -DNO_QSTR -x c
87-
88-
# frozen.c and frozen_mpy.c are created in $(BUILD), so use our rule
89-
# for those as well.
90-
vpath %.c . $(BUILD)
91-
$(BUILD)/%.o: %.c
92-
$(call compile_c)
93-
94-
QSTR_GEN_EXTRA_CFLAGS += -I$(BUILD)/tmp
95-
96-
vpath %.c . $(TOP) $(USER_C_MODULES) $(DEVICES_MODULES)
9786
$(BUILD)/%.pp: %.c
9887
$(ECHO) "PreProcess $<"
9988
$(Q)$(CPP) $(CFLAGS) -Wp,-C,-dD,-dI -o $@ $<
@@ -124,7 +113,7 @@ $(HEADER_BUILD)/qstr.split: $(HEADER_BUILD)/qstr.i.last
124113
$(Q)$(TOUCH) $@
125114

126115
$(QSTR_DEFS_COLLECTED): $(HEADER_BUILD)/qstr.split
127-
$(STEPECHO) "GEN $@"
116+
$(ECHO) "GEN $@"
128117
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py cat qstr _ $(HEADER_BUILD)/qstr $@
129118

130119
# Module definitions via MP_REGISTER_MODULE.
@@ -245,7 +234,4 @@ print-def:
245234
@$(CC) -E -Wp,-dM __empty__.c
246235
@$(RM) -f __empty__.c
247236

248-
tags:
249-
ctags -e -R $(TOP)
250-
251237
-include $(OBJ:.o=.P)

0 commit comments

Comments
 (0)