diff options
author | Karolina Drobnik <karolinadrobnik@gmail.com> | 2022-02-02 12:03:02 +0100 |
---|---|---|
committer | Mike Rapoport <rppt@linux.ibm.com> | 2022-02-20 08:44:37 +0200 |
commit | 5cf67a6051ea2558fd7c3d39c5a808db73073e9d (patch) | |
tree | a2edb90691c797c62c51db6fc5f59497251c4997 /tools/include | |
parent | 884ee1e585ca01b47f66c7e5b6902c62d1af77a3 (diff) | |
download | linux-5cf67a6051ea2558fd7c3d39c5a808db73073e9d.tar.bz2 |
tools/include: Add _RET_IP_ and math definitions to kernel.h
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
Diffstat (limited to 'tools/include')
-rw-r--r-- | tools/include/linux/kernel.h | 6 |
1 files changed, 6 insertions, 0 deletions
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) |