Skip to content

Commit

Permalink
Merge branch 'YosysHQ:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
akashlevy authored Nov 7, 2024
2 parents 0d57928 + 3c30a9a commit 0e3adb3
Show file tree
Hide file tree
Showing 12 changed files with 9,132 additions and 6,644 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ vcxsrc: $(GENFILES) $(EXTRA_TARGETS)
rm -rf yosys-win32-vcxsrc-$(YOSYS_VER){,.zip}
set -e; for f in `ls $(filter %.cc %.cpp,$(GENFILES)) $(addsuffix .cc,$(basename $(OBJS))) $(addsuffix .cpp,$(basename $(OBJS))) 2> /dev/null`; do \
echo "Analyse: $$f" >&2; cpp -std=c++17 -MM -I. -D_YOSYS_ $$f; done | sed 's,.*:,,; s,//*,/,g; s,/[^/]*/\.\./,/,g; y, \\,\n\n,;' | grep '^[^/]' | sort -u | grep -v kernel/version_ > srcfiles.txt
echo "libs/fst/fst_win_unistd.h" >> srcfiles.txt
bash misc/create_vcxsrc.sh yosys-win32-vcxsrc $(YOSYS_VER) $(GIT_REV)
echo "namespace Yosys { extern const char *yosys_version_str; const char *yosys_version_str=\"Yosys (Version Information Unavailable)\"; }" > kernel/version.cc
zip yosys-win32-vcxsrc-$(YOSYS_VER)/genfiles.zip $(GENFILES) kernel/version.cc
Expand Down
58 changes: 58 additions & 0 deletions libs/fst/00_PATCH_win_io.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
--- fst_win_unistd.h
+++ fst_win_unistd.h
@@ -26,7 +26,7 @@
#define WIN_UNISTD_H

#include <stdlib.h>
-#ifdef _WIN64
+#if defined(_MSC_VER)
#include <io.h>
#else
#include <sys/io.h>
--- fstapi.cc
+++ fstapi.cc
@@ -56,7 +56,7 @@
#include <pthread.h>
#endif

-#ifdef __MINGW32__
+#if defined __CYGWIN__ || defined __MINGW32__ || defined _MSC_VER
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif
@@ -137,7 +137,7 @@ void **JenkinsIns(void *base_i, const unsigned char *mem, uint32_t length, uint3
#include <sys/sysctl.h>
#endif

-#if defined(FST_MACOSX) || defined(__MINGW32__) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(FST_MACOSX) || defined(__MINGW32__) || defined(_MSC_VER) || defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__NetBSD__)
#define FST_UNBUFFERED_IO
#endif

@@ -159,7 +159,7 @@ void **JenkinsIns(void *base_i, const unsigned char *mem, uint32_t length, uint3
/*** ***/
/***********************/

-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_MSC_VER)
#include <io.h>
#ifndef HAVE_FSEEKO
#define ftello _ftelli64
@@ -341,7 +341,7 @@ return(NULL);
/*
* mmap compatibility
*/
-#if defined __MINGW32__
+#if defined __CYGWIN__ || defined __MINGW32__ || defined _MSC_VER
#include <limits.h>
#define fstMmap(__addr,__len,__prot,__flags,__fd,__off) fstMmap2((__len), (__fd), (__off))
#define fstMunmap(__addr,__len) UnmapViewOfFile((LPCVOID)__addr)
@@ -4638,7 +4638,7 @@ if(sectype == FST_BL_ZWRAPPER)
#endif

fstReaderFseeko(xc, xc->f, FST_ZWRAPPER_HDR_SIZE, SEEK_SET);
-#ifndef __MINGW32__
+#if !defined(__MINGW32__) && !defined(_MSC_VER)
fflush(xc->f);
#else
/* Windows UCRT runtime library reads one byte ahead in the file
16 changes: 16 additions & 0 deletions libs/fst/00_PATCH_win_zlib.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--- fstapi.h
+++ fstapi.h
@@ -33,11 +33,12 @@ extern "C" {
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-#include <zlib.h>
#include <inttypes.h>
#if defined(_MSC_VER)
+ #include "libs/zlib/zlib.h"
#include "fst_win_unistd.h"
#else
+ #include <zlib.h>
#include <unistd.h>
#endif
#include <time.h>
19 changes: 19 additions & 0 deletions libs/fst/00_UPDATE.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

mv config.h config.h.bak
rm -f *.txt *.cc *.h
git clone --depth 1 https://github.com/gtkwave/gtkwave fst_upstream
rm fst_upstream/lib/libfst/CMakeLists.txt
mv fst_upstream/lib/libfst/*.{h,c,txt} .
rm -rf fst_upstream

for src in *.c; do
mv -- "$src" "${src%.c}.cc"
done
mv config.h.bak config.h

sed -i -e 's,<config.h>,"config.h",' *.cc *.h
sed -i -e 's,"fastlz.c","fastlz.cc",' *.cc *.h

patch -p0 < 00_PATCH_win_zlib.patch
patch -p0 < 00_PATCH_win_io.patch
Loading

0 comments on commit 0e3adb3

Please sign in to comment.