src/cpuinfo/SDL_cpuinfo.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 21 Aug 2017 13:00:40 -0700
changeset 11338 fed4345ff3f2
parent 11308 43e03b947942
child 11700 57a894f4028f
permissions -rw-r--r--
SDL_cpuinfo.c: add os/2 support to SDL_GetCPUCount() and SDL_GetSystemRAM().
slouken@739
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@10737
     3
  Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
slouken@739
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@739
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@739
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@739
    20
*/
slouken@8148
    21
#ifdef TEST_MAIN
slouken@8148
    22
#include "SDL_config.h"
slouken@8148
    23
#else
icculus@8093
    24
#include "../SDL_internal.h"
slouken@8148
    25
#endif
slouken@739
    26
slouken@7828
    27
#if defined(__WIN32__)
slouken@7828
    28
#include "../core/windows/SDL_windows.h"
slouken@7828
    29
#endif
slouken@11338
    30
#if defined(__OS2__)
slouken@11338
    31
#define INCL_DOS
slouken@11338
    32
#include <os2.h>
slouken@11338
    33
#ifndef QSV_NUMPROCESSORS
slouken@11338
    34
#define QSV_NUMPROCESSORS 26
slouken@11338
    35
#endif
slouken@11338
    36
#endif
slouken@7828
    37
slouken@739
    38
/* CPU feature detection for SDL */
slouken@739
    39
slouken@1361
    40
#include "SDL_cpuinfo.h"
slouken@1361
    41
slouken@3586
    42
#ifdef HAVE_SYSCONF
slouken@3586
    43
#include <unistd.h>
slouken@3586
    44
#endif
slouken@3579
    45
#ifdef HAVE_SYSCTLBYNAME
slouken@3579
    46
#include <sys/types.h>
slouken@3579
    47
#include <sys/sysctl.h>
slouken@3579
    48
#endif
slouken@5389
    49
#if defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))
slouken@5389
    50
#include <sys/sysctl.h>         /* For AltiVec check */
slouken@6363
    51
#elif defined(__OpenBSD__) && defined(__powerpc__)
slouken@6363
    52
#include <sys/param.h>
slouken@6363
    53
#include <sys/sysctl.h> /* For AltiVec check */
slouken@6363
    54
#include <machine/cpu.h>
slouken@5389
    55
#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
slouken@5389
    56
#include <signal.h>
slouken@5389
    57
#include <setjmp.h>
slouken@5389
    58
#endif
slouken@793
    59
icculus@11308
    60
#if defined(__QNXNTO__)
icculus@11308
    61
#include <sys/syspage.h>
icculus@11308
    62
#endif
icculus@11308
    63
icculus@10626
    64
#if (defined(__LINUX__) || defined(__ANDROID__)) && defined(__ARM_ARCH)
icculus@10627
    65
/*#include <asm/hwcap.h>*/
icculus@10627
    66
#ifndef AT_HWCAP
icculus@10627
    67
#define AT_HWCAP 16
icculus@10627
    68
#endif
icculus@10627
    69
#ifndef HWCAP_NEON
icculus@10627
    70
#define HWCAP_NEON (1 << 12)
icculus@10627
    71
#endif
icculus@10626
    72
#if defined HAVE_GETAUXVAL
icculus@10620
    73
#include <sys/auxv.h>
icculus@10626
    74
#else
icculus@10625
    75
#include <fcntl.h>
icculus@10625
    76
#endif
icculus@10620
    77
#endif
icculus@10620
    78
slouken@3579
    79
#define CPU_HAS_RDTSC   0x00000001
slouken@5389
    80
#define CPU_HAS_ALTIVEC 0x00000002
slouken@5389
    81
#define CPU_HAS_MMX     0x00000004
slouken@5389
    82
#define CPU_HAS_3DNOW   0x00000008
slouken@5259
    83
#define CPU_HAS_SSE     0x00000010
slouken@5259
    84
#define CPU_HAS_SSE2    0x00000020
slouken@5259
    85
#define CPU_HAS_SSE3    0x00000040
slouken@5389
    86
#define CPU_HAS_SSE41   0x00000100
slouken@5389
    87
#define CPU_HAS_SSE42   0x00000200
slouken@8148
    88
#define CPU_HAS_AVX     0x00000400
slouken@9003
    89
#define CPU_HAS_AVX2    0x00000800
icculus@10620
    90
#define CPU_HAS_NEON    0x00001000
slouken@739
    91
slouken@6363
    92
#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__ && !__OpenBSD__
slouken@5389
    93
/* This is the brute force way of detecting instruction sets...
slouken@5389
    94
   the idea is borrowed from the libmpeg2 library - thanks!
slouken@5389
    95
 */
slouken@5389
    96
static jmp_buf jmpbuf;
slouken@5389
    97
static void
slouken@5389
    98
illegal_instruction(int sig)
slouken@5389
    99
{
slouken@5389
   100
    longjmp(jmpbuf, 1);
slouken@5389
   101
}
slouken@5389
   102
#endif /* HAVE_SETJMP */
slouken@793
   103
slouken@9003
   104
static int
slouken@1895
   105
