FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-85283: Build posixshmem extension with Limited C API by vstinner · Pull Request #111087 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .h  (1) .rst  (2) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 3 additions & 2 deletions Doc/whatsnew/3.13.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -938,8 +938,9 @@ Build Changes
library, GCC built-in atomic functions, or MSVC interlocked intrinsics.

* The ``errno``, ``md5``, ``resource``, ``winsound``, ``_ctypes_test``,
``_scproxy``, ``_stat``, ``_testimportmultiple`` and ``_uuid`` C extensions
are now built with the :ref:`limited C API <limited-c-api>`.
``_multiprocessing.posixshmem``, ``_scproxy``, ``_stat``,
``_testimportmultiple`` and ``_uuid`` C extensions are now built with the
:ref:`limited C API <limited-c-api>`.
(Contributed by Victor Stinner in :gh:`85283`.)


Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
The ``errno``, ``md5``, ``resource``, ``winsound``, ``_ctypes_test``,
``_scproxy``, ``_stat``, ``_testimportmultiple`` and ``_uuid`` C extensions are
now built with the :ref:`limited C API <limited-c-api>`.
``_multiprocessing.posixshmem``, ``_scproxy``, ``_stat``,
``_testimportmultiple`` and ``_uuid`` C extensions are now built with the
:ref:`limited C API <limited-c-api>`.
Patch by Victor Stinner.
103 changes: 11 additions & 92 deletions Modules/_multiprocessing/clinic/posixshmem.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions Modules/_multiprocessing/posixshmem.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@
posixshmem - A Python extension that provides shm_open() and shm_unlink()
*/

// clinic/posixshmem.c.h uses internal pycore_modsupport.h API
#ifndef Py_BUILD_CORE_BUILTIN
# define Py_BUILD_CORE_MODULE 1
#endif
// Need limited C API version 3.13 for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
#define Py_LIMITED_API 0x030d0000

#include <Python.h>

// for shm_open() and shm_unlink()
#include <errno.h> // EINTR
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
# include <sys/mman.h> // shm_open(), shm_unlink()
#endif


/*[clinic input]
module _posixshmem
[clinic start generated code]*/
Expand Down Expand Up @@ -45,7 +44,7 @@ _posixshmem_shm_open_impl(PyObject *module, PyObject *path, int flags,
{
int fd;
int async_err = 0;
const char *name = PyUnicode_AsUTF8(path);
const char *name = PyUnicode_AsUTF8AndSize(path, NULL);
if (name == NULL) {
return -1;
}
Expand Down Expand Up @@ -84,7 +83,7 @@ _posixshmem_shm_unlink_impl(PyObject *module, PyObject *path)
{
int rv;
int async_err = 0;
const char *name = PyUnicode_AsUTF8(path);
const char *name = PyUnicode_AsUTF8AndSize(path, NULL);
if (name == NULL) {
return NULL;
}
Expand Down

Back | FazBrowse Home | New Git URL