Commit 95dc9940a28b797375b696f1d7313e46c73e1e8e

Sam Lantinga 2013-10-17T20:49:30

Fix to unbreak SDL_GetSystemRAM() on FreeBSD Marcus von Appen Revision eecbcfed77c9 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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c
index d39075f..5e048f9 100644
--- a/src/cpuinfo/SDL_cpuinfo.c
+++ b/src/cpuinfo/SDL_cpuinfo.c
@@ -620,7 +620,16 @@ SDL_GetSystemRAM(void)
 #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);