Skip to content

Commit 6f963f5

Browse files
committed
fix(Lib/signal): not compile on Windows
1 parent 10c413c commit 6f963f5

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

src/pylib/Lib/signal_impl/state.nim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,17 @@ when (NimMajor, NimMinor, NimPatch) >= (2, 1, 1):
101101
else:
102102
using destSelf: var signal_state_t
103103

104-
proc PySignal_Fini(state: signal_state_t) =
104+
proc PySignal_Fini(destSelf) =
105105
for signum in cint(1) ..< Py_NSIG.cint:
106106
let fn = get_handler(signum)
107107
Py_atomic_store(Handlers[signum].tripped, false)
108108
set_handler(signum, nil)
109-
if not fn.isNil and fn != state.default_handler and
110-
fn != state.ignore_handler:
109+
if not fn.isNil and fn != destSelf.default_handler and
110+
fn != destSelf.ignore_handler:
111111
discard PyOS_setsig(signum, SIG_DFL)
112112
when DWin:
113113
if destSelf.sigint_event != Handle(0):
114-
closeHandle(destSelf.sigint_event)
114+
discard closeHandle(destSelf.sigint_event)
115115

116116
proc PySignal_Fini*() = PySignal_Fini state
117117

src/pylib/Python/pylifecycle/signal/c_syms.nim

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,24 @@ const
1010
when defined(windows):
1111
import std/winlean
1212
export winlean
13-
let SIGBREAK*{.importc, header: "<signal.h>".}: cint
13+
import ./handler_types
14+
template sig(sym) =
15+
let sym*{.importc, header: "<signal.h>".}: cint
16+
17+
sig SIGBREAK
18+
sig SIGABRT
19+
sig SIGFPE
20+
sig SIGILL
21+
sig SIGINT
22+
sig SIGSEGV
23+
sig SIGTERM
1424
let
1525
CTRL_C_EVENT*{.importc, header: "<Windows.h>".}: cint
1626
CTRL_BREAK_EVENT*{.importc, header: "<Windows.h>".}: cint
17-
type Sighandler = proc (a1: cint) {.cdecl.}
1827
let
19-
SIG_DFL*{.importc, header: "<signal.h>".}: Sighandler
20-
SIG_IGN*{.importc, header: "<signal.h>".}: Sighandler
28+
SIG_DFL*{.importc, header: "<signal.h>".}: CSighandler
29+
SIG_IGN*{.importc, header: "<signal.h>".}: CSighandler
30+
SIG_ERR*{.importc, header: "<signal.h>".}: CSighandler
2131
else:
2232
import std/posix except EINTR, ERANGE
2333
export posix except EINTR, ERANGE
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11

22
template ifInvalidOnVcc*(signalnum: cint, handleExc) =
33
when defined(windows):
4-
case signalnum
5-
of SIGABRT, SIGBREAK, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM: discard
4+
if signalnum in {SIGABRT, SIGBREAK, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM}: discard
65
else:
76
handleExc
87

0 commit comments

Comments
 (0)