summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_winapi.c3
-rw-r--r--Modules/clinic/posixmodule.c.h40
-rw-r--r--Modules/posixmodule.c37
3 files changed, 78 insertions, 2 deletions
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index c596cba..75d1f06 100644
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -163,6 +163,7 @@ create_converter('LPSECURITY_ATTRIBUTES', '" F_POINTER "')
create_converter('BOOL', 'i') # F_BOOL used previously (always 'i')
create_converter('DWORD', 'k') # F_DWORD is always "k" (which is much shorter)
create_converter('LPCTSTR', 's')
+create_converter('LPCWSTR', 'u')
create_converter('LPWSTR', 'u')
create_converter('UINT', 'I') # F_UINT used previously (always 'I')
@@ -186,7 +187,7 @@ class DWORD_return_converter(CReturnConverter):
data.return_conversion.append(
'return_value = Py_BuildValue("k", _return_value);\n')
[python start generated code]*/
-/*[python end generated code: output=da39a3ee5e6b4b0d input=4527052fe06e5823]*/
+/*[python end generated code: output=da39a3ee5e6b4b0d input=27456f8555228b62]*/
#include "clinic/_winapi.c.h"
diff --git a/Modules/clinic/posixmodule.c.h b/Modules/clinic/posixmodule.c.h
index e4bbd08..c41d131 100644
--- a/Modules/clinic/posixmodule.c.h
+++ b/Modules/clinic/posixmodule.c.h
@@ -3853,6 +3853,40 @@ exit:
return return_value;
}
+#if defined(__APPLE__)
+
+PyDoc_STRVAR(os__fcopyfile__doc__,
+"_fcopyfile($module, infd, outfd, flags, /)\n"
+"--\n"
+"\n"
+"Efficiently copy content or metadata of 2 regular file descriptors (OSX).");
+
+#define OS__FCOPYFILE_METHODDEF \
+ {"_fcopyfile", (PyCFunction)os__fcopyfile, METH_FASTCALL, os__fcopyfile__doc__},
+
+static PyObject *
+os__fcopyfile_impl(PyObject *module, int infd, int outfd, int flags);
+
+static PyObject *
+os__fcopyfile(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
+{
+ PyObject *return_value = NULL;
+ int infd;
+ int outfd;
+ int flags;
+
+ if (!_PyArg_ParseStack(args, nargs, "iii:_fcopyfile",
+ &infd, &outfd, &flags)) {
+ goto exit;
+ }
+ return_value = os__fcopyfile_impl(module, infd, outfd, flags);
+
+exit:
+ return return_value;
+}
+
+#endif /* defined(__APPLE__) */
+
PyDoc_STRVAR(os_fstat__doc__,
"fstat($module, /, fd)\n"
"--\n"
@@ -6414,6 +6448,10 @@ exit:
#define OS_PREADV_METHODDEF
#endif /* !defined(OS_PREADV_METHODDEF) */
+#ifndef OS__FCOPYFILE_METHODDEF
+ #define OS__FCOPYFILE_METHODDEF
+#endif /* !defined(OS__FCOPYFILE_METHODDEF) */
+
#ifndef OS_PIPE_METHODDEF
#define OS_PIPE_METHODDEF
#endif /* !defined(OS_PIPE_METHODDEF) */
@@ -6589,4 +6627,4 @@ exit:
#ifndef OS_GETRANDOM_METHODDEF
#define OS_GETRANDOM_METHODDEF
#endif /* !defined(OS_GETRANDOM_METHODDEF) */
-/*[clinic end generated code: output=8d3d9dddf254c3c2 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=b5d1ec71bc6f0651 input=a9049054013a1b77]*/
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 247af1b..24d8be6 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -97,6 +97,10 @@ corresponding Unix manual entries for more information on calls.");
#include <sys/sendfile.h>
#endif
+#if defined(__APPLE__)
+#include <copyfile.h>
+#endif
+
#ifdef HAVE_SCHED_H
#include <sched.h>
#endif
@@ -8742,6 +8746,34 @@ done:
#endif /* HAVE_SENDFILE */
+#if defined(__APPLE__)
+/*[clinic input]
+os._fcopyfile
+
+ infd: int
+ outfd: int
+ flags: int
+ /
+
+Efficiently copy content or metadata of 2 regular file descriptors (OSX).
+[clinic start generated code]*/
+
+static PyObject *
+os__fcopyfile_impl(PyObject *module, int infd, int outfd, int flags)
+/*[clinic end generated code: output=8e8885c721ec38e3 input=aeb9456804eec879]*/
+{
+ int ret;
+
+ Py_BEGIN_ALLOW_THREADS
+ ret = fcopyfile(infd, outfd, NULL, flags);
+ Py_END_ALLOW_THREADS
+ if (ret < 0)
+ return posix_error();
+ Py_RETURN_NONE;
+}
+#endif
+
+
/*[clinic input]
os.fstat
@@ -12918,6 +12950,7 @@ static PyMethodDef posix_methods[] = {
OS_UTIME_METHODDEF
OS_TIMES_METHODDEF
OS__EXIT_METHODDEF
+ OS__FCOPYFILE_METHODDEF
OS_EXECV_METHODDEF
OS_EXECVE_METHODDEF
OS_SPAWNV_METHODDEF
@@ -13537,6 +13570,10 @@ all_ins(PyObject *m)
if (PyModule_AddIntMacro(m, GRND_NONBLOCK)) return -1;
#endif
+#if defined(__APPLE__)
+ if (PyModule_AddIntConstant(m, "_COPYFILE_DATA", COPYFILE_DATA)) return -1;
+#endif
+
return 0;
}