I think this fixes bug #244 SDL-1.3
authorSam Lantinga <slouken@libsdl.org>
Tue, 20 Jun 2006 05:40:57 +0000
branchSDL-1.3
changeset 1691c901fd2a42da
parent 1690 43ba677b4f62
child 1692 75f2ace8511a
I think this fixes bug #244
src/SDL.c
src/SDL_compat.c
src/cpuinfo/SDL_cpuinfo.c
     1.1 --- a/src/SDL.c	Tue Jun 20 05:27:03 2006 +0000
     1.2 +++ b/src/SDL.c	Tue Jun 20 05:40:57 2006 +0000
     1.3 @@ -349,4 +349,5 @@
     1.4  #endif /* building DLL with Watcom C */
     1.5  
     1.6  #endif /* OS/2 elif __WIN32__ */
     1.7 +
     1.8  /* vi: set ts=4 sw=4 expandtab: */
     2.1 --- a/src/SDL_compat.c	Tue Jun 20 05:27:03 2006 +0000
     2.2 +++ b/src/SDL_compat.c	Tue Jun 20 05:40:57 2006 +0000
     2.3 @@ -209,7 +209,7 @@
     2.4              Uint32 unicode = 0;
     2.5              if (event->key.type == SDL_KEYDOWN && event->key.keysym.sym < 256) {
     2.6                  unicode = event->key.keysym.sym;
     2.7 -                if(unicode >= 'a' && unicode <= 'z') {
     2.8 +                if (unicode >= 'a' && unicode <= 'z') {
     2.9                      int shifted = !!(event->key.keysym.mod & KMOD_SHIFT);
    2.10                      int capslock = !!(event->key.keysym.mod & KMOD_CAPS);
    2.11                      if ((shifted ^ capslock) != 0) {
     3.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Tue Jun 20 05:27:03 2006 +0000
     3.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Tue Jun 20 05:40:57 2006 +0000
     3.3 @@ -58,53 +58,92 @@
     3.4  CPU_haveCPUID(void)
     3.5  {
     3.6      int has_CPUID = 0;
     3.7 +/* *INDENT-OFF* */
     3.8  #if defined(__GNUC__) && defined(i386)
     3.9 -  __asm__("        pushfl                      # Get original EFLAGS             \n" "        popl    %%eax                                                 \n" "        movl    %%eax,%%ecx                                           \n" "        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n" "        pushl   %%eax               # Save new EFLAGS value on stack  \n" "        popfl                       # Replace current EFLAGS value    \n" "        pushfl                      # Get new EFLAGS                  \n" "        popl    %%eax               # Store new EFLAGS in EAX         \n" "        xorl    %%ecx,%%eax         # Can not toggle ID bit,          \n" "        jz      1f                  # Processor=80486                 \n" "        movl    $1,%0               # We have CPUID support           \n" "1:                                                                    \n": "=m"(has_CPUID):
    3.10 -  :"%eax", "%ecx");
    3.11 +	__asm__ (
    3.12 +"        pushfl                      # Get original EFLAGS             \n"
    3.13 +"        popl    %%eax                                                 \n"
    3.14 +"        movl    %%eax,%%ecx                                           \n"
    3.15 +"        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n"
    3.16 +"        pushl   %%eax               # Save new EFLAGS value on stack  \n"
    3.17 +"        popfl                       # Replace current EFLAGS value    \n"
    3.18 +"        pushfl                      # Get new EFLAGS                  \n"
    3.19 +"        popl    %%eax               # Store new EFLAGS in EAX         \n"
    3.20 +"        xorl    %%ecx,%%eax         # Can not toggle ID bit,          \n"
    3.21 +"        jz      1f                  # Processor=80486                 \n"
    3.22 +"        movl    $1,%0               # We have CPUID support           \n"
    3.23 +"1:                                                                    \n"
    3.24 +	: "=m" (has_CPUID)
    3.25 +	:
    3.26 +	: "%eax", "%ecx"
    3.27 +	);
    3.28  #elif defined(__GNUC__) && defined(__x86_64__)
    3.29  /* Technically, if this is being compiled under __x86_64__ then it has 
    3.30  CPUid by definition.  But it's nice to be able to prove it.  :)      */
    3.31 -  __asm__("        pushfq                      # Get original EFLAGS             \n" "        popq    %%rax                                                 \n" "        movq    %%rax,%%rcx                                           \n" "        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n" "        pushq   %%rax               # Save new EFLAGS value on stack  \n" "        popfq                       # Replace current EFLAGS value    \n" "        pushfq                      # Get new EFLAGS                  \n" "        popq    %%rax               # Store new EFLAGS in EAX         \n" "        xorl    %%ecx,%%eax         # Can not toggle ID bit,          \n" "        jz      1f                  # Processor=80486                 \n" "        movl    $1,%0               # We have CPUID support           \n" "1:                                                                    \n": "=m"(has_CPUID):
    3.32 -  :"%rax", "%rcx");
    3.33 +	__asm__ (
    3.34 +"        pushfq                      # Get original EFLAGS             \n"
    3.35 +"        popq    %%rax                                                 \n"
    3.36 +"        movq    %%rax,%%rcx                                           \n"
    3.37 +"        xorl    $0x200000,%%eax     # Flip ID bit in EFLAGS           \n"
    3.38 +"        pushq   %%rax               # Save new EFLAGS value on stack  \n"
    3.39 +"        popfq                       # Replace current EFLAGS value    \n"
    3.40 +"        pushfq                      # Get new EFLAGS                  \n"
    3.41 +"        popq    %%rax               # Store new EFLAGS in EAX         \n"
    3.42 +"        xorl    %%ecx,%%eax         # Can not toggle ID bit,          \n"
    3.43 +"        jz      1f                  # Processor=80486                 \n"
    3.44 +"        movl    $1,%0               # We have CPUID support           \n"
    3.45 +"1:                                                                    \n"
    3.46 +	: "=m" (has_CPUID)
    3.47 +	:
    3.48 +	: "%rax", "%rcx"
    3.49 +	);
    3.50  #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
    3.51 -    __asm {
    3.52 -        pushfd;
    3.53 -        Get original EFLAGS pop eax mov ecx, eax xor eax, 200000 h;
    3.54 -        Flip ID bit in EFLAGS push eax;
    3.55 -        Save new EFLAGS value on stack popfd;
    3.56 -        Replace current EFLAGS value pushfd;
    3.57 -        Get new EFLAGS pop eax;
    3.58 -        Store new EFLAGS in EAX xor eax, ecx;
    3.59 -        Can not toggle ID bit, jz done;
    3.60 -        Processor = 80486 mov has_CPUID, 1;
    3.61 -    We have CPUID support done:}
    3.62 -#elif defined(__sun) && defined(__x86)
    3.63 -    __asm("       pushfl                 \n"
    3.64 -          "	popl    %eax           \n"
    3.65 -          "	movl    %eax,%ecx      \n"
    3.66 -          "	xorl    $0x200000,%eax \n"
    3.67 -          "	pushl   %eax           \n"
    3.68 -          "	popfl                  \n"
    3.69 -          "	pushfl                 \n"
    3.70 -          "	popl    %eax           \n"
    3.71 -          "	xorl    %ecx,%eax      \n"
    3.72 -          "	jz      1f             \n"
    3.73 -          "	movl    $1,-8(%ebp)    \n"
    3.74 -          "1:                            \n");
    3.75 +	__asm {
    3.76 +        pushfd                      ; Get original EFLAGS
    3.77 +        pop     eax
    3.78 +        mov     ecx, eax
    3.79 +        xor     eax, 200000h        ; Flip ID bit in EFLAGS
    3.80 +        push    eax                 ; Save new EFLAGS value on stack
    3.81 +        popfd                       ; Replace current EFLAGS value
    3.82 +        pushfd                      ; Get new EFLAGS
    3.83 +        pop     eax                 ; Store new EFLAGS in EAX
    3.84 +        xor     eax, ecx            ; Can not toggle ID bit,
    3.85 +        jz      done                ; Processor=80486
    3.86 +        mov     has_CPUID,1         ; We have CPUID support
    3.87 +done:
    3.88 +	}
    3.89 +#elif defined(__sun) && defined(__i386)
    3.90 +	__asm (
    3.91 +"       pushfl                 \n"
    3.92 +"	popl    %eax           \n"
    3.93 +"	movl    %eax,%ecx      \n"
    3.94 +"	xorl    $0x200000,%eax \n"
    3.95 +"	pushl   %eax           \n"
    3.96 +"	popfl                  \n"
    3.97 +"	pushfl                 \n"
    3.98 +"	popl    %eax           \n"
    3.99 +"	xorl    %ecx,%eax      \n"
   3.100 +"	jz      1f             \n"
   3.101 +"	movl    $1,-8(%ebp)    \n"
   3.102 +"1:                            \n"
   3.103 +	);
   3.104  #elif defined(__sun) && defined(__amd64)
   3.105 -    __asm("       pushfq                 \n"
   3.106 -          "       popq    %rax           \n"
   3.107 -          "       movq    %rax,%rcx      \n"
   3.108 -          "       xorl    $0x200000,%eax \n"
   3.109 -          "       pushq   %rax           \n"
   3.110 -          "       popfq                  \n"
   3.111 -          "       pushfq                 \n"
   3.112 -          "       popq    %rax           \n"
   3.113 -          "       xorl    %ecx,%eax      \n"
   3.114 -          "       jz      1f             \n"
   3.115 -          "       movl    $1,-8(%rbp)    \n"
   3.116 -          "1:                            \n");
   3.117 +	__asm (
   3.118 +"       pushfq                 \n"
   3.119 +"       popq    %rax           \n"
   3.120 +"       movq    %rax,%rcx      \n"
   3.121 +"       xorl    $0x200000,%eax \n"
   3.122 +"       pushq   %rax           \n"
   3.123 +"       popfq                  \n"
   3.124 +"       pushfq                 \n"
   3.125 +"       popq    %rax           \n"
   3.126 +"       xorl    %ecx,%eax      \n"
   3.127 +"       jz      1f             \n"
   3.128 +"       movl    $1,-8(%rbp)    \n"
   3.129 +"1:                            \n"
   3.130 +	);
   3.131  #endif
   3.132 +/* *INDENT-ON* */
   3.133      return has_CPUID;
   3.134  }
   3.135  
   3.136 @@ -112,38 +151,55 @@
   3.137  CPU_getCPUIDFeatures(void)
   3.138  {
   3.139      int features = 0;
   3.140 +/* *INDENT-OFF* */
   3.141  #if defined(__GNUC__) && ( defined(i386) || defined(__x86_64__) )
   3.142 -  __asm__("        movl    %%ebx,%%edi\n" "        xorl    %%eax,%%eax         # Set up for CPUID instruction    \n" "        cpuid                       # Get and save vendor ID          \n" "        cmpl    $1,%%eax            # Make sure 1 is valid input for CPUID\n" "        jl      1f                  # We dont have the CPUID instruction\n" "        xorl    %%eax,%%eax                                           \n" "        incl    %%eax                                                 \n" "        cpuid                       # Get family/model/stepping/features\n" "        movl    %%edx,%0                                              \n" "1:                                                                    \n" "        movl    %%edi,%%ebx\n": "=m"(features):
   3.143 -  :"%eax", "%ecx", "%edx", "%edi");
   3.144 +	__asm__ (
   3.145 +"        movl    %%ebx,%%edi\n"
   3.146 +"        xorl    %%eax,%%eax         # Set up for CPUID instruction    \n"
   3.147 +"        cpuid                       # Get and save vendor ID          \n"
   3.148 +"        cmpl    $1,%%eax            # Make sure 1 is valid input for CPUID\n"
   3.149 +"        jl      1f                  # We dont have the CPUID instruction\n"
   3.150 +"        xorl    %%eax,%%eax                                           \n"
   3.151 +"        incl    %%eax                                                 \n"
   3.152 +"        cpuid                       # Get family/model/stepping/features\n"
   3.153 +"        movl    %%edx,%0                                              \n"
   3.154 +"1:                                                                    \n"
   3.155 +"        movl    %%edi,%%ebx\n"
   3.156 +	: "=m" (features)
   3.157 +	:
   3.158 +	: "%eax", "%ecx", "%edx", "%edi"
   3.159 +	);
   3.160  #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
   3.161 -    __asm {
   3.162 -        xor eax, eax;
   3.163 -    Set up for CPUID instruction
   3.164 -            cpuid; Get and save vendor ID
   3.165 -            cmp eax, 1; Make sure 1 is valid input for CPUID
   3.166 -            jl done; We dont have the CPUID instruction
   3.167 -            xor eax, eax
   3.168 -            inc eax
   3.169 -            cpuid; Get family / model / stepping / features
   3.170 -            mov features, edx done:}
   3.171 -#elif defined(__sun) && (defined(__x86) || defined(__amd64))
   3.172 -    __asm
   3.173 -        ("        movl    %ebx,%edi\n"
   3.174 -         "        xorl    %eax,%eax         \n"
   3.175 -         "        cpuid                     \n"
   3.176 -         "        cmpl    $1,%eax           \n"
   3.177 -         "        jl      1f                \n"
   3.178 -         "        xorl    %eax,%eax         \n"
   3.179 -         "        incl    %eax              \n"
   3.180 -         "        cpuid                     \n"
   3.181 +	__asm {
   3.182 +        xor     eax, eax            ; Set up for CPUID instruction
   3.183 +        cpuid                       ; Get and save vendor ID
   3.184 +        cmp     eax, 1              ; Make sure 1 is valid input for CPUID
   3.185 +        jl      done                ; We dont have the CPUID instruction
   3.186 +        xor     eax, eax
   3.187 +        inc     eax
   3.188 +        cpuid                       ; Get family/model/stepping/features
   3.189 +        mov     features, edx
   3.190 +done:
   3.191 +	}
   3.192 +#elif defined(__sun) && (defined(__i386) || defined(__amd64))
   3.193 +	    __asm(
   3.194 +"        movl    %ebx,%edi\n"
   3.195 +"        xorl    %eax,%eax         \n"
   3.196 +"        cpuid                     \n"
   3.197 +"        cmpl    $1,%eax           \n"
   3.198 +"        jl      1f                \n"
   3.199 +"        xorl    %eax,%eax         \n"
   3.200 +"        incl    %eax              \n"
   3.201 +"        cpuid                     \n"
   3.202  #ifdef __i386
   3.203 -         "        movl    %edx,-8(%ebp)     \n"
   3.204 +"        movl    %edx,-8(%ebp)     \n"
   3.205  #else
   3.206 -         "        movl    %edx,-8(%rbp)     \n"
   3.207 +"        movl    %edx,-8(%rbp)     \n"
   3.208  #endif
   3.209 -         "1:                                \n"
   3.210 -         "        movl    %edi,%ebx\n");
   3.211 +"1:                                \n"
   3.212 +"        movl    %edi,%ebx\n" );
   3.213  #endif
   3.214 +/* *INDENT-ON* */
   3.215      return features;
   3.216  }
   3.217  
   3.218 @@ -151,34 +207,53 @@
   3.219  CPU_getCPUIDFeaturesExt(void)
   3.220  {
   3.221      int features = 0;
   3.222 +/* *INDENT-OFF* */
   3.223  #if defined(__GNUC__) && (defined(i386) || defined (__x86_64__) )
   3.224 -  __asm__("        movl    %%ebx,%%edi\n" "        movl    $0x80000000,%%eax   # Query for extended functions    \n" "        cpuid                       # Get extended function limit     \n" "        cmpl    $0x80000001,%%eax                                     \n" "        jl      1f                  # Nope, we dont have function 800000001h\n" "        movl    $0x80000001,%%eax   # Setup extended function 800000001h\n" "        cpuid                       # and get the information         \n" "        movl    %%edx,%0                                              \n" "1:                                                                    \n" "        movl    %%edi,%%ebx\n": "=m"(features):
   3.225 -  :"%eax", "%ecx", "%edx", "%edi");
   3.226 +	__asm__ (
   3.227 +"        movl    %%ebx,%%edi\n"
   3.228 +"        movl    $0x80000000,%%eax   # Query for extended functions    \n"
   3.229 +"        cpuid                       # Get extended function limit     \n"
   3.230 +"        cmpl    $0x80000001,%%eax                                     \n"
   3.231 +"        jl      1f                  # Nope, we dont have function 800000001h\n"
   3.232 +"        movl    $0x80000001,%%eax   # Setup extended function 800000001h\n"
   3.233 +"        cpuid                       # and get the information         \n"
   3.234 +"        movl    %%edx,%0                                              \n"
   3.235 +"1:                                                                    \n"
   3.236 +"        movl    %%edi,%%ebx\n"
   3.237 +	: "=m" (features)
   3.238 +	:
   3.239 +	: "%eax", "%ecx", "%edx", "%edi"
   3.240 +	);
   3.241  #elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
   3.242 -    __asm {
   3.243 -        mov eax, 80000000 h;
   3.244 -        Query for extended functions
   3.245 -            cpuid; Get extended function limit
   3.246 -            cmp eax, 80000001 h jl done; Nope
   3.247 -            , we dont have function 800000001 h mov eax, 80000001 h;
   3.248 -        Setup extended function 800000001 h cpuid;
   3.249 -    and get the information mov features, edx done:}
   3.250 +	__asm {
   3.251 +        mov     eax,80000000h       ; Query for extended functions
   3.252 +        cpuid                       ; Get extended function limit
   3.253 +        cmp     eax,80000001h
   3.254 +        jl      done                ; Nope, we dont have function 800000001h
   3.255 +        mov     eax,80000001h       ; Setup extended function 800000001h
   3.256 +        cpuid                       ; and get the information
   3.257 +        mov     features,edx
   3.258 +done:
   3.259 +	}
   3.260  #elif defined(__sun) && ( defined(__i386) || defined(__amd64) )
   3.261 -    __asm("        movl    %ebx,%edi\n"
   3.262 -          "        movl    $0x80000000,%eax \n"
   3.263 -          "        cpuid                    \n"
   3.264 -          "        cmpl    $0x80000001,%eax \n"
   3.265 -          "        jl      1f               \n"
   3.266 -          "        movl    $0x80000001,%eax \n"
   3.267 -          "        cpuid                    \n"
   3.268 +	    __asm (
   3.269 +"        movl    %ebx,%edi\n"
   3.270 +"        movl    $0x80000000,%eax \n"
   3.271 +"        cpuid                    \n"
   3.272 +"        cmpl    $0x80000001,%eax \n"
   3.273 +"        jl      1f               \n"
   3.274 +"        movl    $0x80000001,%eax \n"
   3.275 +"        cpuid                    \n"
   3.276  #ifdef __i386
   3.277 -          "        movl    %edx,-8(%ebp)   \n"
   3.278 +"        movl    %edx,-8(%ebp)   \n"
   3.279  #else
   3.280 -          "        movl    %edx,-8(%rbp)   \n"
   3.281 +"        movl    %edx,-8(%rbp)   \n"
   3.282  #endif
   3.283 -          "1:                               \n"
   3.284 -          "        movl    %edi,%ebx\n");
   3.285 +"1:                               \n"
   3.286 +"        movl    %edi,%ebx\n"
   3.287 +	    );
   3.288  #endif
   3.289 +/* *INDENT-ON* */
   3.290      return features;
   3.291  }
   3.292  
   3.293 @@ -394,4 +469,5 @@
   3.294  }
   3.295  
   3.296  #endif /* TEST_MAIN */
   3.297 +
   3.298  /* vi: set ts=4 sw=4 expandtab: */