CPU_haveCPUID(void)
slouken@745
   106
{
slouken@1895
   107
    int has_CPUID = 0;
icculus@10619
   108
slouken@1895
   109
/* *INDENT-OFF* */
icculus@9278
   110
#ifndef SDL_CPUINFO_DISABLED
slouken@745
   111
#if defined(__GNUC__) && defined(i386)
slouken@3579
   112
    __asm__ (
slouken@745
   113
"        pushfl                      # Get original EFLAGS             \n"
slouken@745
   114
"        popl    %%eax                                                 \n"
slouken@745
   115
"        movl    %%eax,%%ecx                                           \n"
slouken@745
   116
"        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n"
slouken@745
   117
"        pushl   %%eax               # Save new EFLAGS value on stack  \n"
slouken@745
   118
"        popfl                       # Replace current EFLAGS value    \n"
slouken@745
   119
"        pushfl                      # Get new EFLAGS                  \n"
slouken@745
   120
"        popl    %%eax               # Store new EFLAGS in EAX         \n"
slouken@745
   121
"        xorl    %%ecx,%%eax         # Can not toggle ID bit,          \n"
slouken@745
   122
"        jz      1f                  # Processor=80486                 \n"
slouken@745
   123
"        movl    $1,%0               # We have CPUID support           \n"
slouken@745
   124
"1:                                                                    \n"
slouken@3579
   125
    : "=m" (has_CPUID)
slouken@3579
   126
    :
slouken@3579
   127
    : "%eax", "%ecx"
slouken@3579
   128
    );
slouken@881
   129
#elif defined(__GNUC__) && defined(__x86_64__)
slouken@881
   130
/* Technically, if this is being compiled under __x86_64__ then it has 
slouken@8241
   131
   CPUid by definition.  But it's nice to be able to prove it.  :)      */
slouken@3579
   132
    __asm__ (
slouken@881
   133
"        pushfq                      # Get original EFLAGS             \n"
slouken@881
   134
"        popq    %%rax                                                 \n"
slouken@881
   135
"        movq    %%rax,%%rcx                                           \n"
slouken@881
   136
"        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n"
slouken@881
   137
"        pushq   %%rax               # Save new EFLAGS value on stack  \n"
slouken@881
   138
"        popfq                       # Replace current EFLAGS value    \n"
slouken@881
   139
"        pushfq                      # Get new EFLAGS                  \n"
slouken@881
   140
"        popq    %%rax               # Store new EFLAGS in EAX         \n"
slouken@881
   141
"        xorl    %%ecx,%%eax         # Can not toggle ID bit,          \n"
slouken@881
   142
"        jz      1f                  # Processor=80486                 \n"
slouken@881
   143
"        movl    $1,%0               # We have CPUID support           \n"
slouken@881
   144
"1:                                                                    \n"
slouken@3579
   145
    : "=m" (has_CPUID)
slouken@3579
   146
    :
slouken@3579
   147
    : "%rax", "%rcx"
slouken@3579
   148
    );
slouken@1442
   149
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
slouken@3579
   150
    __asm {
slouken@745
   151
        pushfd                      ; Get original EFLAGS
slouken@745
   152
        pop     eax
slouken@745
   153
        mov     ecx, eax
slouken@745
   154
        xor     eax, 200000h        ; Flip ID bit in EFLAGS
slouken@745
   155
        push    eax                 ; Save new EFLAGS value on stack
slouken@745
   156
        popfd                       ; Replace current EFLAGS value
slouken@745
   157
        pushfd                      ; Get new EFLAGS
slouken@745
   158
        pop     eax                 ; Store new EFLAGS in EAX
slouken@745
   159
        xor     eax, ecx            ; Can not toggle ID bit,
slouken@745
   160
        jz      done                ; Processor=80486
slouken@745
   161
        mov     has_CPUID,1         ; We have CPUID support
slouken@745
   162
done:
slouken@3579
   163
    }
slouken@8241
   164
#elif defined(_MSC_VER) && defined(_M_X64)
slouken@8241
   165
    has_CPUID = 1;
slouken@1864
   166
#elif defined(__sun) && defined(__i386)
slouken@3579
   167
    __asm (
icculus@1229
   168
"       pushfl                 \n"
slouken@3584
   169
"       popl    %eax           \n"
slouken@3584
   170
"       movl    %eax,%ecx      \n"
slouken@3584
   171
"       xorl    $0x200000,%eax \n"
slouken@3584
   172
"       pushl   %eax           \n"
slouken@3584
   173
"       popfl                  \n"
slouken@3584
   174
"       pushfl                 \n"
slouken@3584
   175
"       popl    %eax           \n"
slouken@3584
   176
"       xorl    %ecx,%eax      \n"
slouken@3584
   177
"       jz      1f             \n"
slouken@3584
   178
"       movl    $1,-8(%ebp)    \n"
icculus@1229
   179
"1:                            \n"
slouken@3579
   180
    );
icculus@1229
   181
#elif defined(__sun) && defined(__amd64)
slouken@3579
   182
    __asm (
icculus@1229
   183
"       pushfq                 \n"
icculus@1229
   184
"       popq    %rax           \n"
icculus@1229
   185
"       movq    %rax,%rcx      \n"
icculus@1229
   186
"       xorl    $0x200000,%eax \n"
icculus@1229
   187
"       pushq   %rax           \n"
icculus@1229
   188
"       popfq                  \n"
icculus@1229
   189
"       pushfq                 \n"
icculus@1229
   190
"       popq    %rax           \n"
icculus@1229
   191
"       xorl    %ecx,%eax      \n"
icculus@1229
   192
"       jz      1f             \n"
icculus@1229
   193
"       movl    $1,-8(%rbp)    \n"
icculus@1229
   194
"1:                            \n"
slouken@3579
   195
    );
slouken@745
   196
#endif
icculus@9278
   197
#endif
slouken@1895
   198
/* *INDENT-ON* */
slouken@1895
   199
    return has_CPUID;
slouken@745
   200
}
slouken@745
   201
slouken@3587
   202
