src/cpuinfo/SDL_cpuinfo.c
author Sam Lantinga <slouken@libsdl.org>
Mon, 10 Jul 2006 21:04:37 +0000
changeset 1895 c121d94672cb
parent 1864 7bea26ad3130
child 2859 99210400e8b9
permissions -rw-r--r--
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
slouken@739
     1
/*
slouken@739
     2
    SDL - Simple DirectMedia Layer
slouken@1312
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@739
     4
slouken@739
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@739
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@739
     9
slouken@739
    10
    This library is distributed in the hope that it will be useful,
slouken@739
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@739
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@739
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@739
    18
slouken@739
    19
    Sam Lantinga
slouken@739
    20
    slouken@libsdl.org
slouken@739
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@739
    23
slouken@739
    24
/* CPU feature detection for SDL */
slouken@739
    25
slouken@1361
    26
#include "SDL.h"
slouken@1361
    27
#include "SDL_cpuinfo.h"
slouken@1361
    28
slouken@1590
    29
#if defined(__MACOSX__) && defined(__ppc__)
slouken@1895
    30
#include <sys/sysctl.h>         /* For AltiVec check */
slouken@1487
    31
#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
slouken@793
    32
#include <signal.h>
slouken@793
    33
#include <setjmp.h>
slouken@793
    34
#endif
slouken@793
    35
slouken@745
    36
#define CPU_HAS_RDTSC	0x00000001
slouken@745
    37
#define CPU_HAS_MMX	0x00000002
slouken@785
    38
#define CPU_HAS_MMXEXT	0x00000004
slouken@785
    39
#define CPU_HAS_3DNOW	0x00000010
slouken@785
    40
#define CPU_HAS_3DNOWEXT 0x00000020
slouken@785
    41
#define CPU_HAS_SSE	0x00000040
slouken@785
    42
#define CPU_HAS_SSE2	0x00000080
slouken@785
    43
#define CPU_HAS_ALTIVEC	0x00000100
slouken@739
    44
slouken@1487
    45
#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__
slouken@793
    46
/* This is the brute force way of detecting instruction sets...
slouken@793
    47
   the idea is borrowed from the libmpeg2 library - thanks!
slouken@793
    48
 */
slouken@793
    49
static jmp_buf jmpbuf;
slouken@1895
    50
static void
slouken@1895
    51
illegal_instruction(int sig)
slouken@793
    52
{
slouken@1895
    53
    longjmp(jmpbuf, 1);
slouken@793
    54
}
slouken@1361
    55
#endif /* HAVE_SETJMP */
slouken@793
    56
slouken@1895
    57
static __inline__ int
slouken@1895
    58
CPU_haveCPUID(void)
slouken@745
    59
{
slouken@1895
    60
    int has_CPUID = 0;
slouken@1895
    61
/* *INDENT-OFF* */
slouken@745
    62
#if defined(__GNUC__) && defined(i386)
slouken@745
    63
	__asm__ (
slouken@745
    64
"        pushfl                      # Get original EFLAGS             \n"
slouken@745
    65
"        popl    %%eax                                                 \n"
slouken@745
    66
"        movl    %%eax,%%ecx                                           \n"
slouken@745
    67
"        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n"
slouken@745
    68
"        pushl   %%eax               # Save new EFLAGS value on stack  \n"
slouken@745
    69
"        popfl                       # Replace current EFLAGS value    \n"
slouken@745
    70
"        pushfl                      # Get new EFLAGS                  \n"
slouken@745
    71
"        popl    %%eax               # Store new EFLAGS in EAX         \n"
slouken@745
    72
"        xorl    %%ecx,%%eax         # Can not toggle ID bit,          \n"
slouken@745
    73
"        jz      1f                  # Processor=80486                 \n"
slouken@745
    74
"        movl    $1,%0               # We have CPUID support           \n"
slouken@745
    75
"1:                                                                    \n"
slouken@784
    76
	: "=m" (has_CPUID)
slouken@745
    77
	:
slouken@745
    78
	: "%eax", "%ecx"
slouken@745
    79
	);
slouken@881
    80
#elif defined(__GNUC__) && defined(__x86_64__)
slouken@881
    81
/* Technically, if this is being compiled under __x86_64__ then it has 
slouken@881
    82
CPUid by definition.  But it's nice to be able to prove it.  :)      */
slouken@881
    83
	__asm__ (
slouken@881
    84
"        pushfq                      # Get original EFLAGS             \n"
slouken@881
    85
"        popq    %%rax                                                 \n"
slouken@881
    86
"        movq    %%rax,%%rcx                                           \n"
slouken@881
    87
"        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n"
slouken@881
    88
"        pushq   %%rax               # Save new EFLAGS value on stack  \n"
slouken@881
    89
"        popfq                       # Replace current EFLAGS value    \n"
slouken@881
    90
"        pushfq                      # Get new EFLAGS                  \n"
slouken@881
    91
"        popq    %%rax               # Store new EFLAGS in EAX         \n"
slouken@881
    92
"        xorl    %%ecx,%%eax         # Can not toggle ID bit,          \n"
slouken@881
    93
"        jz      1f                  # Processor=80486                 \n"
slouken@881
    94
"        movl    $1,%0               # We have CPUID support           \n"
slouken@881
    95
"1:                                                                    \n"
slouken@881
    96
	: "=m" (has_CPUID)
slouken@881
    97
	:
slouken@881
    98
	: "%rax", "%rcx"
slouken@881
    99
	);
slouken@1442
   100
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
slouken@749
   101
	__asm {
slouken@745
   102
        pushfd                      ; Get original EFLAGS
slouken@745
   103
        pop     eax
slouken@745
   104
        mov     ecx, eax
slouken@745
   105
        xor     eax, 200000h        ; Flip ID bit in EFLAGS
slouken@745
   106
        push    eax                 ; Save new EFLAGS value on stack
slouken@745
   107
        popfd                       ; Replace current EFLAGS value
slouken@745
   108
        pushfd                      ; Get new EFLAGS
slouken@745
   109
        pop     eax                 ; Store new EFLAGS in EAX
slouken@745
   110
        xor     eax, ecx            ; Can not toggle ID bit,
slouken@745
   111
        jz      done                ; Processor=80486
slouken@745
   112
        mov     has_CPUID,1         ; We have CPUID support
slouken@745
   113
done:
slouken@745
   114
	}
slouken@1864
   115
#elif defined(__sun) && defined(__i386)
slouken@1361
   116
	__asm (
icculus@1229
   117
"       pushfl                 \n"
slouken@1361
   118
"	popl    %eax           \n"
slouken@1361
   119
"	movl    %eax,%ecx      \n"
slouken@1361
   120
"	xorl    $0x200000,%eax \n"
slouken@1361
   121
"	pushl   %eax           \n"
slouken@1361
   122
"	popfl                  \n"
slouken@1361
   123
"	pushfl                 \n"
slouken@1361
   124
"	popl    %eax           \n"
slouken@1361
   125
"	xorl    %ecx,%eax      \n"
slouken@1361
   126
"	jz      1f             \n"
slouken@1361
   127
"	movl    $1,-8(%ebp)    \n"
icculus@1229
   128
"1:                            \n"
icculus@1229
   129
	);
icculus@1229
   130
#elif defined(__sun) && defined(__amd64)
icculus@1229
   131
	__asm (
icculus@1229
   132
"       pushfq                 \n"
icculus@1229
   133
"       popq    %rax           \n"
icculus@1229
   134
"       movq    %rax,%rcx      \n"
icculus@1229
   135
"       xorl    $0x200000,%eax \n"
icculus@1229
   136
"       pushq   %rax           \n"
icculus@1229
   137
"       popfq                  \n"
icculus@1229
   138
"       pushfq                 \n"
icculus@1229
   139
"       popq    %rax           \n"
icculus@1229
   140
"       xorl    %ecx,%eax      \n"
icculus@1229
   141
"       jz      1f             \n"
icculus@1229
   142
"       movl    $1,-8(%rbp)    \n"
icculus@1229
   143
"1:                            \n"
icculus@1229
   144
	);
slouken@745
   145
#endif
slouken@1895
   146
/* *INDENT-ON* */
slouken@1895
   147
    return has_CPUID;
slouken@745
   148
}
slouken@745
   149
slouken@1895
   150
static __inline__ int
slouken@1895
   151
