diff options
author | Sverker Eriksson <[email protected]> | 2016-05-17 20:21:06 +0200 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2016-05-17 20:21:06 +0200 |
commit | 86477f342663bfcc3e87a7746d405f5c079b6d86 (patch) | |
tree | a61c7960dce385d63d4b101a188756407b8e08a2 /lib | |
parent | 7392c48c0c4ff35f9d9d1887c7d4fd396732c3de (diff) | |
download | otp-86477f342663bfcc3e87a7746d405f5c079b6d86.tar.gz otp-86477f342663bfcc3e87a7746d405f5c079b6d86.tar.bz2 otp-86477f342663bfcc3e87a7746d405f5c079b6d86.zip |
os_mon: Fix compile error on FreeBSD
implicit declaration of function 'EXIT_WITH'
Move code chunk up a bit to #define EXIT_WITH
before it's used.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/os_mon/c_src/cpu_sup.c | 57 |
1 files changed, 29 insertions, 28 deletions
diff --git a/lib/os_mon/c_src/cpu_sup.c b/lib/os_mon/c_src/cpu_sup.c index 353c7e674e..17ef48c26e 100644 --- a/lib/os_mon/c_src/cpu_sup.c +++ b/lib/os_mon/c_src/cpu_sup.c @@ -603,6 +603,35 @@ static void util_measure(unsigned int **result_vec, int *result_sz) { #endif /* ---------------------------- * + * Utils for OSX and FreeBSD * + * ---------------------------- */ + +#if (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) + +#define EXIT_WITH(msg) (rich_error(msg, __FILE__, __LINE__)) +#define RICH_BUFLEN (213) /* left in error(char*) */ + +void rich_error(const char *reason, const char *file, const int line) { + char buf[RICH_BUFLEN]; + snprintf(buf, RICH_BUFLEN, "%s (%s:%i)", reason, file, line); + error(buf); +} +#undef RICH_BUFLEN + +void getsysctl(const char *name, void *ptr, size_t len) +{ + size_t gotlen = len; + if (sysctlbyname(name, ptr, &gotlen, NULL, 0) != 0) { + EXIT_WITH("sysctlbyname failed"); + } + if (gotlen != len) { + EXIT_WITH("sysctlbyname: unexpected length"); + } +} +#endif + + +/* ---------------------------- * * FreeBSD stat functions * * ---------------------------- */ @@ -645,34 +674,6 @@ static void util_measure(unsigned int **result_vec, int *result_sz) { } #endif -/* ---------------------------- * - * Utils for OSX and FreeBSD * - * ---------------------------- */ - -#if (defined(__APPLE__) && defined(__MACH__)) || defined(__FreeBSD__) - -#define EXIT_WITH(msg) (rich_error(msg, __FILE__, __LINE__)) -#define RICH_BUFLEN (213) /* left in error(char*) */ - -void rich_error(const char *reason, const char *file, const int line) { - char buf[RICH_BUFLEN]; - snprintf(buf, RICH_BUFLEN, "%s (%s:%i)", reason, file, line); - error(buf); -} -#undef RICH_BUFLEN - -void getsysctl(const char *name, void *ptr, size_t len) -{ - size_t gotlen = len; - if (sysctlbyname(name, ptr, &gotlen, NULL, 0) != 0) { - EXIT_WITH("sysctlbyname failed"); - } - if (gotlen != len) { - EXIT_WITH("sysctlbyname: unexpected length"); - } -} -#endif - /* ---------------------------- * * Generic functions * |