indent
authorSam Lantinga <slouken@libsdl.org>
Wed, 10 Jun 2009 13:34:20 +0000
changeset 318651750b7a966f
parent 3185 44d5474c2c8a
child 3187 e041d2c603fe
indent
include/SDL_atomic.h
src/events/SDL_mouse.c
src/power/SDL_power.c
src/power/beos/SDL_syspower.c
src/power/linux/SDL_syspower.c
src/power/macosx/SDL_syspower.c
src/power/nds/SDL_syspower.c
src/power/os2/SDL_syspower.c
src/power/windows/SDL_syspower.c
src/video/SDL_video.c
src/video/photon/SDL_photon.c
src/video/qnxgf/SDL_qnxgf.c
src/video/win32/SDL_win32modes.c
src/video/x11/SDL_x11events.c
test/common.c
test/testatomic.c
test/testpower.c
test/testsprite2.c
     1.1 --- a/include/SDL_atomic.h	Wed Jun 10 08:09:04 2009 +0000
     1.2 +++ b/include/SDL_atomic.h	Wed Jun 10 13:34:20 2009 +0000
     1.3 @@ -44,58 +44,44 @@
     1.4  
     1.5  #if defined(__GNUC__) && (defined(i386) || defined(__i386__)  || defined(__x86_64__))
     1.6  static __inline__ void
     1.7 -SDL_atomic_int_add(volatile int* atomic, int value)
     1.8 +SDL_atomic_int_add(volatile int *atomic, int value)
     1.9  {
    1.10 -  __asm__ __volatile__("lock;"
    1.11 -                       "addl %1, %0"
    1.12 -                       : "=m" (*atomic)
    1.13 -                       : "ir" (value),
    1.14 -                         "m" (*atomic));
    1.15 +    __asm__ __volatile__("lock;" "addl %1, %0":"=m"(*atomic)
    1.16 +                         :"ir"(value), "m"(*atomic));
    1.17  }
    1.18  
    1.19  static __inline__ int
    1.20 -SDL_atomic_int_xchg_add(volatile int* atomic, int value)
    1.21 -{                                              
    1.22 -  int rv;                                    
    1.23 -  __asm__ __volatile__("lock;"               
    1.24 -                       "xaddl %0, %1"        
    1.25 -                       : "=r" (rv),          
    1.26 -                         "=m" (*atomic)    
    1.27 -                       : "0" (value),        
    1.28 -                         "m" (*atomic));   
    1.29 -  return rv;                                        
    1.30 +SDL_atomic_int_xchg_add(volatile int *atomic, int value)
    1.31 +{
    1.32 +    int rv;
    1.33 +    __asm__ __volatile__("lock;" "xaddl %0, %1":"=r"(rv), "=m"(*atomic)
    1.34 +                         :"0"(value), "m"(*atomic));
    1.35 +    return rv;
    1.36  }
    1.37  
    1.38  static __inline__ SDL_bool
    1.39 -SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
    1.40 +SDL_atomic_int_cmp_xchg(volatile int *atomic, int oldvalue, int newvalue)
    1.41  {
    1.42 -  int rv;                                                      
    1.43 -  __asm__ __volatile__("lock;"                               
    1.44 -                       "cmpxchgl %2, %1"                     
    1.45 -                       : "=a" (rv),                          
    1.46 -                         "=m" (*atomic)             
    1.47 -                       : "r" (newvalue),                     
    1.48 -                         "m" (*atomic),                    
    1.49 -                         "0" (oldvalue));
    1.50 -  return (SDL_bool)(rv == oldvalue);                                          
    1.51 +    int rv;
    1.52 +    __asm__ __volatile__("lock;" "cmpxchgl %2, %1":"=a"(rv), "=m"(*atomic)
    1.53 +                         :"r"(newvalue), "m"(*atomic), "0"(oldvalue));
    1.54 +    return (SDL_bool) (rv == oldvalue);
    1.55  }
    1.56  
    1.57  static __inline__ SDL_bool
    1.58 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
    1.59 +SDL_atomic_ptr_cmp_xchg(volatile void **atomic, void *oldvalue,
    1.60 +                        void *newvalue)
    1.61  {
    1.62 -  void* rv;
    1.63 -  __asm__ __volatile__("lock;"
    1.64 -# if defined(__x86_64__)                       
    1.65 -                       "cmpxchgq %q2, %1"
    1.66 +    void *rv;
    1.67 +    __asm__ __volatile__("lock;"
    1.68 +# if defined(__x86_64__)
    1.69 +                         "cmpxchgq %q2, %1"
    1.70  # else
    1.71 -                       "cmpxchgl %2, %1"
    1.72 -# endif                       
    1.73 -                       : "=a" (rv),
    1.74 -                         "=m" (*atomic)
    1.75 -                       : "r" (newvalue),
    1.76 -                         "m" (*atomic),
    1.77 -                         "0" (oldvalue));
    1.78 -  return (SDL_bool)(rv == oldvalue);
    1.79 +                         "cmpxchgl %2, %1"
    1.80 +# endif
    1.81 +                         :"=a"(rv), "=m"(*atomic)
    1.82 +                         :"r"(newvalue), "m"(*atomic), "0"(oldvalue));
    1.83 +    return (SDL_bool) (rv == oldvalue);
    1.84  }
    1.85  #elif defined(__GNUC__) && defined(__alpha__)
    1.86  # define ATOMIC_MEMORY_BARRIER (__asm__ __volatile__ ("mb" : : : "memory"))
    1.87 @@ -122,53 +108,45 @@
    1.88  
    1.89  # if (SIZEOF_VOIDP == 4)
    1.90  static __inline__ SDL_bool
    1.91 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
    1.92 +SDL_atomic_ptr_cmp_xchg(volatile void **atomic, void *oldvalue,
    1.93 +                        void *newvalue)
    1.94  {
    1.95 -  int rv;
    1.96 -  void* prev;
    1.97 -  __asm__ __volatile__("   mb\n"
    1.98 -                       "1: ldl_l %0,%2\n"
    1.99 -                       "   cmpeq %0,%3,%1\n"
   1.100 -                       "   beq   $1,2f\n"
   1.101 -                       "   mov   %4,%1\n"
   1.102 -                       "   stl_c %1,%2\n"
   1.103 -                       "   beq   %1,1b\n"
   1.104 -                       "   mb\n"
   1.105 -                       "2:"
   1.106 -                       : "=&r" (prev),
   1.107 -                         "=&r" (rv)
   1.108 -                       : "m" (*atomic),
   1.109 -                         "Ir" (oldvalue),
   1.110 -                         "Ir" (newvalue)
   1.111 -                       : "memory");
   1.112 -  return (SDL_bool)(rv != 0);
   1.113 +    int rv;
   1.114 +    void *prev;
   1.115 +    __asm__ __volatile__("   mb\n"
   1.116 +                         "1: ldl_l %0,%2\n"
   1.117 +                         "   cmpeq %0,%3,%1\n"
   1.118 +                         "   beq   $1,2f\n"
   1.119 +                         "   mov   %4,%1\n"
   1.120 +                         "   stl_c %1,%2\n"
   1.121 +                         "   beq   %1,1b\n"
   1.122 +                         "   mb\n" "2:":"=&r"(prev), "=&r"(rv)
   1.123 +                         :"m"(*atomic), "Ir"(oldvalue), "Ir"(newvalue)
   1.124 +                         :"memory");
   1.125 +    return (SDL_bool) (rv != 0);
   1.126  }
   1.127  # elif (SIZEOF_VOIDP == 8)
   1.128  static __inline__ SDL_bool
   1.129 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   1.130 +SDL_atomic_ptr_cmp_xchg(volatile void **atomic, void *oldvalue,
   1.131 +                        void *newvalue)
   1.132  {
   1.133 -  int rv;
   1.134 -  void* prev;
   1.135 -  __asm__ __volatile__("   mb\n"
   1.136 -                       "1: ldq_l %0,%2\n"
   1.137 -                       "   cmpeq %0,%3,%1\n"
   1.138 -                       "   beq   %1,2f\n"
   1.139 -                       "   mov   %4,%1\n"
   1.140 -                       "   stq_c %1,%2\n"
   1.141 -                       "   beq   %1,1b\n"
   1.142 -                       "   mb\n"
   1.143 -                       "2:"
   1.144 -                       : "=&r" (prev),
   1.145 -                         "=&r" (rv)
   1.146 -                       : "m" (*atomic),
   1.147 -                         "Ir" (oldvalue),
   1.148 -                         "Ir" (newvalue)
   1.149 -                       : "memory");
   1.150 -  return (SDL_bool)(rv != 0);
   1.151 +    int rv;
   1.152 +    void *prev;
   1.153 +    __asm__ __volatile__("   mb\n"
   1.154 +                         "1: ldq_l %0,%2\n"
   1.155 +                         "   cmpeq %0,%3,%1\n"
   1.156 +                         "   beq   %1,2f\n"
   1.157 +                         "   mov   %4,%1\n"
   1.158 +                         "   stq_c %1,%2\n"
   1.159 +                         "   beq   %1,1b\n"
   1.160 +                         "   mb\n" "2:":"=&r"(prev), "=&r"(rv)
   1.161 +                         :"m"(*atomic), "Ir"(oldvalue), "Ir"(newvalue)
   1.162 +                         :"memory");
   1.163 +    return (SDL_bool) (rv != 0);
   1.164  }
   1.165  # else
   1.166 -#  error "Your system has an unsupported pointer size"  
   1.167 -# endif  /* SIZEOF_VOIDP */
   1.168 +#  error "Your system has an unsupported pointer size"
   1.169 +# endif /* SIZEOF_VOIDP */
   1.170  #elif defined(__GNUC__) && defined(__sparc__)
   1.171  # define ATOMIC_MEMORY_BARRIER                                          \
   1.172    (__asm__ __volatile__("membar #LoadLoad | #LoadStore"                 \
   1.173 @@ -185,32 +163,25 @@
   1.174  
   1.175  # if (SIZEOF_VOIDP == 4)
   1.176  static __inline__ SDL_bool
   1.177 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   1.178 +SDL_atomic_ptr_cmp_xchg(volatile void **atomic, void *oldvalue,
   1.179 +                        void *newvalue)
   1.180  {
   1.181 -  void* rv;
   1.182 -  __asm__ __volatile__("cas [%4], %2, %0"
   1.183 -                       : "=r" (rv),
   1.184 -                         "=m" (*atomic)
   1.185 -                       : "r" (oldvalue),
   1.186 -                         "m" (*atomic),
   1.187 -                         "r" (atomic),
   1.188 -                         "0" (newvalue));
   1.189 -  return (SDL_bool)(rv == oldvalue);
   1.190 +    void *rv;
   1.191 +    __asm__ __volatile__("cas [%4], %2, %0":"=r"(rv), "=m"(*atomic)
   1.192 +                         :"r"(oldvalue),
   1.193 +                         "m"(*atomic), "r"(atomic), "0"(newvalue));
   1.194 +    return (SDL_bool) (rv == oldvalue);
   1.195  }
   1.196  # elif (SIZEOF_VOIDP == 8)
   1.197  static __inline__ SDL_bool
   1.198 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   1.199 +SDL_atomic_ptr_cmp_xchg(volatile void **atomic, void *oldvalue,
   1.200 +                        void *newvalue)
   1.201  {
   1.202 -  void* rv;
   1.203 -  void** a = atomic;
   1.204 -  __asm__ __volatile__("casx [%4], %2, %0"
   1.205 -                       : "=r" (rv),
   1.206 -                         "=m" (*a)
   1.207 -                       : "r" (oldvalue),
   1.208 -                         "m" (*a),
   1.209 -                         "r" (a),
   1.210 -                         "0" (newvalue));
   1.211 -  return (SDL_bool)(rv == oldvalue);
   1.212 +    void *rv;
   1.213 +    void **a = atomic;
   1.214 +    __asm__ __volatile__("casx [%4], %2, %0":"=r"(rv), "=m"(*a)
   1.215 +                         :"r"(oldvalue), "m"(*a), "r"(a), "0"(newvalue));
   1.216 +    return (SDL_bool) (rv == oldvalue);
   1.217  }
   1.218  # else
   1.219  #  error "Your system has an unsupported pointer size"
   1.220 @@ -219,122 +190,90 @@
   1.221  # define ATOMIC_MEMORY_BARRIER \
   1.222    (__asm__ __volatile__ ("sync" : : : "memory"))
   1.223  static __inline__ void
   1.224 -SDL_atomic_int_add(volatile int* atomic, int value)
   1.225 -{                                           
   1.226 -  int rv,tmp;                                   
   1.227 -  __asm__ __volatile__("1: lwarx   %0,  0, %3\n" 
   1.228 -                       "   add     %1, %0, %4\n"
   1.229 -                       "   stwcx.  %1,  0, %3\n" 
   1.230 -                       "   bne-    1b"          
   1.231 -                       : "=&b" (rv),            
   1.232 -                         "=&r" (tmp),           
   1.233 -                         "=m" (*atomic)       
   1.234 -                       : "b" (atomic),          
   1.235 -                         "r" (value),           
   1.236 -                         "m" (*atomic)        
   1.237 -                       : "cr0",                 
   1.238 -                         "memory");             
   1.239 +SDL_atomic_int_add(volatile int *atomic, int value)
   1.240 +{
   1.241 +    int rv, tmp;
   1.242 +    __asm__ __volatile__("1: lwarx   %0,  0, %3\n"
   1.243 +                         "   add     %1, %0, %4\n"
   1.244 +                         "   stwcx.  %1,  0, %3\n"
   1.245 +                         "   bne-    1b":"=&b"(rv), "=&r"(tmp), "=m"(*atomic)
   1.246 +                         :"b"(atomic), "r"(value), "m"(*atomic)
   1.247 +                         :"cr0", "memory");
   1.248  }
   1.249  
   1.250  static __inline__ int
   1.251 -SDL_atomic_int_xchg_add(volatile int* atomic, int value)
   1.252 -{                                          
   1.253 -  int rv,tmp;                               
   1.254 -  __asm__ __volatile__("1: lwarx  %0, 0, %3\n"        
   1.255 -                       "   add    %1, %0, %4\n"       
   1.256 -                       "   stwcx. %1, 0, %3\n"        
   1.257 -                       "   bne-   1b"                 
   1.258 -                       : "=&b" (rv),                  
   1.259 -                         "=&r" (tmp),                 
   1.260 -                         "=m" (*atomic)
   1.261 -                       : "b" (atomic),                
   1.262 -                         "r" (value),                 
   1.263 -                         "m" (*atomic)
   1.264 -                       : "cr0",                       
   1.265 -                       "memory");                   
   1.266 -  return rv;                                                 
   1.267 +SDL_atomic_int_xchg_add(volatile int *atomic, int value)
   1.268 +{
   1.269 +    int rv, tmp;
   1.270 +    __asm__ __volatile__("1: lwarx  %0, 0, %3\n"
   1.271 +                         "   add    %1, %0, %4\n"
   1.272 +                         "   stwcx. %1, 0, %3\n"
   1.273 +                         "   bne-   1b":"=&b"(rv), "=&r"(tmp), "=m"(*atomic)
   1.274 +                         :"b"(atomic), "r"(value), "m"(*atomic)
   1.275 +                         :"cr0", "memory");
   1.276 +    return rv;
   1.277  }
   1.278  
   1.279  # if (SIZEOF_VOIDP == 4)
   1.280  static __inline__ SDL_bool
   1.281 -SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
   1.282 -{                                                        
   1.283 -  int rv;                                                 
   1.284 -  __asm__ __volatile__("   sync\n"                         
   1.285 -                       "1: lwarx   %0, 0, %1\n"           
   1.286 -                       "   subf.   %0, %2, %0\n"          
   1.287 -                       "   bne     2f\n"                  
   1.288 -                       "   stwcx.  %3, 0, %1\n"           
   1.289 -                       "   bne-    1b\n"                  
   1.290 -                       "2: isync"                         
   1.291 -                       : "=&r" (rv)                       
   1.292 -                       : "b" (atomic),                    
   1.293 -                         "r" (oldvalue),                  
   1.294 -                         "r"                              
   1.295 -                       : "cr0",                           
   1.296 -                         "memory");                         
   1.297 -  return (SDL_bool)(rv == 0);                                              
   1.298 +SDL_atomic_int_cmp_xchg(volatile int *atomic, int oldvalue, int newvalue)
   1.299 +{
   1.300 +    int rv;
   1.301 +    __asm__ __volatile__("   sync\n"
   1.302 +                         "1: lwarx   %0, 0, %1\n"
   1.303 +                         "   subf.   %0, %2, %0\n"
   1.304 +                         "   bne     2f\n"
   1.305 +                         "   stwcx.  %3, 0, %1\n"
   1.306 +                         "   bne-    1b\n" "2: isync":"=&r"(rv)
   1.307 +                         :"b"(atomic), "r"(oldvalue), "r":"cr0", "memory");
   1.308 +    return (SDL_bool) (rv == 0);
   1.309  }
   1.310  
   1.311  static __inline__ SDL_bool
   1.312 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   1.313 +SDL_atomic_ptr_cmp_xchg(volatile void **atomic, void *oldvalue,
   1.314 +                        void *newvalue)
   1.315  {
   1.316 -  void* rv;
   1.317 -  __asm__ __volatile__("sync\n"
   1.318 -                       "1: lwarx  %0,  0, %1\n"
   1.319 -                       "   subf.  %0, %2, %0\n"
   1.320 -                       "   bne    2f\n"
   1.321 -                       "   stwcx. %3,  0, %1\n"
   1.322 -                       "   bne-   1b\n"
   1.323 -                       "2: isync"
   1.324 -                       : "=&r" (rv)
   1.325 -                       : "b" (atomic),
   1.326 -                         "r" (oldvalue),
   1.327 -                         "r" (newvalue)
   1.328 -                       : "cr0",
   1.329 -                       "memory");
   1.330 -  return (SDL_bool)(rv == 0);
   1.331 +    void *rv;
   1.332 +    __asm__ __volatile__("sync\n"
   1.333 +                         "1: lwarx  %0,  0, %1\n"
   1.334 +                         "   subf.  %0, %2, %0\n"
   1.335 +                         "   bne    2f\n"
   1.336 +                         "   stwcx. %3,  0, %1\n"
   1.337 +                         "   bne-   1b\n" "2: isync":"=&r"(rv)
   1.338 +                         :"b"(atomic), "r"(oldvalue), "r"(newvalue)
   1.339 +                         :"cr0", "memory");
   1.340 +    return (SDL_bool) (rv == 0);
   1.341  }
   1.342  # elif (SIZEOF_VOIDP == 8)
   1.343  static __inline__ SDL_bool
   1.344 -SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
   1.345 -{                                                        
   1.346 -  int rv;                                                 
   1.347 -  __asm__ __volatile__("   sync\n"                         
   1.348 -                       "1: lwarx   %0,  0, %1\n"
   1.349 -                       "   extsw   %0, %0\n"
   1.350 -                       "   subf.   %0, %2, %0\n"          
   1.351 -                       "   bne     2f\n"                  
   1.352 -                       "   stwcx.  %3,  0, %1\n"           
   1.353 -                       "   bne-    1b\n"                  
   1.354 -                       "2: isync"                         
   1.355 -                       : "=&r" (rv)                       
   1.356 -                       : "b" (atomic),                    
   1.357 -                         "r" (oldvalue),                  
   1.358 -                         "r"                              
   1.359 -                       : "cr0",                           
   1.360 -                         "memory");                         
   1.361 -  return (SDL_bool)(rv == 0);                                              
   1.362 +SDL_atomic_int_cmp_xchg(volatile int *atomic, int oldvalue, int newvalue)
   1.363 +{
   1.364 +    int rv;
   1.365 +    __asm__ __volatile__("   sync\n"
   1.366 +                         "1: lwarx   %0,  0, %1\n"
   1.367 +                         "   extsw   %0, %0\n"
   1.368 +                         "   subf.   %0, %2, %0\n"
   1.369 +                         "   bne     2f\n"
   1.370 +                         "   stwcx.  %3,  0, %1\n"
   1.371 +                         "   bne-    1b\n" "2: isync":"=&r"(rv)
   1.372 +                         :"b"(atomic), "r"(oldvalue), "r":"cr0", "memory");
   1.373 +    return (SDL_bool) (rv == 0);
   1.374  }
   1.375  
   1.376  static __inline__ SDL_bool
   1.377 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   1.378 +SDL_atomic_ptr_cmp_xchg(volatile void **atomic, void *oldvalue,
   1.379 +                        void *newvalue)
   1.380  {
   1.381 -  void* rv;
   1.382 -  __asm__ __volatile__("sync\n"
   1.383 -                       "1: ldarx  %0,  0, %1\n"
   1.384 -                       "   subf.  %0, %2, %0\n"
   1.385 -                       "   bne    2f\n"
   1.386 -                       "   stdcx. %3,  0, %1\n"
   1.387 -                       "   bne-   1b\n"
   1.388 -                       "2: isync"
   1.389 -                       : "=&r" (rv)
   1.390 -                       : "b" (atomic),
   1.391 -                         "r" (oldvalue),
   1.392 -                         "r" (newvalue)
   1.393 -                       : "cr0",
   1.394 -                       "memory");
   1.395 -  return (SDL_bool)(rv == 0);
   1.396 +    void *rv;
   1.397 +    __asm__ __volatile__("sync\n"
   1.398 +                         "1: ldarx  %0,  0, %1\n"
   1.399 +                         "   subf.  %0, %2, %0\n"
   1.400 +                         "   bne    2f\n"
   1.401 +                         "   stdcx. %3,  0, %1\n"
   1.402 +                         "   bne-   1b\n" "2: isync":"=&r"(rv)
   1.403 +                         :"b"(atomic), "r"(oldvalue), "r"(newvalue)
   1.404 +                         :"cr0", "memory");
   1.405 +    return (SDL_bool) (rv == 0);
   1.406  }
   1.407  # else
   1.408  #  error "Your system has an unsupported pointer size"
   1.409 @@ -351,161 +290,130 @@
   1.410    (__sync_bool_compare_and_swap((long*)(atomic),(long)(oldvalue),(long)(newvalue)))
   1.411  #elif defined(__GNUC__) && defined(__LINUX__) && (defined(__mips__) || defined(__MIPS__))
   1.412  static __inline__ int
   1.413 -SDL_atomic_int_xchg_add(volatile int* atomic, int value)
   1.414 -{                                            
   1.415 -  int rv,tmp;                                 
   1.416 -  __asm__ __volatile__("1:              \n"                 
   1.417 -                       ".set  push      \n"         
   1.418 -                       ".set  mips2     \n"        
   1.419 -                       "ll    %0,%3     \n"        
   1.420 -                       "addu  %1,%4,%0  \n"     
   1.421 -                       "sc    %1,%2     \n"        
   1.422 -                       ".set  pop       \n"          
   1.423 -                       "beqz  %1,1b     \n"        
   1.424 -                       : "=&r" (rv),          
   1.425 -                         "=&r" (tmp),         
   1.426 -                         "=m" (*atomic)     
   1.427 -                       : "m" (*atomic),     
   1.428 -                         "r" (value)          
   1.429 -                       : "memory");           
   1.430 -  return rv;                                         
   1.431 +SDL_atomic_int_xchg_add(volatile int *atomic, int value)
   1.432 +{
   1.433 +    int rv, tmp;
   1.434 +    __asm__ __volatile__("1:              \n"
   1.435 +                         ".set  push      \n"
   1.436 +                         ".set  mips2     \n"
   1.437 +                         "ll    %0,%3     \n"
   1.438 +                         "addu  %1,%4,%0  \n"
   1.439 +                         "sc    %1,%2     \n"
   1.440 +                         ".set  pop       \n"
   1.441 +                         "beqz  %1,1b     \n":"=&r"(rv),
   1.442 +                         "=&r"(tmp), "=m"(*atomic)
   1.443 +                         :"m"(*atomic), "r"(value)
   1.444 +                         :"memory");
   1.445 +    return rv;
   1.446  }
   1.447  
   1.448  static __inline__ void
   1.449 -SDL_atomic_int_add(volatile int* atomic, int value)
   1.450 -{                                           
   1.451 -  int rv;                                    
   1.452 -  __asm__ __volatile__("1:               \n"                
   1.453 -                       ".set  push       \n"        
   1.454 -                       ".set  mips2      \n"       
   1.455 -                       "ll    %0,%2      \n"       
   1.456 -                       "addu  %0,%3,%0   \n"    
   1.457 -                       "sc    %0,%1      \n"       
   1.458 -                       ".set  pop        \n"         
   1.459 -                       "beqz  %0,1b      \n"       
   1.460 -                       : "=&r" (rv),         
   1.461 -                         "=m" (*atomic)    
   1.462 -                       : "m" (*atomic),    
   1.463 -                         "r" (value)         
   1.464 -                       : "memory");          
   1.465 +SDL_atomic_int_add(volatile int *atomic, int value)
   1.466 +{
   1.467 +    int rv;
   1.468 +    __asm__ __volatile__("1:               \n"
   1.469 +                         ".set  push       \n"
   1.470 +                         ".set  mips2      \n"
   1.471 +                         "ll    %0,%2      \n"
   1.472 +                         "addu  %0,%3,%0   \n"
   1.473 +                         "sc    %0,%1      \n"
   1.474 +                         ".set  pop        \n"
   1.475 +                         "beqz  %0,1b      \n":"=&r"(rv), "=m"(*atomic)
   1.476 +                         :"m"(*atomic), "r"(value)
   1.477 +                         :"memory");
   1.478  }
   1.479  
   1.480  static __inline__ SDL_bool
   1.481 -SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
   1.482 +SDL_atomic_int_cmp_xchg(volatile int *atomic, int oldvalue, int newvalue)
   1.483  {
   1.484 -  int rv;
   1.485 -  __asm__ __volatile__("     .set push        \n"
   1.486 -                       "     .set noat        \n"
   1.487 -                       "     .set mips3       \n"
   1.488 -                       "1:   ll   %0, %2      \n"
   1.489 -                       "     bne  %0, %z3, 2f \n"
   1.490 -                       "     .set mips0       \n"
   1.491 -                       "     move $1, %z4     \n"
   1.492 -                       "     .set mips3       \n"
   1.493 -                       "     sc   $1, %1      \n"
   1.494 -                       "     beqz $1, 1b      \n"
   1.495 -                       "     sync             \n"
   1.496 -                       "2:                    \n"
   1.497 -                       "     .set pop         \n"
   1.498 -                       : "=&r" (rv),
   1.499 -                         "=R" (*atomic)
   1.500 -                       : "R" (*atomic),
   1.501 -                         "Jr" (oldvalue),
   1.502 -                         "Jr" (newvalue)
   1.503 -                       : "memory");
   1.504 -  return (SDL_bool)rv;                  
   1.505 +    int rv;
   1.506 +    __asm__ __volatile__("     .set push        \n"
   1.507 +                         "     .set noat        \n"
   1.508 +                         "     .set mips3       \n"
   1.509 +                         "1:   ll   %0, %2      \n"
   1.510 +                         "     bne  %0, %z3, 2f \n"
   1.511 +                         "     .set mips0       \n"
   1.512 +                         "     move $1, %z4     \n"
   1.513 +                         "     .set mips3       \n"
   1.514 +                         "     sc   $1, %1      \n"
   1.515 +                         "     beqz $1, 1b      \n"
   1.516 +                         "     sync             \n"
   1.517 +                         "2:                    \n"
   1.518 +                         "     .set pop         \n":"=&r"(rv), "=R"(*atomic)
   1.519 +                         :"R"(*atomic), "Jr"(oldvalue), "Jr"(newvalue)
   1.520 +                         :"memory");
   1.521 +    return (SDL_bool) rv;
   1.522  }
   1.523  
   1.524  static __inline__ SDL_bool
   1.525 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   1.526 -{                                                     
   1.527 -  int rv;
   1.528 -  __asm__ __volatile__("     .set push        \n"
   1.529 -                       "     .set noat        \n"
   1.530 -                       "     .set mips3       \n"
   1.531 +SDL_atomic_ptr_cmp_xchg(volatile void **atomic, void *oldvalue,
   1.532 +                        void *newvalue)
   1.533 +{
   1.534 +    int rv;
   1.535 +    __asm__ __volatile__("     .set push        \n"
   1.536 +                         "     .set noat        \n" "     .set mips3       \n"
   1.537  # if defined(__mips64)
   1.538 -                       "1:   lld  %0, %2      \n"
   1.539 +                         "1:   lld  %0, %2      \n"
   1.540  # else
   1.541 -                       "1:   ll   %0, %2      \n"
   1.542 -# endif                       
   1.543 -                       "     bne  %0, %z3, 2f \n"
   1.544 -                       "     move $1, %z4     \n"
   1.545 +                         "1:   ll   %0, %2      \n"
   1.546 +# endif
   1.547 +                         "     bne  %0, %z3, 2f \n" "     move $1, %z4     \n"
   1.548  # if defined(__mips64)
   1.549 -                       "     sc   $1, %1      \n"
   1.550 +                         "     sc   $1, %1      \n"
   1.551  # else
   1.552 -                       "     scd  $1, %1      \n"
   1.553 -# endif                       
   1.554 -                       "     beqz $1, 1b      \n"
   1.555 -                       "     sync             \n"
   1.556 -                       "2:                    \n"
   1.557 -                       "     .set pop         \n"
   1.558 -                       : "=&r" (rv),
   1.559 -                         "=R" (*atomic)
   1.560 -                       : "R" (*atomic),
   1.561 -                         "Jr" (oldvalue),
   1.562 -                         "Jr" (newvalue)
   1.563 -                       : "memory");
   1.564 -  return (SDL_bool)rv;                                                  
   1.565 +                         "     scd  $1, %1      \n"
   1.566 +# endif
   1.567 +                         "     beqz $1, 1b      \n"
   1.568 +                         "     sync             \n"
   1.569 +                         "2:                    \n"
   1.570 +                         "     .set pop         \n":"=&r"(rv), "=R"(*atomic)
   1.571 +                         :"R"(*atomic), "Jr"(oldvalue), "Jr"(newvalue)
   1.572 +                         :"memory");
   1.573 +    return (SDL_bool) rv;
   1.574  }
   1.575  #elif defined(__GNUC__) && defined(__m68k__)
   1.576  static __inline__ int
   1.577 -SDL_atomic_int_xchg_add(volatile int* atomic, int value)
   1.578 -{                                          
   1.579 -  int rv = *atomic;
   1.580 -  int tmp;
   1.581 -  __asm__ __volatile__("1: move%.l %0,%1    \n"
   1.582 -                       "   add%.l  %2,%1    \n"
   1.583 -                       "   cas%.l  %0,%1,%3 \n"
   1.584 -                       "   jbne    1b       \n"
   1.585 -                       : "=d" (rv),
   1.586 -                         "=&d" (tmp)
   1.587 -                       : "d" (value),
   1.588 -                         "m" (*atomic),
   1.589 -                         "0" (rv)
   1.590 -                       : "memory");
   1.591 -  return (SDL_bool)rv;
   1.592 +SDL_atomic_int_xchg_add(volatile int *atomic, int value)
   1.593 +{
   1.594 +    int rv = *atomic;
   1.595 +    int tmp;
   1.596 +    __asm__ __volatile__("1: move%.l %0,%1    \n"
   1.597 +                         "   add%.l  %2,%1    \n"
   1.598 +                         "   cas%.l  %0,%1,%3 \n"
   1.599 +                         "   jbne    1b       \n":"=d"(rv), "=&d"(tmp)
   1.600 +                         :"d"(value), "m"(*atomic), "0"(rv)
   1.601 +                         :"memory");
   1.602 +    return (SDL_bool) rv;
   1.603  }
   1.604  
   1.605  static __inline__ void
   1.606 -SDL_atomic_int_add(volatile int* atomic, int value)
   1.607 -{                                           
   1.608 -  __asm__ __volatile__("add%.l %0,%1"        
   1.609 -                       :                     
   1.610 -                       : "id" (value),       
   1.611 -                         "m" (*atomic)
   1.612 -                       : "memory");          
   1.613 +SDL_atomic_int_add(volatile int *atomic, int value)
   1.614 +{
   1.615 +    __asm__ __volatile__("add%.l %0,%1"::"id"(value), "m"(*atomic)
   1.616 +                         :"memory");
   1.617  }
   1.618  
   1.619  static __inline__ SDL_bool
   1.620 -SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
   1.621 -{                                           
   1.622 -  char rv;                                   
   1.623 -  int readvalue;                             
   1.624 -  __asm__ __volatile__("cas%.l %2,%3,%1\n"   
   1.625 -                       "seq    %0"           
   1.626 -                       : "=dm" (rv),         
   1.627 -                         "=m" (*atomic),   
   1.628 -                         "=d" (readvalue)    
   1.629 -                       : "d" (newvalue),     
   1.630 -                         "m" (*atomic),    
   1.631 -                         "2" (oldvalue));    
   1.632 -    return (SDL_bool)rv;                                        
   1.633 +SDL_atomic_int_cmp_xchg(volatile int *atomic, int oldvalue, int newvalue)
   1.634 +{
   1.635 +    char rv;
   1.636 +    int readvalue;
   1.637 +    __asm__ __volatile__("cas%.l %2,%3,%1\n"
   1.638 +                         "seq    %0":"=dm"(rv), "=m"(*atomic), "=d"(readvalue)
   1.639 +                         :"d"(newvalue), "m"(*atomic), "2"(oldvalue));
   1.640 +    return (SDL_bool) rv;
   1.641  }
   1.642  
   1.643  static __inline__ SDL_bool
   1.644 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   1.645 +SDL_atomic_ptr_cmp_xchg(volatile void **atomic, void *oldvalue,
   1.646 +                        void *newvalue)
   1.647  {
   1.648 -  char rv;                                   
   1.649 -  int readvalue;                             
   1.650 -  __asm__ __volatile__("cas%.l %2,%3,%1\n"   
   1.651 -                       "seq    %0"           
   1.652 -                       : "=dm" (rv),         
   1.653 -                         "=m" (*atomic),   
   1.654 -                         "=d" (readvalue)    
   1.655 -                       : "d" (newvalue),     
   1.656 -                         "m" (*atomic),    
   1.657 -                         "2" (oldvalue));    
   1.658 -    return (SDL_bool)rv;                                        
   1.659 +    char rv;
   1.660 +    int readvalue;
   1.661 +    __asm__ __volatile__("cas%.l %2,%3,%1\n"
   1.662 +                         "seq    %0":"=dm"(rv), "=m"(*atomic), "=d"(readvalue)
   1.663 +                         :"d"(newvalue), "m"(*atomic), "2"(oldvalue));
   1.664 +    return (SDL_bool) rv;
   1.665  }
   1.666  #elif defined(__GNUC__) && defined(__s390__)
   1.667  # define ATOMIC_INT_CMP_XCHG(atomic,oldvalue,newvalue)  \
   1.668 @@ -521,30 +429,26 @@
   1.669    })
   1.670  # if (SIZEOF_VOIDP == 4)
   1.671  static __inline__ SDL_bool
   1.672 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   1.673 +SDL_atomic_ptr_cmp_xchg(volatile void **atomic, void *oldvalue,
   1.674 +                        void *newvalue)
   1.675  {
   1.676 -  void* rv = oldvalue;
   1.677 -  __asm__ __volatile__("cs %0, %2, %1"
   1.678 -                       : "+d" (rv),
   1.679 -                         "=Q" (*atomic)
   1.680 -                       : "d" (newvalue),
   1.681 -                         "m" (*atomic)
   1.682 -                       : "cc");
   1.683 -  return (SDL_bool)(rv == oldvalue);
   1.684 +    void *rv = oldvalue;
   1.685 +    __asm__ __volatile__("cs %0, %2, %1":"+d"(rv), "=Q"(*atomic)
   1.686 +                         :"d"(newvalue), "m"(*atomic)
   1.687 +                         :"cc");
   1.688 +    return (SDL_bool) (rv == oldvalue);
   1.689  }
   1.690  # elif (SIZEOF_VOIDP == 8)
   1.691  static __inline__ SDL_bool
   1.692 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   1.693 +SDL_atomic_ptr_cmp_xchg(volatile void **atomic, void *oldvalue,
   1.694 +                        void *newvalue)
   1.695  {
   1.696 -  void* rv = oldvalue;
   1.697 -  void** a = atomic;
   1.698 -  __asm__ __volatile__("csg %0, %2, %1"
   1.699 -                       : "+d" (rv),
   1.700 -                         "=Q" (*a)
   1.701 -                       : "d" ((long)(newvalue)),
   1.702 -                         "m" (*a)
   1.703 -                       : "cc");
   1.704 -  return (SDL_bool)(rv == oldvalue);
   1.705 +    void *rv = oldvalue;
   1.706 +    void **a = atomic;
   1.707 +    __asm__ __volatile__("csg %0, %2, %1":"+d"(rv), "=Q"(*a)
   1.708 +                         :"d"((long) (newvalue)), "m"(*a)
   1.709 +                         :"cc");
   1.710 +    return (SDL_bool) (rv == oldvalue);
   1.711  }
   1.712  # else
   1.713  #  error "Your system has an unsupported pointer size"
   1.714 @@ -552,31 +456,34 @@
   1.715  #elif defined(__WIN32__)
   1.716  # include <windows.h>
   1.717  static __inline__ int
   1.718 -SDL_atomic_int_xchg_add(volatile int* atomic, int value)
   1.719 +SDL_atomic_int_xchg_add(volatile int *atomic, int value)
   1.720  {
   1.721 -  return InterlockedExchangeAdd(atomic, value);
   1.722 +    return InterlockedExchangeAdd(atomic, value);
   1.723  }
   1.724  
   1.725  static __inline__ void
   1.726 -SDL_atomic_int_add(volatile int* atomic, int value)
   1.727 +SDL_atomic_int_add(volatile int *atomic, int value)
   1.728  {
   1.729 -  InterlockedExchangeAdd(atomic, value);
   1.730 +    InterlockedExchangeAdd(atomic, value);
   1.731  }
   1.732  
   1.733  # if (WINVER > 0X0400)
   1.734  static __inline__ SDL_bool
   1.735 -SDL_atmoic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
   1.736 +SDL_atmoic_int_cmp_xchg(volatile int *atomic, int oldvalue, int newvalue)
   1.737  {
   1.738 -   return (SDL_bool)(InterlockedCompareExchangePointer((PVOID*)atomic,
   1.739 -                                                       (PVOID)newvalue,
   1.740 -                                                       (PVOID)oldvalue) == oldvalue);
   1.741 +    return (SDL_bool) (InterlockedCompareExchangePointer((PVOID *) atomic,
   1.742 +                                                         (PVOID) newvalue,
   1.743 +                                                         (PVOID) oldvalue) ==
   1.744 +                       oldvalue);
   1.745  }
   1.746  
   1.747  
   1.748  static __inline__ SDL_bool
   1.749 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   1.750 +SDL_atomic_ptr_cmp_xchg(volatile void **atomic, void *oldvalue,
   1.751 +                        void *newvalue)
   1.752  {
   1.753 -  return (InterlockedCompareExchangePointer(atomic, newvalue, oldvalue) == oldvalue);
   1.754 +    return (InterlockedCompareExchangePointer(atomic, newvalue, oldvalue) ==
   1.755 +            oldvalue);
   1.756  }
   1.757  # else /* WINVER <= 0x0400 */
   1.758  #  if (SIZEOF_VOIDP != 4)
   1.759 @@ -584,66 +491,69 @@
   1.760  #  endif
   1.761  
   1.762  static __inline__ SDL_bool
   1.763 -SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
   1.764 +SDL_atomic_int_cmp_xchg(volatile int *atomic, int oldvalue, int newvalue)
   1.765  {
   1.766 -  return (InterlockedCompareExchange(atomic, newvalue, oldvalue) == oldvalue);
   1.767 +    return (InterlockedCompareExchange(atomic, newvalue, oldvalue) ==
   1.768 +            oldvalue);
   1.769  }
   1.770  
   1.771  static __inline__ SDL_bool
   1.772 -SDL_atomic_ptr_cmp_xchg(volatile void** atomic, void* oldvalue, void* newvalue)
   1.773 +SDL_atomic_ptr_cmp_xchg(volatile void **atomic, void *oldvalue,
   1.774 +                        void *newvalue)
   1.775  {
   1.776 -  return (InterlockedCompareExchange(atomic, newvalue, oldvalue) == oldvalue);
   1.777 +    return (InterlockedCompareExchange(atomic, newvalue, oldvalue) ==
   1.778 +            oldvalue);
   1.779  }
   1.780  # endif
   1.781  #else /* when all else fails */
   1.782  # define SDL_ATOMIC_OPS_NOT_SUPPORTED
   1.783  # warning "Atomic Ops for this platform not supported!"
   1.784  static __inline__ int
   1.785 -SDL_atomic_int_xchg_add(volatile int* atomic, int value)
   1.786 -{                                           
   1.787 -  int rv = *atomic;                          
   1.788 -  *(atomic) += value;                        
   1.789 -  return rv;                                        
   1.790 +SDL_atomic_int_xchg_add(volatile int *atomic, int value)
   1.791 +{
   1.792 +    int rv = *atomic;
   1.793 +    *(atomic) += value;
   1.794 +    return rv;
   1.795  }
   1.796  
   1.797  static __inline__ SDL_bool
   1.798 -SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
   1.799 +SDL_atomic_int_cmp_xchg(volatile int *atomic, int oldvalue, int newvalue)
   1.800  {
   1.801 -  return (*atomic == oldvalue) ?  
   1.802 -    ((*atomic = newvalue), SDL_TRUE) : SDL_FALSE;
   1.803 +    return (*atomic == oldvalue) ?
   1.804 +        ((*atomic = newvalue), SDL_TRUE) : SDL_FALSE;
   1.805  }
   1.806  
   1.807  static __inline__ void
   1.808 -SDL_atomic_int_add(volatile int* atomic, int value)
   1.809 +SDL_atomic_int_add(volatile int *atomic, int value)
   1.810  {
   1.811 -  *atomic += value;
   1.812 +    *atomic += value;
   1.813  }
   1.814  #endif /* arch & platforms */
   1.815 -  
   1.816 +
   1.817  #ifdef ATOMIC_INT_CMP_XCHG
   1.818  static __inline__ SDL_bool
   1.819 -SDL_atomic_int_cmp_xchg(volatile int* atomic, int oldvalue, int newvalue)
   1.820 +SDL_atomic_int_cmp_xchg(volatile int *atomic, int oldvalue, int newvalue)
   1.821  {
   1.822 -  return (SDL_bool)ATOMIC_INT_CMP_XCHG(atomic,oldvalue,newvalue);
   1.823 +    return (SDL_bool) ATOMIC_INT_CMP_XCHG(atomic, oldvalue, newvalue);
   1.824  }
   1.825  
   1.826  static __inline__ int
   1.827 -SDL_atomic_int_xchg_add(volatile int* atomic, int value)   
   1.828 -{                                                   
   1.829 -  int rv;                                            
   1.830 -  do                                                 
   1.831 -    rv = *atomic;                                
   1.832 -  while(!ATOMIC_INT_CMP_XCHG(atomic,rv,rv+value)); 
   1.833 -  return rv;                                                
   1.834 +SDL_atomic_int_xchg_add(volatile int *atomic, int value)
   1.835 +{
   1.836 +    int rv;
   1.837 +    do
   1.838 +        rv = *atomic;
   1.839 +    while (!ATOMIC_INT_CMP_XCHG(atomic, rv, rv + value));
   1.840 +    return rv;
   1.841  }
   1.842  
   1.843  static __inline__ void
   1.844 -SDL_atomic_int_add(volatile int* atomic, int value)
   1.845 +SDL_atomic_int_add(volatile int *atomic, int value)
   1.846  {
   1.847 -  int rv;
   1.848 -  do
   1.849 -    rv = *atomic;
   1.850 -  while(!ATOMIC_INT_CMP_XCHG(atomic,rv,rv+value));
   1.851 +    int rv;
   1.852 +    do
   1.853 +        rv = *atomic;
   1.854 +    while (!ATOMIC_INT_CMP_XCHG(atomic, rv, rv + value));
   1.855  }
   1.856  #endif /* ATOMIC_CMP_XCHG */
   1.857  
     2.1 --- a/src/events/SDL_mouse.c	Wed Jun 10 08:09:04 2009 +0000
     2.2 +++ b/src/events/SDL_mouse.c	Wed Jun 10 13:34:20 2009 +0000
     2.3 @@ -369,6 +369,7 @@
     2.4          event.proximity.y = y;
     2.5          event.proximity.cursor = mouse->current_end;
     2.6          event.proximity.type = type;
     2.7 +        event.proximity.windowID = mouse->focus;
     2.8          posted = (SDL_PushEvent(&event) > 0);
     2.9          if (type == SDL_PROXIMITYIN) {
    2.10              mouse->proximity = SDL_TRUE;
     3.1 --- a/src/power/SDL_power.c	Wed Jun 10 08:09:04 2009 +0000
     3.2 +++ b/src/power/SDL_power.c	Wed Jun 10 13:34:20 2009 +0000
     3.3 @@ -27,22 +27,23 @@
     3.4   * SDL_FALSE to try next implementation.
     3.5   */
     3.6  typedef SDL_bool
     3.7 -(*SDL_GetPowerInfo_Impl)(SDL_PowerState *state, int *seconds, int *percent);
     3.8 +    (*SDL_GetPowerInfo_Impl) (SDL_PowerState * state, int *seconds,
     3.9 +                              int *percent);
    3.10  
    3.11 -SDL_bool SDL_GetPowerInfo_Linux_sys_power(SDL_PowerState*, int*, int*);
    3.12 -SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState*, int*, int*);
    3.13 -SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState*, int*, int*);
    3.14 -SDL_bool SDL_GetPowerInfo_Windows(SDL_PowerState*, int*, int*);
    3.15 -SDL_bool SDL_GetPowerInfo_MacOSX(SDL_PowerState*, int*, int*);
    3.16 -SDL_bool SDL_GetPowerInfo_OS2(SDL_PowerState*, int*, int*);
    3.17 -SDL_bool SDL_GetPowerInfo_BeOS(SDL_PowerState*, int*, int*);
    3.18 -SDL_bool SDL_GetPowerInfo_NintendoDS(SDL_PowerState*, int*, int*);
    3.19 +SDL_bool SDL_GetPowerInfo_Linux_sys_power(SDL_PowerState *, int *, int *);
    3.20 +SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *, int *, int *);
    3.21 +SDL_bool SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *, int *, int *);
    3.22 +SDL_bool SDL_GetPowerInfo_Windows(SDL_PowerState *, int *, int *);
    3.23 +SDL_bool SDL_GetPowerInfo_MacOSX(SDL_PowerState *, int *, int *);
    3.24 +SDL_bool SDL_GetPowerInfo_OS2(SDL_PowerState *, int *, int *);
    3.25 +SDL_bool SDL_GetPowerInfo_BeOS(SDL_PowerState *, int *, int *);
    3.26 +SDL_bool SDL_GetPowerInfo_NintendoDS(SDL_PowerState *, int *, int *);
    3.27  
    3.28  #ifndef SDL_POWER_DISABLED
    3.29  #ifdef SDL_POWER_HARDWIRED
    3.30  /* This is for things that _never_ have a battery, like the Dreamcast, etc. */
    3.31  static SDL_bool
    3.32 -SDL_GetPowerInfo_Hardwired(SDL_PowerState *state, int *seconds, int *percent)
    3.33 +SDL_GetPowerInfo_Hardwired(SDL_PowerState * state, int *seconds, int *percent)
    3.34  {
    3.35      *seconds = -1;
    3.36      *percent = -1;
    3.37 @@ -55,24 +56,24 @@
    3.38  
    3.39  static SDL_GetPowerInfo_Impl implementations[] = {
    3.40  #ifndef SDL_POWER_DISABLED
    3.41 -#ifdef SDL_POWER_LINUX /* in order of preference. More than could work. */
    3.42 +#ifdef SDL_POWER_LINUX          /* in order of preference. More than could work. */
    3.43      SDL_GetPowerInfo_Linux_sys_power,
    3.44      SDL_GetPowerInfo_Linux_proc_acpi,
    3.45      SDL_GetPowerInfo_Linux_proc_apm,
    3.46  #endif
    3.47 -#ifdef SDL_POWER_WINDOWS /* handles Win32, Win64, PocketPC. */
    3.48 +#ifdef SDL_POWER_WINDOWS        /* handles Win32, Win64, PocketPC. */
    3.49      SDL_GetPowerInfo_Windows,
    3.50  #endif
    3.51 -#ifdef SDL_POWER_MACOSX  /* handles Mac OS X, Darwin, iPhone. */
    3.52 +#ifdef SDL_POWER_MACOSX         /* handles Mac OS X, Darwin, iPhone. */
    3.53      SDL_GetPowerInfo_MacOSX,
    3.54  #endif
    3.55 -#ifdef SDL_POWER_OS2  /* handles OS/2, Warp, eComStation. */
    3.56 +#ifdef SDL_POWER_OS2            /* handles OS/2, Warp, eComStation. */
    3.57      SDL_GetPowerInfo_OS2,
    3.58  #endif
    3.59 -#ifdef SDL_POWER_NINTENDODS  /* handles Nintendo DS. */
    3.60 +#ifdef SDL_POWER_NINTENDODS     /* handles Nintendo DS. */
    3.61      SDL_GetPowerInfo_NintendoDS,
    3.62  #endif
    3.63 -#ifdef SDL_POWER_BEOS  /* handles BeOS, Zeta, with euc.jp apm driver. */
    3.64 +#ifdef SDL_POWER_BEOS           /* handles BeOS, Zeta, with euc.jp apm driver. */
    3.65      SDL_GetPowerInfo_BeOS,
    3.66  #endif
    3.67  #ifdef SDL_POWER_HARDWIRED
    3.68 @@ -84,7 +85,7 @@
    3.69  SDL_PowerState
    3.70  SDL_GetPowerInfo(int *seconds, int *percent)
    3.71  {
    3.72 -    const int total = sizeof (implementations) / sizeof (implementations[0]);
    3.73 +    const int total = sizeof(implementations) / sizeof(implementations[0]);
    3.74      int _seconds, _percent;
    3.75      SDL_PowerState retval;
    3.76      int i;
    3.77 @@ -99,7 +100,7 @@
    3.78      }
    3.79  
    3.80      for (i = 0; i < total; i++) {
    3.81 -        if (implementations[i](&retval, seconds, percent)) {
    3.82 +        if (implementations[i] (&retval, seconds, percent)) {
    3.83              return retval;
    3.84          }
    3.85      }
    3.86 @@ -111,4 +112,3 @@
    3.87  }
    3.88  
    3.89  /* vi: set ts=4 sw=4 expandtab: */
    3.90 -
     4.1 --- a/src/power/beos/SDL_syspower.c	Wed Jun 10 08:09:04 2009 +0000
     4.2 +++ b/src/power/beos/SDL_syspower.c	Wed Jun 10 13:34:20 2009 +0000
     4.3 @@ -41,7 +41,7 @@
     4.4  #include "SDL_power.h"
     4.5  
     4.6  SDL_bool
     4.7 -SDL_GetPowerInfo_BeOS(SDL_PowerState *state, int *seconds, int *percent)
     4.8 +SDL_GetPowerInfo_BeOS(SDL_PowerState * state, int *seconds, int *percent)
     4.9  {
    4.10      const int fd = open("/dev/misc/apm", O_RDONLY);
    4.11      SDL_bool need_details = SDL_FALSE;
    4.12 @@ -53,10 +53,10 @@
    4.13      uint32 battery_time;
    4.14  
    4.15      if (fd == -1) {
    4.16 -        return SDL_FALSE;  /* maybe some other method will work? */
    4.17 +        return SDL_FALSE;       /* maybe some other method will work? */
    4.18      }
    4.19  
    4.20 -    memset(regs, '\0', sizeof (regs));
    4.21 +    memset(regs, '\0', sizeof(regs));
    4.22      regs[0] = APM_FUNC_OFFSET + APM_FUNC_GET_POWER_STATUS;
    4.23      regs[1] = APM_DEVICE_ALL;
    4.24      rc = ioctl(fd, APM_BIOS_CALL, regs);
    4.25 @@ -73,7 +73,7 @@
    4.26      battery_time = (uint32) regs[3];
    4.27  
    4.28      /* in theory, _something_ should be set in battery_flags, right? */
    4.29 -    if (battery_flags == 0x00) {  /* older APM BIOS? Less fields. */
    4.30 +    if (battery_flags == 0x00) {        /* older APM BIOS? Less fields. */
    4.31          battery_time = 0xFFFF;
    4.32          if (battery_status == 0xFF) {
    4.33              battery_flags = 0xFF;
    4.34 @@ -82,23 +82,23 @@
    4.35          }
    4.36      }
    4.37  
    4.38 -    if ( (battery_time != 0xFFFF) && (battery_time & (1 << 15)) ) {
    4.39 +    if ((battery_time != 0xFFFF) && (battery_time & (1 << 15))) {
    4.40          /* time is in minutes, not seconds */
    4.41          battery_time = (battery_time & 0x7FFF) * 60;
    4.42      }
    4.43  
    4.44 -    if (battery_flags == 0xFF) {  /* unknown state */
    4.45 +    if (battery_flags == 0xFF) {        /* unknown state */
    4.46          *state = SDL_POWERSTATE_UNKNOWN;
    4.47 -    } else if (battery_flags & (1 << 7)) {  /* no battery */
    4.48 +    } else if (battery_flags & (1 << 7)) {      /* no battery */
    4.49          *state = SDL_POWERSTATE_NO_BATTERY;
    4.50 -    } else if (battery_flags & (1 << 3)) {  /* charging */
    4.51 +    } else if (battery_flags & (1 << 3)) {      /* charging */
    4.52          *state = SDL_POWERSTATE_CHARGING;
    4.53          need_details = SDL_TRUE;
    4.54      } else if (ac_status == 1) {
    4.55 -        *state = SDL_POWERSTATE_CHARGED;  /* on AC, not charging. */
    4.56 +        *state = SDL_POWERSTATE_CHARGED;        /* on AC, not charging. */
    4.57          need_details = SDL_TRUE;
    4.58      } else {
    4.59 -        *state = SDL_POWERSTATE_ON_BATTERY;  /* not on AC. */
    4.60 +        *state = SDL_POWERSTATE_ON_BATTERY;     /* not on AC. */
    4.61          need_details = SDL_TRUE;
    4.62      }
    4.63  
    4.64 @@ -108,19 +108,18 @@
    4.65          const int pct = (int) battery_life;
    4.66          const int secs = (int) battery_time;
    4.67  
    4.68 -        if (pct != 255) {  /* 255 == unknown */
    4.69 -            *percent = (pct > 100) ? 100 : pct;  /* clamp between 0%, 100% */
    4.70 +        if (pct != 255) {       /* 255 == unknown */
    4.71 +            *percent = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */
    4.72          }
    4.73 -        if (secs != 0xFFFF) {  /* 0xFFFF == unknown */
    4.74 +        if (secs != 0xFFFF) {   /* 0xFFFF == unknown */
    4.75              *seconds = secs;
    4.76          }
    4.77      }
    4.78  
    4.79 -    return SDL_TRUE;  /* the definitive answer if APM driver replied. */
    4.80 +    return SDL_TRUE;            /* the definitive answer if APM driver replied. */
    4.81  }
    4.82  
    4.83  #endif /* SDL_POWER_BEOS */
    4.84  #endif /* SDL_POWER_DISABLED */
    4.85  
    4.86  /* vi: set ts=4 sw=4 expandtab: */
    4.87 -
     5.1 --- a/src/power/linux/SDL_syspower.c	Wed Jun 10 08:09:04 2009 +0000
     5.2 +++ b/src/power/linux/SDL_syspower.c	Wed Jun 10 13:34:20 2009 +0000
     5.3 @@ -34,28 +34,28 @@
     5.4  #include "SDL_power.h"
     5.5  
     5.6  SDL_bool
     5.7 -SDL_GetPowerInfo_Linux_sys_power(SDL_PowerState *state,
     5.8 +SDL_GetPowerInfo_Linux_sys_power(SDL_PowerState * state,
     5.9                                   int *seconds, int *percent)
    5.10  {
    5.11 -    return SDL_FALSE;  /* !!! FIXME: write me. */
    5.12 +    return SDL_FALSE;           /* !!! FIXME: write me. */
    5.13  #if 0
    5.14      const int fd = open("/sys/power", O_RDONLY);
    5.15      if (fd == -1) {
    5.16 -        return SDL_FALSE;  /* can't use this interface. */
    5.17 +        return SDL_FALSE;       /* can't use this interface. */
    5.18      }
    5.19      return SDL_TRUE;
    5.20  #endif
    5.21  }
    5.22  
    5.23  SDL_bool
    5.24 -SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state,
    5.25 -				 int *seconds, int *percent)
    5.26 +SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState * state,
    5.27 +                                 int *seconds, int *percent)
    5.28  {
    5.29 -    return SDL_FALSE;  /* !!! FIXME: write me. */
    5.30 +    return SDL_FALSE;           /* !!! FIXME: write me. */
    5.31  #if 0
    5.32      const int fd = open("/proc/acpi", O_RDONLY);
    5.33      if (fd == -1) {
    5.34 -        return SDL_FALSE;  /* can't use this interface. */
    5.35 +        return SDL_FALSE;       /* can't use this interface. */
    5.36      }
    5.37      return SDL_TRUE;
    5.38  #endif
    5.39 @@ -67,7 +67,7 @@
    5.40      char *ptr = *_ptr;
    5.41      char *str = *_str;
    5.42  
    5.43 -    while (*ptr == ' ') {  /* skip any spaces... */
    5.44 +    while (*ptr == ' ') {       /* skip any spaces... */
    5.45          ptr++;
    5.46      }
    5.47  
    5.48 @@ -91,14 +91,14 @@
    5.49  int_string(char *str, int *val)
    5.50  {
    5.51      char *endptr = NULL;
    5.52 -    *val = (int) strtol(str+2, &endptr, 16);
    5.53 +    *val = (int) strtol(str + 2, &endptr, 16);
    5.54      return ((*str != '\0') && (*endptr == '\0'));
    5.55  }
    5.56  
    5.57  /* http://lxr.linux.no/linux+v2.6.29/drivers/char/apm-emulation.c */
    5.58  SDL_bool
    5.59 -SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState *state,
    5.60 -				int *seconds, int *percent)
    5.61 +SDL_GetPowerInfo_Linux_proc_apm(SDL_PowerState * state,
    5.62 +                                int *seconds, int *percent)
    5.63  {
    5.64      SDL_bool need_details = SDL_FALSE;
    5.65      int ac_status = 0;
    5.66 @@ -113,44 +113,44 @@
    5.67      ssize_t br;
    5.68  
    5.69      if (fd == -1) {
    5.70 -        return SDL_FALSE;  /* can't use this interface. */
    5.71 +        return SDL_FALSE;       /* can't use this interface. */
    5.72      }
    5.73  
    5.74 -    br = read(fd, buf, sizeof (buf) - 1);
    5.75 +    br = read(fd, buf, sizeof(buf) - 1);
    5.76      close(fd);
    5.77  
    5.78      if (br < 0) {
    5.79          return SDL_FALSE;
    5.80      }
    5.81  
    5.82 -    buf[br] = '\0';  // null-terminate the string.
    5.83 -    if (!next_string(&ptr, &str)) {  /* driver version */
    5.84 +    buf[br] = '\0';             // null-terminate the string.
    5.85 +    if (!next_string(&ptr, &str)) {     /* driver version */
    5.86          return SDL_FALSE;
    5.87      }
    5.88 -    if (!next_string(&ptr, &str)) {  /* BIOS version */
    5.89 +    if (!next_string(&ptr, &str)) {     /* BIOS version */
    5.90          return SDL_FALSE;
    5.91      }
    5.92 -    if (!next_string(&ptr, &str)) {  /* APM flags */
    5.93 +    if (!next_string(&ptr, &str)) {     /* APM flags */
    5.94          return SDL_FALSE;
    5.95      }
    5.96  
    5.97 -    if (!next_string(&ptr, &str)) {  /* AC line status */
    5.98 +    if (!next_string(&ptr, &str)) {     /* AC line status */
    5.99          return SDL_FALSE;
   5.100      } else if (!int_string(str, &ac_status)) {
   5.101          return SDL_FALSE;
   5.102      }
   5.103  
   5.104 -    if (!next_string(&ptr, &str)) {  /* battery status */
   5.105 +    if (!next_string(&ptr, &str)) {     /* battery status */
   5.106          return SDL_FALSE;
   5.107      } else if (!int_string(str, &battery_status)) {
   5.108          return SDL_FALSE;
   5.109      }
   5.110 -    if (!next_string(&ptr, &str)) {  /* battery flag */
   5.111 +    if (!next_string(&ptr, &str)) {     /* battery flag */
   5.112          return SDL_FALSE;
   5.113      } else if (!int_string(str, &battery_flag)) {
   5.114          return SDL_FALSE;
   5.115      }
   5.116 -    if (!next_string(&ptr, &str)) {  /* remaining battery life percent */
   5.117 +    if (!next_string(&ptr, &str)) {     /* remaining battery life percent */
   5.118          return SDL_FALSE;
   5.119      }
   5.120      if (str[strlen(str) - 1] == '%') {
   5.121 @@ -160,27 +160,27 @@
   5.122          return SDL_FALSE;
   5.123      }
   5.124  
   5.125 -    if (!next_string(&ptr, &str)) {  /* remaining battery life time */
   5.126 +    if (!next_string(&ptr, &str)) {     /* remaining battery life time */
   5.127          return SDL_FALSE;
   5.128      } else if (!int_string(str, &battery_time)) {
   5.129          return SDL_FALSE;
   5.130      }
   5.131  
   5.132 -    if (!next_string(&ptr, &str)) {  /* remaining battery life time units */
   5.133 +    if (!next_string(&ptr, &str)) {     /* remaining battery life time units */
   5.134          return SDL_FALSE;
   5.135      } else if (strcmp(str, "min") == 0) {
   5.136          battery_time *= 60;
   5.137      }
   5.138  
   5.139 -    if (battery_flag == 0xFF) {  /* unknown state */
   5.140 +    if (battery_flag == 0xFF) { /* unknown state */
   5.141          *state = SDL_POWERSTATE_UNKNOWN;
   5.142 -    } else if (battery_flag & (1 << 7)) {  /* no battery */
   5.143 +    } else if (battery_flag & (1 << 7)) {       /* no battery */
   5.144          *state = SDL_POWERSTATE_NO_BATTERY;
   5.145 -    } else if (battery_flag & (1 << 3)) {  /* charging */
   5.146 +    } else if (battery_flag & (1 << 3)) {       /* charging */
   5.147          *state = SDL_POWERSTATE_CHARGING;
   5.148          need_details = SDL_TRUE;
   5.149      } else if (ac_status == 1) {
   5.150 -        *state = SDL_POWERSTATE_CHARGED;  /* on AC, not charging. */
   5.151 +        *state = SDL_POWERSTATE_CHARGED;        /* on AC, not charging. */
   5.152          need_details = SDL_TRUE;
   5.153      } else {
   5.154          *state = SDL_POWERSTATE_ON_BATTERY;
   5.155 @@ -193,10 +193,10 @@
   5.156          const int pct = battery_percent;
   5.157          const int secs = battery_time;
   5.158  
   5.159 -        if (pct >= 0) {  /* -1 == unknown */
   5.160 -            *percent = (pct > 100) ? 100 : pct;  /* clamp between 0%, 100% */
   5.161 +        if (pct >= 0) {         /* -1 == unknown */
   5.162 +            *percent = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */
   5.163          }
   5.164 -        if (secs >= 0) {  /* -1 == unknown */
   5.165 +        if (secs >= 0) {        /* -1 == unknown */
   5.166              *seconds = secs;
   5.167          }
   5.168      }
   5.169 @@ -208,4 +208,3 @@
   5.170  #endif /* SDL_POWER_DISABLED */
   5.171  
   5.172  /* vi: set ts=4 sw=4 expandtab: */
   5.173 -
     6.1 --- a/src/power/macosx/SDL_syspower.c	Wed Jun 10 08:09:04 2009 +0000
     6.2 +++ b/src/power/macosx/SDL_syspower.c	Wed Jun 10 13:34:20 2009 +0000
     6.3 @@ -37,10 +37,10 @@
     6.4  
     6.5  /* Note that AC power sources also include a laptop battery it is charging. */
     6.6  static void
     6.7 -checkps(CFDictionaryRef dict, SDL_bool *have_ac, SDL_bool *have_battery,
     6.8 -        SDL_bool *charging, int *seconds, int *percent)
     6.9 +checkps(CFDictionaryRef dict, SDL_bool * have_ac, SDL_bool * have_battery,
    6.10 +        SDL_bool * charging, int *seconds, int *percent)
    6.11  {
    6.12 -    CFStringRef strval;  /* don't CFRelease() this. */
    6.13 +    CFStringRef strval;         /* don't CFRelease() this. */
    6.14      CFBooleanRef bval;
    6.15      CFNumberRef numval;
    6.16      SDL_bool charge = SDL_FALSE;
    6.17 @@ -51,7 +51,7 @@
    6.18      int pct = -1;
    6.19  
    6.20      if ((GETVAL(kIOPSIsPresentKey, &bval)) && (bval == kCFBooleanFalse)) {
    6.21 -        return;  /* nothing to see here. */
    6.22 +        return;                 /* nothing to see here. */
    6.23      }
    6.24  
    6.25      if (!GETVAL(kIOPSPowerSourceStateKey, &strval)) {
    6.26 @@ -61,7 +61,7 @@
    6.27      if (STRMATCH(strval, CFSTR(kIOPSACPowerValue))) {
    6.28          is_ac = *have_ac = SDL_TRUE;
    6.29      } else if (!STRMATCH(strval, CFSTR(kIOPSBatteryPowerValue))) {
    6.30 -        return;  /* not a battery? */
    6.31 +        return;                 /* not a battery? */
    6.32      }
    6.33  
    6.34      if ((GETVAL(kIOPSIsChargingKey, &bval)) && (bval == kCFBooleanTrue)) {
    6.35 @@ -92,12 +92,12 @@
    6.36  
    6.37          /* Mac OS X reports 0 minutes until empty if you're plugged in. :( */
    6.38          if ((val == 0) && (is_ac)) {
    6.39 -            val = -1;  /* !!! FIXME: calc from timeToFull and capacity? */
    6.40 +            val = -1;           /* !!! FIXME: calc from timeToFull and capacity? */
    6.41          }
    6.42  
    6.43          secs = (int) val;
    6.44          if (secs > 0) {
    6.45 -            secs *= 60;  /* value is in minutes, so convert to seconds. */
    6.46 +            secs *= 60;         /* value is in minutes, so convert to seconds. */
    6.47          }
    6.48      }
    6.49  
    6.50 @@ -108,7 +108,7 @@
    6.51      }
    6.52  
    6.53      if ((pct > 0) && (maxpct > 0)) {
    6.54 -    	pct = (int) ((((double)pct)/((double)maxpct)) * 100.0);
    6.55 +        pct = (int) ((((double) pct) / ((double) maxpct)) * 100.0);
    6.56      }
    6.57  
    6.58      if (pct > 100) {
    6.59 @@ -121,7 +121,7 @@
    6.60       */
    6.61      if ((secs < 0) && (*seconds < 0)) {
    6.62          if ((pct < 0) && (*percent < 0)) {
    6.63 -            choose = SDL_TRUE; /* at least we know there's a battery. */
    6.64 +            choose = SDL_TRUE;  /* at least we know there's a battery. */
    6.65          }
    6.66          if (pct > *percent) {
    6.67              choose = SDL_TRUE;
    6.68 @@ -142,7 +142,7 @@
    6.69  
    6.70  
    6.71  SDL_bool
    6.72 -SDL_GetPowerInfo_MacOSX(SDL_PowerState *state, int *seconds, int *percent)
    6.73 +SDL_GetPowerInfo_MacOSX(SDL_PowerState * state, int *seconds, int *percent)
    6.74  {
    6.75      CFTypeRef blob = IOPSCopyPowerSourcesInfo();
    6.76  
    6.77 @@ -161,7 +161,8 @@
    6.78              CFIndex i;
    6.79              for (i = 0; i < total; i++) {
    6.80                  CFTypeRef ps = (CFTypeRef) CFArrayGetValueAtIndex(list, i);
    6.81 -                CFDictionaryRef dict = IOPSGetPowerSourceDescription(blob, ps);
    6.82 +                CFDictionaryRef dict =
    6.83 +                    IOPSGetPowerSourceDescription(blob, ps);
    6.84                  if (dict != NULL) {
    6.85                      checkps(dict, &have_ac, &have_battery, &charging,
    6.86                              seconds, percent);
    6.87 @@ -183,11 +184,10 @@
    6.88          CFRelease(blob);
    6.89      }
    6.90  
    6.91 -    return SDL_TRUE;  /* always the definitive answer on Mac OS X. */
    6.92 +    return SDL_TRUE;            /* always the definitive answer on Mac OS X. */
    6.93  }
    6.94  
    6.95  #endif /* SDL_POWER_MACOSX */
    6.96  #endif /* SDL_POWER_DISABLED */
    6.97  
    6.98  /* vi: set ts=4 sw=4 expandtab: */
    6.99 -
     7.1 --- a/src/power/nds/SDL_syspower.c	Wed Jun 10 08:09:04 2009 +0000
     7.2 +++ b/src/power/nds/SDL_syspower.c	Wed Jun 10 13:34:20 2009 +0000
     7.3 @@ -27,7 +27,8 @@
     7.4  #include "SDL_power.h"
     7.5  
     7.6  SDL_bool
     7.7 -SDL_GetPowerInfo_NintendoDS(SDL_PowerState *state, int *seconds, int *percent)
     7.8 +SDL_GetPowerInfo_NintendoDS(SDL_PowerState * state, int *seconds,
     7.9 +                            int *percent)
    7.10  {
    7.11      /* !!! FIXME: write me. */
    7.12  
    7.13 @@ -35,11 +36,10 @@
    7.14      *percent = -1;
    7.15      *seconds = -1;
    7.16  
    7.17 -    return SDL_TRUE;  /* always the definitive answer on Nintendo DS. */
    7.18 +    return SDL_TRUE;            /* always the definitive answer on Nintendo DS. */
    7.19  }
    7.20  
    7.21  #endif /* SDL_POWER_NINTENDODS */
    7.22  #endif /* SDL_POWER_DISABLED */
    7.23  
    7.24  /* vi: set ts=4 sw=4 expandtab: */
    7.25 -
     8.1 --- a/src/power/os2/SDL_syspower.c	Wed Jun 10 08:09:04 2009 +0000
     8.2 +++ b/src/power/os2/SDL_syspower.c	Wed Jun 10 13:34:20 2009 +0000
     8.3 @@ -38,7 +38,8 @@
     8.4  
     8.5  #include "SDL_power.h"
     8.6  
     8.7 -typedef struct {
     8.8 +typedef struct
     8.9 +{
    8.10      USHORT len;
    8.11      USHORT flags;
    8.12      UCHAR ac_status;
    8.13 @@ -48,11 +49,11 @@
    8.14      USHORT battery_time;
    8.15      UCHAR battery_flags;
    8.16  } PowerStatus;
    8.17 -extern int CompilerAssertPowerStatus[(sizeof (PowerStatus) == 10) ? 1 : -1];
    8.18 +extern int CompilerAssertPowerStatus[(sizeof(PowerStatus) == 10) ? 1 : -1];
    8.19  
    8.20  
    8.21  SDL_bool
    8.22 -SDL_GetPowerInfo_OS2(SDL_PowerState *state, int *seconds, int *percent)
    8.23 +SDL_GetPowerInfo_OS2(SDL_PowerState * state, int *seconds, int *percent)
    8.24  {
    8.25      PowerStatus status;
    8.26      HFILE hfile = 0;
    8.27 @@ -69,11 +70,11 @@
    8.28  
    8.29      if (rc == NO_ERROR) {
    8.30          USHORT iorc = 0;
    8.31 -        ULONG iorclen = sizeof (iorc);
    8.32 -        ULONG statuslen = sizeof (status);
    8.33 +        ULONG iorclen = sizeof(iorc);
    8.34 +        ULONG statuslen = sizeof(status);
    8.35  
    8.36 -        SDL_memset(&status, '\0', sizeof (status));
    8.37 -        status.len = sizeof (status);
    8.38 +        SDL_memset(&status, '\0', sizeof(status));
    8.39 +        status.len = sizeof(status);
    8.40  
    8.41          rc = DosDevIOCtl(hfile, IOCTL_POWER, POWER_GETPOWERSTATUS, &status,
    8.42                           statuslen, &statuslen, &iorc, iorclen, &iorclen);
    8.43 @@ -81,7 +82,7 @@
    8.44  
    8.45          /* (status.flags & 0x1) == power subsystem enabled. */
    8.46          if ((rc == NO_ERROR) && (status.flags & 0x1)) {
    8.47 -            if (statuslen == 7) {  /* older OS/2 APM driver? Less fields. */
    8.48 +            if (statuslen == 7) {       /* older OS/2 APM driver? Less fields. */
    8.49                  status.battery_time_form = 0xFF;
    8.50                  status.battery_time = 0;
    8.51                  if (status.battery_status == 0xFF) {
    8.52 @@ -91,18 +92,18 @@
    8.53                  }
    8.54              }
    8.55  
    8.56 -            if (status.battery_flags == 0xFF) {  /* unknown state */
    8.57 +            if (status.battery_flags == 0xFF) { /* unknown state */
    8.58                  *state = SDL_POWERSTATE_UNKNOWN;
    8.59 -            } else if (status.battery_flags & (1 << 7)) {  /* no battery */
    8.60 +            } else if (status.battery_flags & (1 << 7)) {       /* no battery */
    8.61                  *state = SDL_POWERSTATE_NO_BATTERY;
    8.62 -            } else if (status.battery_flags & (1 << 3)) {  /* charging */
    8.63 +            } else if (status.battery_flags & (1 << 3)) {       /* charging */
    8.64                  *state = SDL_POWERSTATE_CHARGING;
    8.65                  need_details = SDL_TRUE;
    8.66              } else if (status.ac_status == 1) {
    8.67 -                *state = SDL_POWERSTATE_CHARGED;  /* on AC, not charging. */
    8.68 +                *state = SDL_POWERSTATE_CHARGED;        /* on AC, not charging. */
    8.69                  need_details = SDL_TRUE;
    8.70              } else {
    8.71 -                *state = SDL_POWERSTATE_ON_BATTERY;  /* not on AC. */
    8.72 +                *state = SDL_POWERSTATE_ON_BATTERY;     /* not on AC. */
    8.73                  need_details = SDL_TRUE;
    8.74              }
    8.75  
    8.76 @@ -110,13 +111,13 @@
    8.77                  const int pct = (int) status.battery_life;
    8.78                  const int secs = (int) status.battery_time;
    8.79  
    8.80 -                if (pct != 0xFF) {  /* 255 == unknown */
    8.81 +                if (pct != 0xFF) {      /* 255 == unknown */
    8.82                      *percent = (pct > 100) ? 100 : pct;
    8.83                  }
    8.84  
    8.85 -                if (status.battery_time_form == 0xFF) {  /* unknown */
    8.86 +                if (status.battery_time_form == 0xFF) { /* unknown */
    8.87                      *seconds = -1;
    8.88 -                } else if (status.battery_time_form == 1) {  /* minutes */
    8.89 +                } else if (status.battery_time_form == 1) {     /* minutes */
    8.90                      *seconds = secs * 60;
    8.91                  } else {
    8.92                      *seconds = secs;
    8.93 @@ -125,11 +126,10 @@
    8.94          }
    8.95      }
    8.96  
    8.97 -    return SDL_TRUE;  /* always the definitive answer on OS/2. */
    8.98 +    return SDL_TRUE;            /* always the definitive answer on OS/2. */
    8.99  }
   8.100  
   8.101  #endif /* SDL_POWER_OS2 */
   8.102  #endif /* SDL_POWER_DISABLED */
   8.103  
   8.104  /* vi: set ts=4 sw=4 expandtab: */
   8.105 -
     9.1 --- a/src/power/windows/SDL_syspower.c	Wed Jun 10 08:09:04 2009 +0000
     9.2 +++ b/src/power/windows/SDL_syspower.c	Wed Jun 10 13:34:20 2009 +0000
     9.3 @@ -30,7 +30,7 @@
     9.4  #include "SDL_power.h"
     9.5  
     9.6  SDL_bool
     9.7 -SDL_GetPowerInfo_Windows(SDL_PowerState *state, int *seconds, int *percent)
     9.8 +SDL_GetPowerInfo_Windows(SDL_PowerState * state, int *seconds, int *percent)
     9.9  {
    9.10      SYSTEM_POWER_STATUS status;
    9.11      SDL_bool need_details = SDL_FALSE;
    9.12 @@ -39,18 +39,18 @@
    9.13      if (!GetSystemPowerStatus(&status)) {
    9.14          /* !!! FIXME: push GetLastError() into SDL_GetError() */
    9.15          *state = SDL_POWERSTATE_UNKNOWN;
    9.16 -    } else if (status.BatteryFlag == 0xFF) {  /* unknown state */
    9.17 +    } else if (status.BatteryFlag == 0xFF) {    /* unknown state */
    9.18          *state = SDL_POWERSTATE_UNKNOWN;
    9.19 -    } else if (status.BatteryFlag & (1 << 7)) {  /* no battery */
    9.20 +    } else if (status.BatteryFlag & (1 << 7)) { /* no battery */
    9.21          *state = SDL_POWERSTATE_NO_BATTERY;
    9.22 -    } else if (status.BatteryFlag & (1 << 3)) {  /* charging */
    9.23 +    } else if (status.BatteryFlag & (1 << 3)) { /* charging */
    9.24          *state = SDL_POWERSTATE_CHARGING;
    9.25          need_details = SDL_TRUE;
    9.26      } else if (status.ACLineStatus == 1) {
    9.27 -        *state = SDL_POWERSTATE_CHARGED;  /* on AC, not charging. */
    9.28 +        *state = SDL_POWERSTATE_CHARGED;        /* on AC, not charging. */
    9.29          need_details = SDL_TRUE;
    9.30      } else {
    9.31 -        *state = SDL_POWERSTATE_ON_BATTERY;  /* not on AC. */
    9.32 +        *state = SDL_POWERSTATE_ON_BATTERY;     /* not on AC. */
    9.33          need_details = SDL_TRUE;
    9.34      }
    9.35  
    9.36 @@ -60,19 +60,18 @@
    9.37          const int pct = (int) status.BatteryLifePercent;
    9.38          const int secs = (int) status.BatteryLifeTime;
    9.39  
    9.40 -        if (pct != 255) {  /* 255 == unknown */
    9.41 -            *percent = (pct > 100) ? 100 : pct;  /* clamp between 0%, 100% */
    9.42 +        if (pct != 255) {       /* 255 == unknown */
    9.43 +            *percent = (pct > 100) ? 100 : pct; /* clamp between 0%, 100% */
    9.44          }
    9.45 -        if (secs != 0xFFFFFFFF) {  /* ((DWORD)-1) == unknown */
    9.46 +        if (secs != 0xFFFFFFFF) {       /* ((DWORD)-1) == unknown */
    9.47              *seconds = secs;
    9.48          }
    9.49      }
    9.50  
    9.51 -    return SDL_TRUE;  /* always the definitive answer on Windows. */
    9.52 +    return SDL_TRUE;            /* always the definitive answer on Windows. */
    9.53  }
    9.54  
    9.55  #endif /* SDL_POWER_WINDOWS */
    9.56  #endif /* SDL_POWER_DISABLED */
    9.57  
    9.58  /* vi: set ts=4 sw=4 expandtab: */
    9.59 -
    10.1 --- a/src/video/SDL_video.c	Wed Jun 10 08:09:04 2009 +0000
    10.2 +++ b/src/video/SDL_video.c	Wed Jun 10 13:34:20 2009 +0000
    10.3 @@ -413,7 +413,7 @@
    10.4  
    10.5      /* Re-sort video modes */
    10.6      SDL_qsort(display->display_modes, display->num_display_modes,
    10.7 -        sizeof(SDL_DisplayMode), cmpmodes);
    10.8 +              sizeof(SDL_DisplayMode), cmpmodes);
    10.9  
   10.10      return SDL_TRUE;
   10.11  }
   10.12 @@ -1634,32 +1634,33 @@
   10.13              int pfmt;
   10.14  
   10.15              /* Pixel formats, sorted by best first */
   10.16 -            static const Uint32 sdl_pformats[]={
   10.17 -               SDL_PIXELFORMAT_ARGB8888,
   10.18 -               SDL_PIXELFORMAT_RGBA8888,
   10.19 -               SDL_PIXELFORMAT_ABGR8888,
   10.20 -               SDL_PIXELFORMAT_BGRA8888,
   10.21 -               SDL_PIXELFORMAT_RGB888,
   10.22 -               SDL_PIXELFORMAT_BGR888,
   10.23 -               SDL_PIXELFORMAT_RGB24,
   10.24 -               SDL_PIXELFORMAT_BGR24,
   10.25 -               SDL_PIXELFORMAT_RGB565,
   10.26 -               SDL_PIXELFORMAT_BGR565,
   10.27 -               SDL_PIXELFORMAT_ARGB1555,
   10.28 -               SDL_PIXELFORMAT_ABGR1555,
   10.29 -               SDL_PIXELFORMAT_RGB555,
   10.30 -               SDL_PIXELFORMAT_BGR555,
   10.31 -               SDL_PIXELFORMAT_ARGB4444,
   10.32 -               SDL_PIXELFORMAT_ABGR4444,
   10.33 -               SDL_PIXELFORMAT_RGB444,
   10.34 -               SDL_PIXELFORMAT_ARGB2101010,
   10.35 -               SDL_PIXELFORMAT_INDEX8,
   10.36 -               SDL_PIXELFORMAT_INDEX4LSB,
   10.37 -               SDL_PIXELFORMAT_INDEX4MSB,
   10.38 -               SDL_PIXELFORMAT_RGB332,
   10.39 -               SDL_PIXELFORMAT_INDEX1LSB,
   10.40 -               SDL_PIXELFORMAT_INDEX1MSB,
   10.41 -               SDL_PIXELFORMAT_UNKNOWN};
   10.42 +            static const Uint32 sdl_pformats[] = {
   10.43 +                SDL_PIXELFORMAT_ARGB8888,
   10.44 +                SDL_PIXELFORMAT_RGBA8888,
   10.45 +                SDL_PIXELFORMAT_ABGR8888,
   10.46 +                SDL_PIXELFORMAT_BGRA8888,
   10.47 +                SDL_PIXELFORMAT_RGB888,
   10.48 +                SDL_PIXELFORMAT_BGR888,
   10.49 +                SDL_PIXELFORMAT_RGB24,
   10.50 +                SDL_PIXELFORMAT_BGR24,
   10.51 +                SDL_PIXELFORMAT_RGB565,
   10.52 +                SDL_PIXELFORMAT_BGR565,
   10.53 +                SDL_PIXELFORMAT_ARGB1555,
   10.54 +                SDL_PIXELFORMAT_ABGR1555,
   10.55 +                SDL_PIXELFORMAT_RGB555,
   10.56 +                SDL_PIXELFORMAT_BGR555,
   10.57 +                SDL_PIXELFORMAT_ARGB4444,
   10.58 +                SDL_PIXELFORMAT_ABGR4444,
   10.59 +                SDL_PIXELFORMAT_RGB444,
   10.60 +                SDL_PIXELFORMAT_ARGB2101010,
   10.61 +                SDL_PIXELFORMAT_INDEX8,
   10.62 +                SDL_PIXELFORMAT_INDEX4LSB,
   10.63 +                SDL_PIXELFORMAT_INDEX4MSB,
   10.64 +                SDL_PIXELFORMAT_RGB332,
   10.65 +                SDL_PIXELFORMAT_INDEX1LSB,
   10.66 +                SDL_PIXELFORMAT_INDEX1MSB,
   10.67 +                SDL_PIXELFORMAT_UNKNOWN
   10.68 +            };
   10.69  
   10.70              bpp = fmt->BitsPerPixel;
   10.71              Rmask = fmt->Rmask;
   10.72 @@ -1667,7 +1668,8 @@
   10.73              Bmask = fmt->Bmask;
   10.74              Amask = fmt->Amask;
   10.75  
   10.76 -            format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
   10.77 +            format =
   10.78 +                SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
   10.79              if (!format) {
   10.80                  SDL_SetError("Unknown pixel format");
   10.81                  return 0;
   10.82 @@ -1675,53 +1677,47 @@
   10.83  
   10.84              /* Search requested format in the supported texture */
   10.85              /* formats by current renderer                      */
   10.86 -            for (it=0; it<renderer->info.num_texture_formats; it++)
   10.87 -            {
   10.88 -                if (renderer->info.texture_formats[it]==format)
   10.89 -                {
   10.90 -                   break;
   10.91 +            for (it = 0; it < renderer->info.num_texture_formats; it++) {
   10.92 +                if (renderer->info.texture_formats[it] == format) {
   10.93 +                    break;
   10.94                  }
   10.95              }
   10.96  
   10.97              /* If requested format can't be found, search any best */
   10.98              /* format which renderer provides                      */
   10.99 -            if (it==renderer->info.num_texture_formats)
  10.100 -            {
  10.101 -                pfmt=0;
  10.102 -                for (;;)
  10.103 -                {
  10.104 -                    if (sdl_pformats[pfmt]==SDL_PIXELFORMAT_UNKNOWN)
  10.105 -                    {
  10.106 +            if (it == renderer->info.num_texture_formats) {
  10.107 +                pfmt = 0;
  10.108 +                for (;;) {
  10.109 +                    if (sdl_pformats[pfmt] == SDL_PIXELFORMAT_UNKNOWN) {
  10.110                          break;
  10.111                      }
  10.112  
  10.113 -                    for (it=0; it<renderer->info.num_texture_formats; it++)
  10.114 -                    {
  10.115 -                       if (renderer->info.texture_formats[it]==sdl_pformats[pfmt])
  10.116 -                       {
  10.117 -                          break;
  10.118 -                       }
  10.119 +                    for (it = 0; it < renderer->info.num_texture_formats;
  10.120 +                         it++) {
  10.121 +                        if (renderer->info.texture_formats[it] ==
  10.122 +                            sdl_pformats[pfmt]) {
  10.123 +                            break;
  10.124 +                        }
  10.125                      }
  10.126  
  10.127 -                    if (it!=renderer->info.num_texture_formats)
  10.128 -                    {
  10.129 -                       /* The best format has been found */
  10.130 -                       break;
  10.131 +                    if (it != renderer->info.num_texture_formats) {
  10.132 +                        /* The best format has been found */
  10.133 +                        break;
  10.134                      }
  10.135                      pfmt++;
  10.136                  }
  10.137  
  10.138                  /* If any format can't be found, then return an error */
  10.139 -                if (it==renderer->info.num_texture_formats)
  10.140 -                {
  10.141 -                    SDL_SetError("Any of the supported pixel formats can't be found");
  10.142 +                if (it == renderer->info.num_texture_formats) {
  10.143 +                    SDL_SetError
  10.144 +                        ("Any of the supported pixel formats can't be found");
  10.145                      return 0;
  10.146                  }
  10.147  
  10.148                  /* Convert found pixel format back to color masks */
  10.149 -                if (SDL_PixelFormatEnumToMasks(renderer->info.texture_formats[it],
  10.150 -                       &bpp, &Rmask, &Gmask, &Bmask, &Amask)!=SDL_TRUE)
  10.151 -                {
  10.152 +                if (SDL_PixelFormatEnumToMasks
  10.153 +                    (renderer->info.texture_formats[it], &bpp, &Rmask, &Gmask,
  10.154 +                     &Bmask, &Amask) != SDL_TRUE) {
  10.155                      SDL_SetError("Unknown pixel format");
  10.156                      return 0;
  10.157                  }
    11.1 --- a/src/video/photon/SDL_photon.c	Wed Jun 10 08:09:04 2009 +0000
    11.2 +++ b/src/video/photon/SDL_photon.c	Wed Jun 10 13:34:20 2009 +0000
    11.3 @@ -385,42 +385,42 @@
    11.4          status = PgGetGraphicsHWCaps(&hwcaps);
    11.5          if (status != 0) {
    11.6              PhRect_t extent;
    11.7 -            PdOffscreenContext_t* curctx;
    11.8 +            PdOffscreenContext_t *curctx;
    11.9  
   11.10              /* If error happens, this also could mean, that photon is working */
   11.11              /* under custom (not listed by photon) video mode                 */
   11.12 -            status=PhWindowQueryVisible(Ph_QUERY_GRAPHICS, 0, 0, &extent);
   11.13 +            status = PhWindowQueryVisible(Ph_QUERY_GRAPHICS, 0, 0, &extent);
   11.14              if (status != 0) {
   11.15                  SDL_SetError("Photon: Can't get graphics driver region");
   11.16                  SDL_free(didata->cursor);
   11.17                  SDL_free(didata);
   11.18                  return -1;
   11.19              }
   11.20 -            modeinfo.width=extent.lr.x+1;
   11.21 -            modeinfo.height=extent.lr.y+1;
   11.22 +            modeinfo.width = extent.lr.x + 1;
   11.23 +            modeinfo.height = extent.lr.y + 1;
   11.24              /* Hardcode 60Hz, as the base refresh rate frequency */
   11.25 -            hwcaps.current_rrate=60;
   11.26 +            hwcaps.current_rrate = 60;
   11.27              /* Clear current video driver name, no way to get it somehow */
   11.28 -            hwcaps.chip_name[0]=0x00;
   11.29 +            hwcaps.chip_name[0] = 0x00;
   11.30  
   11.31              /* Create offscreen context from video memory, which is currently */
   11.32              /* displayed on the screen                                        */
   11.33 -            curctx=PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY);
   11.34 -            if (curctx==NULL)
   11.35 -            {
   11.36 +            curctx = PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY);
   11.37 +            if (curctx == NULL) {
   11.38                  SDL_SetError("Photon: Can't get display area capabilities");
   11.39                  SDL_free(didata->cursor);
   11.40                  SDL_free(didata);
   11.41                  return -1;
   11.42              }
   11.43              /* Retrieve current bpp */
   11.44 -            modeinfo.type=curctx->format;
   11.45 +            modeinfo.type = curctx->format;
   11.46              PhDCRelease(curctx);
   11.47          } else {
   11.48              /* Get current video mode details */
   11.49              status = PgGetVideoModeInfo(hwcaps.current_video_mode, &modeinfo);
   11.50              if (status != 0) {
   11.51 -                SDL_SetError("Photon: Can't get current video mode information");
   11.52 +                SDL_SetError
   11.53 +                    ("Photon: Can't get current video mode information");
   11.54                  SDL_free(didata->cursor);
   11.55                  SDL_free(didata);
   11.56                  return -1;
    12.1 --- a/src/video/qnxgf/SDL_qnxgf.c	Wed Jun 10 08:09:04 2009 +0000
    12.2 +++ b/src/video/qnxgf/SDL_qnxgf.c	Wed Jun 10 13:34:20 2009 +0000
    12.3 @@ -645,7 +645,7 @@
    12.4                      SDL_AddDisplayMode(_this->current_display, &mode);
    12.5  
    12.6                      /* If mode is RGBA8888, add the same mode as RGBx888 */
    12.7 -                    if (modeinfo.primary_format==GF_FORMAT_BGRA8888) {
    12.8 +                    if (modeinfo.primary_format == GF_FORMAT_BGRA8888) {
    12.9                          mode.w = generic_mode[jt].w;
   12.10                          mode.h = generic_mode[jt].h;
   12.11                          mode.refresh_rate = generic_mode[jt].refresh_rate;
   12.12 @@ -654,7 +654,7 @@
   12.13                          SDL_AddDisplayMode(_this->current_display, &mode);
   12.14                      }
   12.15                      /* If mode is RGBA1555, add the same mode as RGBx555 */
   12.16 -                    if (modeinfo.primary_format==GF_FORMAT_PACK_ARGB1555) {
   12.17 +                    if (modeinfo.primary_format == GF_FORMAT_PACK_ARGB1555) {
   12.18                          mode.w = generic_mode[jt].w;
   12.19                          mode.h = generic_mode[jt].h;
   12.20                          mode.refresh_rate = generic_mode[jt].refresh_rate;
   12.21 @@ -681,7 +681,7 @@
   12.22                          SDL_AddDisplayMode(_this->current_display, &mode);
   12.23  
   12.24                          /* If mode is RGBA8888, add the same mode as RGBx888 */
   12.25 -                        if (modeinfo.primary_format==GF_FORMAT_BGRA8888) {
   12.26 +                        if (modeinfo.primary_format == GF_FORMAT_BGRA8888) {
   12.27                              mode.w = modeinfo.xres;
   12.28                              mode.h = modeinfo.yres;
   12.29                              mode.refresh_rate = modeinfo.refresh[jt];
   12.30 @@ -690,7 +690,8 @@
   12.31                              SDL_AddDisplayMode(_this->current_display, &mode);
   12.32                          }
   12.33                          /* If mode is RGBA1555, add the same mode as RGBx555 */
   12.34 -                        if (modeinfo.primary_format==GF_FORMAT_PACK_ARGB1555) {
   12.35 +                        if (modeinfo.primary_format ==
   12.36 +                            GF_FORMAT_PACK_ARGB1555) {
   12.37                              mode.w = modeinfo.xres;
   12.38                              mode.h = modeinfo.yres;
   12.39                              mode.refresh_rate = modeinfo.refresh[jt];
   12.40 @@ -1573,8 +1574,7 @@
   12.41  
   12.42          /* No available configs */
   12.43          if (configs == 0) {
   12.44 -            SDL_SetError
   12.45 -                ("GF: Can't find any configuration for OpenGL ES");
   12.46 +            SDL_SetError("GF: Can't find any configuration for OpenGL ES");
   12.47              return NULL;
   12.48          }
   12.49      }
    13.1 --- a/src/video/win32/SDL_win32modes.c	Wed Jun 10 08:09:04 2009 +0000
    13.2 +++ b/src/video/win32/SDL_win32modes.c	Wed Jun 10 13:34:20 2009 +0000
    13.3 @@ -103,7 +103,7 @@
    13.4  #endif /* _WIN32_WCE */
    13.5      {
    13.6          /* FIXME: Can we tell what this will be? */
    13.7 -	if ((devmode.dmFields & DM_BITSPERPEL)==DM_BITSPERPEL) {
    13.8 +        if ((devmode.dmFields & DM_BITSPERPEL) == DM_BITSPERPEL) {
    13.9              switch (devmode.dmBitsPerPel) {
   13.10              case 32:
   13.11                  mode->format = SDL_PIXELFORMAT_RGB888;
   13.12 @@ -124,7 +124,7 @@
   13.13                  mode->format = SDL_PIXELFORMAT_INDEX4LSB;
   13.14                  break;
   13.15              }
   13.16 -	}
   13.17 +        }
   13.18      }
   13.19      return SDL_TRUE;
   13.20  }
   13.21 @@ -206,10 +206,10 @@
   13.22          if (!WIN_GetDisplayMode(data->DeviceName, i, &mode)) {
   13.23              break;
   13.24          }
   13.25 -	if (mode.format != SDL_PIXELFORMAT_UNKNOWN)
   13.26 +        if (mode.format != SDL_PIXELFORMAT_UNKNOWN)
   13.27              if (!SDL_AddDisplayMode(_this->current_display, &mode)) {
   13.28                  SDL_free(mode.driverdata);
   13.29 -        }
   13.30 +            }
   13.31      }
   13.32  }
   13.33  
    14.1 --- a/src/video/x11/SDL_x11events.c	Wed Jun 10 08:09:04 2009 +0000
    14.2 +++ b/src/video/x11/SDL_x11events.c	Wed Jun 10 13:34:20 2009 +0000
    14.3 @@ -339,6 +339,7 @@
    14.4                  if (xevent.type == data->proximity_in) {
    14.5                      XProximityNotifyEvent *proximity =
    14.6                          (XProximityNotifyEvent *) & xevent;
    14.7 +                    SDL_SetMouseFocus(proximity->deviceid, data->windowID);
    14.8                      SDL_SendProximity(proximity->deviceid, proximity->x,
    14.9                                        proximity->y, SDL_PROXIMITYIN);
   14.10                      return;
   14.11 @@ -346,6 +347,7 @@
   14.12                  if (xevent.type == data->proximity_out) {
   14.13                      XProximityNotifyEvent *proximity =
   14.14                          (XProximityNotifyEvent *) & xevent;
   14.15 +                    SDL_SetMouseFocus(proximity->deviceid, data->windowID);
   14.16                      SDL_SendProximity(proximity->deviceid, proximity->x,
   14.17                                        proximity->y, SDL_PROXIMITYOUT);
   14.18                      return;
    15.1 --- a/test/common.c	Wed Jun 10 08:09:04 2009 +0000
    15.2 +++ b/test/common.c	Wed Jun 10 13:34:20 2009 +0000
    15.3 @@ -11,56 +11,59 @@
    15.4  #define AUDIO_USAGE \
    15.5  "[--rate N] [--format U8|S8|U16|U16LE|U16BE|S16|S16LE|S16BE] [--channels N] [--samples N]"
    15.6  
    15.7 -struct pformat {
    15.8 +struct pformat
    15.9 +{
   15.10      Uint32 id;
   15.11 -    const char* idstr;
   15.12 -} pixel_format[]={
   15.13 -    {SDL_PIXELFORMAT_INDEX1LSB, "SDL_PIXELFORMAT_INDEX1LSB"},
   15.14 -    {SDL_PIXELFORMAT_INDEX1MSB, "SDL_PIXELFORMAT_INDEX1MSB"},
   15.15 -    {SDL_PIXELFORMAT_INDEX4LSB, "SDL_PIXELFORMAT_INDEX4LSB"},
   15.16 -    {SDL_PIXELFORMAT_INDEX4MSB, "SDL_PIXELFORMAT_INDEX4MSB"},
   15.17 -    {SDL_PIXELFORMAT_INDEX8, "SDL_PIXELFORMAT_INDEX8"},
   15.18 -    {SDL_PIXELFORMAT_RGB332, "SDL_PIXELFORMAT_RGB332"},
   15.19 -    {SDL_PIXELFORMAT_RGB444, "SDL_PIXELFORMAT_RGB444"},
   15.20 -    {SDL_PIXELFORMAT_RGB555, "SDL_PIXELFORMAT_RGB555"},
   15.21 -    {SDL_PIXELFORMAT_BGR555, "SDL_PIXELFORMAT_BGR555"},
   15.22 -    {SDL_PIXELFORMAT_ARGB4444, "SDL_PIXELFORMAT_ARGB4444"},
   15.23 -    {SDL_PIXELFORMAT_ABGR4444, "SDL_PIXELFORMAT_ABGR4444"},
   15.24 -    {SDL_PIXELFORMAT_ARGB1555, "SDL_PIXELFORMAT_ARGB1555"},
   15.25 -    {SDL_PIXELFORMAT_ABGR1555, "SDL_PIXELFORMAT_ABGR1555"},
   15.26 -    {SDL_PIXELFORMAT_RGB565, "SDL_PIXELFORMAT_RGB565"},
   15.27 -    {SDL_PIXELFORMAT_BGR565, "SDL_PIXELFORMAT_BGR565"},
   15.28 -    {SDL_PIXELFORMAT_RGB24, "SDL_PIXELFORMAT_RGB24"},
   15.29 -    {SDL_PIXELFORMAT_BGR24, "SDL_PIXELFORMAT_BGR24"},
   15.30 -    {SDL_PIXELFORMAT_RGB888, "SDL_PIXELFORMAT_RGB888"},
   15.31 -    {SDL_PIXELFORMAT_BGR888, "SDL_PIXELFORMAT_BGR888"},
   15.32 -    {SDL_PIXELFORMAT_ARGB8888, "SDL_PIXELFORMAT_ARGB8888"},
   15.33 -    {SDL_PIXELFORMAT_RGBA8888, "SDL_PIXELFORMAT_RGBA8888"},
   15.34 -    {SDL_PIXELFORMAT_ABGR8888, "SDL_PIXELFORMAT_ABGR8888"},
   15.35 -    {SDL_PIXELFORMAT_BGRA8888, "SDL_PIXELFORMAT_BGRA8888"},
   15.36 -    {SDL_PIXELFORMAT_ARGB2101010, "SDL_PIXELFORMAT_ARGB2101010"},
   15.37 -    {SDL_PIXELFORMAT_YV12, "SDL_PIXELFORMAT_YV12"},
   15.38 -    {SDL_PIXELFORMAT_IYUV, "SDL_PIXELFORMAT_IYUV"},
   15.39 -    {SDL_PIXELFORMAT_YUY2, "SDL_PIXELFORMAT_YUY2"},
   15.40 -    {SDL_PIXELFORMAT_UYVY, "SDL_PIXELFORMAT_UYVY"},
   15.41 -    {SDL_PIXELFORMAT_YVYU, "SDL_PIXELFORMAT_YVYU"}
   15.42 +    const char *idstr;
   15.43 +} pixel_format[] = {
   15.44 +    {
   15.45 +    SDL_PIXELFORMAT_INDEX1LSB, "SDL_PIXELFORMAT_INDEX1LSB"}, {
   15.46 +    SDL_PIXELFORMAT_INDEX1MSB, "SDL_PIXELFORMAT_INDEX1MSB"}, {
   15.47 +    SDL_PIXELFORMAT_INDEX4LSB, "SDL_PIXELFORMAT_INDEX4LSB"}, {
   15.48 +    SDL_PIXELFORMAT_INDEX4MSB, "SDL_PIXELFORMAT_INDEX4MSB"}, {
   15.49 +    SDL_PIXELFORMAT_INDEX8, "SDL_PIXELFORMAT_INDEX8"}, {
   15.50 +    SDL_PIXELFORMAT_RGB332, "SDL_PIXELFORMAT_RGB332"}, {
   15.51 +    SDL_PIXELFORMAT_RGB444, "SDL_PIXELFORMAT_RGB444"}, {
   15.52 +    SDL_PIXELFORMAT_RGB555, "SDL_PIXELFORMAT_RGB555"}, {
   15.53 +    SDL_PIXELFORMAT_BGR555, "SDL_PIXELFORMAT_BGR555"}, {
   15.54 +    SDL_PIXELFORMAT_ARGB4444, "SDL_PIXELFORMAT_ARGB4444"}, {
   15.55 +    SDL_PIXELFORMAT_ABGR4444, "SDL_PIXELFORMAT_ABGR4444"}, {
   15.56 +    SDL_PIXELFORMAT_ARGB1555, "SDL_PIXELFORMAT_ARGB1555"}, {
   15.57 +    SDL_PIXELFORMAT_ABGR1555, "SDL_PIXELFORMAT_ABGR1555"}, {
   15.58 +    SDL_PIXELFORMAT_RGB565, "SDL_PIXELFORMAT_RGB565"}, {
   15.59 +    SDL_PIXELFORMAT_BGR565, "SDL_PIXELFORMAT_BGR565"}, {
   15.60 +    SDL_PIXELFORMAT_RGB24, "SDL_PIXELFORMAT_RGB24"}, {
   15.61 +    SDL_PIXELFORMAT_BGR24, "SDL_PIXELFORMAT_BGR24"}, {
   15.62 +    SDL_PIXELFORMAT_RGB888, "SDL_PIXELFORMAT_RGB888"}, {
   15.63 +    SDL_PIXELFORMAT_BGR888, "SDL_PIXELFORMAT_BGR888"}, {
   15.64 +    SDL_PIXELFORMAT_ARGB8888, "SDL_PIXELFORMAT_ARGB8888"}, {
   15.65 +    SDL_PIXELFORMAT_RGBA8888, "SDL_PIXELFORMAT_RGBA8888"}, {
   15.66 +    SDL_PIXELFORMAT_ABGR8888, "SDL_PIXELFORMAT_ABGR8888"}, {
   15.67 +    SDL_PIXELFORMAT_BGRA8888, "SDL_PIXELFORMAT_BGRA8888"}, {
   15.68 +    SDL_PIXELFORMAT_ARGB2101010, "SDL_PIXELFORMAT_ARGB2101010"}, {
   15.69 +    SDL_PIXELFORMAT_YV12, "SDL_PIXELFORMAT_YV12"}, {
   15.70 +    SDL_PIXELFORMAT_IYUV, "SDL_PIXELFORMAT_IYUV"}, {
   15.71 +    SDL_PIXELFORMAT_YUY2, "SDL_PIXELFORMAT_YUY2"}, {
   15.72 +    SDL_PIXELFORMAT_UYVY, "SDL_PIXELFORMAT_UYVY"}, {
   15.73 +    SDL_PIXELFORMAT_YVYU, "SDL_PIXELFORMAT_YVYU"}
   15.74  };
   15.75  
   15.76 -const char* PixelFormatToString(Uint32 pformat)
   15.77 +const char *
   15.78 +PixelFormatToString(Uint32 pformat)
   15.79  {
   15.80 -   Uint32 it=0;
   15.81 +    Uint32 it = 0;
   15.82  
   15.83 -   do {
   15.84 -      if (pixel_format[it].idstr == NULL) {
   15.85 -          break;
   15.86 -      }
   15.87 -      if (pixel_format[it].id == pformat) {
   15.88 -          return pixel_format[it].idstr;
   15.89 -      }
   15.90 -      it++;
   15.91 -   } while(1);
   15.92 +    do {
   15.93 +        if (pixel_format[it].idstr == NULL) {
   15.94 +            break;
   15.95 +        }
   15.96 +        if (pixel_format[it].id == pformat) {
   15.97 +            return pixel_format[it].idstr;
   15.98 +        }
   15.99 +        it++;
  15.100 +    } while (1);
  15.101  
  15.102 -   return "SDL_PIXELFORMAT_UNKNOWN";
  15.103 +    return "SDL_PIXELFORMAT_UNKNOWN";
  15.104  }
  15.105  
  15.106  CommonState *
  15.107 @@ -706,7 +709,7 @@
  15.108          fullscreen_mode.w = state->window_w;
  15.109          fullscreen_mode.h = state->window_h;
  15.110          fullscreen_mode.refresh_rate = state->refresh_rate;
  15.111 -        if (SDL_SetFullscreenDisplayMode(&fullscreen_mode)<0) {
  15.112 +        if (SDL_SetFullscreenDisplayMode(&fullscreen_mode) < 0) {
  15.113              fprintf(stderr, "Can't switch to fullscreen display mode: %s\n",
  15.114                      SDL_GetError());
  15.115              return SDL_FALSE;
    16.1 --- a/test/testatomic.c	Wed Jun 10 08:09:04 2009 +0000
    16.2 +++ b/test/testatomic.c	Wed Jun 10 13:34:20 2009 +0000
    16.3 @@ -1,64 +1,64 @@
    16.4  #include "SDL.h"
    16.5  
    16.6  int
    16.7 -main(int argc, char** argv)
    16.8 +main(int argc, char **argv)
    16.9  {
   16.10 -  int rv = 10;
   16.11 -  volatile int atomic;
   16.12 +    int rv = 10;
   16.13 +    volatile int atomic;
   16.14  
   16.15 -  SDL_atomic_int_set(&atomic, 10);
   16.16 -  if(SDL_atomic_int_get(&atomic) != 10)
   16.17 -    printf("Error: ");
   16.18 -  printf("SDL_atomic_int_set(atomic, 10): atomic-> %d\n",
   16.19 -         SDL_atomic_int_get(&atomic));
   16.20 -    
   16.21 -  SDL_atomic_int_add(&atomic, 10);
   16.22 -  if(SDL_atomic_int_get(&atomic) != 20)
   16.23 -    printf("Error: ");
   16.24 -  printf("SDL_atomic_int_add(atomic, 10): atomic-> %d\n",
   16.25 -         SDL_atomic_int_get(&atomic));
   16.26 -  
   16.27 -  rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30);
   16.28 -  if(rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 30)
   16.29 -    printf("Error: ");
   16.30 -  printf("SDL_atomic_int_cmp_xchg(atomic, 20, 30): rv-> %d, atomic-> %d\n",
   16.31 -         rv, SDL_atomic_int_get(&atomic));
   16.32 -  
   16.33 -  rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30);
   16.34 -  if(rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 30)
   16.35 -    printf("Error: ");
   16.36 -  printf("SDL_atomic_int_cmp_xchg(atomic, 20, 40): rv-> %d, atomic-> %d\n",
   16.37 -         rv, SDL_atomic_int_get(&atomic));
   16.38 -  
   16.39 -  rv = SDL_atomic_int_xchg_add(&atomic, 10);
   16.40 -  if(rv != 30 || SDL_atomic_int_get(&atomic) != 40)
   16.41 -    printf("Error: ");
   16.42 -  printf("SDL_atomic_int_xchg_add(atomic, 10): rv-> %d, atomic-> %d\n",
   16.43 -         rv, SDL_atomic_int_get(&atomic));
   16.44 +    SDL_atomic_int_set(&atomic, 10);
   16.45 +    if (SDL_atomic_int_get(&atomic) != 10)
   16.46 +        printf("Error: ");
   16.47 +    printf("SDL_atomic_int_set(atomic, 10): atomic-> %d\n",
   16.48 +           SDL_atomic_int_get(&atomic));
   16.49  
   16.50 -  SDL_atomic_int_inc(&atomic);
   16.51 -  if(SDL_atomic_int_get(&atomic) != 41)
   16.52 -    printf("Error: ");
   16.53 -  printf("SDL_atomic_int_inc(atomic): atomic-> %d\n",
   16.54 -         SDL_atomic_int_get(&atomic));
   16.55 +    SDL_atomic_int_add(&atomic, 10);
   16.56 +    if (SDL_atomic_int_get(&atomic) != 20)
   16.57 +        printf("Error: ");
   16.58 +    printf("SDL_atomic_int_add(atomic, 10): atomic-> %d\n",
   16.59 +           SDL_atomic_int_get(&atomic));
   16.60  
   16.61 -  rv = SDL_atomic_int_dec_test(&atomic);
   16.62 -  if(rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 40)
   16.63 -    printf("Error: ");
   16.64 -  printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n",
   16.65 -         rv, SDL_atomic_int_get(&atomic));
   16.66 -  
   16.67 -  SDL_atomic_int_set(&atomic, 1);
   16.68 -  if(SDL_atomic_int_get(&atomic) != 1)
   16.69 -    printf("Error: ");    
   16.70 +    rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30);
   16.71 +    if (rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 30)
   16.72 +        printf("Error: ");
   16.73 +    printf("SDL_atomic_int_cmp_xchg(atomic, 20, 30): rv-> %d, atomic-> %d\n",
   16.74 +           rv, SDL_atomic_int_get(&atomic));
   16.75 +
   16.76 +    rv = SDL_atomic_int_cmp_xchg(&atomic, 20, 30);
   16.77 +    if (rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 30)
   16.78 +        printf("Error: ");
   16.79 +    printf("SDL_atomic_int_cmp_xchg(atomic, 20, 40): rv-> %d, atomic-> %d\n",
   16.80 +           rv, SDL_atomic_int_get(&atomic));
   16.81 +
   16.82 +    rv = SDL_atomic_int_xchg_add(&atomic, 10);
   16.83 +    if (rv != 30 || SDL_atomic_int_get(&atomic) != 40)
   16.84 +        printf("Error: ");
   16.85 +    printf("SDL_atomic_int_xchg_add(atomic, 10): rv-> %d, atomic-> %d\n",
   16.86 +           rv, SDL_atomic_int_get(&atomic));
   16.87 +
   16.88 +    SDL_atomic_int_inc(&atomic);
   16.89 +    if (SDL_atomic_int_get(&atomic) != 41)
   16.90 +        printf("Error: ");
   16.91 +    printf("SDL_atomic_int_inc(atomic): atomic-> %d\n",
   16.92 +           SDL_atomic_int_get(&atomic));
   16.93 +
   16.94 +    rv = SDL_atomic_int_dec_test(&atomic);
   16.95 +    if (rv != SDL_FALSE || SDL_atomic_int_get(&atomic) != 40)
   16.96 +        printf("Error: ");
   16.97 +    printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n",
   16.98 +           rv, SDL_atomic_int_get(&atomic));
   16.99 +
  16.100 +    SDL_atomic_int_set(&atomic, 1);
  16.101 +    if (SDL_atomic_int_get(&atomic) != 1)
  16.102 +        printf("Error: ");
  16.103      printf("SDL_atomic_int_set(atomic, 1): atomic-> %d\n",
  16.104             SDL_atomic_int_get(&atomic));
  16.105  
  16.106 -  rv = SDL_atomic_int_dec_test(&atomic);
  16.107 -  if(rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 0)
  16.108 -    printf("Error: ");
  16.109 -  printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n",
  16.110 -         rv, SDL_atomic_int_get(&atomic));
  16.111 -  
  16.112 -  return 0;
  16.113 +    rv = SDL_atomic_int_dec_test(&atomic);
  16.114 +    if (rv != SDL_TRUE || SDL_atomic_int_get(&atomic) != 0)
  16.115 +        printf("Error: ");
  16.116 +    printf("SDL_atomic_int_dec_test(atomic): rv-> %d, atomic-> %d\n",
  16.117 +           rv, SDL_atomic_int_get(&atomic));
  16.118 +
  16.119 +    return 0;
  16.120  }
    17.1 --- a/test/testpower.c	Wed Jun 10 08:09:04 2009 +0000
    17.2 +++ b/test/testpower.c	Wed Jun 10 13:34:20 2009 +0000
    17.3 @@ -3,33 +3,33 @@
    17.4  #include <stdio.h>
    17.5  #include "SDL.h"
    17.6  
    17.7 -static void report_power(void)
    17.8 +static void
    17.9 +report_power(void)
   17.10  {
   17.11      int seconds, percent;
   17.12      const SDL_PowerState state = SDL_GetPowerInfo(&seconds, &percent);
   17.13      char *statestr = NULL;
   17.14  
   17.15      printf("SDL-reported power info...\n");
   17.16 -    switch(state)
   17.17 -    {
   17.18 -        case SDL_POWERSTATE_UNKNOWN:
   17.19 -            statestr = "Unknown";
   17.20 -            break;
   17.21 -        case SDL_POWERSTATE_ON_BATTERY:
   17.22 -            statestr = "On battery";
   17.23 -            break;
   17.24 -        case SDL_POWERSTATE_NO_BATTERY:
   17.25 -            statestr = "No battery";
   17.26 -            break;
   17.27 -        case SDL_POWERSTATE_CHARGING:
   17.28 -            statestr = "Charging";
   17.29 -            break;
   17.30 -        case SDL_POWERSTATE_CHARGED:
   17.31 -            statestr = "Charged";
   17.32 -            break;
   17.33 -        default:
   17.34 -            statestr = "!!API ERROR!!";
   17.35 -            break;
   17.36 +    switch (state) {
   17.37 +    case SDL_POWERSTATE_UNKNOWN:
   17.38 +        statestr = "Unknown";
   17.39 +        break;
   17.40 +    case SDL_POWERSTATE_ON_BATTERY:
   17.41 +        statestr = "On battery";
   17.42 +        break;
   17.43 +    case SDL_POWERSTATE_NO_BATTERY:
   17.44 +        statestr = "No battery";
   17.45 +        break;
   17.46 +    case SDL_POWERSTATE_CHARGING:
   17.47 +        statestr = "Charging";
   17.48 +        break;
   17.49 +    case SDL_POWERSTATE_CHARGED:
   17.50 +        statestr = "Charged";
   17.51 +        break;
   17.52 +    default:
   17.53 +        statestr = "!!API ERROR!!";
   17.54 +        break;
   17.55      }
   17.56  
   17.57      printf("State: %s\n", statestr);
   17.58 @@ -43,12 +43,14 @@
   17.59      if (seconds == -1) {
   17.60          printf("Time left: unknown\n");
   17.61      } else {
   17.62 -        printf("Time left: %d minutes, %d seconds\n", (int) (seconds / 60), (int) (seconds % 60));
   17.63 +        printf("Time left: %d minutes, %d seconds\n", (int) (seconds / 60),
   17.64 +               (int) (seconds % 60));
   17.65      }
   17.66  }
   17.67  
   17.68  
   17.69 -int main(int argc, char *argv[])
   17.70 +int
   17.71 +main(int argc, char *argv[])
   17.72  {
   17.73      if (SDL_Init(SDL_INIT_VIDEO) == -1) {
   17.74          fprintf(stderr, "SDL_Init() failed: %s\n", SDL_GetError());
   17.75 @@ -62,4 +64,3 @@
   17.76  }
   17.77  
   17.78  /* end of testpower.c ... */
   17.79 -
    18.1 --- a/test/testsprite2.c	Wed Jun 10 08:09:04 2009 +0000
    18.2 +++ b/test/testsprite2.c	Wed Jun 10 13:34:20 2009 +0000
    18.3 @@ -61,13 +61,15 @@
    18.4      } else {
    18.5          switch (temp->format->BitsPerPixel) {
    18.6          case 15:
    18.7 -            SDL_SetColorKey(temp, SDL_SRCCOLORKEY, (*(Uint16 *) temp->pixels) & 0x00007FFF);
    18.8 +            SDL_SetColorKey(temp, SDL_SRCCOLORKEY,
    18.9 +                            (*(Uint16 *) temp->pixels) & 0x00007FFF);
   18.10              break;
   18.11          case 16:
   18.12              SDL_SetColorKey(temp, SDL_SRCCOLORKEY, *(Uint16 *) temp->pixels);
   18.13              break;
   18.14          case 24:
   18.15 -            SDL_SetColorKey(temp, SDL_SRCCOLORKEY, (*(Uint32 *) temp->pixels) & 0x00FFFFFF);
   18.16 +            SDL_SetColorKey(temp, SDL_SRCCOLORKEY,
   18.17 +                            (*(Uint32 *) temp->pixels) & 0x00FFFFFF);
   18.18              break;
   18.19          case 32:
   18.20              SDL_SetColorKey(temp, SDL_SRCCOLORKEY, *(Uint32 *) temp->pixels);