From 2254e20d4cc5d497cd8bcdb0fd50098408534e75 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 22 Jul 2020 10:54:58 +0100 Subject: [PATCH 1/3] some apis are available on Illumos which are not available on stock Solaris thus availability evelavated from cflags. discard some sporadically for large pages support mainly. --- src/os.c | 8 ++++++++ src/static.c | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/src/os.c b/src/os.c index 8079e5a0..24252c85 100644 --- a/src/os.c +++ b/src/os.c @@ -8,6 +8,14 @@ terms of the MIT license. A copy of the license can be found in the file #define _DEFAULT_SOURCE // ensure mmap flags are defined #endif +#if defined(__sun) +// illumos provides new mman.h api when any of these are defined +// otherwise the old api based on caddr_t which predates the void pointers one. +// stock solaris provides only the former, chose to atomically to discard those +// flags only here rather than project wide tough. +#undef _XOPEN_SOURCE +#undef _POSIX_C_SOURCE +#endif #include "mimalloc.h" #include "mimalloc-internal.h" #include "mimalloc-atomic.h" diff --git a/src/static.c b/src/static.c index bf86166d..4fafb4f5 100644 --- a/src/static.c +++ b/src/static.c @@ -5,6 +5,11 @@ terms of the MIT license. A copy of the license can be found in the file "LICENSE" at the root of this distribution. -----------------------------------------------------------------------------*/ #define _DEFAULT_SOURCE +#if defined(__sun) +// same remarks as os.c for the static's context. +#undef _XOPEN_SOURCE +#undef _POSIX_C_SOURCE +#endif #include "mimalloc.h" #include "mimalloc-internal.h" From eb1188a1ddfa15130227e51b52a718dd93bcee6d Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 26 Jul 2020 17:00:54 +0000 Subject: [PATCH 2/3] Enables subset of stats for haiku. --- src/stats.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/stats.c b/src/stats.c index 172a3c0a..4c4f2486 100644 --- a/src/stats.c +++ b/src/stats.c @@ -466,7 +466,7 @@ static void mi_process_info(mi_msecs_t* utime, mi_msecs_t* stime, size_t* peak_r *page_reclaim = 0; } -#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__)) +#elif defined(__unix__) || defined(__unix) || defined(unix) || (defined(__APPLE__) && defined(__MACH__)) || defined(__HAIKU__) #include #include #include @@ -482,6 +482,7 @@ static mi_msecs_t timeval_secs(const struct timeval* tv) { static void mi_process_info(mi_msecs_t* utime, mi_msecs_t* stime, size_t* peak_rss, size_t* page_faults, size_t* page_reclaim, size_t* peak_commit) { struct rusage rusage; getrusage(RUSAGE_SELF, &rusage); +#if !defined(__HAIKU__) #if defined(__APPLE__) && defined(__MACH__) *peak_rss = rusage.ru_maxrss; #else @@ -490,6 +491,14 @@ static void mi_process_info(mi_msecs_t* utime, mi_msecs_t* stime, size_t* peak_r *page_faults = rusage.ru_majflt; *page_reclaim = rusage.ru_minflt; *peak_commit = 0; +#else +// Haiku does not have (yet?) a way to +// get these stats per process + *peak_rss = 0; + *page_faults = 0; + *page_reclaim = 0; + *peak_commit = 0; +#endif *utime = timeval_secs(&rusage.ru_utime); *stime = timeval_secs(&rusage.ru_stime); } From d964be2caa5a1f9837f9b0bb45e6296259e94a19 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Sun, 26 Jul 2020 18:56:10 +0000 Subject: [PATCH 3/3] getting resident mem at least --- src/stats.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/stats.c b/src/stats.c index 4c4f2486..203bad81 100644 --- a/src/stats.c +++ b/src/stats.c @@ -475,6 +475,10 @@ static void mi_process_info(mi_msecs_t* utime, mi_msecs_t* stime, size_t* peak_r #include #endif +#if defined(__HAIKU__) +#include +#endif + static mi_msecs_t timeval_secs(const struct timeval* tv) { return ((mi_msecs_t)tv->tv_sec * 1000L) + ((mi_msecs_t)tv->tv_usec / 1000L); } @@ -494,10 +498,18 @@ static void mi_process_info(mi_msecs_t* utime, mi_msecs_t* stime, size_t* peak_r #else // Haiku does not have (yet?) a way to // get these stats per process + thread_info tid; + area_info mem; + ssize_t c; *peak_rss = 0; *page_faults = 0; *page_reclaim = 0; *peak_commit = 0; + get_thread_info(find_thread(0), &tid); + + while (get_next_area_info(tid.team, &c, &mem) == B_OK) { + *peak_rss += mem.ram_size; + } #endif *utime = timeval_secs(&rusage.ru_utime); *stime = timeval_secs(&rusage.ru_stime);