2 * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
3 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38 * Declaration of atomic manipulation functions.
44 #include <complib/cl_atomic_osd.h>
47 # define BEGIN_C_DECLS extern "C" {
48 # define END_C_DECLS }
49 #else /* !__cplusplus */
50 # define BEGIN_C_DECLS
52 #endif /* __cplusplus */
55 /****h* Component Library/Atomic Operations
60 * The Atomic Operations functions allow callers to operate on
61 * 32-bit signed integers in an atomic fashion.
63 /****f* Component Library: Atomic Operations/cl_atomic_inc
68 * The cl_atomic_inc function atomically increments a 32-bit signed
69 * integer and returns the incremented value.
73 int32_t cl_atomic_inc(IN atomic32_t * const p_value);
77 * [in] Pointer to a 32-bit integer to increment.
80 * Returns the incremented value pointed to by p_value.
83 * The provided value is incremented and its value returned in one atomic
86 * cl_atomic_inc maintains data consistency without requiring additional
87 * synchronization mechanisms in multi-threaded environments.
90 * Atomic Operations, cl_atomic_dec, cl_atomic_add, cl_atomic_sub,
91 * cl_atomic_xchg, cl_atomic_comp_xchg
94 /****f* Component Library: Atomic Operations/cl_atomic_dec
99 * The cl_atomic_dec function atomically decrements a 32-bit signed
100 * integer and returns the decremented value.
104 int32_t cl_atomic_dec(IN atomic32_t * const p_value);
108 * [in] Pointer to a 32-bit integer to decrement.
111 * Returns the decremented value pointed to by p_value.
114 * The provided value is decremented and its value returned in one atomic
117 * cl_atomic_dec maintains data consistency without requiring additional
118 * synchronization mechanisms in multi-threaded environments.
121 * Atomic Operations, cl_atomic_inc, cl_atomic_add, cl_atomic_sub,
122 * cl_atomic_xchg, cl_atomic_comp_xchg
125 /****f* Component Library: Atomic Operations/cl_atomic_add
130 * The cl_atomic_add function atomically adds a value to a
131 * 32-bit signed integer and returns the resulting value.
136 cl_atomic_add(IN atomic32_t * const p_value, IN const int32_t increment);
140 * [in] Pointer to a 32-bit integer that will be added to.
143 * [in] Value by which to increment the integer pointed to by p_value.
146 * Returns the value pointed to by p_value after the addition.
149 * The provided increment is added to the value and the result returned in
150 * one atomic operation.
152 * cl_atomic_add maintains data consistency without requiring additional
153 * synchronization mechanisms in multi-threaded environments.
156 * Atomic Operations, cl_atomic_inc, cl_atomic_dec, cl_atomic_sub,
157 * cl_atomic_xchg, cl_atomic_comp_xchg
160 /****f* Component Library: Atomic Operations/cl_atomic_sub
165 * The cl_atomic_sub function atomically subtracts a value from a
166 * 32-bit signed integer and returns the resulting value.
171 cl_atomic_sub(IN atomic32_t * const p_value, IN const int32_t decrement);
175 * [in] Pointer to a 32-bit integer that will be subtracted from.
178 * [in] Value by which to decrement the integer pointed to by p_value.
181 * Returns the value pointed to by p_value after the subtraction.
184 * The provided decrement is subtracted from the value and the result
185 * returned in one atomic operation.
187 * cl_atomic_sub maintains data consistency without requiring additional
188 * synchronization mechanisms in multi-threaded environments.
191 * Atomic Operations, cl_atomic_inc, cl_atomic_dec, cl_atomic_add,
192 * cl_atomic_xchg, cl_atomic_comp_xchg
196 #endif /* _CL_ATOMIC_H_ */