diff options
author | vkalintiris <vasilis@netdata.cloud> | 2022-01-19 08:54:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-19 08:54:37 +0200 |
commit | 37082fcbc150619b54b2a64c3621afc617607adc (patch) | |
tree | c0a5559cd3c5f1abcda0c099de993273bcebaff5 /libnetdata | |
parent | cc119e9e878959f155d38630c6d8e504d213383e (diff) |
Compute platform-specific list of static_threads at runtime. (#11955)
Compute array of static threads at runtime.
Diffstat (limited to 'libnetdata')
-rw-r--r-- | libnetdata/libnetdata.c | 1 | ||||
-rw-r--r-- | libnetdata/libnetdata.h | 1 | ||||
-rw-r--r-- | libnetdata/os.c | 19 | ||||
-rw-r--r-- | libnetdata/os.h | 22 |
4 files changed, 22 insertions, 21 deletions
diff --git a/libnetdata/libnetdata.c b/libnetdata/libnetdata.c index eb6fce74f8..18d0224076 100644 --- a/libnetdata/libnetdata.c +++ b/libnetdata/libnetdata.c @@ -14,7 +14,6 @@ struct rlimit rlimit_nofile = { .rlim_cur = 1024, .rlim_max = 1024 }; int enable_ksm = 1; volatile sig_atomic_t netdata_exit = 0; -const char *os_type = NETDATA_OS_TYPE; const char *program_version = VERSION; // ---------------------------------------------------------------------------- diff --git a/libnetdata/libnetdata.h b/libnetdata/libnetdata.h index 432c74f461..809cefa013 100644 --- a/libnetdata/libnetdata.h +++ b/libnetdata/libnetdata.h @@ -274,7 +274,6 @@ extern int verify_netdata_host_prefix(); extern int recursively_delete_dir(const char *path, const char *reason); extern volatile sig_atomic_t netdata_exit; -extern const char *os_type; extern const char *program_version; diff --git a/libnetdata/os.c b/libnetdata/os.c index 4271a917cd..196288a6ae 100644 --- a/libnetdata/os.c +++ b/libnetdata/os.c @@ -123,7 +123,9 @@ void get_system_HZ(void) { // ===================================================================================================================== // FreeBSD -#if (TARGET_OS == OS_FREEBSD) +#if __FreeBSD__ + +const char *os_type = "freebsd"; int getsysctl_by_name(const char *name, void *ptr, size_t len) { size_t nlen = len; @@ -198,7 +200,9 @@ int getsysctl_mib(const char *name, int *mib, size_t len) { // ===================================================================================================================== // MacOS -#if (TARGET_OS == OS_MACOS) +#if __APPLE__ + +const char *os_type = "macos"; int getsysctl_by_name(const char *name, void *ptr, size_t len) { size_t nlen = len; @@ -214,4 +218,13 @@ int getsysctl_by_name(const char *name, void *ptr, size_t len) { return 0; } -#endif // (TARGET_OS == OS_MACOS) +#endif + +// ===================================================================================================================== +// Linux + +#if __linux__ + +const char *os_type = "linux"; + +#endif diff --git a/libnetdata/os.h b/libnetdata/os.h index 2494174bc7..7872f82b90 100644 --- a/libnetdata/os.h +++ b/libnetdata/os.h @@ -6,15 +6,9 @@ #include "libnetdata.h" // ===================================================================================================================== -// Linux - -#if (TARGET_OS == OS_LINUX) - - -// ===================================================================================================================== // FreeBSD -#elif (TARGET_OS == OS_FREEBSD) +#if __FreeBSD__ #include <sys/sysctl.h> @@ -35,28 +29,24 @@ extern int getsysctl_simple(const char *name, int *mib, size_t miblen, void *ptr extern int getsysctl(const char *name, int *mib, size_t miblen, void *ptr, size_t *len); +#endif // ===================================================================================================================== // MacOS -#elif (TARGET_OS == OS_MACOS) +#if __APPLE__ #include <sys/sysctl.h> #define GETSYSCTL_BY_NAME(name, var) getsysctl_by_name(name, &(var), sizeof(var)) extern int getsysctl_by_name(const char *name, void *ptr, size_t len); - -// ===================================================================================================================== -// unknown O/S - -#else -#error unsupported operating system #endif - // ===================================================================================================================== -// common for all O/S +// common defs for Apple/FreeBSD/Linux + +extern const char *os_type; extern int processors; extern long get_system_cpus(void); |