linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Karolina Drobnik <karolinadrobnik@gmail.com>
To: linux-mm@kvack.org
Cc: akpm@linux-foundation.org, rppt@kernel.org,
	linux-kernel@vger.kernel.org,
	Karolina Drobnik <karolinadrobnik@gmail.com>
Subject: [PATCH v2 03/16] tools/include: Add _RET_IP_ and math definitions to kernel.h
Date: Wed,  2 Feb 2022 12:03:02 +0100	[thread overview]
Message-ID: <230fea382cb1e1659cdd52a55201854d38a0a149.1643796665.git.karolinadrobnik@gmail.com> (raw)
In-Reply-To: <cover.1643796665.git.karolinadrobnik@gmail.com>

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>
---
 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 9701e8307db0..4b0673bf52c2 100644
--- a/tools/include/linux/kernel.h
+++ b/tools/include/linux/kernel.h
@@ -15,6 +15,8 @@
 #define UINT_MAX	(~0U)
 #endif
 
+#define _RET_IP_		((unsigned long)__builtin_return_address(0))
+
 #define PERF_ALIGN(x, a)	__PERF_ALIGN_MASK(x, (typeof(x))(a)-1)
 #define __PERF_ALIGN_MASK(x, mask)	(((x)+(mask))&~(mask))
 
@@ -51,6 +53,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 BUG_ON
 #ifdef NDEBUG
 #define BUG_ON(cond) do { if (cond) {} } while (0)
-- 
2.30.2



  parent reply	other threads:[~2022-02-02 11:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-02 11:02 [PATCH v2 00/16] Introduce memblock simulator Karolina Drobnik
2022-02-02 11:03 ` [PATCH v2 01/16] tools: Move gfp.h and slab.h from radix-tree to lib Karolina Drobnik
2022-02-02 11:03 ` [PATCH v2 02/16] tools/include: Add phys_addr_t to types.h Karolina Drobnik
2022-02-02 11:03 ` Karolina Drobnik [this message]
2022-02-02 11:03 ` [PATCH v2 04/16] tools/include: Update atomic definitions Karolina Drobnik
2022-02-02 11:03 ` [PATCH v2 05/16] tools/include: Add mm.h file Karolina Drobnik
2022-02-02 11:03 ` [PATCH v2 06/16] tools/include: Add cache.h stub Karolina Drobnik
2022-02-02 11:03 ` [PATCH v2 07/16] tools/include: Add io.h stub Karolina Drobnik
2022-02-02 11:03 ` [PATCH v2 08/16] tools/include: Add pfn.h stub Karolina Drobnik
2022-02-02 11:03 ` [PATCH v2 09/16] tools/include: Add debugfs.h stub Karolina Drobnik
2022-02-02 11:03 ` [PATCH v2 10/16] memblock tests: Add skeleton of the memblock simulator Karolina Drobnik
2022-02-02 11:03 ` [PATCH v2 11/16] memblock tests: Add memblock reset function Karolina Drobnik
2022-02-02 11:03 ` [PATCH v2 12/16] memblock tests: Add memblock_add tests Karolina Drobnik
2022-02-02 11:03 ` [PATCH v2 13/16] memblock tests: Add memblock_reserve tests Karolina Drobnik
2022-02-02 11:03 ` [PATCH v2 14/16] memblock tests: Add memblock_remove tests Karolina Drobnik
2022-02-02 11:03 ` [PATCH v2 15/16] memblock tests: Add memblock_add_node test Karolina Drobnik
2022-02-02 11:03 ` [PATCH v2 16/16] memblock tests: Add memblock_free tests Karolina Drobnik
2022-02-09  7:30 ` [PATCH v2 00/16] Introduce memblock simulator Mike Rapoport

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=230fea382cb1e1659cdd52a55201854d38a0a149.1643796665.git.karolinadrobnik@gmail.com \
    --to=karolinadrobnik@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rppt@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).