blob: 531a562967c075d2e0b5b7924275121dec6af543 [file] [log] [blame]
Andrew Geisslerd159c7f2021-09-02 21:05:58 -05001Upstream-Status: Backport
2Signed-off-by: Ross Burton <ross.burton@arm.com>
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05003
Andrew Geisslerd159c7f2021-09-02 21:05:58 -05004From 26f2889113789c176273bd24fcd1592a8064c346 Mon Sep 17 00:00:00 2001
5From: "Anthony G. Basile" <blueness@gentoo.org>
6Date: Tue, 6 Jul 2021 07:54:47 -0600
7Subject: [PATCH 1/2] Replace __BEGIN_DECLS and __END_DECLS with extern "C".
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05008
Andrew Geisslerd159c7f2021-09-02 21:05:58 -05009The macros __BEGIN_DECLS and __END_DECLS are a GNU-ism found in
10glibc and uClibc, but not musl. We replace them by the more general
11extern "C" { ... } block exposed only if we have __cplusplus.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050012
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050013Forward ported from a patch by Anthony G. Basile <blueness@gentoo.org>.
14
15Signed-off-by: Alex Xu (Hello71) <alex_y_xu@yahoo.ca>
16Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
17---
18 include/libcgroup/config.h | 8 ++++++--
19 include/libcgroup/error.h | 8 ++++++--
20 include/libcgroup/groups.h | 8 ++++++--
21 include/libcgroup/init.h | 8 ++++++--
22 include/libcgroup/iterators.h | 8 ++++++--
23 include/libcgroup/log.h | 8 ++++++--
24 include/libcgroup/tasks.h | 8 ++++++--
25 src/bindings/libcgroup.p | 8 --------
26 src/daemon/cgrulesengd.h | 8 ++++++--
27 src/libcgroup-internal.h | 8 ++++++--
28 src/tools/tools-common.h | 8 ++++++--
29 11 files changed, 60 insertions(+), 28 deletions(-)
30
31diff --git a/include/libcgroup/config.h b/include/libcgroup/config.h
32index 9aaa390..f835009 100644
33--- a/include/libcgroup/config.h
34+++ b/include/libcgroup/config.h
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050035@@ -9,7 +9,9 @@
36 #include <features.h>
37 #endif
38
39-__BEGIN_DECLS
40+#ifdef __cplusplus
41+extern "C" {
42+#endif
43
44 /**
45 * @defgroup group_config 5. Configuration
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050046@@ -128,6 +130,8 @@ int cgroup_config_create_template_group(
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050047 * @}
48 * @}
49 */
50-__END_DECLS
51+#ifdef __cplusplus
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050052+} /* extern "C" */
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050053+#endif
54
55 #endif /*_LIBCGROUP_CONFIG_H*/
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050056diff --git a/include/libcgroup/error.h b/include/libcgroup/error.h
57index 1dfdde9..14a6e16 100644
58--- a/include/libcgroup/error.h
59+++ b/include/libcgroup/error.h
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050060@@ -9,7 +9,9 @@
61 #include <features.h>
62 #endif
63
64-__BEGIN_DECLS
65+#ifdef __cplusplus
66+extern "C" {
67+#endif
68
69 /**
70 * @defgroup group_errors 6. Error handling
71@@ -99,6 +101,8 @@ int cgroup_get_last_errno(void);
72 * @}
73 * @}
74 */
75-__END_DECLS
76+#ifdef __cplusplus
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050077+} /* extern "C" */
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050078+#endif
79
80 #endif /* _LIBCGROUP_INIT_H */
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050081diff --git a/include/libcgroup/groups.h b/include/libcgroup/groups.h
82index 201558f..39ec3cd 100644
83--- a/include/libcgroup/groups.h
84+++ b/include/libcgroup/groups.h
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050085@@ -11,7 +11,9 @@
86 #include <stdbool.h>
87 #endif
88
89-__BEGIN_DECLS
90+#ifdef __cplusplus
91+extern "C" {
92+#endif
93
94 /**
95 * Flags for cgroup_delete_cgroup_ext().
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050096@@ -587,6 +589,8 @@ char *cgroup_get_cgroup_name(struct cgroup *cgroup);
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050097 */
98
99
100-__END_DECLS
101+#ifdef __cplusplus
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500102+} /* extern "C" */
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500103+#endif
104
105 #endif /* _LIBCGROUP_GROUPS_H */
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500106diff --git a/include/libcgroup/init.h b/include/libcgroup/init.h
107index 5150f2f..ea2dcc9 100644
108--- a/include/libcgroup/init.h
109+++ b/include/libcgroup/init.h
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500110@@ -9,7 +9,9 @@
111 #include <features.h>
112 #endif
113
114-__BEGIN_DECLS
115+#ifdef __cplusplus
116+extern "C" {
117+#endif
118
119 /**
120 * @defgroup group_init 1. Initialization
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500121@@ -58,6 +60,8 @@ int cgroup_get_subsys_mount_point(const char *controller, char **mount_point);
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500122 * @}
123 * @}
124 */
125-__END_DECLS
126+#ifdef __cplusplus
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500127+} /* extern "C" */
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500128+#endif
129
130 #endif /* _LIBCGROUP_INIT_H */
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500131diff --git a/include/libcgroup/iterators.h b/include/libcgroup/iterators.h
132index c6d453d..b3ba3af 100644
133--- a/include/libcgroup/iterators.h
134+++ b/include/libcgroup/iterators.h
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500135@@ -11,7 +11,9 @@
136 #include <features.h>
137 #endif
138
139-__BEGIN_DECLS
140+#ifdef __cplusplus
141+extern "C" {
142+#endif
143
144 /**
145 * @defgroup group_iterators 3. Iterators
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500146@@ -423,6 +425,8 @@ int cgroup_get_subsys_mount_point_end(void **handle);
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500147 * @}
148 */
149
150-__END_DECLS
151+#ifdef __cplusplus
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500152+} /* extern "C" */
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500153+#endif
154
155 #endif /* _LIBCGROUP_ITERATORS_H */
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500156diff --git a/include/libcgroup/log.h b/include/libcgroup/log.h
157index 0dd03b4..f693473 100644
158--- a/include/libcgroup/log.h
159+++ b/include/libcgroup/log.h
160@@ -11,7 +11,9 @@
161
162 #include <stdarg.h>
163
164-__BEGIN_DECLS
165+#ifdef __cplusplus
166+extern "C" {
167+#endif
168
169 /**
170 * @defgroup group_log 7. Logging
171@@ -142,6 +144,8 @@ extern int cgroup_parse_log_level_str(const char *levelstr);
172 * @}
173 * @}
174 */
175-__END_DECLS
176+#ifdef __cplusplus
177+} /* extern "C" */
178+#endif
179
180 #endif /* _LIBCGROUP_LOG_H */
181diff --git a/include/libcgroup/tasks.h b/include/libcgroup/tasks.h
182index aad438a..8553c30 100644
183--- a/include/libcgroup/tasks.h
184+++ b/include/libcgroup/tasks.h
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500185@@ -12,7 +12,9 @@
186 #include <stdbool.h>
187 #endif
188
189-__BEGIN_DECLS
190+#ifdef __cplusplus
191+extern "C" {
192+#endif
193
194 /** Flags for cgroup_change_cgroup_uid_gid(). */
195 enum cgflags {
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500196@@ -204,6 +206,8 @@ int cgroup_register_unchanged_process(pid_t pid, int flags);
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500197 * @}
198 * @}
199 */
200-__END_DECLS
201+#ifdef __cplusplus
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500202+} /* extern "C" */
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500203+#endif
204
205 #endif /* _LIBCGROUP_TASKS_H */
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500206diff --git a/src/daemon/cgrulesengd.h b/src/daemon/cgrulesengd.h
207index e273b4b..0b12076 100644
208--- a/src/daemon/cgrulesengd.h
209+++ b/src/daemon/cgrulesengd.h
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500210@@ -17,7 +17,9 @@
211
212 #include <features.h>
213
214-__BEGIN_DECLS
215+#ifdef __cplusplus
216+extern "C" {
217+#endif
218
219 #include "config.h"
220 #include "libcgroup.h"
221@@ -119,7 +121,9 @@ void cgre_flash_templates(int signum);
222 */
223 void cgre_catch_term(int signum);
224
225-__END_DECLS
226+#ifdef __cplusplus
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500227+} /* extern "C" */
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500228+#endif
229
230 #endif /* _CGRULESENGD_H */
231
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500232diff --git a/src/libcgroup-internal.h b/src/libcgroup-internal.h
233index 1dfc92b..edc5abb 100644
234--- a/src/libcgroup-internal.h
235+++ b/src/libcgroup-internal.h
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500236@@ -16,7 +16,9 @@
237
238 #define __LIBCG_INTERNAL
239
240-__BEGIN_DECLS
241+#ifdef __cplusplus
242+extern "C" {
243+#endif
244
245 #include "config.h"
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500246 #include <dirent.h>
247@@ -407,6 +409,8 @@ int cgroupv2_controller_enabled(const char * const cg_name,
248
249 #endif /* UNIT_TEST */
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500250
251-__END_DECLS
252+#ifdef __cplusplus
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500253+} /* extern "C" */
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500254+#endif
255
256 #endif
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500257diff --git a/src/tools/tools-common.h b/src/tools/tools-common.h
258index 292c408..e3541b1 100644
259--- a/src/tools/tools-common.h
260+++ b/src/tools/tools-common.h
261@@ -18,7 +18,9 @@
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500262
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500263 #define __TOOLS_COMMON
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500264
265-__BEGIN_DECLS
266+#ifdef __cplusplus
267+extern "C" {
268+#endif
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500269 #include "config.h"
270 #include <libcgroup.h>
271 #include "../libcgroup-internal.h"
272@@ -136,6 +138,8 @@ int parse_r_flag(const char * const program_name,
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500273
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500274 #endif /* UNIT_TEST */
275
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500276-__END_DECLS
277+#ifdef __cplusplus
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500278+} /* extern "C" */
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500279+#endif
280
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500281 #endif /* TOOLS_COMMON */
282--
2832.32.0
284