1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * A generic stack depot implementation
4  *
5  * Author: Alexander Potapenko <glider@google.com>
6  * Copyright (C) 2016 Google, Inc.
7  *
8  * Based on code by Dmitry Chernenkov.
9  */
10 
11 #ifndef _LINUX_STACKDEPOT_H
12 #define _LINUX_STACKDEPOT_H
13 
14 #include <linux/gfp.h>
15 
16 typedef u32 depot_stack_handle_t;
17 
18 depot_stack_handle_t __stack_depot_save(unsigned long *entries,
19 					unsigned int nr_entries,
20 					gfp_t gfp_flags, bool can_alloc);
21 
22 depot_stack_handle_t stack_depot_save(unsigned long *entries,
23 				      unsigned int nr_entries, gfp_t gfp_flags);
24 
25 unsigned int stack_depot_fetch(depot_stack_handle_t handle,
26 			       unsigned long **entries);
27 
28 int stack_depot_snprint(depot_stack_handle_t handle, char *buf, size_t size,
29 		       int spaces);
30 
31 void stack_depot_print(depot_stack_handle_t stack);
32 
33 #ifdef CONFIG_STACKDEPOT
34 int stack_depot_init(void);
35 #else
stack_depot_init(void)36 static inline int stack_depot_init(void)
37 {
38 	return 0;
39 }
40 #endif	/* CONFIG_STACKDEPOT */
41 
42 #endif
43