CPU_getCPUIDFeatures(void)
slouken@745
   152
{
slouken@1895
   153
    int features = 0;
slouken@1895
   154
/* *INDENT-OFF* */
slouken@881
   155
#if defined(__GNUC__) && ( defined(i386) || defined(__x86_64__) )
slouken@745
   156
	__asm__ (
slouken@785
   157
"        movl    %%ebx,%%edi\n"
slouken@745
   158
"        xorl    %%eax,%%eax         # Set up for CPUID instruction    \n"
slouken@745
   159
"        cpuid                       # Get and save vendor ID          \n"
slouken@745
   160
"        cmpl    $1,%%eax            # Make sure 1 is valid input for CPUID\n"
slouken@745
   161
"        jl      1f                  # We dont have the CPUID instruction\n"
slouken@745
   162
"        xorl    %%eax,%%eax                                           \n"
slouken@745
   163
"        incl    %%eax                                                 \n"
slouken@745
   164
"        cpuid                       # Get family/model/stepping/features\n"
slouken@745
   165
"        movl    %%edx,%0                                              \n"
slouken@745
   166
"1:                                                                    \n"
slouken@785
   167
"        movl    %%edi,%%ebx\n"
slouken@784
   168
	: "=m" (features)
slouken@745
   169
	:
slouken@887
   170
	: "%eax", "%ecx", "%edx", "%edi"
slouken@745
   171
	);
slouken@1442
   172
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
slouken@749
   173
	__asm {
slouken@745
   174
        xor     eax, eax            ; Set up for CPUID instruction
slouken@745
   175
        cpuid                       ; Get and save vendor ID
slouken@745
   176
        cmp     eax, 1              ; Make sure 1 is valid input for CPUID
slouken@745
   177
        jl      done                ; We dont have the CPUID instruction
slouken@745
   178
        xor     eax, eax
slouken@745
   179
        inc     eax
slouken@745
   180
        cpuid                       ; Get family/model/stepping/features
slouken@745
   181
        mov     features, edx
slouken@745
   182
done:
slouken@745
   183
	}
slouken@1864
   184
#elif defined(__sun) && (defined(__i386) || defined(__amd64))
icculus@1229
   185
	    __asm(
icculus@1229
   186
"        movl    %ebx,%edi\n"
icculus@1229
   187
"        xorl    %eax,%eax         \n"
icculus@1229
   188
"        cpuid                     \n"
icculus@1229
   189
"        cmpl    $1,%eax           \n"
icculus@1229
   190
"        jl      1f                \n"
icculus@1229
   191
"        xorl    %eax,%eax         \n"
icculus@1229
   192
"        incl    %eax              \n"
icculus@1229
   193
"        cpuid                     \n"
icculus@1229
   194
#ifdef __i386
icculus@1229
   195
"        movl    %edx,-8(%ebp)     \n"
icculus@1229
   196
#else
icculus@1229
   197
"        movl    %edx,-8(%rbp)     \n"
icculus@1229
   198
#endif
icculus@1229
   199
"1:                                \n"
icculus@1229
   200
"        movl    %edi,%ebx\n" );
slouken@745
   201
#endif
slouken@1895
   202
/* *INDENT-ON* */
slouken@1895
   203
    return features;
slouken@745
   204
}
slouken@745
   205
slouken@1895
   206
static __inline__ int
slouken@1895
   207
CPU_getCPUIDFeaturesExt(void)
slouken@785
   208
{
slouken@1895
   209
    int features = 0;
slouken@1895
   210
/* *INDENT-OFF* */
slouken@881
   211
#if defined(__GNUC__) && (defined(i386) || defined (__x86_64__) )
slouken@785
   212
	__asm__ (
slouken@785
   213
"        movl    %%ebx,%%edi\n"
slouken@785
   214
"        movl    $0x80000000,%%eax   # Query for extended functions    \n"
slouken@785
   215
"        cpuid                       # Get extended function limit     \n"
slouken@785
   216
"        cmpl    $0x80000001,%%eax                                     \n"
slouken@787
   217
"        jl      1f                  # Nope, we dont have function 800000001h\n"
slouken@785
   218
"        movl    $0x80000001,%%eax   # Setup extended function 800000001h\n"
slouken@785
   219
"        cpuid                       # and get the information         \n"
slouken@785
   220
"        movl    %%edx,%0                                              \n"
slouken@785
   221
"1:                                                                    \n"
slouken@785
   222
"        movl    %%edi,%%ebx\n"
slouken@785
   223
	: "=m" (features)
slouken@785
   224
	:
slouken@887
   225
	: "%eax", "%ecx", "%edx", "%edi"
slouken@785
   226
	);
slouken@1442
   227
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
slouken@785
   228
	__asm {
slouken@785
   229
        mov     eax,80000000h       ; Query for extended functions
slouken@785
   230
        cpuid                       ; Get extended function limit
slouken@785
   231
        cmp     eax,80000001h
slouken@787
   232
        jl      done                ; Nope, we dont have function 800000001h
slouken@785
   233
        mov     eax,80000001h       ; Setup extended function 800000001h
slouken@785
   234
        cpuid                       ; and get the information
slouken@785
   235
        mov     features,edx
slouken@785
   236
done:
slouken@785
   237
	}
icculus@1229
   238
#elif defined(__sun) && ( defined(__i386) || defined(__amd64) )
icculus@1229
   239
	    __asm (
icculus@1229
   240
"        movl    %ebx,%edi\n"
icculus@1229
   241
"        movl    $0x80000000,%eax \n"
icculus@1229
   242
"        cpuid                    \n"
icculus@1229
   243
"        cmpl    $0x80000001,%eax \n"
icculus@1229
   244
"        jl      1f               \n"
icculus@1229
   245
"        movl    $0x80000001,%eax \n"
icculus@1229
   246
"        cpuid                    \n"
icculus@1229
   247
#ifdef __i386
icculus@1229
   248
"        movl    %edx,-8(%ebp)   \n"
icculus@1229
   249
#else
icculus@1229
   250
"        movl    %edx,-8(%rbp)   \n"
icculus@1229
   251
#endif
icculus@1229
   252
"1:                               \n"
icculus@1229
   253
"        movl    %edi,%ebx\n"
icculus@1229
   254
	    );
slouken@785
   255
#endif
slouken@1895
   256
/* *INDENT-ON* */
slouken@1895
   257
    return features;
slouken@785
   258
}
slouken@785
   259
slouken@1895
   260
static __inline__ int
slouken@1895
   261
CPU_haveRDTSC(void)
slouken@745
   262
{
slouken@1895
   263
    if (CPU_haveCPUID()) {
slouken@1895
   264
        return (CPU_getCPUIDFeatures() & 0x00000010);
slouken@1895
   265
    }
slouken@1895
   266
    return 0;
slouken@745
   267
}
slouken@745
   268
slouken@1895
   269
static __inline__ int
slouken@1895
   270
CPU_haveMMX(void)
slouken@745
   271
{
slouken@1895
   272
    if (CPU_haveCPUID()) {
slouken@1895
   273
        return (CPU_getCPUIDFeatures() & 0x00800000);
slouken@1895
   274
    }
slouken@1895
   275
    return 0;
slouken@745
   276
}
slouken@745
   277
slouken@1895
   278
static __inline__ int
slouken@1895
   279
CPU_haveMMXExt(void)
slouken@785
   280
{
slouken@1895
   281
    if (CPU_haveCPUID()) {
slouken@1895
   282
        return (CPU_getCPUIDFeaturesExt() & 0x00400000);
slouken@1895
   283
    }
slouken@1895
   284
    return 0;
slouken@785
   285
}
slouken@785
   286
slouken@1895
   287
static __inline__ int
slouken@1895
   288
CPU_have3DNow(void)
slouken@745
   289
{
slouken@1895
   290
    if (CPU_haveCPUID()) {
slouken@1895
   291
        return (CPU_getCPUIDFeaturesExt() & 0x80000000);
slouken@1895
   292
    }
slouken@1895
   293
    return 0;
slouken@785
   294
}
slouken@785
   295
slouken@1895
   296
static __inline__ int
slouken@1895
   297
CPU_have3DNowExt(void)
slouken@785
   298
{
slouken@1895
   299
    if (CPU_haveCPUID()) {
slouken@1895
   300
        return (CPU_getCPUIDFeaturesExt() & 0x40000000);
slouken@1895
   301
    }
slouken@1895
   302
    return 0;
slouken@745
   303
}
slouken@745
   304
slouken@1895
   305
static __inline__ int
slouken@1895
   306
CPU_haveSSE(void)
slouken@745
   307
{
slouken@1895
   308
    if (CPU_haveCPUID()) {
slouken@1895
   309
        return (CPU_getCPUIDFeatures() & 0x02000000);
slouken@1895
   310
    }
slouken@1895
   311
    return 0;
slouken@745
   312
}
slouken@739
   313
slouken@1895
   314
static __inline__ int
slouken@1895
   315
CPU_haveSSE2(void)
slouken@785
   316
{
slouken@1895
   317
    if (CPU_haveCPUID()) {
slouken@1895
   318
        return (CPU_getCPUIDFeatures() & 0x04000000);
slouken@1895
   319
    }
slouken@1895
   320
    return 0;
slouken@785
   321
}
slouken@785
   322
slouken@1895
   323
static __inline__ int
slouken@1895
   324
CPU_haveAltiVec(void)
slouken@778
   325
{
slouken@1895
   326
    volatile int altivec = 0;
slouken@1590
   327
#if defined(__MACOSX__) && defined(__ppc__)
slouken@1895
   328
    int selectors[2] = { CTL_HW, HW_VECTORUNIT };
slouken@1895
   329
    int hasVectorUnit = 0;
slouken@1895
   330
    size_t length = sizeof(hasVectorUnit);
slouken@1895
   331
    int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0);
slouken@1895
   332
    if (0 == error)
slouken@1895
   333
        altivec = (hasVectorUnit != 0);
slouken@1361
   334
#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
slouken@1895
   335
    void (*handler) (int sig);
slouken@1895
   336
    handler = signal(SIGILL, illegal_instruction);
slouken@1895
   337
    if (setjmp(jmpbuf) == 0) {
slouken@1895
   338
        asm volatile ("mtspr 256, %0\n\t" "vand %%v0, %%v0, %%v0"::"r" (-1));
slouken@1895
   339
        altivec = 1;
slouken@1895
   340
    }
slouken@1895
   341
    signal(SIGILL, handler);
slouken@778
   342
#endif
slouken@1895
   343
    return altivec;
slouken@778
   344
}
slouken@778
   345
slouken@739
   346
static Uint32 SDL_CPUFeatures = 0xFFFFFFFF;
slouken@739
   347
slouken@1895
   348
static Uint32
slouken@1895
   349
SDL_GetCPUFeatures(void)
slouken@739
   350
{
slouken@1895
   351
    if (SDL_CPUFeatures == 0xFFFFFFFF) {
slouken@1895
   352
        SDL_CPUFeatures = 0;
slouken@1895
   353
        if (CPU_haveRDTSC()) {
slouken@1895
   354
            SDL_CPUFeatures |= CPU_HAS_RDTSC;
slouken@1895
   355
        }
slouken@1895
   356
        if (CPU_haveMMX()) {
slouken@1895
   357
            SDL_CPUFeatures |= CPU_HAS_MMX;
slouken@1895
   358
        }
slouken@1895
   359
        if (CPU_haveMMXExt()) {
slouken@1895
   360
            SDL_CPUFeatures |= CPU_HAS_MMXEXT;
slouken@1895
   361
        }
slouken@1895
   362
        if (CPU_have3DNow()) {
slouken@1895
   363
            SDL_CPUFeatures |= CPU_HAS_3DNOW;
slouken@1895
   364
        }
slouken@1895
   365
        if (CPU_have3DNowExt()) {
slouken@1895
   366
            SDL_CPUFeatures |= CPU_HAS_3DNOWEXT;
slouken@1895
   367
        }
slouken@1895
   368
        if (CPU_haveSSE()) {
slouken@1895
   369
            SDL_CPUFeatures |= CPU_HAS_SSE;
slouken@1895
   370
        }
slouken@1895
   371
        if (CPU_haveSSE2()) {
slouken@1895
   372
            SDL_CPUFeatures |= CPU_HAS_SSE2;
slouken@1895
   373
        }
slouken@1895
   374
        if (CPU_haveAltiVec()) {
slouken@1895
   375
            SDL_CPUFeatures |= CPU_HAS_ALTIVEC;
slouken@1895
   376
        }
slouken@1895
   377
    }
slouken@1895
   378
    return SDL_CPUFeatures;
slouken@739
   379
}
slouken@739
   380
slouken@1895
   381
SDL_bool
slouken@1895
   382
SDL_HasRDTSC(void)
slouken@745
   383
{
slouken@1895
   384
    if (SDL_GetCPUFeatures() & CPU_HAS_RDTSC) {
slouken@1895
   385
        return SDL_TRUE;
slouken@1895
   386
    }
slouken@1895
   387
    return SDL_FALSE;
slouken@745
   388
}
slouken@745
   389
