From 16a595004cff2237c73278528245fdf30fc4db60 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Tue, 3 Dec 2024 12:48:48 +1300 Subject: [PATCH 1/2] libs/fst: Fix Cygwin compat --- libs/fst/00_PATCH_win_io.patch | 2 +- libs/fst/fstapi.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/fst/00_PATCH_win_io.patch b/libs/fst/00_PATCH_win_io.patch index bf86794062a..a5bc989a8a4 100644 --- a/libs/fst/00_PATCH_win_io.patch +++ b/libs/fst/00_PATCH_win_io.patch @@ -43,7 +43,7 @@ * mmap compatibility */ -#if defined __MINGW32__ -+#if defined __CYGWIN__ || defined __MINGW32__ || defined _MSC_VER ++#if defined __MINGW32__ || defined _MSC_VER #include #define fstMmap(__addr,__len,__prot,__flags,__fd,__off) fstMmap2((__len), (__fd), (__off)) #define fstMunmap(__addr,__len) UnmapViewOfFile((LPCVOID)__addr) diff --git a/libs/fst/fstapi.cc b/libs/fst/fstapi.cc index 74e755d3168..a4329cf322f 100644 --- a/libs/fst/fstapi.cc +++ b/libs/fst/fstapi.cc @@ -341,7 +341,7 @@ return(NULL); /* * mmap compatibility */ -#if defined __CYGWIN__ || defined __MINGW32__ || defined _MSC_VER +#if defined __MINGW32__ || defined _MSC_VER #include #define fstMmap(__addr,__len,__prot,__flags,__fd,__off) fstMmap2((__len), (__fd), (__off)) #define fstMunmap(__addr,__len) UnmapViewOfFile((LPCVOID)__addr) From 7d8140ddea3706c6d569f241fde698d99b220315 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Tue, 3 Dec 2024 13:15:33 +1300 Subject: [PATCH 2/2] kernel/mem: Fix Cygwin compat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid error: ``` kernel/mem.cc:1683:7: error: conflicting declaration ‘using addr_t = using addr_t = uint32_t’ 1683 | using addr_t = MemContents::addr_t; | ^~~~~~ In file included from /usr/include/sys/types.h:222, from /usr/include/pthread.h:11, from /usr/lib/gcc/x86_64-pc-cygwin/12/include/c++/x86_64-pc-cygwin/bits/gthr-default.h:35, from /usr/lib/gcc/x86_64-pc-cygwin/12/include/c++/x86_64-pc-cygwin/bits/gthr.h:148, from /usr/lib/gcc/x86_64-pc-cygwin/12/include/c++/ext/atomicity.h:35, from /usr/lib/gcc/x86_64-pc-cygwin/12/include/c++/bits/cow_string.h:37, from /usr/lib/gcc/x86_64-pc-cygwin/12/include/c++/bits/basic_string.h:51, from /usr/lib/gcc/x86_64-pc-cygwin/12/include/c++/string:53, from ./kernel/yosys_common.h:27, from ./kernel/yosys.h:42, from ./kernel/mem.h:23, from kernel/mem.cc:20: /usr/include/machine/types.h:63:15: note: previous declaration as ‘typedef char* addr_t’ 63 | typedef char *addr_t; ``` According to IntelliSense, only the return types need to be prefixed with `MemContents::`, the rest are automagically using the class definition and highlight as `using Yosys::MemContents::addr_t = uint32_t`. --- kernel/mem.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/kernel/mem.cc b/kernel/mem.cc index 5e20c83eeed..67501acfdb4 100644 --- a/kernel/mem.cc +++ b/kernel/mem.cc @@ -1680,8 +1680,6 @@ SigSpec MemWr::decompress_en(const std::vector &swizzle, SigSpec sig) { return res; } -using addr_t = MemContents::addr_t; - MemContents::MemContents(Mem *mem) : MemContents(ceil_log2(mem->size), mem->width) { @@ -1758,7 +1756,7 @@ bool MemContents::_range_overlaps(std::map::iterator it, a return !(top1 < begin_addr || top2 < _range_begin(it)); } -std::map::iterator MemContents::_range_at(addr_t addr) const { +std::map::iterator MemContents::_range_at(addr_t addr) const { // allow addr == 1<<_addr_width (which will just return end()) log_assert(addr <= (addr_t)(1<<_addr_width)); // get the first range with base > addr @@ -1786,7 +1784,7 @@ RTLIL::Const MemContents::operator[](addr_t addr) const { return _default_value; } -addr_t MemContents::count_range(addr_t begin_addr, addr_t end_addr) const { +MemContents::addr_t MemContents::count_range(addr_t begin_addr, addr_t end_addr) const { addr_t count = 0; for(auto it = _range_at(begin_addr); _range_overlaps(it, begin_addr, end_addr); it++) { auto first = std::max(_range_begin(it), begin_addr); @@ -1829,7 +1827,7 @@ void MemContents::clear_range(addr_t begin_addr, addr_t end_addr) { _values.erase(begin_it, end_it); } -std::map::iterator MemContents::_reserve_range(addr_t begin_addr, addr_t end_addr) { +std::map::iterator MemContents::_reserve_range(addr_t begin_addr, addr_t end_addr) { if(begin_addr >= end_addr) return _values.end(); // need a dummy value to return, end() is cheap // find the first range containing any addr >= begin_addr - 1