library: replace the troublesome '__BEGIN_DECLS' macro

When 'newlib' was introduced, in the commit referenced
below, the use of that glibc '__BEGIN_DECLS' macro was
standardized. However, as issue #88 revealed, this may
result in a fatal build error with other environments.

So, this patch just trades that macro for the standard
'#ifdef __cplusplus' conventions (thus avoiding use of
all those '#include <features.h>' directives as well).

Reference(s):
. newlib introduced
commit a410e236ab
. procps-ng-3.3.13 issue
https://gitlab.com/procps-ng/procps/issues/88
. some additional discussion
https://www.freelists.org/post/procps/PATCH-Replace-glibcspecific-macros-in-procnumah,1
. musl wiki (see: sys/cdefs.h error messages)
https://wiki.musl-libc.org/faq.html

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner 2018-04-06 00:00:00 -05:00 committed by Craig Small
parent bae272fe22
commit b0908eec4b
10 changed files with 63 additions and 40 deletions

View File

@ -23,9 +23,9 @@
#ifndef PROCPS_DISKSTATS_H
#define PROCPS_DISKSTATS_H
#include <sys/cdefs.h>
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
enum diskstats_item {
DISKSTATS_noop, // ( never altered )
@ -126,5 +126,7 @@ struct diskstats_stack **procps_diskstats_sort (
enum diskstats_item sortitem,
enum diskstats_sort_order order);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif

View File

@ -19,9 +19,9 @@
#ifndef PROCPS_MEMINFO_H
#define PROCPS_MEMINFO_H
#include <sys/cdefs.h>
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
enum meminfo_item {
MEMINFO_noop, // ( never altered )
@ -171,5 +171,7 @@ struct meminfo_stack *procps_meminfo_select (
enum meminfo_item *items,
int numitems);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif

View File

@ -23,7 +23,9 @@
#ifndef PROC_NAMESPACE_H
#define PROC_NAMESPACE_H
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
enum namespace_type {
PROCPS_NS_IPC,
@ -44,6 +46,8 @@ const char *procps_ns_get_name(const int id);
int procps_ns_get_id(const char *name);
int procps_ns_read_pid(const int pid, struct procps_namespaces *nsp);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif

View File

@ -23,9 +23,9 @@
#ifndef PROCPS_PIDS_H
#define PROCPS_PIDS_H
#include <sys/cdefs.h>
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
enum pids_item {
PIDS_noop, // ( never altered )
@ -233,5 +233,7 @@ struct pids_stack **procps_pids_sort (
enum pids_item sortitem,
enum pids_sort_order order);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif

View File

@ -23,9 +23,9 @@
#ifndef PROCPS_SLABINFO_H
#define PROCPS_SLABINFO_H
#include <sys/cdefs.h>
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
enum slabinfo_item {
SLABINFO_noop, // ( never altered )
@ -130,5 +130,7 @@ struct slabinfo_stack **procps_slabinfo_sort (
enum slabinfo_item sortitem,
enum slabinfo_sort_order order);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif

View File

@ -19,9 +19,9 @@
#ifndef PROCPS_STAT_H
#define PROCPS_STAT_H
#include <sys/cdefs.h>
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
enum stat_item {
STAT_noop, // ( never altered )
@ -154,5 +154,7 @@ struct stat_stack **procps_stat_sort (
enum stat_item sortitem,
enum stat_sort_order order);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif

View File

@ -3,13 +3,16 @@
#include <sys/types.h>
#include <dirent.h>
#include <features.h>
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
long procps_cpu_count(void);
long procps_hertz_get(void);
int procps_loadavg(double *av1, double *av5, double *av15);
unsigned int procps_pid_length(void);
__END_DECLS
#endif /* SYSINFO_H */
#ifdef __cplusplus
}
#endif
#endif

View File

@ -25,13 +25,15 @@
#ifndef PROC_UPTIME_H
#define PROC_UPTIME_H
#include <features.h>
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
int procps_uptime(double *uptime_secs, double *idle_secs);
char *procps_uptime_sprint(void);
char *procps_uptime_sprint_short(void);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif

View File

@ -23,10 +23,9 @@
#ifndef PROC_VERSION_H
#define PROC_VERSION_H
#include <features.h>
__BEGIN_DECLS
int procps_linux_version(void);
#ifdef __cplusplus
extern "C" {
#endif
/* Convenience macros for composing/decomposing version codes */
#define LINUX_VERSION(x,y,z) (0x10000*((x)&0x7fff) + 0x100*((y)&0xff) + ((z)&0xff))
@ -34,6 +33,9 @@ int procps_linux_version(void);
#define LINUX_VERSION_MINOR(x) (((x)>> 8) & 0xFF)
#define LINUX_VERSION_PATCH(x) ( (x) & 0xFF)
__END_DECLS
int procps_linux_version(void);
#endif /* PROC_VERSION_H */
#ifdef __cplusplus
}
#endif
#endif

View File

@ -24,9 +24,9 @@
#ifndef PROCPS_VMSTAT_H
#define PROCPS_VMSTAT_H
#include <sys/cdefs.h>
__BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
enum vmstat_item {
VMSTAT_noop, // ( never altered )
@ -308,5 +308,7 @@ struct vmstat_stack *procps_vmstat_select (
enum vmstat_item *items,
int numitems);
__END_DECLS
#ifdef __cplusplus
}
#endif
#endif