Skip to content

Commit

Permalink
Restore atomic voidp routines
Browse files Browse the repository at this point in the history
Signed-off-by: Quincey Koziol <[email protected]>
  • Loading branch information
qkoziol committed Jul 18, 2024
1 parent b3b1584 commit ce70682
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/H5TSatomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,57 @@ H5TS_atomic_destroy_uint(H5TS_atomic_uint_t *obj)
FUNC_LEAVE_NOAPI_VOID_NAMECHECK_ONLY
} /* end H5TS_atomic_destroy_uint() */

/*--------------------------------------------------------------------------
* Function: H5TS_atomic_init_voidp
*
* Purpose: Initializes an atomic 'void *' variable object with a value.
*
* Note: Per the C11 standard, this function is not atomic and
* concurrent execution from multiple threads is a data race.
*
* Return: None
*
*--------------------------------------------------------------------------
*/
void
H5TS_atomic_init_voidp(H5TS_atomic_voidp_t *obj, void *desired)
{
FUNC_ENTER_NOAPI_NAMECHECK_ONLY

/* Initialize mutex that protects the "atomic" value */
(void)
H5TS_mutex_init(&obj->mutex, H5TS_MUTEX_TYPE_PLAIN);

/* Set the value */
obj->value = desired;

FUNC_LEAVE_NOAPI_VOID_NAMECHECK_ONLY
} /* end H5TS_atomic_init_voidp() */

/*--------------------------------------------------------------------------
* Function: H5TS_atomic_destroy_voidp
*
* Purpose: Destroys / releases resources for an atomic 'void *' variable
*
* Note: No equivalent in the C11 atomics, but needed here, to destroy
* the mutex used to protect the atomic value.
*
* Return: None
*
*--------------------------------------------------------------------------
*/
void
H5TS_atomic_destroy_voidp(H5TS_atomic_voidp_t *obj)
{
FUNC_ENTER_NOAPI_NAMECHECK_ONLY

/* Destroy mutex that protects the "atomic" value */
(void)
H5TS_mutex_destroy(&obj->mutex);

FUNC_LEAVE_NOAPI_VOID_NAMECHECK_ONLY
} /* end H5TS_atomic_destroy_voidp() */

#endif /* H5_HAVE_STDATOMIC_H */

#endif /* H5_HAVE_THREADS */

0 comments on commit ce70682

Please sign in to comment.