From: Tyler Hicks <code@tyhicks.com>
To: gregkh@linuxfoundation.org, stable@vger.kernel.org
Cc: Karolina Drobnik <karolinadrobnik@gmail.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Shuah Khan <shuah@kernel.org>,
kvm@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org, Gavin Shan <gshan@redhat.com>,
Marc Zyngier <maz@kernel.org>, Mike Rapoport <rppt@kernel.org>,
Tyler Hicks <code@tyhicks.com>
Subject: [PATCH 5.15 1/2] tools/include: Add _RET_IP_ and math definitions to kernel.h
Date: Thu, 22 Dec 2022 18:09:57 -0600 [thread overview]
Message-ID: <20221223000958.729256-2-code@tyhicks.com> (raw)
In-Reply-To: <20221223000958.729256-1-code@tyhicks.com>
From: Karolina Drobnik <karolinadrobnik@gmail.com>
commit 5cf67a6051ea2558fd7c3d39c5a808db73073e9d upstream.
Add max_t, min_t and clamp functions, together with _RET_IP_
definition, so they can be used in testing.
Signed-off-by: Karolina Drobnik <karolinadrobnik@gmail.com>
Signed-off-by: Mike Rapoport <rppt@kernel.org>
Link: https://lore.kernel.org/r/230fea382cb1e1659cdd52a55201854d38a0a149.1643796665.git.karolinadrobnik@gmail.com
[tyhicks: Backport around contextual differences due to the lack of v5.16 commit
d6e6a27d960f ("tools: Fix math.h breakage"). That commit fixed a commit
that was merged in v5.16-rc1 and, therefore, doesn't need to go back to
the stable branches.]
Signed-off-by: Tyler Hicks (Microsoft) <code@tyhicks.com>
---
tools/include/linux/kernel.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h
index a7e54a08fb54..c2e109860fbc 100644
--- a/tools/include/linux/kernel.h
+++ b/tools/include/linux/kernel.h
@@ -14,6 +14,8 @@
#define UINT_MAX (~0U)
#endif
+#define _RET_IP_ ((unsigned long)__builtin_return_address(0))
+
#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
#define PERF_ALIGN(x, a) __PERF_ALIGN_MASK(x, (typeof(x))(a)-1)
@@ -52,6 +54,10 @@
_min1 < _min2 ? _min1 : _min2; })
#endif
+#define max_t(type, x, y) max((type)x, (type)y)
+#define min_t(type, x, y) min((type)x, (type)y)
+#define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi)
+
#ifndef roundup
#define roundup(x, y) ( \
{ \
--
2.34.1
next prev parent reply other threads:[~2022-12-23 0:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-23 0:09 [PATCH 5.15 0/2] Fix kvm selftest build failures in linux-5.15.y Tyler Hicks
2022-12-23 0:09 ` Tyler Hicks [this message]
2022-12-23 0:09 ` [PATCH 5.15 2/2] KVM: selftests: Fix build regression by using accessor function Tyler Hicks
2022-12-23 16:45 ` [PATCH 5.15 0/2] Fix kvm selftest build failures in linux-5.15.y Paolo Bonzini
2022-12-25 3:33 ` Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221223000958.729256-2-code@tyhicks.com \
--to=code@tyhicks.com \
--cc=gregkh@linuxfoundation.org \
--cc=gshan@redhat.com \
--cc=karolinadrobnik@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maz@kernel.org \
--cc=pbonzini@redhat.com \
--cc=rppt@kernel.org \
--cc=shuah@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).