mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-85283: Build posixshmem extension with Limited C API (#111087)
Build the _multiprocessing.posixshmem extension with the Limited C API. * Add <errno.h> include. * Replace PyUnicode_AsUTF8() with PyUnicode_AsUTF8AndSize().
This commit is contained in:
parent
9376728ce4
commit
8d234cd315
4 changed files with 24 additions and 104 deletions
|
@ -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]*/
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue