From 3291f94e0731683456a2a4c530d0e354f18bfd2d Mon Sep 17 00:00:00 2001 From: Frederik Haxel Date: Fri, 12 Jan 2024 17:53:46 +0100 Subject: [PATCH] pkg: 64 bit compatibility * Added arch_64bit feature and added it to all packages that require 32 bit. * hacl, wolfssl: Fixed different types between function declaration and implementation. * lwip: Add required flag for 64 bit and bug fix in `lwip_sock`. * micro-ecc: Workaround for GCC warning when using `__int128`. --- kconfigs/Kconfig.features | 5 +++++ pkg/cifra/Kconfig | 2 +- pkg/cifra/Makefile.dep | 2 +- pkg/cn-cbor/Kconfig | 2 +- pkg/cn-cbor/Makefile.dep | 2 +- pkg/flashdb/Makefile.dep | 2 +- pkg/hacl/Kconfig | 2 +- pkg/hacl/Makefile.dep | 2 +- pkg/hacl/patches/0003-64-bit-fix.patch | Bin 0 -> 1003 bytes pkg/jerryscript/Kconfig | 2 +- pkg/jerryscript/Makefile.dep | 2 +- pkg/libhydrogen/Kconfig | 2 +- pkg/libhydrogen/Makefile.dep | 2 +- pkg/lorabasics/Makefile.dep | 2 +- pkg/lua/Kconfig | 2 +- pkg/lua/Makefile.dep | 2 +- pkg/lwip/Makefile.dep | 2 +- pkg/lwip/Makefile.include | 5 +++++ pkg/lwip/contrib/sock/lwip_sock.c | 2 +- .../patches/0001-int128-fix-for-GCC.patch | Bin 0 -> 936 bytes pkg/monocypher/Kconfig | 2 +- pkg/monocypher/Makefile.dep | 2 +- pkg/qcbor/Kconfig | 2 +- pkg/qcbor/Makefile.dep | 2 +- pkg/tinycbor/Kconfig | 2 +- pkg/tinycbor/Makefile.dep | 2 +- pkg/tinycrypt/Kconfig | 2 +- pkg/tinycrypt/Makefile.dep | 2 +- pkg/tinyusb/Kconfig | 2 +- pkg/tlsf/Kconfig | 2 +- pkg/tlsf/Makefile.dep | 2 +- pkg/uwb-dw1000/Kconfig | 2 +- pkg/uwb-dw1000/Makefile.dep | 2 +- pkg/wolfssl/Makefile.dep | 2 +- pkg/wolfssl/include/user_settings.h | 2 +- pkg/wolfssl/sock_tls/sock_tls.c | 2 +- 36 files changed, 42 insertions(+), 32 deletions(-) create mode 100644 pkg/hacl/patches/0003-64-bit-fix.patch create mode 100644 pkg/micro-ecc/patches/0001-int128-fix-for-GCC.patch diff --git a/kconfigs/Kconfig.features b/kconfigs/Kconfig.features index 7614d72a85..f7b8a7b0ce 100644 --- a/kconfigs/Kconfig.features +++ b/kconfigs/Kconfig.features @@ -22,6 +22,11 @@ config HAS_ARCH_32BIT help Indicates that the CPU has a 32-bits architecture. +config HAS_ARCH_64BIT + bool + help + Indicates that the CPU has a 64-bits architecture. + config HAS_ARCH_ARM bool help diff --git a/pkg/cifra/Kconfig b/pkg/cifra/Kconfig index 7f1b4400de..279f3ec5f2 100644 --- a/pkg/cifra/Kconfig +++ b/pkg/cifra/Kconfig @@ -8,7 +8,7 @@ config PACKAGE_CIFRA bool "Cifra cryptographic primitives" depends on TEST_KCONFIG - depends on HAS_ARCH_32BIT + depends on HAS_ARCH_32BIT || HAS_ARCH_64BIT help Cifra is a collection of cryptographic primitives targeted at embedded use. diff --git a/pkg/cifra/Makefile.dep b/pkg/cifra/Makefile.dep index 57d8d54026..bbb39611d8 100644 --- a/pkg/cifra/Makefile.dep +++ b/pkg/cifra/Makefile.dep @@ -1,2 +1,2 @@ # Cifra is only supported by 32 bit architectures -FEATURES_REQUIRED += arch_32bit +FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit diff --git a/pkg/cn-cbor/Kconfig b/pkg/cn-cbor/Kconfig index 89d0c8af9b..1c6a3ecc8b 100644 --- a/pkg/cn-cbor/Kconfig +++ b/pkg/cn-cbor/Kconfig @@ -8,7 +8,7 @@ config PACKAGE_CN-CBOR bool "Constrained Node CBOR" depends on TEST_KCONFIG - depends on HAS_ARCH_32BIT + depends on HAS_ARCH_32BIT || HAS_ARCH_64BIT select MODULE_POSIX_HEADERS help A constrained node implementation of CBOR in C. diff --git a/pkg/cn-cbor/Makefile.dep b/pkg/cn-cbor/Makefile.dep index d2baa35dfe..ff9e6dbea5 100644 --- a/pkg/cn-cbor/Makefile.dep +++ b/pkg/cn-cbor/Makefile.dep @@ -1,4 +1,4 @@ USEMODULE += posix_headers # CN-CBOR is only supported by 32 bit architectures -FEATURES_REQUIRED += arch_32bit +FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit diff --git a/pkg/flashdb/Makefile.dep b/pkg/flashdb/Makefile.dep index 98f771e1a2..e85e9b7ac8 100644 --- a/pkg/flashdb/Makefile.dep +++ b/pkg/flashdb/Makefile.dep @@ -1,5 +1,5 @@ # FlashDB is only supported by 32 bit architectures -FEATURES_REQUIRED += arch_32bit +FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit CFLAGS += -DFDB_USING_NATIVE_ASSERT ifneq (,$(filter flashdb_tsdb,$(USEMODULE))) diff --git a/pkg/hacl/Kconfig b/pkg/hacl/Kconfig index 162edb9b8c..e15e9e0e5d 100644 --- a/pkg/hacl/Kconfig +++ b/pkg/hacl/Kconfig @@ -9,4 +9,4 @@ config PACKAGE_HACL bool "High Assurance Cryptographic Library package" depends on TEST_KCONFIG depends on MODULE_RANDOM - depends on HAS_ARCH_32BIT + depends on HAS_ARCH_32BIT || HAS_ARCH_64BIT diff --git a/pkg/hacl/Makefile.dep b/pkg/hacl/Makefile.dep index f9aabaca2e..4d3de698e3 100644 --- a/pkg/hacl/Makefile.dep +++ b/pkg/hacl/Makefile.dep @@ -1,4 +1,4 @@ USEMODULE+=random # HACL is only supported by 32 bit architectures -FEATURES_REQUIRED += arch_32bit +FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit diff --git a/pkg/hacl/patches/0003-64-bit-fix.patch b/pkg/hacl/patches/0003-64-bit-fix.patch new file mode 100644 index 0000000000000000000000000000000000000000..64be9a564c6aece915437c147e31a0efed706425 GIT binary patch literal 1003 zcmZvaTaTMC5QX3UE6!uG1Zq1hPH0tS)hgPTN|m;6RTXg=h#S^KK%{Ih|9uUFEu@hE z%V%beKhLnO%4f(`5Gb__WW+PI%G7#IN|2C&@G~V7E@RGB;B$N_4W8%-p}=|AJ&>FW zwzW1PwiTsR=>s04GZpx-ZOM5AOWS^sk!q#E|;p5?y+fuo-Ug1)P_W};LR_y5% z|D>b|@%`(=w@;5h5cr67gG`?pb6uBVA0>scub1EtBpfRV8!iaRJ~BC_)*sr`R5iLZ zGiToJQ!1$2x^u=-on>&{+}cL(Mt1RN!?a2146bA()7bM!CGwsW1m}V8wIPTA=Q>~f(~8pM zC`tyPqUKbYk?oG6`einlT^};?(}}U z@= 7.0 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60040) # MSP430 boards: invalid alignment of 'hydro_random_context' -FEATURES_REQUIRED += arch_32bit +FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit diff --git a/pkg/lorabasics/Makefile.dep b/pkg/lorabasics/Makefile.dep index 08222d5ccd..afc70f28db 100644 --- a/pkg/lorabasics/Makefile.dep +++ b/pkg/lorabasics/Makefile.dep @@ -7,5 +7,5 @@ ifneq (,$(filter lorabasics_sx1280_driver,$(USEMODULE))) USEMODULE += lorabasics_driver_sx1280_hal endif # This package has assumptions that only work for 32-bit architectures -FEATURES_REQUIRED += arch_32bit +FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit USEMODULE += lorabasics_smtc_ral diff --git a/pkg/lua/Kconfig b/pkg/lua/Kconfig index 66422b3f26..925c5a62ab 100644 --- a/pkg/lua/Kconfig +++ b/pkg/lua/Kconfig @@ -8,7 +8,7 @@ config PACKAGE_LUA bool "LUA language package" depends on TEST_KCONFIG - depends on HAS_ARCH_32BIT + depends on HAS_ARCH_32BIT || HAS_ARCH_64BIT depends on !HAS_ARCH_RISCV depends on !MODULE_PICOLIBC diff --git a/pkg/lua/Makefile.dep b/pkg/lua/Makefile.dep index d2cab70e55..62104e0b47 100644 --- a/pkg/lua/Makefile.dep +++ b/pkg/lua/Makefile.dep @@ -3,7 +3,7 @@ USEMODULE += lua-contrib USEMODULE += printf_float # LUA is only supported by 32-bit architectures -FEATURES_REQUIRED += arch_32bit +FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit # LUA is not supported on RISCV because of build issues with the toolchain # (undefined reference to _times, _unlink and _link functions in provided diff --git a/pkg/lwip/Makefile.dep b/pkg/lwip/Makefile.dep index 29a1089e9e..5be5109d8b 100644 --- a/pkg/lwip/Makefile.dep +++ b/pkg/lwip/Makefile.dep @@ -1,6 +1,6 @@ # lwIP's memory management doesn't seem to work on non 32-bit platforms at the # moment. -FEATURES_REQUIRED += arch_32bit +FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit DEFAULT_MODULE += auto_init_lwip diff --git a/pkg/lwip/Makefile.include b/pkg/lwip/Makefile.include index c2fac0ad53..f5292f97a6 100644 --- a/pkg/lwip/Makefile.include +++ b/pkg/lwip/Makefile.include @@ -17,6 +17,11 @@ PSEUDOMODULES += lwip_udp PSEUDOMODULES += lwip_udplite PSEUDOMODULES += lwip_sock_async +ifneq (,$(filter arch_64bit,$(FEATURES_USED))) +# Required for platforms where sizeof(void*) > 4 + CFLAGS += -DIPV6_FRAG_COPYHEADER=1 +endif + ifneq (,$(filter lwip_contrib,$(USEMODULE))) DIRS += $(RIOTBASE)/pkg/lwip/contrib endif diff --git a/pkg/lwip/contrib/sock/lwip_sock.c b/pkg/lwip/contrib/sock/lwip_sock.c index e13d7126c6..6a52f74c01 100644 --- a/pkg/lwip/contrib/sock/lwip_sock.c +++ b/pkg/lwip/contrib/sock/lwip_sock.c @@ -616,7 +616,7 @@ ssize_t lwip_sock_sendv(struct netconn *conn, const iolist_t *snips, struct netconn *tmp; struct netbuf *buf = NULL; size_t payload_len = 0; - int res; + ssize_t res; err_t err= ERR_OK; u16_t remote_port = 0; diff --git a/pkg/micro-ecc/patches/0001-int128-fix-for-GCC.patch b/pkg/micro-ecc/patches/0001-int128-fix-for-GCC.patch new file mode 100644 index 0000000000000000000000000000000000000000..7a220b4748e868b488a3482f4d83566223690d53 GIT binary patch literal 936 zcmah{!EVz)5WVkLjMPga*RJh2j^hFN(RFz|AXOji9j@D}>AP)Tu_`QA! z6NeD092Q3--sT2lNLS4%cpkjV6}9>S zcz)a;#(o5r>$xtQHN|IKm>BMEUZ=_A9|?D#T;Y}1P{65Fh7vp|83UmN*m-3o6qOW5VP7@ z#iTO!qWFLp!*q5H3GfPQP?dpt-v*BlKM!z^55J&ohr8qCdj>#Q@T1-0D4BnxkL9eW)d!1mkIXG`=agC^r}F`+YSf0@?O5Gi&auQcwY!XQ zDFoQ|Qj+SkKeC`Wd@-pwZefTRc|k7{`J(4ILJT-Yz8eg}{*HAR1dOO0`%O3S@e2jFv@XFv~ifuNB8mI_-A5=L}9zk!g%bo)AN+5GK>hN%m%%X0uTW?ly9t RK22GYKfrva7dReczX4~XBMkrm literal 0 HcmV?d00001 diff --git a/pkg/monocypher/Kconfig b/pkg/monocypher/Kconfig index 689fbe732f..ea4992eaa4 100644 --- a/pkg/monocypher/Kconfig +++ b/pkg/monocypher/Kconfig @@ -8,7 +8,7 @@ config PACKAGE_MONOCYPHER bool "Monocypher high performance cryptographic library package" depends on TEST_KCONFIG - depends on HAS_ARCH_32BIT + depends on HAS_ARCH_32BIT || HAS_ARCH_64BIT select MODULE_MONOCYPHER_OPTIONAL help Provides functions for authenticated encryption, hashing, diff --git a/pkg/monocypher/Makefile.dep b/pkg/monocypher/Makefile.dep index 21096b0b43..be8438f947 100644 --- a/pkg/monocypher/Makefile.dep +++ b/pkg/monocypher/Makefile.dep @@ -2,4 +2,4 @@ USEMODULE += monocypher_optional # monocypher is only supported by 32 bit architectures -FEATURES_REQUIRED += arch_32bit +FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit diff --git a/pkg/qcbor/Kconfig b/pkg/qcbor/Kconfig index 016dbb9264..6ed49ee5cd 100644 --- a/pkg/qcbor/Kconfig +++ b/pkg/qcbor/Kconfig @@ -8,4 +8,4 @@ config PACKAGE_QCBOR bool "QCBOR CBOR encoder/decoder" depends on TEST_KCONFIG - depends on HAS_ARCH_32BIT + depends on HAS_ARCH_32BIT || HAS_ARCH_64BIT diff --git a/pkg/qcbor/Makefile.dep b/pkg/qcbor/Makefile.dep index bdbbad5895..ddb8a6ad1d 100644 --- a/pkg/qcbor/Makefile.dep +++ b/pkg/qcbor/Makefile.dep @@ -1 +1 @@ -FEATURES_REQUIRED += arch_32bit +FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit diff --git a/pkg/tinycbor/Kconfig b/pkg/tinycbor/Kconfig index b63d52e830..5b2778b300 100644 --- a/pkg/tinycbor/Kconfig +++ b/pkg/tinycbor/Kconfig @@ -8,7 +8,7 @@ menuconfig PACKAGE_TINYCBOR bool "Tiny CBOR encode/decoder package" depends on TEST_KCONFIG - depends on HAS_ARCH_32BIT + depends on HAS_ARCH_32BIT || HAS_ARCH_64BIT help TinyCBOR is a CBOR encoder and decoder with a very small footprint, optimized for very fast operation. diff --git a/pkg/tinycbor/Makefile.dep b/pkg/tinycbor/Makefile.dep index 10f81a15ca..b33f081360 100644 --- a/pkg/tinycbor/Makefile.dep +++ b/pkg/tinycbor/Makefile.dep @@ -1,2 +1,2 @@ # tinycbor is only supported by 32 bit architectures -FEATURES_REQUIRED += arch_32bit +FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit diff --git a/pkg/tinycrypt/Kconfig b/pkg/tinycrypt/Kconfig index afbaf3c560..e0e7a90c12 100644 --- a/pkg/tinycrypt/Kconfig +++ b/pkg/tinycrypt/Kconfig @@ -8,4 +8,4 @@ config PACKAGE_TINYCRYPT bool "TinyCrypt crypto library package" depends on TEST_KCONFIG - depends on HAS_ARCH_32BIT + depends on HAS_ARCH_32BIT || HAS_ARCH_64BIT diff --git a/pkg/tinycrypt/Makefile.dep b/pkg/tinycrypt/Makefile.dep index bdbbad5895..ddb8a6ad1d 100644 --- a/pkg/tinycrypt/Makefile.dep +++ b/pkg/tinycrypt/Makefile.dep @@ -1 +1 @@ -FEATURES_REQUIRED += arch_32bit +FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit diff --git a/pkg/tinyusb/Kconfig b/pkg/tinyusb/Kconfig index 22bf0bf29a..1d35b34855 100644 --- a/pkg/tinyusb/Kconfig +++ b/pkg/tinyusb/Kconfig @@ -32,7 +32,7 @@ choice USB_IMPLEMENTATION menuconfig PACKAGE_TINYUSB bool "TinyUSB stack package" depends on TEST_KCONFIG - depends on HAS_ARCH_32BIT + depends on HAS_ARCH_32BIT || HAS_ARCH_64BIT depends on HAS_TINYUSB_DEVICE || HAS_TINYUSB_HOST select MODULE_FMT select MODULE_LUID diff --git a/pkg/tlsf/Kconfig b/pkg/tlsf/Kconfig index 56392395c2..f6b34d41b2 100644 --- a/pkg/tlsf/Kconfig +++ b/pkg/tlsf/Kconfig @@ -8,7 +8,7 @@ menuconfig PACKAGE_TLSF bool "TLFS malloc/realloc/free/etc package" depends on TEST_KCONFIG - depends on HAS_ARCH_32BIT + depends on HAS_ARCH_32BIT || HAS_ARCH_64BIT help TLSF provides an implementation of malloc/realloc/free/etc. diff --git a/pkg/tlsf/Makefile.dep b/pkg/tlsf/Makefile.dep index 3ca354f82c..448c5d76a5 100644 --- a/pkg/tlsf/Makefile.dep +++ b/pkg/tlsf/Makefile.dep @@ -9,4 +9,4 @@ ifneq (,$(filter tlsf-malloc,$(USEMODULE))) endif # tlsf is not compatible with 8bit and 16bit architectures -FEATURES_REQUIRED += arch_32bit +FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit diff --git a/pkg/uwb-dw1000/Kconfig b/pkg/uwb-dw1000/Kconfig index 539e7d9a18..fa3cc8f2af 100644 --- a/pkg/uwb-dw1000/Kconfig +++ b/pkg/uwb-dw1000/Kconfig @@ -14,7 +14,7 @@ menuconfig PACKAGE_UWB-DW1000 select MODULE_PERIPH_GPIO_IRQ depends on HAS_PERIPH_SPI select MODULE_PERIPH_SPI - depends on HAS_ARCH_32BIT + depends on HAS_ARCH_32BIT || HAS_ARCH_64BIT if PACKAGE_UWB-DW1000 diff --git a/pkg/uwb-dw1000/Makefile.dep b/pkg/uwb-dw1000/Makefile.dep index 2f7e3f9ec4..5ea65c36dc 100644 --- a/pkg/uwb-dw1000/Makefile.dep +++ b/pkg/uwb-dw1000/Makefile.dep @@ -7,4 +7,4 @@ FEATURES_REQUIRED += periph_gpio_irq FEATURES_REQUIRED += periph_spi # Some of the pkg operation would overflow on 16bit -FEATURES_REQUIRED += arch_32bit +FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit diff --git a/pkg/wolfssl/Makefile.dep b/pkg/wolfssl/Makefile.dep index f4262b0242..9aff99de46 100644 --- a/pkg/wolfssl/Makefile.dep +++ b/pkg/wolfssl/Makefile.dep @@ -91,4 +91,4 @@ ifneq (,$(filter native,$(CPU))) endif # wolfssl is only supported by 32 bit architectures -FEATURES_REQUIRED += arch_32bit +FEATURES_REQUIRED_ANY += arch_32bit|arch_64bit diff --git a/pkg/wolfssl/include/user_settings.h b/pkg/wolfssl/include/user_settings.h index 79f58f2aca..b2602ce829 100644 --- a/pkg/wolfssl/include/user_settings.h +++ b/pkg/wolfssl/include/user_settings.h @@ -73,7 +73,7 @@ extern "C" { #endif /* defined somewhere else */ -int strncasecmp(const char *s1, const char * s2, unsigned int sz); +int strncasecmp(const char *s1, const char * s2, size_t sz); #define SINGLE_THREADED diff --git a/pkg/wolfssl/sock_tls/sock_tls.c b/pkg/wolfssl/sock_tls/sock_tls.c index 37bcbaf754..3e170cccfb 100644 --- a/pkg/wolfssl/sock_tls/sock_tls.c +++ b/pkg/wolfssl/sock_tls/sock_tls.c @@ -85,7 +85,7 @@ void sock_dtls_session_destroy(sock_tls_t *sk) #endif #include -int strncasecmp(const char *s1, const char * s2, unsigned int sz) +int strncasecmp(const char *s1, const char * s2, size_t sz) { unsigned int i; for( i = 0; i < sz; i++) {