Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

authored by

Karolina Drobnik and committed by
Mike Rapoport
5cf67a60 884ee1e5

+6
+6
tools/include/linux/kernel.h
··· 15 15 #define UINT_MAX (~0U) 16 16 #endif 17 17 18 + #define _RET_IP_ ((unsigned long)__builtin_return_address(0)) 19 + 18 20 #define PERF_ALIGN(x, a) __PERF_ALIGN_MASK(x, (typeof(x))(a)-1) 19 21 #define __PERF_ALIGN_MASK(x, mask) (((x)+(mask))&~(mask)) 20 22 ··· 52 50 (void) (&_min1 == &_min2); \ 53 51 _min1 < _min2 ? _min1 : _min2; }) 54 52 #endif 53 + 54 + #define max_t(type, x, y) max((type)x, (type)y) 55 + #define min_t(type, x, y) min((type)x, (type)y) 56 + #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) 55 57 56 58 #ifndef BUG_ON 57 59 #ifdef NDEBUG