#if defined(__GNUC__) && defined(i386)
slouken@3580
   203
#define cpuid(func, a, b, c, d) \
slouken@3584
   204
    __asm__ __volatile__ ( \
slouken@3584
   205
"        pushl %%ebx        \n" \
slouken@9003
   206
"        xorl %%ecx,%%ecx   \n" \
slouken@3584
   207
"        cpuid              \n" \
slouken@3584
   208
"        movl %%ebx, %%esi  \n" \
slouken@3584
   209
"        popl %%ebx         \n" : \
slouken@3584
   210
            "=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (func))
slouken@3587
   211
#elif defined(__GNUC__) && defined(__x86_64__)
slouken@3587
   212
#define cpuid(func, a, b, c, d) \
slouken@3587
   213
    __asm__ __volatile__ ( \
slouken@3587
   214
"        pushq %%rbx        \n" \
slouken@9003
   215
"        xorq %%rcx,%%rcx   \n" \
slouken@3587
   216
"        cpuid              \n" \
slouken@3587
   217
"        movq %%rbx, %%rsi  \n" \
slouken@3587
   218
"        popq %%rbx         \n" : \
slouken@3587
   219
            "=a" (a), "=S" (b), "=c" (c), "=d" (d) : "a" (func))
slouken@3579
   220
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
slouken@3580
   221
#define cpuid(func, a, b, c, d) \
slouken@3580
   222
    __asm { \
slouken@3580
   223
        __asm mov eax, func \
slouken@9003
   224
        __asm xor ecx, ecx \
slouken@3580
   225
        __asm cpuid \
slouken@3580
   226
        __asm mov a, eax \
slouken@3580
   227
        __asm mov b, ebx \
slouken@3580
   228
        __asm mov c, ecx \
slouken@3580
   229
        __asm mov d, edx \
slouken@8241
   230
}
slouken@8241
   231
#elif defined(_MSC_VER) && defined(_M_X64)
slouken@8241
   232
#define cpuid(func, a, b, c, d) \
slouken@8241
   233
{ \
slouken@8241
   234
    int CPUInfo[4]; \
slouken@8241
   235
    __cpuid(CPUInfo, func); \
slouken@8241
   236
    a = CPUInfo[0]; \
slouken@8241
   237
    b = CPUInfo[1]; \
slouken@8241
   238
    c = CPUInfo[2]; \
slouken@8241
   239
    d = CPUInfo[3]; \
slouken@8241
   240
}
slouken@3579
   241
#else
slouken@3580
   242
#define cpuid(func, a, b, c, d) \
icculus@10926
   243
    do { a = b = c = d = 0; (void) a; (void) b; (void) c; (void) d; } while (0)
slouken@3579
   244
#endif
slouken@3579
   245
icculus@10619
   246
static int CPU_CPUIDFeatures[4];
icculus@10619
   247
static int CPU_CPUIDMaxFunction = 0;
icculus@10619
   248
static SDL_bool CPU_OSSavesYMM = SDL_FALSE;
icculus@10619
   249
icculus@10619
   250
static void
icculus@10619
   251
CPU_calcCPUIDFeatures(void)
slouken@745
   252
{
icculus@10619
   253
    static SDL_bool checked = SDL_FALSE;
icculus@10619
   254
    if (!checked) {
icculus@10619
   255
        checked = SDL_TRUE;
icculus@10619
   256
        if (CPU_haveCPUID()) {
icculus@10619
   257
            int a, b, c, d;
icculus@10619
   258
            cpuid(0, a, b, c, d);
icculus@10619
   259
            CPU_CPUIDMaxFunction = a;
icculus@10619
   260
            if (CPU_CPUIDMaxFunction >= 1) {
icculus@10619
   261
                cpuid(1, a, b, c, d);
icculus@10619
   262
                CPU_CPUIDFeatures[0] = a;
icculus@10619
   263
                CPU_CPUIDFeatures[1] = b;
icculus@10619
   264
                CPU_CPUIDFeatures[2] = c;
icculus@10619
   265
                CPU_CPUIDFeatures[3] = d;
slouken@3579
   266
icculus@10619
   267
                /* Check to make sure we can call xgetbv */
icculus@10619
   268
                if (c & 0x08000000) {
icculus@10619
   269
                    /* Call xgetbv to see if YMM register state is saved */
icculus@10619
   270
#if defined(__GNUC__) && (defined(i386) || defined(__x86_64__))
slouken@10931
   271
                    __asm__(".byte 0x0f, 0x01, 0xd0" : "=a" (a) : "c" (0) : "%edx");
icculus@10619
   272
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64)) && (_MSC_FULL_VER >= 160040219) /* VS2010 SP1 */
icculus@10619
   273
                    a = (int)_xgetbv(0);
icculus@10619
   274
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
icculus@10619
   275
                    __asm
icculus@10619
   276
                    {
icculus@10619
   277
                        xor ecx, ecx
icculus@10619
   278
                        _asm _emit 0x0f _asm _emit 0x01 _asm _emit 0xd0
icculus@10619
   279
                        mov a, eax
icculus@10619
   280
                    }
icculus@10619
   281
#endif
icculus@10619
   282
                    CPU_OSSavesYMM = ((a & 6) == 6) ? SDL_TRUE : SDL_FALSE;
icculus@10619
   283
                }
icculus@10619
   284
            }
icculus@10619
   285
        }
slouken@3579
   286
    }
slouken@745
   287
}
slouken@745
   288
slouken@9003
   289
static int
slouken@5389
   290
CPU_haveAltiVec(void)
slouken@5389
   291
{
slouken@5389
   292
    volatile int altivec = 0;
icculus@9278
   293
#ifndef SDL_CPUINFO_DISABLED
slouken@6363
   294
#if (defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))) || (defined(__OpenBSD__) && defined(__powerpc__))
slouken@6363
   295
#ifdef __OpenBSD__
slouken@6363
   296
    int selectors[2] = { CTL_MACHDEP, CPU_ALTIVEC };
slouken@6363
   297
#else
slouken@5389
   298
    int selectors[2] = { CTL_HW, HW_VECTORUNIT };
slouken@6363
   299
#endif
slouken@5389
   300
    int hasVectorUnit = 0;
slouken@5389
   301
    size_t length = sizeof(hasVectorUnit);
slouken@5389
   302
    int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0);
slouken@5389
   303
    if (0 == error)
slouken@5389
   304
        altivec = (hasVectorUnit != 0);
slouken@5389
   305
#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
slouken@5389
   306
    void (*handler) (int sig);
slouken@5389
   307
    handler = signal(SIGILL, illegal_instruction);
slouken@5389
   308
    if (setjmp(jmpbuf) == 0) {
slouken@5389
   309
        asm volatile ("mtspr 256, %0\n\t" "vand %%v0, %%v0, %%v0"::"r" (-1));
slouken@5389
   310
        altivec = 1;
slouken@5389
   311
    }
slouken@5389
   312
    signal(SIGILL, handler);
slouken@5389
   313
#endif
icculus@9278
   314
#endif
slouken@5389
   315
    return altivec;
slouken@5389
   316
}
slouken@5389
   317
icculus@10626
   318
#if (defined(__LINUX__) || defined(__ANDROID__)) && defined(__ARM_ARCH) && !defined(HAVE_GETAUXVAL)
icculus@10624
   319
static int
icculus@10624
   320
readProcAuxvForNeon(void)
icculus@10624
   321
{
icculus@10624
   322
    int neon = 0;
icculus@10624
   323
    int kv[2];
icculus@10624
   324
    const int fd = open("/proc/self/auxv", O_RDONLY);
icculus@10626
   325
    if (fd != -1) {
icculus@10626
   326
        while (read(fd, kv, sizeof (kv)) == sizeof (kv)) {
icculus@10626
   327
            if (kv[0] == AT_HWCAP) {
icculus@10626
   328
                neon = ((kv[1] & HWCAP_NEON) == HWCAP_NEON);
icculus@10626
   329
                break;
icculus@10626
   330
            }
icculus@10626
   331
        }
icculus@10626
   332
        close(fd);
icculus@10624
   333
    }
icculus@10624
   334
    return neon;
icculus@10624
   335
}
icculus@10624
   336
#endif
icculus@10624
   337
icculus@10624
   338
slouken@9003
   339
static int
icculus@10620
   340
CPU_haveNEON(void)
icculus@10620
   341
{
icculus@10620
   342
/* The way you detect NEON is a privileged instruction on ARM, so you have
icculus@10620
   343
   query the OS kernel in a platform-specific way. :/ */
icculus@10624
   344
#if defined(SDL_CPUINFO_DISABLED) || !defined(__ARM_ARCH)
icculus@10625
   345
    return 0;  /* disabled or not an ARM CPU at all. */
icculus@10624
   346
#elif __ARM_ARCH >= 8
icculus@10639
   347
    return 1;  /* ARMv8 always has non-optional NEON support. */
icculus@10639
   348
#elif defined(__APPLE__) && (__ARM_ARCH >= 7)
icculus@10639
   349
    /* (note that sysctlbyname("hw.optional.neon") doesn't work!) */
icculus@10639
   350
    return 1;  /* all Apple ARMv7 chips and later have NEON. */
icculus@10624
   351
#elif defined(__APPLE__)
icculus@10639
   352
    return 0;  /* assune anything else from Apple doesn't have NEON. */
icculus@11308
   353
#elif defined(__QNXNTO__)
icculus@11308
   354
    return SYSPAGE_ENTRY(cpuinfo)->flags & ARM_CPU_FLAG_NEON;
icculus@10625
   355
#elif (defined(__LINUX__) || defined(__ANDROID__)) && defined(HAVE_GETAUXVAL)
icculus@10628
   356
    return ((getauxval(AT_HWCAP) & HWCAP_NEON) == HWCAP_NEON);
icculus@10624
   357
#elif (defined(__LINUX__) || defined(__ANDROID__))
icculus@10626
   358
    return readProcAuxvForNeon();   /* Android offers a static library for this, but it just parses /proc/self/auxv */
icculus@10620
   359
#elif (defined(__WINDOWS__) || defined(__WINRT__)) && defined(_M_ARM)
icculus@10620
   360
    /* All WinRT ARM devices are required to support NEON, but just in case. */
icculus@10625
   361
    return IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != 0;
icculus@10624
   362
#else
icculus@10624
   363
#warning SDL_HasNEON is not implemented for this ARM platform. Write me.
icculus@10625
   364
    return 0;
icculus@10620
   365
#endif
icculus@10620
   366
}
icculus@10620
   367
icculus@10620
   368
static int
slouken@5389
   369
CPU_have3DNow(void)
slouken@5389
   370
{
icculus@10619
   371
    if (CPU_CPUIDMaxFunction > 0) {  /* that is, do we have CPUID at all? */
slouken@5389
   372
        int a, b, c, d;
slouken@5389
   373
        cpuid(0x80000000, a, b, c, d);
slouken@5389
   374
        if (a >= 0x80000001) {
slouken@5389
   375
            cpuid(0x80000001, a, b, c, d);
slouken@5389
   376
            return (d & 0x80000000);
slouken@5389
   377
        }
slouken@5389
   378
    }
slouken@5389
   379
    return 0;
slouken@5389
   380
}
slouken@5389
   381
icculus@10619
   382
#define CPU_haveRDTSC() (CPU_CPUIDFeatures[3] & 0x00000010)
icculus@10619
   383
#define CPU_haveMMX() (CPU_CPUIDFeatures[3] & 0x00800000)
icculus@10619
   384
#define CPU_haveSSE() (CPU_CPUIDFeatures[3] & 0x02000000)
icculus@10619
   385
#define CPU_haveSSE2() (CPU_CPUIDFeatures[3] & 0x04000000)
icculus@10619
   386
#define CPU_haveSSE3() (CPU_CPUIDFeatures[2] & 0x00000001)
icculus@10619
   387
#define CPU_haveSSE41() (CPU_CPUIDFeatures[2] & 0x00080000)
icculus@10619
   388
#define CPU_haveSSE42() (CPU_CPUIDFeatures[2] & 0x00100000)
icculus@10619
   389
#define CPU_haveAVX() (CPU_OSSavesYMM && (CPU_CPUIDFeatures[2] & 0x10000000))
slouken@8148
   390
slouken@9003
   391
static int
slouken@9003
   392
CPU_haveAVX2(void)
slouken@9003
   393
{
icculus@10619
   394
    if (CPU_OSSavesYMM && (CPU_CPUIDMaxFunction >= 7)) {
slouken@9003
   395
        int a, b, c, d;
icculus@10623
   396
        (void) a; (void) b; (void) c; (void) d;  /* compiler warnings... */
icculus@10619
   397
        cpuid(7, a, b, c, d);
icculus@10619
   398
        return (b & 0x00000020);
slouken@9003
   399
    }
slouken@9003
   400
    return 0;
slouken@9003
   401
}
slouken@9003
   402
slouken@3579
   403
static int SDL_CPUCount = 0;
slouken@3579
   404
slouken@3579
   405
int
slouken@5120
   406
SDL_GetCPUCount(void)
slouken@3579
   407
{
slouken@3579
   408
    if (!SDL_CPUCount) {
icculus@9278
   409
#ifndef SDL_CPUINFO_DISABLED
slouken@3606
   410
#if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
slouken@3586
   411
        if (SDL_CPUCount <= 0) {
slouken@3586
   412
            SDL_CPUCount = (int)sysconf(_SC_NPROCESSORS_ONLN);
slouken@3586
   413
        }
slouken@3586
   414
#endif
slouken@3579
   415
#ifdef HAVE_SYSCTLBYNAME
slouken@3586
   416
        if (SDL_CPUCount <= 0) {
slouken@3580
   417
            size_t size = sizeof(SDL_CPUCount);
slouken@3580
   418
            sysctlbyname("hw.ncpu", &SDL_CPUCount, &size, NULL, 0);
slouken@3580
   419
        }
slouken@3580
   420
#endif
slouken@5086
   421
#ifdef __WIN32__
slouken@3586
   422
        if (SDL_CPUCount <= 0) {
slouken@3580
   423
            SYSTEM_INFO info;
slouken@3580
   424
            GetSystemInfo(&info);
slouken@3580
   425
            SDL_CPUCount = info.dwNumberOfProcessors;
slouken@3580
   426
        }
slouken@3579
   427
#endif
slouken@11338
   428
#ifdef __OS2__
slouken@11338
   429
        if (SDL_CPUCount <= 0) {
slouken@11338
   430
            DosQuerySysInfo(QSV_NUMPROCESSORS, QSV_NUMPROCESSORS,
slouken@11338
   431
                            &SDL_CPUCount, sizeof(SDL_CPUCount) );
slouken@11338
   432
        }
slouken@11338
   433
#endif
icculus@9278
   434
#endif
slouken@3579
   435
        /* There has to be at least 1, right? :) */
slouken@3586
   436
        if (SDL_CPUCount <= 0) {
slouken@3579
   437
            SDL_CPUCount = 1;
slouken@3579
   438
        }
slouken@3579
   439
    }
slouken@3579
   440
    return SDL_CPUCount;
slouken@3579
   441
}
slouken@3579
   442
slouken@3579
   443
/* Oh, such a sweet sweet trick, just not very useful. :) */
slouken@4472
   444
static const char *
slouken@5120
   445
SDL_GetCPUType(void)
slouken@3579
   446
{
slouken@5115
   447
    static char SDL_CPUType[13];
slouken@3579
   448
slouken@3579
   449
    if (!SDL_CPUType[0]) {
slouken@3579
   450
        int i = 0;
slouken@3579
   451
icculus@10619
   452
        CPU_calcCPUIDFeatures();
icculus@10619
   453
        if (CPU_CPUIDMaxFunction > 0) {  /* do we have CPUID at all? */
icculus@9300
   454
            int a, b, c, d;
slouken@5115
   455
            cpuid(0x00000000, a, b, c, d);
icculus@9300
   456
            (void) a;
slouken@5115
   457
            SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
slouken@5115
   458
            SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
slouken@5115
   459
            SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
icculus@8642
   460
            SDL_CPUType[i++] = (char)(b & 0xff);
icculus@8642
   461
slouken@5115
   462
            SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
slouken@5115
   463
            SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
slouken@5115
   464
            SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
icculus@8642
   465
            SDL_CPUType[i++] = (char)(d & 0xff);
icculus@8642
   466
slouken@5115
   467
            SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
slouken@5115
   468
            SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
slouken@5115
   469
            SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
icculus@8642
   470
            SDL_CPUType[i++] = (char)(c & 0xff);
slouken@5115
   471
        }
slouken@5115
   472
        if (!SDL_CPUType[0]) {
slouken@5115
   473
            SDL_strlcpy(SDL_CPUType, "Unknown", sizeof(SDL_CPUType));
slouken@5115
   474
        }
slouken@5115
   475
    }
slouken@5115
   476
    return SDL_CPUType;
slouken@5115
   477
}
slouken@5115
   478
icculus@5981
   479
icculus@5981
   480
#ifdef TEST_MAIN  /* !!! FIXME: only used for test at the moment. */
slouken@5115
   481
static const char *
slouken@5120
   482
SDL_GetCPUName(void)
slouken@5115
   483
{
slouken@5115
   484
    static char SDL_CPUName[48];
slouken@5115
   485
slouken@5115
   486
    if (!SDL_CPUName[0]) {
slouken@5115
   487
        int i = 0;
slouken@5115
   488
        int a, b, c, d;
slouken@5115
   489
icculus@10619
   490
        CPU_calcCPUIDFeatures();
icculus@10619
   491
        if (CPU_CPUIDMaxFunction > 0) {  /* do we have CPUID at all? */
slouken@3580
   492
            cpuid(0x80000000, a, b, c, d);
slouken@3580
   493
            if (a >= 0x80000004) {
slouken@3580
   494
                cpuid(0x80000002, a, b, c, d);
slouken@5115
   495
                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
slouken@5115
   496
                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
slouken@5115
   497
                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
slouken@5115
   498
                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
slouken@5115
   499
                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
slouken@5115
   500
                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
slouken@5115
   501
                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
slouken@5115
   502
                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
slouken@5115
   503
                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
slouken@5115
   504
                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
slouken@5115
   505
                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
slouken@5115
   506
                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
slouken@5115
   507
                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
slouken@5115
   508
                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
slouken@5115
   509
                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
slouken@5115
   510
                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
slouken@3580
   511
                cpuid(0x80000003, a, b, c, d);
slouken@5115
   512
                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
slouken@5115
   513
                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
slouken@5115
   514
                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
slouken@5115
   515
                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
slouken@5115
   516
                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
slouken@5115
   517
                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
slouken@5115
   518
                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
slouken@5115
   519
                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
slouken@5115
   520
                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
slouken@5115
   521
                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
slouken@5115
   522
                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
slouken@5115
   523
                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
slouken@5115
   524
                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
slouken@5115
   525
                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
slouken@5115
   526
                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
slouken@5115
   527
                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
slouken@3580
   528
                cpuid(0x80000004, a, b, c, d);
slouken@5115
   529
                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
slouken@5115
   530
                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
slouken@5115
   531
                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
slouken@5115
   532
                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
slouken@5115
   533
                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
slouken@5115
   534
                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
slouken@5115
   535
                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
slouken@5115
   536
                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
slouken@5115
   537
                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
slouken@5115
   538
                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
slouken@5115
   539
                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
slouken@5115
   540
                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
slouken@5115
   541
                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
slouken@5115
   542
                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
slouken@5115
   543
                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
slouken@5115
   544
                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
slouken@3579
   545
            }
slouken@3579
   546
        }
slouken@5115
   547
        if (!SDL_CPUName[0]) {
slouken@5115
   548
            SDL_strlcpy(SDL_CPUName, "Unknown", sizeof(SDL_CPUName));
slouken@3579
   549
        }
slouken@3579
   550
    }
slouken@5115
   551
    return SDL_CPUName;
slouken@5115
   552
}
icculus@5981
   553
#endif
slouken@5115
   554
slouken@5120
   555
int
slouken@5120
   556
SDL_GetCPUCacheLineSize(void)
slouken@5115
   557
{
slouken@5115
   558
    const char *cpuType = SDL_GetCPUType();
icculus@9300
   559
    int a, b, c, d;
icculus@9300
   560
    (void) a; (void) b; (void) c; (void) d;
slouken@5115
   561
    if (SDL_strcmp(cpuType, "GenuineIntel") == 0) {
slouken@5115
   562
        cpuid(0x00000001, a, b, c, d);
slouken@5115
   563
        return (((b >> 8) & 0xff) * 8);
slouken@5115
   564
    } else if (SDL_strcmp(cpuType, "AuthenticAMD") == 0) {
slouken@5115
   565
        cpuid(0x80000005, a, b, c, d);
slouken@5115
   566
        return (c & 0xff);
slouken@5115
   567
    } else {
slouken@5115
   568
        /* Just make a guess here... */
slouken@5115
   569
        return SDL_CACHELINE_SIZE;
slouken@5115
   570
    }
slouken@3579
   571
}
slouken@3579
   572
slouken@739
   573
static Uint32 SDL_CPUFeatures = 0xFFFFFFFF;
slouken@739
   574
slouken@1895
   575
static Uint32
slouken@1895
   576
