Skip to content

Commit fe9272d

Browse files
bpf: Replace old school header guards with #pragma once
This commit replaces the old school header guards with #pragma once. This is a more modern way of preventing multiple inclusion of the same header file. In future we will be using scripts to remove macros, by replacing these now with the proper #pragma once we avoid having to write exceptions for these in the scripts. Signed-off-by: Dylan Reimerink <[email protected]>
1 parent 5faea37 commit fe9272d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+142
-457
lines changed

bpf/ep_config.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
22
/* Copyright Authors of Cilium */
33

4+
#pragma once
5+
46
/*
57
* This is just a dummy header with dummy values to allow for test
68
* compilation without the full code generation engine backend.
79
*/
810
#include "lib/utils.h"
911

10-
#ifndef ___EP_CONFIG____
11-
#define ___EP_CONFIG____
12-
1312
DEFINE_IPV6(LXC_IP, 0xbe, 0xef, 0, 0, 0, 0, 0, 0x1, 0, 0, 0, 0x1, 0x01, 0x65, 0x82, 0xbc);
1413

1514
#ifndef LXC_IPV4
@@ -58,5 +57,3 @@ DEFINE_U32(POLICY_VERDICT_LOG_FILTER, 0xffff);
5857
#define CONNTRACK_ACCOUNTING
5958
#define POLICY_ACCOUNTING
6059
#define DIRECT_ROUTING_DEV_IFINDEX 0
61-
62-
#endif

bpf/include/bpf/access.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
22
/* Copyright Authors of Cilium */
33

4-
#ifndef __BPF_ACCESS_H_
5-
#define __BPF_ACCESS_H_
4+
#pragma once
65

76
#include "compiler.h"
87

@@ -34,4 +33,3 @@ map_array_get_32(const __u32 *array, __u32 index, const __u32 limit)
3433
#else
3534
# define map_array_get_32(array, index, limit) __throw_build_bug()
3635
#endif /* __bpf__ */
37-
#endif /* __BPF_ACCESS_H_ */

bpf/include/bpf/api.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
22
/* Copyright Authors of Cilium */
33

4-
#ifndef __BPF_API__
5-
#define __BPF_API__
4+
#pragma once
65

76
#include <linux/types.h>
87
#include <linux/byteorder.h>
@@ -18,5 +17,3 @@
1817
#include "loader.h"
1918
#include "csum.h"
2019
#include "access.h"
21-
22-
#endif /* __BPF_API__ */

bpf/include/bpf/builtins.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
22
/* Copyright Authors of Cilium */
33

4-
#ifndef __BPF_BUILTINS__
5-
#define __BPF_BUILTINS__
4+
#pragma once
65

76
#include "compiler.h"
87

@@ -493,5 +492,3 @@ static __always_inline __nobuiltin("memmove") void memmove(void *d,
493492
{
494493
return __bpf_memmove(d, s, len);
495494
}
496-
497-
#endif /* __BPF_BUILTINS__ */

bpf/include/bpf/compiler.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
22
/* Copyright Authors of Cilium */
33

4-
#ifndef __BPF_COMPILER_H_
5-
#define __BPF_COMPILER_H_
4+
#pragma once
65

76
# include "stddef.h"
87

@@ -118,5 +117,3 @@ static __always_inline void bpf_barrier(void)
118117
#ifndef fallthrough
119118
# define fallthrough __attribute__((fallthrough))
120119
#endif
121-
122-
#endif /* __BPF_COMPILER_H_ */

bpf/include/bpf/csum.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
22
/* Copyright Authors of Cilium */
33

4-
#ifndef __BPF_CSUM_H_
5-
#define __BPF_CSUM_H_
4+
#pragma once
65

76
#include "compiler.h"
87
#include "helpers.h"
@@ -50,5 +49,3 @@ static __always_inline __wsum csum_diff(const void *from, __u32 size_from,
5049

5150
return csum_diff_external(from, size_from, to, size_to, seed);
5251
}
53-
54-
#endif /* __BPF_CSUM_H_ */

bpf/include/bpf/ctx/common.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
22
/* Copyright Authors of Cilium */
33

4-
#ifndef __BPF_CTX_COMMON_H_
5-
#define __BPF_CTX_COMMON_H_
4+
#pragma once
65

76
#include <linux/types.h>
87
#include <linux/bpf.h>
@@ -27,5 +26,3 @@ static __always_inline bool ctx_is_xdp(void)
2726
{
2827
return __ctx_is == __ctx_xdp;
2928
}
30-
31-
#endif /* __BPF_CTX_COMMON_H_ */

bpf/include/bpf/ctx/ctx.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
22
/* Copyright Authors of Cilium */
33

4-
#ifndef __BPF_CTX_CTX_H_
5-
#define __BPF_CTX_CTX_H_
4+
#pragma once
65

76
#ifndef __ctx_buff
87
# error "No __ctx_buff context defined. Please either include 'bpf/ctx/skb.h' or 'bpf/ctx/xdp.h'."
98
#endif
10-
11-
#endif /* __BPF_CTX_CTX_H_ */

bpf/include/bpf/ctx/skb.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
22
/* Copyright Authors of Cilium */
33

4-
#ifndef __BPF_CTX_SKB_H_
5-
#define __BPF_CTX_SKB_H_
4+
#pragma once
65

76
#define __section_entry __section("tc")
87

@@ -153,5 +152,3 @@ ctx_get_ingress_ifindex(const struct __sk_buff *ctx)
153152
{
154153
return ctx->ingress_ifindex;
155154
}
156-
157-
#endif /* __BPF_CTX_SKB_H_ */

bpf/include/bpf/ctx/sock.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
22
/* Copyright Authors of Cilium */
33

4-
#ifndef __BPF_CTX_SOCK_H_
5-
#define __BPF_CTX_SOCK_H_
4+
#pragma once
65

76
#include "../helpers_sock.h"
87

98
#define __ctx_sock bpf_sock_addr
109
#undef ctx_event_output
1110
#define ctx_event_output sock_event_output
12-
13-
#endif /* __BPF_CTX_SOCK_H_ */

0 commit comments

Comments
 (0)