Fix to unbreak SDL_GetSystemRAM() on FreeBSD
authorSam Lantinga <slouken@libsdl.org>
Thu, 17 Oct 2013 20:49:30 -0700
changeset 7826a87057441d01
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
     1.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Thu Oct 17 17:38:55 2013 -0700
     1.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Thu Oct 17 20:49:30 2013 -0700
     1.3 @@ -620,7 +620,16 @@
     1.4  #endif
     1.5  #ifdef HAVE_SYSCTLBYNAME
     1.6          if (SDL_SystemRAM <= 0) {
     1.7 +#ifdef __FreeBSD__
     1.8 +#ifdef HW_REALMEM
     1.9 +            int mib[2] = {CTL_HW, HW_REALMEM};
    1.10 +#else
    1.11 +            /* might only report up to 2 GiB */
    1.12 +            int mib[2] = {CTL_HW, HW_PHYSMEM};
    1.13 +#endif /* HW_REALMEM */
    1.14 +#else
    1.15              int mib[2] = {CTL_HW, HW_MEMSIZE};
    1.16 +#endif /* __FreeBSD__ */
    1.17              Uint64 memsize = 0;
    1.18              size_t len = sizeof(memsize);
    1.19