diff options
Diffstat (limited to 'lib/os_mon')
-rw-r--r-- | lib/os_mon/c_src/cpu_sup.c | 57 | ||||
-rw-r--r-- | lib/os_mon/src/memsup.erl | 2 | ||||
-rw-r--r-- | lib/os_mon/test/memsup_SUITE.erl | 14 |
3 files changed, 41 insertions, 32 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 * diff --git a/lib/os_mon/src/memsup.erl b/lib/os_mon/src/memsup.erl index d9d3083540..4729d090f8 100644 --- a/lib/os_mon/src/memsup.erl +++ b/lib/os_mon/src/memsup.erl @@ -699,6 +699,8 @@ get_os_wordsize_with_uname() -> case String of "x86_64" -> 64; "sparc64" -> 64; + "amd64" -> 64; + "ppc64" -> 64; _ -> 32 end. diff --git a/lib/os_mon/test/memsup_SUITE.erl b/lib/os_mon/test/memsup_SUITE.erl index fcd1417693..e40ed574e7 100644 --- a/lib/os_mon/test/memsup_SUITE.erl +++ b/lib/os_mon/test/memsup_SUITE.erl @@ -100,10 +100,16 @@ api(Config) when is_list(Config) -> %% get_os_wordsize() ok = case memsup:get_os_wordsize() of - 32 -> ok; - 64 -> ok; - unsupported_os -> ok; - _ -> error + 32 -> + 32 = 8*erlang:system_info({wordsize,external}), + ok; + 64 -> + % No reliable test here + ok; + unsupported_os -> + ok; + _ -> + error end, %% get_check_interval() |