sys-apps/kmod: Sync with Gentoo

It's from Gentoo commit 0c2f6e7e4647aa7f51d024da2699a5762297490e.

Signed-off-by: Flatcar Buildbot <buildbot@flatcar-linux.org>
This commit is contained in:
Flatcar Buildbot 2026-03-02 07:29:11 +00:00 committed by Krzesimir Nowak
parent 15cacf5d28
commit 77504ca557
2 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,53 @@
From 4e18b842b3dae5486adb2c6cc11bdfdd53ee8646 Mon Sep 17 00:00:00 2001
From: Tobias Stoeckmann <tobias@stoeckmann.org>
Date: Wed, 14 Jan 2026 20:58:50 +0100
Subject: [PATCH] util: Add s390 31 bit mode support
Even though size_t is of the same size as a uint32_t, the s390
architecture is a bit picky about its 31 bit mode with size_t.
Use custom code to fix this issue in a rather architecture
independent but unfortunately slower way for s390 31 bit mode.
Reference: https://github.com/kmod-project/kmod/issues/402
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
---
shared/util.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/shared/util.h b/shared/util.h
index bf3f1009..b785f5b1 100644
--- a/shared/util.h
+++ b/shared/util.h
@@ -123,7 +123,15 @@ static inline bool uaddsz_overflow(size_t a, size_t b, size_t *res)
#if __SIZEOF_SIZE_T__ == 8
return uadd64_overflow(a, b, res);
#elif __SIZEOF_SIZE_T__ == 4
+#ifdef __s390__
+ if (b < SIZE_MAX - a) {
+ *res = a + b;
+ return true;
+ }
+ return false;
+#else
return uadd32_overflow(a, b, res);
+#endif
#else
#error "Unknown sizeof(size_t)"
#endif
@@ -167,7 +175,15 @@ static inline bool umulsz_overflow(size_t a, size_t b, size_t *res)
#if __SIZEOF_SIZE_T__ == 8
return umul64_overflow(a, b, res);
#elif __SIZEOF_SIZE_T__ == 4
+#ifdef __s390__
+ if (a == 0 || b <= SIZE_MAX / a) {
+ *res = a * b;
+ return true;
+ }
+ return false;
+#else
return umul32_overflow(a, b, res);
+#endif
#else
#error "Unknown sizeof(size_t)"
#endif

View File

@ -1,4 +1,4 @@
# Copyright 1999-2025 Gentoo Authors
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
@ -40,6 +40,10 @@ BDEPEND="
zlib? ( virtual/pkgconfig )
"
PATCHES=(
"${FILESDIR}/${P}-s390.patch"
)
pkg_setup() {
:
}