From a28b5f617276e5e7aaa4fcbf5b895f8250d85a50 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sat, 18 Jun 2011 15:49:44 +0000 Subject: [PATCH] * Get the available memory for Haiku/BeOS * Refactor the code a bit so the warning for missing code will be there for all the people that don't provide code. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1805 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/misc.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/misc.c b/src/misc.c index 4c455ee4..afaa624b 100644 --- a/src/misc.c +++ b/src/misc.c @@ -738,7 +738,7 @@ void Zoom_a_line(byte* original_line, byte* zoomed_line, #elif defined(__macosx__) || defined(__FreeBSD__) || defined(__NetBSD__) #include #elif defined(__BEOS__) || defined(__HAIKU__) - // sysinfo not implemented + #include #elif defined(__AROS__) || defined(__amigaos4__) || defined(__MORPHOS__) || defined(__amigaos__) #include #elif defined(__MINT__) @@ -784,17 +784,23 @@ unsigned long Memory_free(void) len = sizeof(maxmem); sysctl(mib,2,&maxmem,&len,NULL,0); return maxmem; -#elif defined(__BEOS__) || defined(__HAIKU__) || defined(__SKYOS__) || defined(__amigaos4__) || defined(__TRU64__) - // No on BeOS or Haiku - // AvailMem is misleading on os4 (os4 caches stuff in memory that you can still allocate) -#warning "There is missing code there for your platform ! please check and correct :)" - return 10*1024*1024; +#elif defined(__HAIKU__) || defined(__BEOS__) + int pages; + system_info systemInfo; + get_system_info(&systemInfo); + + pages = systemInfo.max_pages - systemInfo.used_pages; + return pages * B_PAGE_SIZE; #elif defined(__AROS__) || defined(__MORPHOS__) || defined(__amigaos__) return AvailMem(MEMF_ANY); -#else +#elif defined(__linux__) struct sysinfo info; sysinfo(&info); return info.freeram*info.mem_unit; +#else + // AvailMem is misleading on os4 (os4 caches stuff in memory that you can still allocate) +#warning "There is missing code there for your platform ! please check and correct :)" + return 10*1024*1024; #endif } #endif