2002-07-09 16:24:59 +04:00
|
|
|
#ifndef _KERNEL_ATOMIC_H
|
|
|
|
#define _KERNEL_ATOMIC_H
|
|
|
|
|
2002-09-03 06:19:22 +04:00
|
|
|
#include <ktypes.h>
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
/**
|
|
|
|
* @file kernel/atomic.h
|
|
|
|
* @brief Prototypes for kernel and user versions of atomic
|
|
|
|
* functions.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @defgroup Kernel_Atomic Atomic Operations
|
|
|
|
* @ingroup OpenBeOS_Kernel
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2002-09-03 06:19:22 +04:00
|
|
|
/* atomic_add(), atomic_and(), atomic_or() must
|
|
|
|
* match the definitions in SupportDefs.h
|
2002-07-09 16:24:59 +04:00
|
|
|
*/
|
2002-09-03 06:19:22 +04:00
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
/**
|
|
|
|
* Perform an atomic addition.
|
|
|
|
* @param val Pointer to an integer
|
|
|
|
* @param incr The increment to add (may be -ve)
|
|
|
|
* @note Returns value of val before addition
|
|
|
|
*/
|
2002-09-03 06:19:22 +04:00
|
|
|
int32 atomic_add(vint32 *val, int32 incr);
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
/**
|
|
|
|
* Atomic and operation
|
|
|
|
* @param val Pointer to an integer
|
|
|
|
* @param incr The increment to add (may be -ve)
|
|
|
|
* @note Returns value of val before addition
|
|
|
|
*/
|
2002-09-03 06:19:22 +04:00
|
|
|
int32 atomic_and(vint32 *val, int32 incr);
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
/**
|
|
|
|
* Atomic or operation
|
|
|
|
* @param val Pointer to an integer
|
|
|
|
* @param incr The increment to add (may be -ve)
|
|
|
|
* @note Returns value of val before addition
|
|
|
|
*/
|
2002-09-03 06:19:22 +04:00
|
|
|
int32 atomic_or(vint32 *val, int32 incr);
|
|
|
|
|
|
|
|
int32 atomic_set(vint32 *val, int32 set_to);
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
/* Compare the value of val with test_val. If they
|
|
|
|
* are equal then set the value of 'val' to
|
|
|
|
* 'set_to'
|
|
|
|
*/
|
2002-09-03 06:19:22 +04:00
|
|
|
int32 test_and_set(vint32 *val, int32 set_to, int32 test_val);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Atomic add (user version)
|
|
|
|
* @param val Pointer to an integer
|
|
|
|
* @param incr The increment to add (may be -ve)
|
|
|
|
* @note Returns value of val before addition
|
|
|
|
*/
|
2002-09-03 06:19:22 +04:00
|
|
|
int32 user_atomic_add(vint32 *val, int32 incr);
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
/**
|
|
|
|
* Atomic and (user version)
|
|
|
|
* @param val Pointer to an integer
|
|
|
|
* @param incr The increment to add (may be -ve)
|
|
|
|
* @note Returns value of val before addition
|
|
|
|
*/
|
2002-09-03 06:19:22 +04:00
|
|
|
int32 user_atomic_and(vint32 *val, int32 incr);
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
/**
|
|
|
|
* Atomic or (user version)
|
|
|
|
* @param val Pointer to an integer
|
|
|
|
* @param incr The increment to add (may be -ve)
|
|
|
|
* @note Returns value of val before addition
|
|
|
|
*/
|
2002-09-03 06:19:22 +04:00
|
|
|
int32 user_atomic_or(vint32 *val, int32 incr);
|
|
|
|
|
|
|
|
int32 user_atomic_set(vint32 *val, int32 set_to);
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
/* Compare the value of val with test_val. If they
|
|
|
|
* are equal then set the value of 'val' to
|
|
|
|
* 'set_to'
|
|
|
|
* @note This is the user version and should not be used within
|
|
|
|
* the kernel.
|
|
|
|
*/
|
2002-09-03 06:19:22 +04:00
|
|
|
int32 user_test_and_set(vint32 *val, int32 set_to, int32 test_val);
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
#endif /* _KERNEL_ATOMIC_H */
|