Skip to content

Commit 63460de

Browse files
committed
second pass over diffs
1 parent 14c1815 commit 63460de

File tree

17 files changed

+37
-274
lines changed

17 files changed

+37
-274
lines changed

ports/unix/Makefile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ ifeq ($(MICROPY_PY_JNI),1)
210210
CFLAGS += -I/usr/lib/jvm/java-7-openjdk-amd64/include -DMICROPY_PY_JNI=1
211211
endif
212212

213+
# CIRCUITPY-CHANGE: CircuitPython-specific files.
213214
# source files
214215
SRC_C += \
215216
main.c \
@@ -219,15 +220,13 @@ SRC_C += \
219220
input.c \
220221
alloc.c \
221222
fatfs_port.c \
222-
mpbthciport.c \
223-
mpbtstackport_common.c \
224-
mpbtstackport_h4.c \
225-
mpbtstackport_usb.c \
226-
mpnimbleport.c \
227-
modtermios.c \
228-
modsocket.c \
229-
modffi.c \
230-
modjni.c \
223+
shared-module/os/__init__.c \
224+
supervisor/shared/settings.c \
225+
supervisor/stub/filesystem.c \
226+
supervisor/stub/safe_mode.c \
227+
supervisor/stub/stack.c \
228+
supervisor/shared/translate/translate.c \
229+
$(SRC_MOD) \
231230
$(wildcard $(VARIANT_DIR)/*.c)
232231

233232
# CIRCUITPY-CHANGE

py/binary.c

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -287,11 +287,8 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, size_t index) {
287287
#if MICROPY_PY_BUILTINS_FLOAT
288288
case 'f':
289289
return mp_obj_new_float_from_f(((float *)p)[index]);
290-
// CIRCUITPY-CHANGE:
291-
#if MICROPY_PY_DOUBLE_TYPECODE
292290
case 'd':
293291
return mp_obj_new_float_from_d(((double *)p)[index]);
294-
#endif
295292
#endif
296293
// Extension to CPython: array of objects
297294
#if MICROPY_PY_STRUCT_UNSAFE_TYPECODES
@@ -364,16 +361,13 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte *p_base, byte *
364361
float f;
365362
} fpu = {val};
366363
return mp_obj_new_float_from_f(fpu.f);
367-
// CIRCUITPY-CHANGE
368-
#if MICROPY_PY_DOUBLE_TYPECODE
369364
} else if (val_type == 'd') {
370365
union {
371366
uint64_t i;
372367
double f;
373368
} fpu = {val};
374369
return mp_obj_new_float_from_d(fpu.f);
375370
#endif
376-
#endif
377371
} else if (is_signed(val_type)) {
378372
if ((long long)MP_SMALL_INT_MIN <= val && val <= (long long)MP_SMALL_INT_MAX) {
379373
return mp_obj_new_int((mp_int_t)val);
@@ -503,12 +497,10 @@ void mp_binary_set_val_array(char typecode, void *p, size_t index, mp_obj_t val_
503497
case 'f':
504498
((float *)p)[index] = mp_obj_get_float_to_f(val_in);
505499
break;
506-
#if MICROPY_PY_DOUBLE_TYPECODE
507500
case 'd':
508501
((double *)p)[index] = mp_obj_get_float_to_d(val_in);
509502
break;
510503
#endif
511-
#endif
512504
#if MICROPY_PY_STRUCT_UNSAFE_TYPECODES
513505
// Extension to CPython: array of objects
514506
case 'O':
@@ -577,12 +569,9 @@ void mp_binary_set_val_array_from_int(char typecode, void *p, size_t index, mp_i
577569
case 'f':
578570
((float *)p)[index] = (float)val;
579571
break;
580-
// CIRCUITPY-CHANGE
581-
#if MICROPY_PY_DOUBLE_TYPECODE
582572
case 'd':
583573
((double *)p)[index] = (double)val;
584574
break;
585-
#endif
586575
#endif
587576
// Extension to CPython: array of pointers
588577
#if MICROPY_PY_STRUCT_UNSAFE_TYPECODES

py/dynruntime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static inline void *mp_obj_malloc_helper_dyn(size_t num_bytes, const mp_obj_type
289289

290290
#define nlr_raise(o) (mp_raise_dyn(o))
291291
#define mp_raise_type_arg(type, arg) (mp_raise_dyn(mp_obj_new_exception_arg1_dyn((type), (arg))))
292-
// CIRCUITPY-CHANGE: use str
292+
// CIRCUITPY-CHANGE: use mp_raise_msg_str
293293
#define mp_raise_msg(type, msg) (mp_fun_table.raise_msg_str((type), (msg)))
294294
#define mp_raise_OSError(er) (mp_raise_OSError_dyn(er))
295295
#define mp_raise_NotImplementedError(msg) (mp_raise_msg(&mp_type_NotImplementedError, (msg)))

py/makeqstrdefs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ def qstr_unescape(qstr):
137137
return qstr
138138

139139

140+
# CIRCUITPY-CHANGE: output_filename as an arg
140141
def process_file(f, output_filename=None):
141142
# match gcc-like output (# n "file") and msvc-like output (#line n "file")
142143
re_line = re.compile(r"^#(?:line)?\s+\d+\s\"([^\"]+)\"")
@@ -290,6 +291,7 @@ class Args:
290291
args.input_filename = sys.argv[3] # Unused for command=cat
291292
args.output_dir = sys.argv[4]
292293
args.output_file = None if len(sys.argv) == 5 else sys.argv[5] # Unused for command=split
294+
# CIRCUITPY-CHANGE
293295
if args.output_file == "_":
294296
args.output_file = None
295297

@@ -304,6 +306,7 @@ class Args:
304306

305307
if args.command == "split":
306308
with io.open(args.input_filename, encoding="utf-8") as infile:
309+
# CIRCUITPY-CHANGE: pass output_file
307310
process_file(infile, args.output_file)
308311

309312
if args.command == "cat":

py/malloc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* THE SOFTWARE.
2525
*/
2626

27+
#include <stdbool.h>
2728
#include <stdio.h>
2829
#include <stdlib.h>
2930
#include <string.h>

py/misc.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,24 @@
3535
#include <stdbool.h>
3636
#include <stdint.h>
3737
#include <stddef.h>
38+
#if __cplusplus // Required on at least one compiler to get ULLONG_MAX
39+
#include <climits>
40+
#else
41+
#include <limits.h>
42+
#endif
3843

3944
typedef unsigned char byte;
4045
typedef unsigned int uint;
4146

47+
#ifndef __has_builtin
48+
#define __has_builtin(x) (0)
49+
#endif
50+
#ifndef __has_feature
51+
// This macro is supported by Clang and gcc>=14
52+
#define __has_feature(x) (0)
53+
#endif
54+
55+
4256
/** generic ops *************************************************/
4357

4458
#ifndef MIN

py/mpconfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2387,7 +2387,7 @@ typedef time_t mp_timestamp_t;
23872387
#endif // INT_FMT
23882388

23892389
#if !MICROPY_PREVIEW_VERSION_2
2390-
#define MP_NORETURN MP_NORETURN
2390+
#define NORETURN MP_NORETURN
23912391
#endif
23922392

23932393
// Modifier for weak functions

py/objtype.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1086,7 +1086,7 @@ static mp_obj_t type_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp
10861086

10871087
if (!MP_OBJ_TYPE_HAS_SLOT(self, make_new)) {
10881088
#if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
1089-
mp_raise_TypeError(MP_ERROR_TEXT("cannot create instance"));
1089+
mp_raise_TypeError(MP_ERROR_TEXT("can't create instance"));
10901090
#else
10911091
// CIRCUITPY-CHANGE: more specific mp_raise
10921092
mp_raise_TypeError_varg(MP_ERROR_TEXT("can't create '%q' instances"), self->name);

py/py.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ PY_CORE_O_BASENAME = $(addprefix py/,\
191191
objnamedtuple.o \
192192
objrange.o \
193193
objreversed.o \
194+
objringio.o \
194195
objset.o \
195196
objsingleton.o \
196197
objslice.o \

py/sequence.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,10 @@
3434
#define SWAP(type, var1, var2) { type t = var2; var2 = var1; var1 = t; }
3535

3636
// CIRCUITPY-CHANGE: detect sequence overflow
37-
#if __GNUC__ < 5
38-
// n.b. does not actually detect overflow!
39-
#define __builtin_mul_overflow(a, b, x) (*(x) = (a) * (b), false)
40-
#endif
41-
4237
// Detect when a multiply causes an overflow.
4338
size_t mp_seq_multiply_len(size_t item_sz, size_t len) {
4439
size_t new_len;
45-
if (__builtin_mul_overflow(item_sz, len, &new_len)) {
40+
if (mp_mul_mp_int_t_overflow(item_sz, len, &new_len)) {
4641
mp_raise_msg(&mp_type_OverflowError, MP_ERROR_TEXT("small int overflow"));
4742
}
4843
return new_len;

0 commit comments

Comments
 (0)