aboutsummaryrefslogtreecommitdiffstats
path: root/backends
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2018-08-15 14:00:19 +0200
committerGitHub <noreply@github.com>2018-08-15 14:00:19 +0200
commitdfc0c8ffc84d66d99aa90d104dcc8ad6623ae1c2 (patch)
treefbe9aaf25130dd9ad98f18f0321c5ee4afb209ca /backends
parentd70830a1be15073215d33dc674d8e36e142f7aac (diff)
parent0caa62802ccb3ee67e05c948a9e334504cae9cc4 (diff)
downloadyosys-dfc0c8ffc84d66d99aa90d104dcc8ad6623ae1c2.tar.gz
yosys-dfc0c8ffc84d66d99aa90d104dcc8ad6623ae1c2.tar.bz2
yosys-dfc0c8ffc84d66d99aa90d104dcc8ad6623ae1c2.zip
Merge pull request #576 from cr1901/no-resource
Gate POSIX-only signals and resource module to only run on POSIX Pyth…
Diffstat (limited to 'backends')
-rw-r--r--backends/smt2/smtio.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/backends/smt2/smtio.py b/backends/smt2/smtio.py
index 1a8d2484c..3fc823e3e 100644
--- a/backends/smt2/smtio.py
+++ b/backends/smt2/smtio.py
@@ -17,7 +17,9 @@
#
import sys, re, os, signal
-import resource, subprocess
+import subprocess
+if os.name == "posix":
+ import resource
from copy import deepcopy
from select import select
from time import time
@@ -27,12 +29,13 @@ from threading import Thread
# This is needed so that the recursive SMT2 S-expression parser
# does not run out of stack frames when parsing large expressions
-smtio_reclimit = 64 * 1024
-smtio_stacksize = 128 * 1024 * 1024
-if sys.getrecursionlimit() < smtio_reclimit:
- sys.setrecursionlimit(smtio_reclimit)
-if resource.getrlimit(resource.RLIMIT_STACK)[0] < smtio_stacksize:
- resource.setrlimit(resource.RLIMIT_STACK, (smtio_stacksize, -1))
+if os.name == "posix":
+ smtio_reclimit = 64 * 1024
+ smtio_stacksize = 128 * 1024 * 1024
+ if sys.getrecursionlimit() < smtio_reclimit:
+ sys.setrecursionlimit(smtio_reclimit)
+ if resource.getrlimit(resource.RLIMIT_STACK)[0] < smtio_stacksize:
+ resource.setrlimit(resource.RLIMIT_STACK, (smtio_stacksize, -1))
# currently running solvers (so we can kill them)
@@ -51,8 +54,9 @@ def force_shutdown(signum, frame):
os.kill(p.pid, signal.SIGTERM)
sys.exit(1)
+if os.name == "posix":
+ signal.signal(signal.SIGHUP, force_shutdown)
signal.signal(signal.SIGINT, force_shutdown)
-signal.signal(signal.SIGHUP, force_shutdown)
signal.signal(signal.SIGTERM, force_shutdown)
def except_hook(exctype, value, traceback):
@@ -1053,4 +1057,3 @@ class MkVcd:
print("b0 %s" % self.nets[path][0], file=self.f)
else:
print("b1 %s" % self.nets[path][0], file=self.f)
-