mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-05 22:50:50 +02:00
wolfssl/wolfcrypt/wc_port.h and wolfcrypt/src/wc_port.c: implement wolfSSL_Atomic_Int_Exchange().
This commit is contained in:
@@ -1432,6 +1432,11 @@ unsigned int wolfSSL_Atomic_Uint_SubFetch(wolfSSL_Atomic_Uint* c,
|
||||
return val - i;
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_Exchange(wolfSSL_Atomic_Int* c, int new_i)
|
||||
{
|
||||
return atomic_swap_int(c, new_i);
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_CompareExchange(wolfSSL_Atomic_Int* c, int *expected_i,
|
||||
int new_i)
|
||||
{
|
||||
@@ -1495,6 +1500,11 @@ int wolfSSL_Atomic_Int_SubFetch(wolfSSL_Atomic_Int* c, int i)
|
||||
return ret - i;
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_Exchange(wolfSSL_Atomic_Int* c, int new_i)
|
||||
{
|
||||
return atomic_exchange_explicit(c, new_i, memory_order_seq_cst);
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_CompareExchange(
|
||||
wolfSSL_Atomic_Int* c, int *expected_i, int new_i)
|
||||
{
|
||||
@@ -1600,6 +1610,11 @@ int wolfSSL_Atomic_Int_SubFetch(wolfSSL_Atomic_Int* c, int i)
|
||||
return __atomic_sub_fetch(c, i, __ATOMIC_RELAXED);
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_Exchange(wolfSSL_Atomic_Int* c, int new_i)
|
||||
{
|
||||
return __atomic_exchange_n(c, new_i, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_CompareExchange(wolfSSL_Atomic_Int* c, int *expected_i,
|
||||
int new_i)
|
||||
{
|
||||
@@ -1692,6 +1707,12 @@ int wolfSSL_Atomic_Int_SubFetch(wolfSSL_Atomic_Int* c, int i)
|
||||
return ret - i;
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_Exchange(wolfSSL_Atomic_Int* c, int new_i)
|
||||
{
|
||||
long actual_i = InterlockedExchange(c, (long)new_i);
|
||||
return (int)actual_i;
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Int_CompareExchange(wolfSSL_Atomic_Int* c, int *expected_i,
|
||||
int new_i)
|
||||
{
|
||||
|
||||
@@ -613,6 +613,8 @@
|
||||
WOLFSSL_API int wolfSSL_Atomic_Int_FetchSub(wolfSSL_Atomic_Int* c, int i);
|
||||
WOLFSSL_API int wolfSSL_Atomic_Int_AddFetch(wolfSSL_Atomic_Int* c, int i);
|
||||
WOLFSSL_API int wolfSSL_Atomic_Int_SubFetch(wolfSSL_Atomic_Int* c, int i);
|
||||
WOLFSSL_API int wolfSSL_Atomic_Int_Exchange(
|
||||
wolfSSL_Atomic_Int* c, int new_i);
|
||||
WOLFSSL_API int wolfSSL_Atomic_Int_CompareExchange(
|
||||
wolfSSL_Atomic_Int* c, int *expected_i, int new_i);
|
||||
WOLFSSL_API unsigned int wolfSSL_Atomic_Uint_FetchAdd(
|
||||
@@ -652,6 +654,13 @@
|
||||
static WC_INLINE int wolfSSL_Atomic_Int_SubFetch(int *c, int i) {
|
||||
return (*c -= i);
|
||||
}
|
||||
static WC_INLINE int wolfSSL_Atomic_Int_Exchange(
|
||||
int *c, int new_i)
|
||||
{
|
||||
int ret = *c;
|
||||
*c = new_i;
|
||||
return ret;
|
||||
}
|
||||
static WC_INLINE int wolfSSL_Atomic_Int_CompareExchange(
|
||||
int *c, int *expected_i, int new_i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user