* [gentoo-commits] proj/portage:master commit in: src/
@ 2017-05-14 18:08 Zac Medico
0 siblings, 0 replies; 9+ messages in thread
From: Zac Medico @ 2017-05-14 18:08 UTC (permalink / raw
To: gentoo-commits
commit: a3c87da25dc1944e6b7720e304318ae5474dff95
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed May 10 06:25:01 2017 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun May 14 18:07:44 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=a3c87da2
file_copy: fix lseek offset after EINTR (bug 618086)
Fix the lseek offset for the plain read/write loop to account
for buffered data that has not been written to to the output
file yet (due to previous interruption by EINTR). This code
only affects Linux 2.6.32 and earlier (newer kernels use
copy_file_range or sendfile).
X-Gentoo-bug: 618086
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=618086
Acked-by: Brian Dolbec <dolsen <AT> gentoo.org>
src/portage_util_file_copy_reflink_linux.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/portage_util_file_copy_reflink_linux.c b/src/portage_util_file_copy_reflink_linux.c
index 2fb17a0f5..4be9e0568 100644
--- a/src/portage_util_file_copy_reflink_linux.c
+++ b/src/portage_util_file_copy_reflink_linux.c
@@ -323,12 +323,14 @@ _reflink_linux_file_copy(PyObject *self, PyObject *args)
if (buf == NULL) {
error = errno;
- /* For the read call, the fd_in file offset must be
- * exactly equal to offset_out. Use lseek to ensure
- * correct state, in case an EINTR retry caused it to
- * get out of sync somewhow.
+ /* For the read call, the fd_in file offset must be exactly
+ * equal to offset_out + buf_bytes, where buf_bytes is the
+ * amount of buffered data that has not been written to
+ * to the output file yet. Use lseek to ensure correct state,
+ * in case an EINTR retry caused it to get out of sync
+ * somewhow.
*/
- } else if (lseek(fd_in, offset_out, SEEK_SET) < 0) {
+ } else if (lseek(fd_in, offset_out + buf_bytes, SEEK_SET) < 0) {
error = errno;
} else {
while (1) {
@@ -345,6 +347,7 @@ _reflink_linux_file_copy(PyObject *self, PyObject *args)
} else if (buf_bytes < 0) {
error = errno;
+ buf_bytes = 0;
break;
}
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/portage:master commit in: src/
@ 2017-10-27 18:50 Zac Medico
0 siblings, 0 replies; 9+ messages in thread
From: Zac Medico @ 2017-10-27 18:50 UTC (permalink / raw
To: gentoo-commits
commit: 5b6cf172e378f6da88e9634aa4e89f2f34390659
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 23 01:55:36 2017 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Oct 27 18:38:02 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=5b6cf172
file_copy: use sendfile return value to measure bytes copied (bug 635126)
The sendfile *offset parameter refers to the input file offest, so
it cannot be used in the same way as the copy_file_range *off_out
parameter. Therefore, add sf_wrapper function which implements the
*off_out behavior for sendfile.
Also update cfr_wrapper so that it does not rely on the fd_in file
offset, and remove corresponding fd_in lseek calls which are no
longer needed.
The file offset of fd_in is now completely unused, except in the
plain read/write loop, where lseek is called prior to entering
the loop.
Bug: https://bugs.gentoo.org/635126
src/portage_util_file_copy_reflink_linux.c | 99 ++++++++++++++++++------------
1 file changed, 59 insertions(+), 40 deletions(-)
diff --git a/src/portage_util_file_copy_reflink_linux.c b/src/portage_util_file_copy_reflink_linux.c
index 4be9e0568..c3ce26b2b 100644
--- a/src/portage_util_file_copy_reflink_linux.c
+++ b/src/portage_util_file_copy_reflink_linux.c
@@ -56,12 +56,18 @@ initreflink_linux(void)
/**
* cfr_wrapper - A copy_file_range syscall wrapper function, having a
- * function signature that is compatible with sendfile.
+ * function signature that is compatible with sf_wrapper.
* @fd_out: output file descriptor
* @fd_in: input file descriptor
- * @off_out: offset of the output file
+ * @off_out: must point to a buffer that specifies the starting offset
+ * where bytes will be copied to fd_out, and this buffer is adjusted by
+ * the number of bytes copied.
* @len: number of bytes to copy between the file descriptors
*
+ * Bytes are copied from fd_in starting from *off_out, and the file
+ * offset of fd_in is not changed. Effects on the file offset of
+ * fd_out are undefined.
+ *
* Return: Number of bytes written to out_fd on success, -1 on failure
* (errno is set appropriately).
*/
@@ -69,7 +75,8 @@ static ssize_t
cfr_wrapper(int fd_out, int fd_in, off_t *off_out, size_t len)
{
#ifdef __NR_copy_file_range
- return syscall(__NR_copy_file_range, fd_in, NULL, fd_out,
+ off_t off_in = *off_out;
+ return syscall(__NR_copy_file_range, fd_in, &off_in, fd_out,
off_out, len, 0);
#else
/* This is how it fails at runtime when the syscall is not supported. */
@@ -79,18 +86,50 @@ cfr_wrapper(int fd_out, int fd_in, off_t *off_out, size_t len)
}
/**
+ * sf_wrapper - A sendfile wrapper function, having a function signature
+ * that is compatible with cfr_wrapper.
+ * @fd_out: output file descriptor
+ * @fd_in: input file descriptor
+ * @off_out: must point to a buffer that specifies the starting offset
+ * where bytes will be copied to fd_out, and this buffer is adjusted by
+ * the number of bytes copied.
+ * @len: number of bytes to copy between the file descriptors
+ *
+ * Bytes are copied from fd_in starting from *off_out, and the file
+ * offset of fd_in is not changed. Effects on the file offset of
+ * fd_out are undefined.
+ *
+ * Return: Number of bytes written to out_fd on success, -1 on failure
+ * (errno is set appropriately).
+ */
+static ssize_t
+sf_wrapper(int fd_out, int fd_in, off_t *off_out, size_t len)
+{
+ ssize_t ret;
+ off_t off_in = *off_out;
+ /* The sendfile docs do not specify behavior of the output file
+ * offset, therefore it must be adjusted with lseek.
+ */
+ if (lseek(fd_out, *off_out, SEEK_SET) < 0)
+ return -1;
+ ret = sendfile(fd_out, fd_in, &off_in, len);
+ if (ret > 0)
+ *off_out += ret;
+ return ret;
+}
+
+
+/**
* do_lseek_data - Adjust file offsets to the next location containing
* data, creating sparse empty blocks in the output file as needed.
* @fd_in: input file descriptor
* @fd_out: output file descriptor
* @off_out: offset of the output file
*
- * Use lseek SEEK_DATA to adjust the fd_in file offset to the next
- * location containing data, and adjust the fd_in file offset and
- * off_out to the same location (creating sparse empty blocks as
- * needed). On success, both fd_in and fd_out file offsets are
- * guaranteed to be exactly equal to the value that off_out points to.
- *
+ * Use lseek SEEK_DATA to adjust off_out to the next location from fd_in
+ * containing data (creates sparse empty blocks when appropriate). Effects
+ * on file offsets are undefined.
+ *
* Return: On success, the number of bytes to copy before the next hole,
* and -1 on failure (errno is set appropriately). Returns 0 when fd_in
* reaches EOF.
@@ -145,13 +184,6 @@ do_lseek_data(int fd_out, int fd_in, off_t *off_out) {
return -1;
}
- /* Revert SEEK_HOLE offset change, since we're going
- * to copy the data that comes before the hole.
- */
- if (lseek(fd_in, offset_data, SEEK_SET) < 0) {
- return -1;
- }
-
return offset_hole - offset_data;
#else
/* This is how it fails at runtime when lseek SEEK_DATA is not supported. */
@@ -232,10 +264,6 @@ _reflink_linux_file_copy(PyObject *self, PyObject *args)
break;
}
- /* For the copyfunc call, the fd_in file offset must be
- * exactly equal to offset_out. The above do_lseek_data
- * function guarantees correct state.
- */
copyfunc_ret = copyfunc(fd_out,
fd_in,
&offset_out,
@@ -250,7 +278,7 @@ _reflink_linux_file_copy(PyObject *self, PyObject *args)
* syscall is not available (less than Linux 4.5).
*/
error = 0;
- copyfunc = sendfile;
+ copyfunc = sf_wrapper;
copyfunc_ret = copyfunc(fd_out,
fd_in,
&offset_out,
@@ -284,27 +312,18 @@ _reflink_linux_file_copy(PyObject *self, PyObject *args)
} else {
stat_in_acquired = 1;
- /* For the sendfile call, the fd_in file offset must be
- * exactly equal to offset_out. Use lseek to ensure
- * correct state, in case an EINTR retry caused it to
- * get out of sync somewhow.
- */
- if (lseek(fd_in, offset_out, SEEK_SET) < 0) {
- error = errno;
- } else {
- while (offset_out < stat_in.st_size) {
- copyfunc_ret = sendfile(fd_out,
- fd_in,
- &offset_out,
- stat_in.st_size - offset_out);
+ while (offset_out < stat_in.st_size) {
+ copyfunc_ret = sf_wrapper(fd_out,
+ fd_in,
+ &offset_out,
+ stat_in.st_size - offset_out);
- if (copyfunc_ret < 0) {
- error = errno;
- if (errno == EINVAL && !offset_out) {
- sendfile_works = 0;
- }
- break;
+ if (copyfunc_ret < 0) {
+ error = errno;
+ if (errno == EINVAL && !offset_out) {
+ sendfile_works = 0;
}
+ break;
}
}
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/portage:master commit in: src/
@ 2017-12-15 21:17 Zac Medico
0 siblings, 0 replies; 9+ messages in thread
From: Zac Medico @ 2017-12-15 21:17 UTC (permalink / raw
To: gentoo-commits
commit: 58d44d3f4549a45eac1ec9cc99d497bb104438c3
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 15 21:16:05 2017 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Dec 15 21:16:16 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=58d44d3f
file_copy: handle EOPNOTSUPP from lseek SEEK_DATA (bug 641088)
NFS can set the errno to EOPNOTSUPP for lseek SEEK_DATA.
Bug: https://bugs.gentoo.org/641088
src/portage_util_file_copy_reflink_linux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/portage_util_file_copy_reflink_linux.c b/src/portage_util_file_copy_reflink_linux.c
index c3ce26b2b..81aae873a 100644
--- a/src/portage_util_file_copy_reflink_linux.c
+++ b/src/portage_util_file_copy_reflink_linux.c
@@ -258,7 +258,7 @@ _reflink_linux_file_copy(PyObject *self, PyObject *args)
break;
} else if (len < 0) {
error = errno;
- if (errno == EINVAL && !offset_out) {
+ if ((errno == EINVAL || errno == EOPNOTSUPP) && !offset_out) {
lseek_works = 0;
}
break;
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/portage:master commit in: src/
@ 2017-12-16 0:38 Zac Medico
0 siblings, 0 replies; 9+ messages in thread
From: Zac Medico @ 2017-12-16 0:38 UTC (permalink / raw
To: gentoo-commits
commit: dad9cce8a1e2360e8483e0f78e29e20bd5fdce49
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 16 00:37:40 2017 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Dec 16 00:38:18 2017 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=dad9cce8
file_copy: handle EOPNOTSUPP from copy_file_range (bug 641088)
NFS can set the errno to EOPNOTSUPP for copy_file_range.
Bug: https://bugs.gentoo.org/641088
src/portage_util_file_copy_reflink_linux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/portage_util_file_copy_reflink_linux.c b/src/portage_util_file_copy_reflink_linux.c
index 81aae873a..352342c06 100644
--- a/src/portage_util_file_copy_reflink_linux.c
+++ b/src/portage_util_file_copy_reflink_linux.c
@@ -271,7 +271,7 @@ _reflink_linux_file_copy(PyObject *self, PyObject *args)
if (copyfunc_ret < 0) {
error = errno;
- if ((errno == EXDEV || errno == ENOSYS) &&
+ if ((errno == EXDEV || errno == ENOSYS || errno == EOPNOTSUPP) &&
copyfunc == cfr_wrapper) {
/* Use sendfile instead of copy_file_range for
* cross-device copies, or when the copy_file_range
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/portage:master commit in: src/
@ 2020-12-25 0:28 Mike Gilbert
0 siblings, 0 replies; 9+ messages in thread
From: Mike Gilbert @ 2020-12-25 0:28 UTC (permalink / raw
To: gentoo-commits
commit: ff72973264827cbde7ba642a22e5d0579eeeb57a
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 24 18:11:22 2020 +0000
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Fri Dec 25 00:26:02 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=ff729732
Drop Python 2 compatibility in extension modules
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
src/portage_util_file_copy_reflink_linux.c | 10 +---------
src/portage_util_libc.c | 10 +---------
2 files changed, 2 insertions(+), 18 deletions(-)
diff --git a/src/portage_util_file_copy_reflink_linux.c b/src/portage_util_file_copy_reflink_linux.c
index 352342c06..c6affe57a 100644
--- a/src/portage_util_file_copy_reflink_linux.c
+++ b/src/portage_util_file_copy_reflink_linux.c
@@ -1,4 +1,4 @@
-/* Copyright 2017 Gentoo Foundation
+/* Copyright 2017-2020 Gentoo Authors
* Distributed under the terms of the GNU General Public License v2
*/
@@ -25,7 +25,6 @@ static PyMethodDef reflink_linuxMethods[] = {
{NULL, NULL, 0, NULL}
};
-#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"reflink_linux", /* m_name */
@@ -45,13 +44,6 @@ PyInit_reflink_linux(void)
m = PyModule_Create(&moduledef);
return m;
}
-#else
-PyMODINIT_FUNC
-initreflink_linux(void)
-{
- Py_InitModule("reflink_linux", reflink_linuxMethods);
-}
-#endif
/**
diff --git a/src/portage_util_libc.c b/src/portage_util_libc.c
index 977b95474..2a3e624dc 100644
--- a/src/portage_util_libc.c
+++ b/src/portage_util_libc.c
@@ -1,4 +1,4 @@
-/* Copyright 2005-2016 Gentoo Foundation
+/* Copyright 2005-2020 Gentoo Authors
* Distributed under the terms of the GNU General Public License v2
*/
@@ -15,7 +15,6 @@ static PyMethodDef LibcMethods[] = {
{NULL, NULL, 0, NULL}
};
-#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"libc", /* m_name */
@@ -35,13 +34,6 @@ PyInit_libc(void)
m = PyModule_Create(&moduledef);
return m;
}
-#else
-PyMODINIT_FUNC
-initlibc(void)
-{
- Py_InitModule("libc", LibcMethods);
-}
-#endif
static PyObject *
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/portage:master commit in: src/
@ 2021-12-12 1:14 Zac Medico
0 siblings, 0 replies; 9+ messages in thread
From: Zac Medico @ 2021-12-12 1:14 UTC (permalink / raw
To: gentoo-commits
commit: fe2e58325ffd1d4424564998f64bed4cb4ab8ffa
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 11 20:40:04 2021 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Dec 12 01:14:13 2021 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=fe2e5832
file_copy: handle zero bytes copied by copy_file_range (bug 828844)
When copy_file_range copied zero bytes, fall back to sendfile,
so that we don't call copy_file_range in an infinite loop.
Bug: https://bugs.gentoo.org/828844
Tested-by: John Helmert III <ajak <AT> gentoo.org>
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
src/portage_util_file_copy_reflink_linux.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/portage_util_file_copy_reflink_linux.c b/src/portage_util_file_copy_reflink_linux.c
index c6affe57a..b00b57952 100644
--- a/src/portage_util_file_copy_reflink_linux.c
+++ b/src/portage_util_file_copy_reflink_linux.c
@@ -261,13 +261,14 @@ _reflink_linux_file_copy(PyObject *self, PyObject *args)
&offset_out,
len);
- if (copyfunc_ret < 0) {
+ if (copyfunc_ret <= 0) {
error = errno;
- if ((errno == EXDEV || errno == ENOSYS || errno == EOPNOTSUPP) &&
+ if ((errno == EXDEV || errno == ENOSYS || errno == EOPNOTSUPP || copyfunc_ret == 0) &&
copyfunc == cfr_wrapper) {
/* Use sendfile instead of copy_file_range for
* cross-device copies, or when the copy_file_range
- * syscall is not available (less than Linux 4.5).
+ * syscall is not available (less than Linux 4.5),
+ * or when copy_file_range copies zero bytes.
*/
error = 0;
copyfunc = sf_wrapper;
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/portage:master commit in: src/
@ 2023-06-07 7:29 Sam James
0 siblings, 0 replies; 9+ messages in thread
From: Sam James @ 2023-06-07 7:29 UTC (permalink / raw
To: gentoo-commits
commit: 22e027aef2ddb49d1c4e2423b5b1f3c209ac8efe
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 7 07:25:34 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed Jun 7 07:25:34 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=22e027ae
src: fix comment whitespace
Signed-off-by: Sam James <sam <AT> gentoo.org>
src/portage_util_file_copy_reflink_linux.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/portage_util_file_copy_reflink_linux.c b/src/portage_util_file_copy_reflink_linux.c
index f0badc0e9..74ba4a010 100644
--- a/src/portage_util_file_copy_reflink_linux.c
+++ b/src/portage_util_file_copy_reflink_linux.c
@@ -1,4 +1,4 @@
-/* Copyright 2017-2020 Gentoo Authors
+/* Copyright 2017-2023 Gentoo Authors
* Distributed under the terms of the GNU General Public License v2
*/
@@ -195,7 +195,7 @@ do_lseek_data(int fd_out, int fd_in, off_t *off_out) {
* If a syscall is interrupted by a signal, then the function will
* automatically resume copying a the appropriate location which is
* tracked internally by the offset_out variable.
- *
+ *
* Return: The length of the output file on success. Raise OSError
* on failure.
*/
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/portage:master commit in: src/
@ 2023-08-02 15:50 Mike Gilbert
0 siblings, 0 replies; 9+ messages in thread
From: Mike Gilbert @ 2023-08-02 15:50 UTC (permalink / raw
To: gentoo-commits
commit: 8cc2348a2c0706f57962fee09a91c5a5b85f1b99
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 2 15:21:26 2023 +0000
Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Wed Aug 2 15:26:01 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=8cc2348a
_reflink_linux_file_copy: initialize error to 0
Avoids a compiler warning:
```
../src/portage_util_file_copy_reflink_linux.c: In function ‘_reflink_linux_file_copy’:
../src/portage_util_file_copy_reflink_linux.c:379:12: warning: ‘error’ may be used uninitialized [-Wmaybe-uninitialized]
379 | if (!error && ftruncate(fd_out, offset_out) < 0)
| ^
../src/portage_util_file_copy_reflink_linux.c:205:22: note: ‘error’ was declared here
205 | int eintr_retry, error, fd_in, fd_out, stat_in_acquired, stat_out_acquired;
| ^~~~~
```
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>
src/portage_util_file_copy_reflink_linux.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/portage_util_file_copy_reflink_linux.c b/src/portage_util_file_copy_reflink_linux.c
index 74ba4a010..e98db3db8 100644
--- a/src/portage_util_file_copy_reflink_linux.c
+++ b/src/portage_util_file_copy_reflink_linux.c
@@ -214,6 +214,7 @@ _reflink_linux_file_copy(PyObject *self, PyObject *args)
return NULL;
eintr_retry = 1;
+ error = 0;
offset_out = 0;
stat_in_acquired = 0;
stat_out_acquired = 0;
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/portage:master commit in: src/
@ 2024-06-28 18:16 Zac Medico
0 siblings, 0 replies; 9+ messages in thread
From: Zac Medico @ 2024-06-28 18:16 UTC (permalink / raw
To: gentoo-commits
commit: 918f4a4aa82f47291deac496d13c2761f306e01f
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 16 19:44:37 2024 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Fri Jun 28 18:15:38 2024 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=918f4a4a
Allow GIL to be disabled in whirlpool C extension
In 3.13 python extensions need to declare support for GIL features, for
example if they don't declare Py_MOD_GIL_NOT_USED then it will cause the
GIL to be enabled even when python was launched in free-threaded mode.
This requires "multi-phase initialization" because Py_mod_create is
incompatible with m_slots. There's a PyUnstable_Module_SetGIL() function
that can be used with single-phase init, but it's an unstable API, so
it's better to use multi-phase init. There's no need to use
PyModule_GetState() because the whirlpool module has no mutable state.
Bug: https://bugs.gentoo.org/934220
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
src/portage_util__whirlpool.c | 46 +++++++++++++++++++++++++++----------------
1 file changed, 29 insertions(+), 17 deletions(-)
diff --git a/src/portage_util__whirlpool.c b/src/portage_util__whirlpool.c
index 6c9421e56b..4af9307c71 100644
--- a/src/portage_util__whirlpool.c
+++ b/src/portage_util__whirlpool.c
@@ -1112,30 +1112,42 @@ static PyTypeObject WhirlpoolType = {
.tp_methods = Whirlpool_methods,
};
+static int
+whirlpool_exec(PyObject *mod)
+{
+ if (PyType_Ready(&WhirlpoolType) < 0)
+ return -1;
+
+ Py_INCREF(&WhirlpoolType);
+ if (PyModule_AddObject(mod, "Whirlpool", (PyObject *) &WhirlpoolType) < 0) {
+ Py_DECREF(&WhirlpoolType);
+ return -1;
+ }
+
+ return 0;
+}
+
+static PyModuleDef_Slot _whirlpoolmodule_slots[] = {
+ {Py_mod_exec, whirlpool_exec},
+#ifdef Py_MOD_PER_INTERPRETER_GIL_SUPPORTED
+ {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
+#endif
+#ifdef Py_MOD_GIL_NOT_USED
+ {Py_mod_gil, Py_MOD_GIL_NOT_USED},
+#endif
+ {0, NULL},
+};
+
static PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
.m_name = "_whirlpool",
.m_doc = "Reference Whirlpool implementation",
- .m_size = -1,
+ .m_size = 0,
+ .m_slots = _whirlpoolmodule_slots,
};
PyMODINIT_FUNC
PyInit__whirlpool(void)
{
- PyObject *m;
- if (PyType_Ready(&WhirlpoolType) < 0)
- return NULL;
-
- m = PyModule_Create(&moduledef);
- if (m == NULL)
- return NULL;
-
- Py_INCREF(&WhirlpoolType);
- if (PyModule_AddObject(m, "Whirlpool", (PyObject *) &WhirlpoolType) < 0) {
- Py_DECREF(&WhirlpoolType);
- Py_DECREF(m);
- return NULL;
- }
-
- return m;
+ return PyModuleDef_Init(&moduledef);
}
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-06-28 18:16 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-28 18:16 [gentoo-commits] proj/portage:master commit in: src/ Zac Medico
-- strict thread matches above, loose matches on Subject: below --
2023-08-02 15:50 Mike Gilbert
2023-06-07 7:29 Sam James
2021-12-12 1:14 Zac Medico
2020-12-25 0:28 Mike Gilbert
2017-12-16 0:38 Zac Medico
2017-12-15 21:17 Zac Medico
2017-10-27 18:50 Zac Medico
2017-05-14 18:08 Zac Medico
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox