Changeset 67a56d37474d1336d5e7e07d07f5b1241c66654c

Show
Ignore:
Timestamp:
03/06/08 16:55:06 (7 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1204822506 +0000
git-parent:

[273d4cce9641aea3d517d9617002bd89b432f256]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1204822506 +0000
Message:

more nukes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/utils/noit_atomic.h

    r3b3b432 r67a56d3  
    2121#define noit_atomic_cas32(ref,new,old) (OSAtomicCompareAndSwap32(old,new,ref) ? old : new) 
    2222#define noit_atomic_cas64(ref,new,old) (OSAtomicCompareAndSwap64(old,new,ref) ? old : new) 
     23#define noit_atomic_add32(ref,diff) OSAtomicAdd32(ref,diff) 
     24#define noit_atomic_add64(ref,diff) OSAtomicAdd64(ref,diff) 
     25#define noit_atomic_sub32(ref,diff) OSAtomicAdd32(ref,0-(diff)) 
     26#define noit_atomic_sub64(ref,diff) OSAtomicAdd64(ref,0-(diff)) 
    2327#define noit_atomic_inc32(ref) OSAtomicIncrement32(ref) 
    2428#define noit_atomic_inc64(ref) OSAtomicIncrement64(ref) 
     
    9296  while(noit_atomic_cas32(lock, 0, 1) != 1); 
    9397} 
    94 static inline noit_spinlock_trylock(volatile noit_spinlock_t *lock) { 
     98static inline int noit_spinlock_trylock(volatile noit_spinlock_t *lock) { 
    9599  return (noit_atomic_cas32(lock, 1, 0) == 0); 
    96100} 
     
    100104#endif 
    101105 
     106#ifndef noit_atomic_add32 
     107static inline void noit_atomic_add32(volatile noit_atomic32_t *loc, 
     108                                     volatile noit_atomic32_t diff) { 
     109  register noit_atomic32_t current; 
     110  do { 
     111    current = *(loc); 
     112  } while(noit_atomic_cas32(loc, current + diff, current) != current); 
     113} 
    102114#endif 
     115 
     116#ifndef noit_atomic_add64 
     117static inline void noit_atomic_add64(volatile noit_atomic64_t *loc, 
     118                                     volatile noit_atomic64_t diff) { 
     119  register noit_atomic64_t current; 
     120  do { 
     121    current = *(loc); 
     122  } while(noit_atomic_cas64(loc, current + diff, current) != current); 
     123} 
     124#endif 
     125 
     126#ifndef noit_atomic_sub32 
     127static inline void noit_atomic_sub32(volatile noit_atomic32_t *loc, 
     128                                     volatile noit_atomic32_t diff) { 
     129  register noit_atomic32_t current; 
     130  do { 
     131    current = *(loc); 
     132  } while(noit_atomic_cas32(loc, current - diff, current) != current); 
     133} 
     134#endif 
     135 
     136#ifndef noit_atomic_sub64 
     137static inline void noit_atomic_sub64(volatile noit_atomic64_t *loc, 
     138                                     volatile noit_atomic64_t diff) { 
     139  register noit_atomic64_t current; 
     140  do { 
     141    current = *(loc); 
     142  } while(noit_atomic_cas64(loc, current - diff, current) != current); 
     143} 
     144#endif 
     145 
     146#ifndef noit_atomic_inc32 
     147#define noit_atomic_inc32(a) noit_atomic_add32(a, 1) 
     148#endif 
     149 
     150#ifndef noit_atomic_inc64 
     151#define noit_atomic_inc64(a) noit_atomic_add64(a, 1) 
     152#endif 
     153 
     154#ifndef noit_atomic_dec32 
     155#define noit_atomic_dec32(a) noit_atomic_add32(a, -1) 
     156#endif 
     157 
     158#ifndef noit_atomic_dec64 
     159#define noit_atomic_dec64(a) noit_atomic_add64(a, -1) 
     160#endif 
     161 
     162#endif