slouken@1895
   390
SDL_bool
slouken@1895
   391
SDL_HasMMX(void)
slouken@739
   392
{
slouken@1895
   393
    if (SDL_GetCPUFeatures() & CPU_HAS_MMX) {
slouken@1895
   394
        return SDL_TRUE;
slouken@1895
   395
    }
slouken@1895
   396
    return SDL_FALSE;
slouken@739
   397
}
slouken@739
   398
slouken@1895
   399
SDL_bool
slouken@1895
   400
SDL_HasMMXExt(void)
slouken@804
   401
{
slouken@1895
   402
    if (SDL_GetCPUFeatures() & CPU_HAS_MMXEXT) {
slouken@1895
   403
        return SDL_TRUE;
slouken@1895
   404
    }
slouken@1895
   405
    return SDL_FALSE;
slouken@804
   406
}
slouken@804
   407
slouken@1895
   408
SDL_bool
slouken@1895
   409
SDL_Has3DNow(void)
slouken@739
   410
{
slouken@1895
   411
    if (SDL_GetCPUFeatures() & CPU_HAS_3DNOW) {
slouken@1895
   412
        return SDL_TRUE;
slouken@1895
   413
    }
slouken@1895
   414
    return SDL_FALSE;
slouken@739
   415
}
slouken@739
   416
slouken@1895
   417
SDL_bool
slouken@1895
   418
SDL_Has3DNowExt(void)
slouken@804
   419
{
slouken@1895
   420
    if (SDL_GetCPUFeatures() & CPU_HAS_3DNOWEXT) {
slouken@1895
   421
        return SDL_TRUE;
slouken@1895
   422
    }
slouken@1895
   423
    return SDL_FALSE;
slouken@804
   424
}
slouken@804
   425
slouken@1895
   426
SDL_bool
slouken@1895
   427
SDL_HasSSE(void)
slouken@739
   428
{
slouken@1895
   429
    if (SDL_GetCPUFeatures() & CPU_HAS_SSE) {
slouken@1895
   430
        return SDL_TRUE;
slouken@1895
   431
    }
slouken@1895
   432
    return SDL_FALSE;
slouken@739
   433
}
slouken@739
   434
slouken@1895
   435
SDL_bool
slouken@1895
   436
SDL_HasSSE2(void)
slouken@804
   437
{
slouken@1895
   438
    if (SDL_GetCPUFeatures() & CPU_HAS_SSE2) {
slouken@1895
   439
        return SDL_TRUE;
slouken@1895
   440
    }
slouken@1895
   441
    return SDL_FALSE;
slouken@804
   442
}
slouken@804
   443
slouken@1895
   444
SDL_bool
slouken@1895
   445
SDL_HasAltiVec(void)
slouken@778
   446
{
slouken@1895
   447
    if (SDL_GetCPUFeatures() & CPU_HAS_ALTIVEC) {
slouken@1895
   448
        return SDL_TRUE;
slouken@1895
   449
    }
slouken@1895
   450
    return SDL_FALSE;
slouken@778
   451
}
slouken@778
   452
slouken@739
   453
#ifdef TEST_MAIN
slouken@739
   454
slouken@739
   455
#include <stdio.h>
slouken@739
   456
slouken@1895
   457
int
slouken@1895
   458
main()
slouken@739
   459
{
slouken@1895
   460
    printf("RDTSC: %d\n", SDL_HasRDTSC());
slouken@1895
   461
    printf("MMX: %d\n", SDL_HasMMX());
slouken@1895
   462
    printf("MMXExt: %d\n", SDL_HasMMXExt());
slouken@1895
   463
    printf("3DNow: %d\n", SDL_Has3DNow());
slouken@1895
   464
    printf("3DNowExt: %d\n", SDL_Has3DNowExt());
slouken@1895
   465
    printf("SSE: %d\n", SDL_HasSSE());
slouken@1895
   466
    printf("SSE2: %d\n", SDL_HasSSE2());
slouken@1895
   467
    printf("AltiVec: %d\n", SDL_HasAltiVec());
slouken@1895
   468
    return 0;
slouken@739
   469
}
slouken@739
   470
slouken@739
   471
#endif /* TEST_MAIN */
slouken@1895
   472
slouken@1895
   473
/* vi: set ts=4 sw=4 expandtab: */