Changeset 1240

Show
Ignore:
Timestamp:
06/08/08 20:02:51 (3 months ago)
Author:
drobilla
Message:

Fix SSE detection (for denormal protection).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • configure.ac

    r1218 r1240  
    178178 
    179179CONFIG_H_PATH="$builddir/config/config.h" 
     180 
     181# Check for 64-bit platform 
     182AC_CHECK_SIZEOF([void *]) 
     183 
    180184 
    181185#################### COMMAND LINE PARAMETERS 
  • ingen/configure.ac

    r1217 r1240  
    5656INGEN_CFLAGS="-I$abs_srcdir/src/common -I$abs_srcdir/src/libs -I$abs_srcdir/src/libs/engine/events -I$abs_srcdir/src" 
    5757AC_SUBST(INGEN_CFLAGS) 
     58 
     59# Check for 64-bit platform 
     60AC_CHECK_SIZEOF([void *]) 
     61 
    5862 
    5963#################### COMMAND LINE PARAMETERS 
  • ingen/src/libs/engine/util.hpp

    r1205 r1240  
    2828#endif 
    2929 
     30#ifdef USE_ASSEMBLY 
     31# if SIZEOF_VOID_P==8 
     32#  define cpuid(a,b,c,d,n) asm("xchgq %%rbx, %1; cpuid; xchgq %%rbx, %1": "=a" (a), "=r" (b), "=c" (c), "=d" (d) : "a" (n)); 
     33# else 
     34#  define cpuid(a,b,c,d,n) asm("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1": "=a" (a), "=r" (b), "=c" (c), "=d" (d) : "a" (n)); 
     35# endif 
     36#endif 
     37 
    3038namespace Ingen { 
    3139 
     
    3745#ifdef USE_ASSEMBLY 
    3846#ifdef __SSE__ 
    39         unsigned long a, b, c, d; 
     47        unsigned long a, b, c, d0, d1; 
     48        int stepping, model, family, extfamily; 
    4049 
    41         asm("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (1)); 
    42         if (d & 1<<25) { /* It has SSE support */ 
     50        cpuid(a,b,c,d1,1); 
     51        if (d1 & 1<<25) { /* It has SSE support */ 
    4352                _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); 
    44  
    45                 asm("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (0)); 
     53                family = (a >> 8) & 0xf; 
     54                extfamily = (a >> 20) & 0xff; 
     55                model = (a >> 4) & 0xf; 
     56                stepping = a & 0xf; 
     57                cpuid(a,b,c,d0,0); 
    4658                if (b == 0x756e6547) { /* It's an Intel */ 
    47                         int stepping, model, family, extfamily; 
    48  
    49                         family = (a >> 8) & 0xf; 
    50                         extfamily = (a >> 20) & 0xff; 
    51                         model = (a >> 4) & 0xf; 
    52                         stepping = a & 0xf; 
    5359                        if (family == 15 && extfamily == 0 && model == 0 && stepping < 7) { 
    5460                                return; 
    5561                        } 
    5662                } 
    57                 asm("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (1)); 
    58                 if (d & 1<<26) { /* bit 26, SSE2 support */ 
    59                         _mm_setcsr(_mm_getcsr() | 0x40); 
     63                if (d1 & 1<<26) { /* bit 26, SSE2 support */ 
     64                        _mm_setcsr(_mm_getcsr() | 0x8040); // set DAZ and FZ bits of MXCSR 
    6065                        //cerr << "Set SSE denormal fix flag." << endl; 
    6166                }