Skip to content

Commit dc19e86

Browse files
authored
bpo-41498: Fix build on platforms without sigset_t (GH-29770)
1 parent c456dfa commit dc19e86

File tree

5 files changed

+35
-18
lines changed

5 files changed

+35
-18
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Python now compiles on platforms without ``sigset_t``. Several functions
2+
in :mod:`signal` are not available when ``sigset_t`` is missing.
3+
4+
Based on patch by Roman Yurchak for pyodide.

Modules/clinic/signalmodule.c.h

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/posixmodule.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5934,6 +5934,7 @@ parse_posix_spawn_flags(PyObject *module, const char *func_name, PyObject *setpg
59345934

59355935
}
59365936

5937+
#ifdef HAVE_SIGSET_T
59375938
if (setsigmask) {
59385939
sigset_t set;
59395940
if (!_Py_Sigset_Converter(setsigmask, &set)) {
@@ -5959,6 +5960,13 @@ parse_posix_spawn_flags(PyObject *module, const char *func_name, PyObject *setpg
59595960
}
59605961
all_flags |= POSIX_SPAWN_SETSIGDEF;
59615962
}
5963+
#else
5964+
if (setsigmask || setsigdef) {
5965+
PyErr_SetString(PyExc_NotImplementedError,
5966+
"sigset is not supported on this platform");
5967+
goto fail;
5968+
}
5969+
#endif
59625970

59635971
if (scheduler) {
59645972
#ifdef POSIX_SPAWN_SETSCHEDULER

Modules/posixmodule.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ PyAPI_FUNC(int) _Py_Gid_Converter(PyObject *, gid_t *);
2323
# define HAVE_SIGSET_T
2424
#endif
2525

26-
#ifdef HAVE_SIGSET_T
2726
PyAPI_FUNC(int) _Py_Sigset_Converter(PyObject *, void *);
28-
#endif /* HAVE_SIGSET_T */
2927
#endif /* Py_LIMITED_API */
3028

3129
#ifdef __cplusplus

Modules/signalmodule.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ module signal
6060
[clinic start generated code]*/
6161
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=b0301a3bde5fe9d3]*/
6262

63+
#ifdef HAVE_SETSIG_T
64+
6365
/*[python input]
6466
6567
class sigset_t_converter(CConverter):
@@ -68,6 +70,7 @@ class sigset_t_converter(CConverter):
6870
6971
[python start generated code]*/
7072
/*[python end generated code: output=da39a3ee5e6b4b0d input=b5689d14466b6823]*/
73+
#endif
7174

7275
/*
7376
NOTES ON THE INTERACTION BETWEEN SIGNALS AND THREADS
@@ -932,6 +935,7 @@ signal_getitimer_impl(PyObject *module, int which)
932935
#endif // HAVE_GETITIMER
933936

934937

938+
#ifdef HAVE_SIGSET_T
935939
#if defined(PYPTHREAD_SIGMASK) || defined(HAVE_SIGPENDING)
936940
static PyObject*
937941
sigset_to_set(sigset_t mask)
@@ -1063,9 +1067,9 @@ signal_sigwait_impl(PyObject *module, sigset_t sigset)
10631067
}
10641068

10651069
#endif /* #ifdef HAVE_SIGWAIT */
1070+
#endif /* #ifdef HAVE_SIGSET_T */
10661071

1067-
1068-
#if defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS)
1072+
#if (defined(HAVE_SIGFILLSET) && defined(HAVE_SIGSET_T)) || defined(MS_WINDOWS)
10691073

10701074
/*[clinic input]
10711075
signal.valid_signals
@@ -1103,7 +1107,8 @@ signal_valid_signals_impl(PyObject *module)
11031107
#endif
11041108
}
11051109

1106-
#endif /* #if defined(HAVE_SIGFILLSET) || defined(MS_WINDOWS) */
1110+
#endif /* #if (defined(HAVE_SIGFILLSET) && defined(HAVE_SIGSET_T)) || defined(MS_WINDOWS) */
1111+
11071112

11081113

11091114
#if defined(HAVE_SIGWAITINFO) || defined(HAVE_SIGTIMEDWAIT)
@@ -1168,6 +1173,7 @@ fill_siginfo(siginfo_t *si)
11681173
}
11691174
#endif
11701175

1176+
#ifdef HAVE_SIGSET_T
11711177
#ifdef HAVE_SIGWAITINFO
11721178

11731179
/*[clinic input]
@@ -1270,6 +1276,7 @@ signal_sigtimedwait_impl(PyObject *module, sigset_t sigset,
12701276
}
12711277

12721278
#endif /* #ifdef HAVE_SIGTIMEDWAIT */
1279+
#endif /* #ifdef HAVE_SIGSET_T */
12731280

12741281

12751282
#if defined(HAVE_PTHREAD_KILL)

0 commit comments

Comments
 (0)