Skip to content

Commit 5f13b69

Browse files
re-add intrcheck.c, un-break posixmodule patch
1 parent 8d60a7e commit 5f13b69

2 files changed

Lines changed: 184 additions & 3 deletions

File tree

python_build/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,18 @@ linkPY: soospatchPY
7373
cd $(PYDIR) && make $(MAKEFLAGS) LIBRARY="$(ANAME)" LDLIBRARY="$(ANAME)" $(ANAME) && cd .. && cp $(PYDIR)/$(ANAME) . && touch linkPY
7474

7575
soospatchPY: compilePY
76-
cp $(PYCONFIG_DIR)/pyconfig.h $(PYDIR)/pyconfig.h
76+
cp $(PYCONFIG_DIR)/pyconfig.h $(PYDIR)/
77+
cp $(PYCONFIG_DIR)/intrcheck.c $(PYDIR)/Parser/
7778
cp $(PYDIR)/Modules/posixmodule.c $(PYDIR)/Modules/posixmodule.c_old
78-
cat $(PYDIR)/Modules/posixmodule.c_old | sed '1s/^/#include <sys/socket.h>/' | sed 's/access(path->narrow, mode)/1/' | sed 's/\(^[^rt]*time_t atime, mtime;.*\)/return NULL; \1/' | sed 's/\(^[^ri]*i = (int)umask(i);.*\)/return NULL; \1/' | sed 's/^\([^#][^#]*#undef HAVE_FSTATVFS.*\)/\#undef HAVE_FSTATVFS \1/' | sed 's/#define HAVE_\(EXECV\|FORK\|GETEGID\|GETEUID\|GETGID\|GETPPID\|GETUID\|KILL\|PIPE\|POPEN\|SYSTEM\|TTYNAME\|SYMLINK\|UTIME_H\|FDATASYNC\).*/#undef HAVE_\1/g' | sed 's/^#define HAVE_\(STATVFS\|SYS_STATVFS_H\|FDATASYNC\|FTIME\|SYMLINK\|EXECV\|FORK\|GETEGID\|GETEUID\|GETGID\|GETPPID\|GETUID\|KILL\|PIPE\|POPEN\|SYSTEM\|TTYNAME\|SYMLINK\|UTIME_H\|FDATASYNC\).*/#undef HAVE_\1/' >$(PYDIR)/Modules/posixmodule.c
79+
cat $(PYDIR)/Modules/posixmodule.c_old | sed '1s/^/#include <sys\/socket.h>/' | sed 's/access(path->narrow, mode)/1/' | sed 's/\(^[^rt]*time_t atime, mtime;.*\)/return NULL; \1/' | sed 's/\(^[^ri]*i = (int)umask(i);.*\)/return NULL; \1/' | sed 's/^\([^#][^#]*#undef HAVE_FSTATVFS.*\)/\#undef HAVE_FSTATVFS \1/' | sed 's/#define HAVE_\(EXECV\|FORK\|GETEGID\|GETEUID\|GETGID\|GETPPID\|GETUID\|KILL\|PIPE\|POPEN\|SYSTEM\|TTYNAME\|SYMLINK\|UTIME_H\|FDATASYNC\).*/#undef HAVE_\1/g' | sed 's/^#define HAVE_\(STATVFS\|SYS_STATVFS_H\|FDATASYNC\|FTIME\|SYMLINK\|EXECV\|FORK\|GETEGID\|GETEUID\|GETGID\|GETPPID\|GETUID\|KILL\|PIPE\|POPEN\|SYSTEM\|TTYNAME\|SYMLINK\|UTIME_H\|FDATASYNC\).*/#undef HAVE_\1/' >$(PYDIR)/Modules/posixmodule.c
7980
cp $(PYDIR)/Modules/socketmodule.c $(PYDIR)/Modules/socketmodule.c_old
8081
cat $(PYDIR)/Modules/socketmodule.c_old | sed 's/send(s->sock_fd, buf, len, flags);/send(s->sock_fd, buf, len<4096?len:4096, flags);/g' | sed 's/ sizeof(addr->sa_data)/ 28/g' >$(PYDIR)/Modules/socketmodule.c
8182
cp $(PYDIR)/Objects/exceptions.c $(PYDIR)/Objects/exceptions.c_old
8283
cat $(PYDIR)/Objects/exceptions.c_old | sed 's/ESHUTDOWN/EPIPE/g' >$(PYDIR)/Objects/exceptions.c
8384
cp $(PYDIR)/Python/pytime.c $(PYDIR)/Python/pytime.c_old
8485
cat $(PYDIR)/Python/pytime.c_old | sed 's/CLOCK_MONOTONIC/(clockid_t)4/g' >$(PYDIR)/Python/pytime.c
8586
cp $(PYDIR)/Makefile $(PYDIR)/Makefile_old
86-
cat $(PYDIR)/Makefile_old | sed 's/Parser\/intrcheck.o//' | sed 's/Python\/$$(DYNLOADFILE) \\/\\/' >$(PYDIR)/Makefile
87+
cat $(PYDIR)/Makefile_old | sed 's/Python\/$$(DYNLOADFILE) \\/\\/' >$(PYDIR)/Makefile
8788
touch soospatchPY
8889

