Fix to unbreak SDL_GetSystemRAM() on FreeBSD
authorSam Lantinga <slouken@libsdl.org>
Thu, 17 Oct 2013 20:49:30 -0700
changeset 7826 a87057441d01
parent 7825 10be1bae0f7a
child 7827 a03ec8de0426
Fix to unbreak SDL_GetSystemRAM() on FreeBSD Marcus von Appen Revision c47ae79f0de8 of the SDL hg repo introduces the new SDL_GetSystemRAM() function, which breaks the build on FreeBSD. Find attached a patch, which unbreaks the build and also should (for most cases) properly implement the sysctl support it.
src/cpuinfo/SDL_cpuinfo.c
--- a/src/cpuinfo/SDL_cpuinfo.c	Thu Oct 17 17:38:55 2013 -0700
+++ b/src/cpuinfo/SDL_cpuinfo.c	Thu Oct 17 20:49:30 2013 -0700
@@ -620,7 +620,16 @@
 #endif
 #ifdef HAVE_SYSCTLBYNAME
         if (SDL_SystemRAM <= 0) {
+#ifdef __FreeBSD__
+#ifdef HW_REALMEM
+            int mib[2] = {CTL_HW, HW_REALMEM};
+#else
+            /* might only report up to 2 GiB */
+            int mib[2] = {CTL_HW, HW_PHYSMEM};
+#endif /* HW_REALMEM */
+#else
             int mib[2] = {CTL_HW, HW_MEMSIZE};
+#endif /* __FreeBSD__ */
             Uint64 memsize = 0;
             size_t len = sizeof(memsize);