libsepol: replace non-standard use of __BEGIN_DECLS

While most header files already use the common pattern of `extern "C"`
declarations to enable compiling in a C++ project, some header files in
libsepol instead use the macros `__BEGIN_DECLS` and `__END_DECLS`. These
macros are defined in the "sys/cdefs.h" header file, which provides
some non-standard extensions for glibc.

Convert usage of these declarations with the standard `extern "C"`
pattern. This improves compatibility with other libc implementations,
e.g. musl libc.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
This commit is contained in:
Patrick Steinhardt 2017-06-20 16:07:01 +02:00 committed by Stephen Smalley
parent 297877ab88
commit 34dc7bcc31
4 changed files with 32 additions and 12 deletions

View File

@ -4,9 +4,10 @@
#include <stddef.h>
#include <sepol/context_record.h>
#include <sepol/handle.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
struct sepol_ibendport;
struct sepol_ibendport_key;
@ -64,5 +65,8 @@ extern int sepol_ibendport_clone(sepol_handle_t *handle,
extern void sepol_ibendport_free(sepol_ibendport_t *ibendport);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif

View File

@ -4,9 +4,10 @@
#include <sepol/handle.h>
#include <sepol/policydb.h>
#include <sepol/ibendport_record.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
/* Return the number of ibendports */
extern int sepol_ibendport_count(sepol_handle_t *handle,
@ -41,5 +42,9 @@ extern int sepol_ibendport_iterate(sepol_handle_t *handle,
int (*fn)(const sepol_ibendport_t *ibendport,
void *fn_arg), void *arg);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif

View File

@ -5,11 +5,12 @@
#include <stdint.h>
#include <sepol/context_record.h>
#include <sepol/handle.h>
#include <sys/cdefs.h>
#define INET6_ADDRLEN 16
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
struct sepol_ibpkey;
struct sepol_ibpkey_key;
@ -71,5 +72,9 @@ extern int sepol_ibpkey_clone(sepol_handle_t *handle,
extern void sepol_ibpkey_free(sepol_ibpkey_t *ibpkey);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif

View File

@ -4,9 +4,11 @@
#include <sepol/handle.h>
#include <sepol/policydb.h>
#include <sepol/ibpkey_record.h>
#include <sys/cdefs.h>
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
/* Return the number of ibpkeys */
extern int sepol_ibpkey_count(sepol_handle_t *handle,
@ -40,5 +42,9 @@ extern int sepol_ibpkey_iterate(sepol_handle_t *handle,
int (*fn)(const sepol_ibpkey_t *ibpkey,
void *fn_arg), void *arg);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif