Commit 5cf67a60 authored by Karolina Drobnik's avatar Karolina Drobnik Committed by Mike Rapoport
Browse files

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: default avatarKarolina Drobnik <karolinadrobnik@gmail.com>
Signed-off-by: default avatarMike Rapoport <rppt@kernel.org>
Link: https://lore.kernel.org/r/230fea382cb1e1659cdd52a55201854d38a0a149.1643796665.git.karolinadrobnik@gmail.com
parent 884ee1e5
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -15,6 +15,8 @@
#define UINT_MAX	(~0U)
#define UINT_MAX	(~0U)
#endif
#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(x, a)	__PERF_ALIGN_MASK(x, (typeof(x))(a)-1)
#define __PERF_ALIGN_MASK(x, mask)	(((x)+(mask))&~(mask))
#define __PERF_ALIGN_MASK(x, mask)	(((x)+(mask))&~(mask))


@@ -51,6 +53,10 @@
	_min1 < _min2 ? _min1 : _min2; })
	_min1 < _min2 ? _min1 : _min2; })
#endif
#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
#ifndef BUG_ON
#ifdef NDEBUG
#ifdef NDEBUG
#define BUG_ON(cond) do { if (cond) {} } while (0)
#define BUG_ON(cond) do { if (cond) {} } while (0)