zmalloc_get_rss implementation for haiku. (#10687)

also fixing already defined constants build warning while at it.

Co-authored-by: Oran Agra <oran@redislabs.com>
This commit is contained in:
David CARLIER 2022-05-08 13:12:17 +01:00 committed by GitHub
parent 4e761eb7e2
commit bdcd4b3df8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -91,6 +91,8 @@ typedef long long ustime_t; /* microsecond time type. */
#include "crc64.h"
/* min/max */
#undef min
#undef max
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

View File

@ -492,6 +492,23 @@ size_t zmalloc_get_rss(void) {
return 0L;
}
#elif defined(__HAIKU__)
#include <OS.h>
size_t zmalloc_get_rss(void) {
area_info info;
thread_info th;
size_t rss = 0;
ssize_t cookie = 0;
if (get_thread_info(find_thread(0), &th) != B_OK)
return 0;
while (get_next_area_info(th.team, &cookie, &info) == B_OK)
rss += info.ram_size;
return rss;
}
#elif defined(HAVE_PSINFO)
#include <unistd.h>
#include <sys/procfs.h>