+++ /dev/null
---- a/include/libcgroup/config.h
-+++ b/include/libcgroup/config.h
-@@ -5,12 +5,10 @@
- #error "Only <libcgroup.h> should be included directly."
- #endif
-
--#ifndef SWIG
--#include <features.h>
-+#ifdef __cplusplus
-+extern "C" {
- #endif
-
--__BEGIN_DECLS
--
- /**
- * @defgroup group_config 5. Configuration
- * @{
-@@ -107,6 +105,8 @@ int cgroup_config_create_template_group(
- * @}
- * @}
- */
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-
- #endif /*_LIBCGROUP_CONFIG_H*/
---- a/include/libcgroup/error.h
-+++ b/include/libcgroup/error.h
-@@ -5,12 +5,10 @@
- #error "Only <libcgroup.h> should be included directly."
- #endif
-
--#ifndef SWIG
--#include <features.h>
-+#ifdef __cplusplus
-+extern "C" {
- #endif
-
--__BEGIN_DECLS
--
- /**
- * @defgroup group_errors 6. Error handling
- * @{
-@@ -99,6 +97,8 @@ int cgroup_get_last_errno(void);
- * @}
- * @}
- */
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-
- #endif /* _LIBCGROUP_INIT_H */
---- a/include/libcgroup/groups.h
-+++ b/include/libcgroup/groups.h
-@@ -6,12 +6,13 @@
- #endif
-
- #ifndef SWIG
--#include <features.h>
- #include <sys/types.h>
- #include <stdbool.h>
- #endif
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /**
- * Flags for cgroup_delete_cgroup_ext().
-@@ -577,6 +578,8 @@ char *cgroup_get_cgroup_name(struct cgro
- */
-
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-
- #endif /* _LIBCGROUP_GROUPS_H */
---- a/include/libcgroup/init.h
-+++ b/include/libcgroup/init.h
-@@ -5,12 +5,10 @@
- #error "Only <libcgroup.h> should be included directly."
- #endif
-
--#ifndef SWIG
--#include <features.h>
-+#ifdef __cplusplus
-+extern "C" {
- #endif
-
--__BEGIN_DECLS
--
- /**
- * @defgroup group_init 1. Initialization
- * @{
-@@ -58,6 +56,8 @@ int cgroup_get_subsys_mount_point(const
- * @}
- * @}
- */
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-
- #endif /* _LIBCGROUP_INIT_H */
---- a/include/libcgroup/iterators.h
-+++ b/include/libcgroup/iterators.h
-@@ -8,10 +8,11 @@
- #ifndef SWIG
- #include <sys/types.h>
- #include <stdio.h>
--#include <features.h>
- #endif
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /**
- * @defgroup group_iterators 3. Iterators
-@@ -423,6 +424,8 @@ int cgroup_get_subsys_mount_point_end(vo
- * @}
- */
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-
- #endif /* _LIBCGROUP_ITERATORS_H */
---- a/include/libcgroup/log.h
-+++ b/include/libcgroup/log.h
-@@ -5,13 +5,11 @@
- #error "Only <libcgroup.h> should be included directly."
- #endif
-
--#ifndef SWIG
--#include <features.h>
--#endif
--
- #include <stdarg.h>
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /**
- * @defgroup group_log 7. Logging
-@@ -142,6 +140,8 @@ extern int cgroup_parse_log_level_str(co
- * @}
- * @}
- */
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-
- #endif /* _LIBCGROUP_LOG_H */
---- a/include/libcgroup/tasks.h
-+++ b/include/libcgroup/tasks.h
-@@ -8,11 +8,12 @@
- #include <libcgroup/groups.h>
-
- #ifndef SWIG
--#include <features.h>
- #include <stdbool.h>
- #endif
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- /** Flags for cgroup_change_cgroup_uid_gid(). */
- enum cgflags {
-@@ -204,6 +205,8 @@ int cgroup_register_unchanged_process(pi
- * @}
- * @}
- */
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-
- #endif /* _LIBCGROUP_TASKS_H */
---- a/src/daemon/cgrulesengd.h
-+++ b/src/daemon/cgrulesengd.h
-@@ -15,9 +15,9 @@
- #ifndef _CGRULESENGD_H
- #define _CGRULESENGD_H
-
--#include <features.h>
--
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- #include "config.h"
- #include "libcgroup.h"
-@@ -119,7 +119,9 @@ void cgre_flash_templates(int signum);
- */
- void cgre_catch_term(int signum);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-
- #endif /* _CGRULESENGD_H */
-
---- a/src/libcgroup-internal.h
-+++ b/src/libcgroup-internal.h
-@@ -16,7 +16,9 @@
-
- #define __LIBCG_INTERNAL
-
--__BEGIN_DECLS
-+#ifdef __cplusplus
-+extern "C" {
-+#endif
-
- #include "config.h"
- #include <fts.h>
-@@ -279,6 +281,8 @@ extern void cgroup_dictionary_iterator_e
- */
- int cg_chmod_path(const char *path, mode_t mode, int owner_is_umask);
-
--__END_DECLS
-+#ifdef __cplusplus
-+}
-+#endif
-
- #endif
--- /dev/null
+From 942ef655237b90909edf53eafd121842cdc07ce1 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Fri, 13 Jan 2023 12:44:07 -0700
+Subject: [PATCH] api: Use GNU strerror_r when available
+
+GNU strerror_r is only available in glibc, musl impelents the XSI
+version which is slightly different, therefore check if GNU version is
+available before using it, otherwise use the XSI compliant version.
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
+Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
+TJH: Minor formatting change so that the line doesn't exceed 100 chars
+---
+ configure.ac | 5 +++++
+ src/api.c | 9 +++++++--
+ 2 files changed, 12 insertions(+), 2 deletions(-)
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -186,6 +186,11 @@ AC_FUNC_REALLOC
+ AC_FUNC_STAT
+ AC_CHECK_FUNCS([getmntent hasmntopt memset mkdir rmdir strdup])
+
++orig_CFLAGS="$CFLAGS"
++CFLAGS="$CFLAGS -D_GNU_SOURCE"
++AC_FUNC_STRERROR_R
++CFLAGS="$orig_CFLAGS"
++
+ AC_SEARCH_LIBS(
+ [fts_open],
+ [fts],
+--- a/src/api.c
++++ b/src/api.c
+@@ -4598,9 +4598,14 @@ const char *cgroup_strerror(int code)
+ {
+ int idx = code % ECGROUPNOTCOMPILED;
+
+- if (code == ECGOTHER)
++ if (code == ECGOTHER) {
++#ifdef STRERROR_R_CHAR_P
+ return strerror_r(cgroup_get_last_errno(), errtext, MAXLEN);
+-
++#else
++ return strerror_r(cgroup_get_last_errno(), errtext, sizeof (errtext)) ?
++ "unknown error" : errtext;
++#endif
++ }
+ if (idx >= sizeof(cgroup_strerror_codes)/sizeof(cgroup_strerror_codes[0]))
+ return "Invalid error code";
+