summaryrefslogtreecommitdiff
path: root/debian/patches/kfreebsd-support.patch
blob: ba4fb8c1d29b735b336e955fa80cb1edfd7aa2b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
From: Sebastian Kuzminsky <seb@highlab.com>
Date: Sat, 14 May 2016 15:44:13 +0200
Subject: Change yosys to look for the #define constant "__unix__" instead of
 "__linux__",
 to select code appropriate for Unix-like systems. This has been tested with
 Clang 3.5 and GCC 4.6, 4.8, and 4.9 on Linux,
 and Clang 3.5 and GCC 4.9 on kFreeBSD.

---
 kernel/driver.cc       | 8 ++++----
 kernel/log.cc          | 6 +++---
 kernel/log.h           | 2 +-
 kernel/yosys.cc        | 4 ++--
 libs/minisat/System.cc | 2 +-
 passes/cmds/cover.cc   | 2 +-
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/kernel/driver.cc b/kernel/driver.cc
index a0bb7e6..0ea5505 100644
--- a/kernel/driver.cc
+++ b/kernel/driver.cc
@@ -34,7 +34,7 @@
 #include <limits.h>
 #include <errno.h>
 
-#if defined (__linux__) || defined(__FreeBSD__)
+#if defined (__unix__) || defined(__FreeBSD__)
 #  include <sys/resource.h>
 #  include <sys/types.h>
 #  include <unistd.h>
@@ -456,7 +456,7 @@ int main(int argc, char **argv)
 	if (print_stats)
 		log_hasher = new SHA1;
 
-#if defined(__linux__)
+#if defined(__unix__)
 	// set stack size to >= 128 MB
 	{
 		struct rlimit rl;
@@ -546,7 +546,7 @@ int main(int argc, char **argv)
 #else
 		std::string meminfo;
 		std::string stats_divider = ", ";
-#  if defined(__linux__)
+#  if defined(__unix__)
 		std::ifstream statm;
 		statm.open(stringf("/proc/%lld/statm", (long long)getpid()));
 		if (statm.is_open()) {
@@ -613,7 +613,7 @@ int main(int argc, char **argv)
 		}
 	}
 
-#if defined(YOSYS_ENABLE_COVER) && (defined(__linux__) || defined(__FreeBSD__))
+#if defined(YOSYS_ENABLE_COVER) && (defined(__unix__) || defined(__FreeBSD__))
 	if (getenv("YOSYS_COVER_DIR") || getenv("YOSYS_COVER_FILE"))
 	{
 		string filename;
diff --git a/kernel/log.cc b/kernel/log.cc
index 400a549..757a49c 100644
--- a/kernel/log.cc
+++ b/kernel/log.cc
@@ -25,7 +25,7 @@
 #  include <sys/time.h>
 #endif
 
-#if defined(__linux__) || defined(__FreeBSD__)
+#if defined(__unix__) || defined(__FreeBSD__)
 #  include <dlfcn.h>
 #endif
 
@@ -393,7 +393,7 @@ void log_pop()
 	log_flush();
 }
 
-#if (defined(__linux__) || defined(__FreeBSD__)) && defined(YOSYS_ENABLE_PLUGINS)
+#if (defined(__unix__) || defined(__FreeBSD__)) && defined(YOSYS_ENABLE_PLUGINS)
 void log_backtrace(const char *prefix, int levels)
 {
 	if (levels <= 0) return;
@@ -588,7 +588,7 @@ void log_wire(RTLIL::Wire *wire, std::string indent)
 // ---------------------------------------------------
 // This is the magic behind the code coverage counters
 // ---------------------------------------------------
-#if defined(YOSYS_ENABLE_COVER) && (defined(__linux__) || defined(__FreeBSD__))
+#if defined(YOSYS_ENABLE_COVER) && (defined(__unix__) || defined(__FreeBSD__))
 
 dict<std::string, std::pair<std::string, int>> extra_coverage_data;
 
diff --git a/kernel/log.h b/kernel/log.h
index 7599390..30f2a64 100644
--- a/kernel/log.h
+++ b/kernel/log.h
@@ -121,7 +121,7 @@ static inline void log_assert_worker(bool cond, const char *expr, const char *fi
 // This is the magic behind the code coverage counters
 // ---------------------------------------------------
 
-#if defined(YOSYS_ENABLE_COVER) && (defined(__linux__) || defined(__FreeBSD__))
+#if defined(YOSYS_ENABLE_COVER) && (defined(__unix__) || defined(__FreeBSD__))
 
 #define cover(_id) do { \
     static CoverData __d __attribute__((section("yosys_cover_list"), aligned(1), used)) = { __FILE__, __FUNCTION__, _id, __LINE__, 0 }; \
diff --git a/kernel/yosys.cc b/kernel/yosys.cc
index 450e4e4..68ba3e6 100644
--- a/kernel/yosys.cc
+++ b/kernel/yosys.cc
@@ -79,7 +79,7 @@ std::vector<void*> memhasher_store;
 
 void memhasher_on()
 {
-#if defined(__linux__) || defined(__FreeBSD__)
+#if defined(__unix__) || defined(__FreeBSD__)
 	memhasher_rng += time(NULL) << 16 ^ getpid();
 #endif
 	memhasher_store.resize(0x10000);
@@ -679,7 +679,7 @@ struct TclPass : public Pass {
 } TclPass;
 #endif
 
-#if defined(__linux__) || defined(__CYGWIN__)
+#if defined(__unix__)
 std::string proc_self_dirname()
 {
 	char path[PATH_MAX];
diff --git a/libs/minisat/System.cc b/libs/minisat/System.cc
index 1921a1d..efbfb08 100644
--- a/libs/minisat/System.cc
+++ b/libs/minisat/System.cc
@@ -29,7 +29,7 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
 
 #include "System.h"
 
-#if defined(__linux__)
+#if defined(__unix__)
 
 #include <stdlib.h>
 
diff --git a/passes/cmds/cover.cc b/passes/cmds/cover.cc
index 0ec7476..5f0042a 100644
--- a/passes/cmds/cover.cc
+++ b/passes/cmds/cover.cc
@@ -128,7 +128,7 @@ struct CoverPass : public Pass {
 			log("\n");
 		}
 
-#if defined(YOSYS_ENABLE_COVER) && (defined(__linux__) || defined(__FreeBSD__))
+#if defined(YOSYS_ENABLE_COVER) && (defined(__unix__) || defined(__FreeBSD__))
 		for (auto &it : get_coverage_data()) {
 			if (!patterns.empty()) {
 				for (auto &p : patterns)