SDL_GetCPUFeatures(void)
slouken@739
   577
{
slouken@1895
   578
    if (SDL_CPUFeatures == 0xFFFFFFFF) {
icculus@10619
   579
        CPU_calcCPUIDFeatures();
slouken@1895
   580
        SDL_CPUFeatures = 0;
slouken@1895
   581
        if (CPU_haveRDTSC()) {
slouken@1895
   582
            SDL_CPUFeatures |= CPU_HAS_RDTSC;
slouken@1895
   583
        }
slouken@5389
   584
        if (CPU_haveAltiVec()) {
slouken@5389
   585
            SDL_CPUFeatures |= CPU_HAS_ALTIVEC;
slouken@5389
   586
        }
slouken@1895
   587
        if (CPU_haveMMX()) {
slouken@1895
   588
            SDL_CPUFeatures |= CPU_HAS_MMX;
slouken@1895
   589
        }
slouken@5389
   590
        if (CPU_have3DNow()) {
slouken@5389
   591
            SDL_CPUFeatures |= CPU_HAS_3DNOW;
slouken@5389
   592
        }
slouken@1895
   593
        if (CPU_haveSSE()) {
slouken@1895
   594
            SDL_CPUFeatures |= CPU_HAS_SSE;
slouken@1895
   595
        }
slouken@1895
   596
        if (CPU_haveSSE2()) {
slouken@1895
   597
            SDL_CPUFeatures |= CPU_HAS_SSE2;
slouken@1895
   598
        }
slouken@5259
   599
        if (CPU_haveSSE3()) {
slouken@5259
   600
            SDL_CPUFeatures |= CPU_HAS_SSE3;
slouken@5259
   601
        }
slouken@5263
   602
        if (CPU_haveSSE41()) {
slouken@5263
   603
            SDL_CPUFeatures |= CPU_HAS_SSE41;
slouken@5263
   604
        }
slouken@5263
   605
        if (CPU_haveSSE42()) {
slouken@5263
   606
            SDL_CPUFeatures |= CPU_HAS_SSE42;
slouken@1895
   607
        }
slouken@8148
   608
        if (CPU_haveAVX()) {
slouken@8148
   609
            SDL_CPUFeatures |= CPU_HAS_AVX;
slouken@8148
   610
        }
slouken@9003
   611
        if (CPU_haveAVX2()) {
slouken@9003
   612
            SDL_CPUFeatures |= CPU_HAS_AVX2;
slouken@9003
   613
        }
icculus@10620
   614
        if (CPU_haveNEON()) {
icculus@10620
   615
            SDL_CPUFeatures |= CPU_HAS_NEON;
icculus@10620
   616
        }
slouken@1895
   617
    }
slouken@1895
   618
    return SDL_CPUFeatures;
slouken@739
   619
}
slouken@739
   620
icculus@10619
   621
#define CPU_FEATURE_AVAILABLE(f) ((SDL_GetCPUFeatures() & f) ? SDL_TRUE : SDL_FALSE)
icculus@10619
   622
icculus@10619
   623
SDL_bool SDL_HasRDTSC(void)
slouken@745
   624
{
icculus@10619
   625
    return CPU_FEATURE_AVAILABLE(CPU_HAS_RDTSC);
slouken@745
   626
}
slouken@745
   627
slouken@1895
   628
SDL_bool
slouken@5389
   629
SDL_HasAltiVec(void)
slouken@5389
   630
{
icculus@10619
   631
    return CPU_FEATURE_AVAILABLE(CPU_HAS_ALTIVEC);
slouken@5389
   632
}
slouken@5389
   633
slouken@5389
   634
SDL_bool
slouken@1895
   635
SDL_HasMMX(void)
slouken@739
   636
{
icculus@10619
   637
    return CPU_FEATURE_AVAILABLE(CPU_HAS_MMX);
slouken@739
   638
}
slouken@739
   639
slouken@1895
   640
SDL_bool
slouken@5389
   641
SDL_Has3DNow(void)
slouken@5389
   642
{
icculus@10619
   643
    return CPU_FEATURE_AVAILABLE(CPU_HAS_3DNOW);
slouken@5389
   644
}
slouken@5389
   645
slouken@5389
   646
SDL_bool
slouken@1895
   647
SDL_HasSSE(void)
slouken@739
   648
{
icculus@10619
   649
    return CPU_FEATURE_AVAILABLE(CPU_HAS_SSE);
slouken@739
   650
}
slouken@739
   651
slouken@1895
   652
SDL_bool
slouken@1895
   653
SDL_HasSSE2(void)
slouken@804
   654
{
icculus@10619
   655
    return CPU_FEATURE_AVAILABLE(CPU_HAS_SSE2);
slouken@804
   656
}
slouken@804
   657
slouken@1895
   658
SDL_bool
slouken@5259
   659
SDL_HasSSE3(void)
slouken@778
   660
{
icculus@10619
   661
    return CPU_FEATURE_AVAILABLE(CPU_HAS_SSE3);
slouken@5259
   662
}
slouken@5259
   663
slouken@5259
   664
SDL_bool
slouken@5263
   665
SDL_HasSSE41(void)
slouken@5259
   666
{
icculus@10619
   667
    return CPU_FEATURE_AVAILABLE(CPU_HAS_SSE41);
slouken@5263
   668
}
slouken@5263
   669
slouken@5263
   670
SDL_bool
slouken@5263
   671
SDL_HasSSE42(void)
slouken@5263
   672
{
icculus@10619
   673
    return CPU_FEATURE_AVAILABLE(CPU_HAS_SSE42);
slouken@778
   674
}
slouken@778
   675
slouken@8148
   676
SDL_bool
slouken@8148
   677
SDL_HasAVX(void)
slouken@8148
   678
{
icculus@10619
   679
    return CPU_FEATURE_AVAILABLE(CPU_HAS_AVX);
slouken@8148
   680
}
slouken@8148
   681
slouken@9003
   682
SDL_bool
slouken@9003
   683
SDL_HasAVX2(void)
slouken@9003
   684
{
icculus@10619
   685
    return CPU_FEATURE_AVAILABLE(CPU_HAS_AVX2);
slouken@9003
   686
}
slouken@9003
   687
icculus@10620
   688
