From cac6dd9bcbd2f43c40cca565b7ba4928dd0b7bf8 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Tue, 3 Dec 2024 17:53:00 +0100 Subject: [PATCH] tclapi: Use older bignum API and handle external tommath for mac os --- Makefile | 3 +++ kernel/tclapi.cc | 5 ++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 5407433cf..90baa5f69 100644 --- a/Makefile +++ b/Makefile @@ -449,6 +449,9 @@ LIBS += -ltcl86 -lwsock32 -lws2_32 -lnetapi32 -lz -luserenv else CXXFLAGS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --cflags tcl || echo -I$(TCL_INCLUDE)) -DYOSYS_ENABLE_TCL LIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs tcl || echo $(TCL_LIBS)) +ifneq (,$(findstring TCL_WITH_EXTERNAL_TOMMATH,$(CXXFLAGS))) +LIBS += $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKG_CONFIG) --silence-errors --libs libtommath || echo) +endif endif endif diff --git a/kernel/tclapi.cc b/kernel/tclapi.cc index f6728be15..4516f73cf 100644 --- a/kernel/tclapi.cc +++ b/kernel/tclapi.cc @@ -210,9 +210,8 @@ bool mp_int_to_const(mp_int *a, Const &b, bool is_signed) } std::vector buf; - buf.resize(mp_ubin_size(a)); - size_t written; // dummy - mp_to_ubin(a, buf.data(), buf.size(), &written); + buf.resize(mp_unsigned_bin_size(a)); + mp_to_unsigned_bin(a, buf.data()); b.bits().reserve(mp_count_bits(a) + is_signed); for (int i = 0; i < mp_count_bits(a);) {