Skip to content

Commit

Permalink
Merge pull request #1224 from astrelsky/free_threaded
Browse files Browse the repository at this point in the history
free threaded build
  • Loading branch information
Thrameos authored Nov 5, 2024
2 parents 9cff4e0 + 62f48c5 commit 1dca470
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions native/common/jp_tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void JPypeTracer::tracePythonObject(const char* msg, PyObject* ref)
if (ref != nullptr)
{
std::stringstream str;
str << msg << " " << (void*) ref << " " << ref->ob_refcnt << " " << Py_TYPE(ref)->tp_name;
str << msg << " " << (void*) ref << " " << Py_REFCNT(ref) << " " << Py_TYPE(ref)->tp_name;
JPypeTracer::trace1("PY", str.str().c_str());

} else
Expand Down Expand Up @@ -204,4 +204,4 @@ void JPypeTracer::traceLocks(const string& msg, void* ref)
JPYPE_TRACING_OUTPUT.flush();
}

// GCOVR_EXCL_STOP
// GCOVR_EXCL_STOP
2 changes: 1 addition & 1 deletion native/python/jp_pythontypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

static void assertValid(PyObject *obj)
{
if (obj->ob_refcnt >= 1)
if (Py_REFCNT(obj) >= 1)
return;

// GCOVR_EXCL_START
Expand Down
7 changes: 5 additions & 2 deletions native/python/pyjp_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ PyObject* PyJP_GetAttrDescriptor(PyTypeObject *type, PyObject *attr_name)
for (Py_ssize_t i = 0; i < n; ++i)
{
auto *type2 = (PyTypeObject*) PyTuple_GetItem(mro, i);

// Skip objects without a functioning dictionary
if (type2->tp_dict == NULL)
continue;
Expand Down Expand Up @@ -730,8 +730,11 @@ PyMODINIT_FUNC PyInit__jpype()
// PyJPModule = module;
Py_INCREF(module);
PyJPModule = module;
#ifdef Py_GIL_DISABLED
PyUnstable_Module_SetGIL(module, Py_MOD_GIL_NOT_USED);
#endif
PyModule_AddStringConstant(module, "__version__", "1.5.1_dev0");

// Our module will be used for PyFrame object and it is a requirement that
// we have a builtins in our dictionary.
PyObject *builtins = PyEval_GetBuiltins();
Expand Down
7 changes: 6 additions & 1 deletion setupext/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ def Platform(*, include_dirs: typing.Sequence[Path], sources: typing.Sequence[Pa
'/Zi', '/EHsc', f'/std:c++14']
else:
platform_specific['extra_compile_args'] = ['/Zi', '/EHsc']
if hasattr(sys, "_is_gil_enabled") and not sys._is_gil_enabled():
# running in free threaded build means build the free threaded one
# this is only neecessary for windows
platform_specific['define_macros'].append(('Py_GIL_DISABLED', '1'))

jni_md_platform = 'win32'

elif platform == 'darwin':
Expand All @@ -92,7 +97,7 @@ def Platform(*, include_dirs: typing.Sequence[Path], sources: typing.Sequence[Pa
elif platform.startswith('freebsd'):
distutils.log.info("Add freebsd settings")
jni_md_platform = 'freebsd'

elif platform.startswith('openbsd'):
distutils.log.info("Add openbsd settings")
jni_md_platform = 'openbsd'
Expand Down

0 comments on commit 1dca470

Please sign in to comment.