#if defined(_X86_)
void __declspec (naked) FASTCALL
-cfs_atomic_add(
+atomic_add(
int i,
- cfs_atomic_t *v
+ atomic_t *v
)
{
// ECX = i
}
void __declspec (naked) FASTCALL
-cfs_atomic_sub(
+atomic_sub(
int i,
- cfs_atomic_t *v
+ atomic_t *v
)
{
// ECX = i
}
void __declspec (naked) FASTCALL
-cfs_atomic_inc(
- cfs_atomic_t *v
+atomic_inc(
+ atomic_t *v
)
{
//InterlockedIncrement((PULONG)(&((v)->counter)));
}
void __declspec (naked) FASTCALL
-cfs_atomic_dec(
- cfs_atomic_t *v
+atomic_dec(
+ atomic_t *v
)
{
// ECX = v ; [ECX][0] = v->counter
}
int __declspec (naked) FASTCALL
-cfs_atomic_sub_and_test(
+atomic_sub_and_test(
int i,
- cfs_atomic_t *v
+ atomic_t *v
)
{
}
int __declspec (naked) FASTCALL
-cfs_atomic_inc_and_test(
- cfs_atomic_t *v
+atomic_inc_and_test(
+ atomic_t *v
)
{
// ECX = v ; [ECX][0] = v->counter
}
int __declspec (naked) FASTCALL
-cfs_atomic_dec_and_test(
- cfs_atomic_t *v
+atomic_dec_and_test(
+ atomic_t *v
)
{
// ECX = v ; [ECX][0] = v->counter
#elif defined(_AMD64_)
void FASTCALL
-cfs_atomic_add(
+atomic_add(
int i,
- cfs_atomic_t *v
+ atomic_t *v
)
{
InterlockedExchangeAdd( (PULONG)(&((v)->counter)) , (LONG) (i));
}
void FASTCALL
-cfs_atomic_sub(
+atomic_sub(
int i,
- cfs_atomic_t *v
+ atomic_t *v
)
{
InterlockedExchangeAdd( (PULONG)(&((v)->counter)) , (LONG) (-1*i));
}
void FASTCALL
-cfs_atomic_inc(
- cfs_atomic_t *v
+atomic_inc(
+ atomic_t *v
)
{
InterlockedIncrement((PULONG)(&((v)->counter)));
}
void FASTCALL
-cfs_atomic_dec(
- cfs_atomic_t *v
+atomic_dec(
+ atomic_t *v
)
{
InterlockedDecrement((PULONG)(&((v)->counter)));
}
int FASTCALL
-cfs_atomic_sub_and_test(
+atomic_sub_and_test(
int i,
- cfs_atomic_t *v
+ atomic_t *v
)
{
int counter, result;
}
int FASTCALL
-cfs_atomic_inc_and_test(
- cfs_atomic_t *v
+atomic_inc_and_test(
+ atomic_t *v
)
{
int counter, result;
}
int FASTCALL
-cfs_atomic_dec_and_test(
- cfs_atomic_t *v
+atomic_dec_and_test(
+ atomic_t *v
)
{
int counter, result;
*
* Atomically adds \a i to \a v and returns \a i + \a v
*/
-int FASTCALL cfs_atomic_add_return(int i, cfs_atomic_t *v)
+int FASTCALL atomic_add_return(int i, atomic_t *v)
{
int counter, result;
*
* Atomically subtracts \a i from \a v and returns \a v - \a i
*/
-int FASTCALL cfs_atomic_sub_return(int i, cfs_atomic_t *v)
+int FASTCALL atomic_sub_return(int i, atomic_t *v)
{
- return cfs_atomic_add_return(-i, v);
+ return atomic_add_return(-i, v);
}
-int FASTCALL cfs_atomic_dec_and_lock(cfs_atomic_t *v, spinlock_t *lock)
+int FASTCALL atomic_dec_and_lock(atomic_t *v, spinlock_t *lock)
{
- if (cfs_atomic_read(v) != 1)
+ if (atomic_read(v) != 1)
return 0;
spin_lock(lock);
- if (cfs_atomic_dec_and_test(v))
+ if (atomic_dec_and_test(v))
return 1;
spin_unlock(lock);
return 0;