SDL_bool
icculus@10620
   689
SDL_HasNEON(void)
icculus@10620
   690
{
icculus@10620
   691
    return CPU_FEATURE_AVAILABLE(CPU_HAS_NEON);
icculus@10620
   692
}
icculus@10620
   693
slouken@7821
   694
static int SDL_SystemRAM = 0;
slouken@7821
   695
slouken@7821
   696
int
slouken@7821
   697
SDL_GetSystemRAM(void)
slouken@7821
   698
{
slouken@7821
   699
    if (!SDL_SystemRAM) {
icculus@9278
   700
#ifndef SDL_CPUINFO_DISABLED
slouken@7821
   701
#if defined(HAVE_SYSCONF) && defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)
slouken@7821
   702
        if (SDL_SystemRAM <= 0) {
slouken@7821
   703
            SDL_SystemRAM = (int)((Sint64)sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE) / (1024*1024));
slouken@7821
   704
        }
slouken@7821
   705
#endif
slouken@7821
   706
#ifdef HAVE_SYSCTLBYNAME
slouken@7821
   707
        if (SDL_SystemRAM <= 0) {
icculus@9987
   708
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
slouken@7826
   709
#ifdef HW_REALMEM
slouken@7826
   710
            int mib[2] = {CTL_HW, HW_REALMEM};
slouken@7826
   711
#else
slouken@7826
   712
            /* might only report up to 2 GiB */
slouken@7826
   713
            int mib[2] = {CTL_HW, HW_PHYSMEM};
slouken@7826
   714
#endif /* HW_REALMEM */
slouken@7826
   715
#else
slouken@7821
   716
            int mib[2] = {CTL_HW, HW_MEMSIZE};
slouken@8240
   717
#endif /* __FreeBSD__ || __FreeBSD_kernel__ */
slouken@7823
   718
            Uint64 memsize = 0;
slouken@7821
   719
            size_t len = sizeof(memsize);
slouken@7821
   720
            
slouken@7821
   721
            if (sysctl(mib, 2, &memsize, &len, NULL, 0) == 0) {
slouken@7821
   722
                SDL_SystemRAM = (int)(memsize / (1024*1024));
slouken@7821
   723
            }
slouken@7821
   724
        }
slouken@7821
   725
#endif
slouken@7821
   726
#ifdef __WIN32__
slouken@7821
   727
        if (SDL_SystemRAM <= 0) {
slouken@7821
   728
            MEMORYSTATUSEX stat;
icculus@7889
   729
            stat.dwLength = sizeof(stat);
slouken@7821
   730
            if (GlobalMemoryStatusEx(&stat)) {
slouken@7821
   731
                SDL_SystemRAM = (int)(stat.ullTotalPhys / (1024 * 1024));
slouken@7821
   732
            }
slouken@7821
   733
        }
slouken@7821
   734
#endif
slouken@11338
   735
#ifdef __OS2__
slouken@11338
   736
        if (SDL_SystemRAM <= 0) {
slouken@11338
   737
            Uint32 sysram = 0;
slouken@11338
   738
            DosQuerySysInfo(QSV_TOTPHYSMEM, QSV_TOTPHYSMEM, &sysram, 4);
slouken@11338
   739
            SDL_SystemRAM = (int) (sysram / 0x100000U);
slouken@11338
   740
        }
slouken@11338
   741
#endif
icculus@9278
   742
#endif
slouken@7821
   743
    }
slouken@7821
   744
    return SDL_SystemRAM;
slouken@7821
   745
}
slouken@7821
   746
slouken@7821
   747
slouken@739
   748
#ifdef TEST_MAIN
slouken@739
   749
slouken@739
   750
#include <stdio.h>
slouken@739
   751
slouken@1895
   752
int
slouken@1895
   753
main()
slouken@739
   754
{
slouken@3579
   755
    printf("CPU count: %d\n", SDL_GetCPUCount());
slouken@5115
   756
    printf("CPU type: %s\n", SDL_GetCPUType());
slouken@5115
   757
    printf("CPU name: %s\n", SDL_GetCPUName());
slouken@5115
   758
    printf("CacheLine size: %d\n", SDL_GetCPUCacheLineSize());
slouken@1895
   759
    printf("RDTSC: %d\n", SDL_HasRDTSC());
slouken@5389
   760
    printf("Altivec: %d\n", SDL_HasAltiVec());
slouken@1895
   761
    printf("MMX: %d\n", SDL_HasMMX());
slouken@5389
   762
    printf("3DNow: %d\n", SDL_Has3DNow());
slouken@1895
   763
    printf("SSE: %d\n", SDL_HasSSE());
slouken@1895
   764
    printf("SSE2: %d\n", SDL_HasSSE2());
slouken@5259
   765
    printf("SSE3: %d\n", SDL_HasSSE3());
slouken@5263
   766
    printf("SSE4.1: %d\n", SDL_HasSSE41());
slouken@5263
   767
    printf("SSE4.2: %d\n", SDL_HasSSE42());
slouken@8148
   768
    printf("AVX: %d\n", SDL_HasAVX());
slouken@9003
   769
    printf("AVX2: %d\n", SDL_HasAVX2());
icculus@10620
   770
    printf("NEON: %d\n", SDL_HasNEON());
slouken@7821
   771
    printf("RAM: %d MB\n", SDL_GetSystemRAM());
slouken@1895
   772
    return 0;
slouken@739
   773
}
slouken@739
   774
slouken@739
   775
#endif /* TEST_MAIN */
slouken@1895
   776
slouken@1895
   777
/* vi: set ts=4 sw=4 expandtab: */