xref: /linux/tools/lib/bpf/libbpf_legacy.h (revision bdd1a21b52557ea8f61d0a5dc2f77151b576eb70)
1 /* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
2 
3 /*
4  * Libbpf legacy APIs (either discouraged or deprecated, as mentioned in [0])
5  *
6  *   [0] https://docs.google.com/document/d/1UyjTZuPFWiPFyKk1tV5an11_iaRuec6U-ZESZ54nNTY
7  *
8  * Copyright (C) 2021 Facebook
9  */
10 #ifndef __LIBBPF_LEGACY_BPF_H
11 #define __LIBBPF_LEGACY_BPF_H
12 
13 #include <linux/bpf.h>
14 #include <stdbool.h>
15 #include <stddef.h>
16 #include <stdint.h>
17 #include "libbpf_common.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 enum libbpf_strict_mode {
24 	/* Turn on all supported strict features of libbpf to simulate libbpf
25 	 * v1.0 behavior.
26 	 * This will be the default behavior in libbpf v1.0.
27 	 */
28 	LIBBPF_STRICT_ALL = 0xffffffff,
29 
30 	/*
31 	 * Disable any libbpf 1.0 behaviors. This is the default before libbpf
32 	 * v1.0. It won't be supported anymore in v1.0, please update your
33 	 * code so that it handles LIBBPF_STRICT_ALL mode before libbpf v1.0.
34 	 */
35 	LIBBPF_STRICT_NONE = 0x00,
36 	/*
37 	 * Return NULL pointers on error, not ERR_PTR(err).
38 	 * Additionally, libbpf also always sets errno to corresponding Exx
39 	 * (positive) error code.
40 	 */
41 	LIBBPF_STRICT_CLEAN_PTRS = 0x01,
42 	/*
43 	 * Return actual error codes from low-level APIs directly, not just -1.
44 	 * Additionally, libbpf also always sets errno to corresponding Exx
45 	 * (positive) error code.
46 	 */
47 	LIBBPF_STRICT_DIRECT_ERRS = 0x02,
48 
49 	__LIBBPF_STRICT_LAST,
50 };
51 
52 LIBBPF_API int libbpf_set_strict_mode(enum libbpf_strict_mode mode);
53 
54 
55 #ifdef __cplusplus
56 } /* extern "C" */
57 #endif
58 
59 #endif /* __LIBBPF_LEGACY_BPF_H */
60