mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-01-26 22:12:20 +01:00
bsdkm: add atomic_fcmpset_ptr.
This commit is contained in:
@@ -1352,12 +1352,20 @@ int wolfSSL_Atomic_Int_CompareExchange(wolfSSL_Atomic_Int* c, int *expected_i,
|
||||
int wolfSSL_Atomic_Uint_CompareExchange(
|
||||
wolfSSL_Atomic_Uint* c, unsigned int *expected_i, unsigned int new_i)
|
||||
{
|
||||
u_int exp = (u_int) *expected_i;
|
||||
u_int exp = (u_int)*expected_i;
|
||||
int ret = atomic_fcmpset_int(c, &exp, new_i);
|
||||
*expected_i = (unsigned int)exp;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int wolfSSL_Atomic_Ptr_CompareExchange(
|
||||
void **c, void **expected_ptr, void *new_ptr)
|
||||
{
|
||||
uintptr_t exp = (uintptr_t)*expected_ptr;
|
||||
int ret = atomic_fcmpset_ptr((uintptr_t *)c, &exp, (uintptr_t)new_ptr);
|
||||
*expected_ptr = (void *)exp;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_C___ATOMIC) && defined(WOLFSSL_HAVE_ATOMIC_H) && \
|
||||
!defined(__cplusplus)
|
||||
|
||||
@@ -20061,6 +20061,8 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t memory_test(void)
|
||||
#endif
|
||||
int int_expected;
|
||||
unsigned int uint_expected;
|
||||
void * a_ptr = NULL;
|
||||
void * ptr_expected = NULL;
|
||||
|
||||
if (WOLFSSL_ATOMIC_LOAD(a_int) != -2)
|
||||
return WC_TEST_RET_ENC_NC;
|
||||
@@ -20131,6 +20133,13 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t memory_test(void)
|
||||
return WC_TEST_RET_ENC_NC;
|
||||
if (WOLFSSL_ATOMIC_LOAD(a_uint) != 7)
|
||||
return WC_TEST_RET_ENC_NC;
|
||||
|
||||
a_ptr = NULL;
|
||||
ptr_expected = NULL;
|
||||
if (! wolfSSL_Atomic_Ptr_CompareExchange(&a_ptr, &ptr_expected, &ret))
|
||||
return WC_TEST_RET_ENC_NC;
|
||||
if (a_ptr != &ret)
|
||||
return WC_TEST_RET_ENC_NC;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user