Skip to content

Commit 9709940

Browse files
committed
Backwards compatibility fixes
- Older pythons don't know EXT_SUFFIX - Linux 4.17-4.19 know PR_GET_SPECULATION_CTRL but not PR_SPEC_INDIRECT_BRANCH
1 parent 4668eea commit 9709940

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

_prctlmodule.c

+10
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,11 @@ prctl_prctl(PyObject *self, PyObject *args)
177177
#endif
178178
#ifdef PR_GET_SPECULATION_CTRL
179179
case(PR_SET_SPECULATION_CTRL):
180+
#ifdef PR_SPEC_INDIRECT_BRANCH
180181
if(arg != PR_SPEC_STORE_BYPASS && arg != PR_SPEC_INDIRECT_BRANCH) {
182+
#else
183+
if(arg != PR_SPEC_STORE_BYPASS) {
184+
#endif
181185
PyErr_SetString(PyExc_ValueError, "Invalid speculation control setting");
182186
return NULL;
183187
}
@@ -193,7 +197,11 @@ prctl_prctl(PyObject *self, PyObject *args)
193197
}
194198
/* Intentionally not breaking */
195199
case(PR_GET_SPECULATION_CTRL):
200+
#ifdef PR_SPEC_INDIRECT_BRANCH
196201
if(arg != PR_SPEC_STORE_BYPASS && arg != PR_SPEC_INDIRECT_BRANCH) {
202+
#else
203+
if(arg != PR_SPEC_STORE_BYPASS) {
204+
#endif
197205
PyErr_SetString(PyExc_ValueError, "Invalid speculation control setting");
198206
return NULL;
199207
}
@@ -793,7 +801,9 @@ PyInit__prctl(void)
793801
#ifdef PR_SET_SPECULATION_CTRL
794802
namedattribute(SPECULATION_CTRL);
795803
namedconstant(PR_SPEC_STORE_BYPASS);
804+
#ifdef PR_SPEC_INDIRECT_BRANCH
796805
namedconstant(PR_SPEC_INDIRECT_BRANCH);
806+
#endif
797807
namedconstant(PR_SPEC_PRCTL);
798808
namedconstant(PR_SPEC_ENABLE);
799809
namedconstant(PR_SPEC_DISABLE);

test_prctl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
so = '.so'
1616
try:
1717
import sysconfig
18-
so = sysconfig.get_config_var('EXT_SUFFIX')
18+
so = sysconfig.get_config_var('EXT_SUFFIX') or sysconfig.get_config_var('SO')
1919
except ImportError:
2020
pass
2121

0 commit comments

Comments
 (0)