Skip to content

Commit

Permalink
Centralize LONGINT_IMPL handling
Browse files Browse the repository at this point in the history
This closes adafruit#5782
  • Loading branch information
jepler committed Dec 27, 2021
1 parent 3dcebf1 commit 1d13c4c
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 82 deletions.
16 changes: 0 additions & 16 deletions ports/atmel-samd/mpconfigport.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,6 @@
# parameters that vary based on chip and/or board.
LD_TEMPLATE_FILE = boards/common.template.ld

# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk
# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers.
# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h.

ifeq ($(LONGINT_IMPL),NONE)
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=none
endif

ifeq ($(LONGINT_IMPL),MPZ)
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
endif

ifeq ($(LONGINT_IMPL),LONGLONG)
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=longlong
endif

INTERNAL_LIBM = 1

# Number of USB endpoint pairs.
Expand Down
5 changes: 0 additions & 5 deletions ports/cxd56/mpconfigport.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ USB_HIGHSPEED = 1
# Number of USB endpoint pairs.
USB_NUM_ENDPOINT_PAIRS = 6

# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk
# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers.
# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h.
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz

# Longints can be implemented as mpz, as longlong, or not
LONGINT_IMPL = MPZ

Expand Down
5 changes: 0 additions & 5 deletions ports/espressif/mpconfigport.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk
# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers.
# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h.
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz

# Internal math library is substantially smaller than toolchain one
INTERNAL_LIBM = 1

Expand Down
5 changes: 0 additions & 5 deletions ports/litex/mpconfigport.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk
# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers.
# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h.
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz

# Internal math library is substantially smaller than toolchain one
INTERNAL_LIBM = 1

Expand Down
12 changes: 0 additions & 12 deletions ports/mimxrt10xx/mpconfigport.mk
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
LD_FILE = $(FLASH).ld $(CHIP_FAMILY).ld imxrt10xx.ld

ifeq ($(LONGINT_IMPL),NONE)
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=none
endif

ifeq ($(LONGINT_IMPL),MPZ)
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
endif

ifeq ($(LONGINT_IMPL),LONGLONG)
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=longlong
endif

INTERNAL_LIBM = 1

USB_HIGHSPEED = 1
Expand Down
5 changes: 0 additions & 5 deletions ports/nrf/mpconfigport.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
# parameters that vary based on chip and/or board.
LD_TEMPLATE_FILE = boards/common.template.ld

# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk
# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers.
# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h.
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz

INTERNAL_LIBM = 1

# Number of USB endpoint pairs.
Expand Down
16 changes: 0 additions & 16 deletions ports/raspberrypi/mpconfigport.mk
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk
# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers.
# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h.

ifeq ($(LONGINT_IMPL),NONE)
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=none
endif

ifeq ($(LONGINT_IMPL),MPZ)
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
endif

ifeq ($(LONGINT_IMPL),LONGLONG)
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=longlong
endif

# All raspberrypi ports have longints.
LONGINT_IMPL = MPZ

Expand Down
1 change: 0 additions & 1 deletion ports/stm/mpconfigport.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
MPY_TOOL_LONGINT_IMPL ?= -mlongint-impl=mpz
LONGINT_IMPL ?= MPZ
INTERNAL_LIBM ?= 1

Expand Down
17 changes: 0 additions & 17 deletions py/circuitpy_defns.mk
Original file line number Diff line number Diff line change
Expand Up @@ -85,23 +85,6 @@ CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
endif


###
# Propagate longint choice from .mk to C. There's no easy string comparison
# in cpp conditionals, so we #define separate names for each.
ifeq ($(LONGINT_IMPL),NONE)
CFLAGS += -DLONGINT_IMPL_NONE
endif

ifeq ($(LONGINT_IMPL),MPZ)
CFLAGS += -DLONGINT_IMPL_MPZ
endif

ifeq ($(LONGINT_IMPL),LONGLONG)
CFLAGS += -DLONGINT_IMPL_LONGLONG
endif


###
# Select which builtin modules to compile and include.

Expand Down
28 changes: 28 additions & 0 deletions py/circuitpy_mpconfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -462,3 +462,31 @@ CFLAGS += -DCIRCUITPY_WATCHDOG=$(CIRCUITPY_WATCHDOG)

CIRCUITPY_WIFI ?= 0
CFLAGS += -DCIRCUITPY_WIFI=$(CIRCUITPY_WIFI)

# Define an equivalent for MICROPY_LONGINT_IMPL, to pass to $(MPY-TOOL) in py/mkrules.mk
# $(MPY-TOOL) needs to know what kind of longint to use (if any) to freeze long integers.
# This should correspond to the MICROPY_LONGINT_IMPL definition in mpconfigport.h.
#
# Also propagate longint choice from .mk to C. There's no easy string comparison
# in cpp conditionals, so we #define separate names for each.

ifeq ($(LONGINT_IMPL),NONE)
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=none
CFLAGS += -DLONGINT_IMPL_NONE
else ifeq ($(LONGINT_IMPL),MPZ)
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=mpz
CFLAGS += -DLONGINT_IMPL_MPZ
else ifeq ($(LONGINT_IMPL),LONGLONG)
MPY_TOOL_LONGINT_IMPL = -mlongint-impl=longlong
CFLAGS += -DLONGINT_IMPL_LONGLONG
else
$(error LONGINT_IMPL set to surprising value: "$(LONGINT_IMPL)")
endif

###
ifeq ($(LONGINT_IMPL),NONE)
else ifeq ($(LONGINT_IMPL),MPZ)
else ifeq ($(LONGINT_IMPL),LONGLONG)
else
$(error LONGINT_IMPL set to surprising value: "$(LONGINT_IMPL)")
endif

0 comments on commit 1d13c4c

Please sign in to comment.