[PATCH 04/18] include: import <linux/instruction_pointer.h>
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Nov 10 13:44:07 PST 2023
This header provides definitions for getting the instruction pointer and
the return address in a portable manner, which can be useful for
trace outputs where dump_stack would be overkill.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
include/linux/instruction_pointer.h | 11 +++++++++++
include/linux/kernel.h | 3 +--
2 files changed, 12 insertions(+), 2 deletions(-)
create mode 100644 include/linux/instruction_pointer.h
diff --git a/include/linux/instruction_pointer.h b/include/linux/instruction_pointer.h
new file mode 100644
index 000000000000..6564127a31ba
--- /dev/null
+++ b/include/linux/instruction_pointer.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_INSTRUCTION_POINTER_H
+#define _LINUX_INSTRUCTION_POINTER_H
+
+#define _RET_IP_ (unsigned long)__builtin_return_address(0)
+
+#ifndef _THIS_IP_
+#define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; })
+#endif
+
+#endif /* _LINUX_INSTRUCTION_POINTER_H */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 0e4ba243915b..da6121888ebd 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -8,6 +8,7 @@
#include <linux/limits.h>
#include <linux/math64.h>
#include <linux/container_of.h>
+#include <linux/instruction_pointer.h>
#include <linux/minmax.h>
#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1)
@@ -117,8 +118,6 @@ extern long long simple_strtoll(const char *,char **,unsigned int);
} \
)
-#define _RET_IP_ (unsigned long)__builtin_return_address(0)
-
extern const char hex_asc[];
#define hex_asc_lo(x) hex_asc[((x) & 0x0f)]
#define hex_asc_hi(x) hex_asc[((x) & 0xf0) >> 4]
--
2.39.2
More information about the barebox
mailing list