8990
compilePY: extractedPY patchPY

python_config/intrcheck.c

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
/* This file was removed from newer python versions, so it was
2+
rescued from a python 2.7 branch... */
3+
4+
/* Check for interrupts */
5+
6+
#include "Python.h"
7+
#include "pythread.h"
8+
9+
#ifdef QUICKWIN
10+
11+
#include <io.h>
12+
13+
void
14+
PyOS_InitInterrupts(void)
15+
{
16+
}
17+
18+
void
19+
PyOS_FiniInterrupts(void)
20+
{
21+
}
22+
23+
int
24+
PyOS_InterruptOccurred(void)
25+
{
26+
_wyield();
27+
}
28+
29+
#define OK
30+
31+
#endif /* QUICKWIN */
32+
33+
#if defined(_M_IX86) && !defined(__QNX__)
34+
#include <io.h>
35+
#endif
36+
37+
#if defined(MSDOS) && !defined(QUICKWIN)
38+
39+
#ifdef __GNUC__
40+
41+
/* This is for DJGPP's GO32 extender. I don't know how to trap
42+
* control-C (There's no API for ctrl-C, and I don't want to mess with
43+
* the interrupt vectors.) However, this DOES catch control-break.
44+
* --Amrit
45+
*/
46+
47+
#include <go32.h>
48+
49+
void
50+
PyOS_InitInterrupts(void)
51+
{
52+
_go32_want_ctrl_break(1 /* TRUE */);
53+
}
54+
55+
void
56+
PyOS_FiniInterrupts(void)
57+
{
58+
}
59+
60+
int
61+
PyOS_InterruptOccurred(void)
62+
{
63+
return _go32_was_ctrl_break_hit();
64+
}
65+
66+
#else /* !__GNUC__ */
67+
68+
/* This might work for MS-DOS (untested though): */
69+
70+
void
71+
PyOS_InitInterrupts(void)
72+
{
73+
}
74+
75+
void
76+
PyOS_FiniInterrupts(void)
77+
{
78+
}
79+
80+
int
81+
PyOS_InterruptOccurred(void)
82+
{
83+
int interrupted = 0;
84+
while (kbhit()) {
85+
if (getch() == '\003')
86+
interrupted = 1;
87+
}
88+
return interrupted;
89+
}
90+
91+
#endif /* __GNUC__ */
92+
93+
#define OK
94+
95+
#endif /* MSDOS && !QUICKWIN */
96+
97+
98+
#ifndef OK
99+
100+
/* Default version -- for real operating systems and for Standard C */
101+
102+
#include <stdio.h>
103+
#include <string.h>
104+
#include <signal.h>
105+
106+
static int interrupted;
107+
108+
void
109+
PyErr_SetInterrupt(void)
110+
{
111+
interrupted = 1;
112+
}
113+
114+
extern int PyErr_CheckSignals(void);
115+
116+
static int
117+
checksignals_witharg(void * arg)
118+
{
119+
return PyErr_CheckSignals();
120+
}
121+
122+
static void
123+
intcatcher(int sig)
124+
{
125+
extern void Py_Exit(int);
126+
static char message[] =
127+
"python: to interrupt a truly hanging Python program, interrupt once more.\n";
128+
switch (interrupted++) {
129+
case 0:
130+
break;
131+
case 1:
132+
#ifdef RISCOS
133+
fprintf(stderr, message);
134+
#else
135+
write(2, message, strlen(message));
136+
#endif
137+
break;
138+
case 2:
139+
interrupted = 0;
140+
Py_Exit(1);
141+
break;
142+
}
143+
PyOS_setsig(SIGINT, intcatcher);
144+
Py_AddPendingCall(checksignals_witharg, NULL);
145+
}
146+
147+
static void (*old_siginthandler)(int) = SIG_DFL;
148+
149+
void
150+
PyOS_InitInterrupts(void)
151+
{
152+
if ((old_siginthandler = PyOS_setsig(SIGINT, SIG_IGN)) != SIG_IGN)
153+
PyOS_setsig(SIGINT, intcatcher);
154+
}
155+
156+
void
157+
PyOS_FiniInterrupts(void)
158+
{
159+
PyOS_setsig(SIGINT, old_siginthandler);
160+
}
161+
162+
int
163+
PyOS_InterruptOccurred(void)
164+
{
165+
if (!interrupted)
166+
return 0;
167+
interrupted = 0;
168+
return 1;
169+
}
170+
171+
#endif /* !OK */
172+
173+
void
174+
PyOS_AfterFork(void)
175+
{
176+
#ifdef WITH_THREAD
177+
PyEval_ReInitThreads();
178+
PyThread_ReInitTLS();
179+
#endif
180+
}

0 commit comments

Comments
 (0)