1219820Sjeff/* 2219820Sjeff * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved. 3219820Sjeff * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved. 4219820Sjeff * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. 5219820Sjeff * 6219820Sjeff * This software is available to you under a choice of one of two 7219820Sjeff * licenses. You may choose to be licensed under the terms of the GNU 8219820Sjeff * General Public License (GPL) Version 2, available from the file 9219820Sjeff * COPYING in the main directory of this source tree, or the 10219820Sjeff * OpenIB.org BSD license below: 11219820Sjeff * 12219820Sjeff * Redistribution and use in source and binary forms, with or 13219820Sjeff * without modification, are permitted provided that the following 14219820Sjeff * conditions are met: 15219820Sjeff * 16219820Sjeff * - Redistributions of source code must retain the above 17219820Sjeff * copyright notice, this list of conditions and the following 18219820Sjeff * disclaimer. 19219820Sjeff * 20219820Sjeff * - Redistributions in binary form must reproduce the above 21219820Sjeff * copyright notice, this list of conditions and the following 22219820Sjeff * disclaimer in the documentation and/or other materials 23219820Sjeff * provided with the distribution. 24219820Sjeff * 25219820Sjeff * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26219820Sjeff * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27219820Sjeff * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28219820Sjeff * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29219820Sjeff * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30219820Sjeff * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31219820Sjeff * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32219820Sjeff * SOFTWARE. 33219820Sjeff * 34219820Sjeff */ 35219820Sjeff 36219820Sjeff/* 37219820Sjeff * Abstract: 38219820Sjeff * Declaration of atomic manipulation functions. 39219820Sjeff */ 40219820Sjeff 41219820Sjeff#ifndef _CL_ATOMIC_H_ 42219820Sjeff#define _CL_ATOMIC_H_ 43219820Sjeff 44219820Sjeff#include <complib/cl_atomic_osd.h> 45219820Sjeff 46219820Sjeff#ifdef __cplusplus 47219820Sjeff# define BEGIN_C_DECLS extern "C" { 48219820Sjeff# define END_C_DECLS } 49219820Sjeff#else /* !__cplusplus */ 50219820Sjeff# define BEGIN_C_DECLS 51219820Sjeff# define END_C_DECLS 52219820Sjeff#endif /* __cplusplus */ 53219820Sjeff 54219820SjeffBEGIN_C_DECLS 55219820Sjeff/****h* Component Library/Atomic Operations 56219820Sjeff* NAME 57219820Sjeff* Atomic Operations 58219820Sjeff* 59219820Sjeff* DESCRIPTION 60219820Sjeff* The Atomic Operations functions allow callers to operate on 61219820Sjeff* 32-bit signed integers in an atomic fashion. 62219820Sjeff*********/ 63219820Sjeff/****f* Component Library: Atomic Operations/cl_atomic_inc 64219820Sjeff* NAME 65219820Sjeff* cl_atomic_inc 66219820Sjeff* 67219820Sjeff* DESCRIPTION 68219820Sjeff* The cl_atomic_inc function atomically increments a 32-bit signed 69219820Sjeff* integer and returns the incremented value. 70219820Sjeff* 71219820Sjeff* SYNOPSIS 72219820Sjeff*/ 73219820Sjeffint32_t cl_atomic_inc(IN atomic32_t * const p_value); 74219820Sjeff/* 75219820Sjeff* PARAMETERS 76219820Sjeff* p_value 77219820Sjeff* [in] Pointer to a 32-bit integer to increment. 78219820Sjeff* 79219820Sjeff* RETURN VALUE 80219820Sjeff* Returns the incremented value pointed to by p_value. 81219820Sjeff* 82219820Sjeff* NOTES 83219820Sjeff* The provided value is incremented and its value returned in one atomic 84219820Sjeff* operation. 85219820Sjeff* 86219820Sjeff* cl_atomic_inc maintains data consistency without requiring additional 87219820Sjeff* synchronization mechanisms in multi-threaded environments. 88219820Sjeff* 89219820Sjeff* SEE ALSO 90219820Sjeff* Atomic Operations, cl_atomic_dec, cl_atomic_add, cl_atomic_sub, 91219820Sjeff* cl_atomic_xchg, cl_atomic_comp_xchg 92219820Sjeff*********/ 93219820Sjeff 94219820Sjeff/****f* Component Library: Atomic Operations/cl_atomic_dec 95219820Sjeff* NAME 96219820Sjeff* cl_atomic_dec 97219820Sjeff* 98219820Sjeff* DESCRIPTION 99219820Sjeff* The cl_atomic_dec function atomically decrements a 32-bit signed 100219820Sjeff* integer and returns the decremented value. 101219820Sjeff* 102219820Sjeff* SYNOPSIS 103219820Sjeff*/ 104219820Sjeffint32_t cl_atomic_dec(IN atomic32_t * const p_value); 105219820Sjeff/* 106219820Sjeff* PARAMETERS 107219820Sjeff* p_value 108219820Sjeff* [in] Pointer to a 32-bit integer to decrement. 109219820Sjeff* 110219820Sjeff* RETURN VALUE 111219820Sjeff* Returns the decremented value pointed to by p_value. 112219820Sjeff* 113219820Sjeff* NOTES 114219820Sjeff* The provided value is decremented and its value returned in one atomic 115219820Sjeff* operation. 116219820Sjeff* 117219820Sjeff* cl_atomic_dec maintains data consistency without requiring additional 118219820Sjeff* synchronization mechanisms in multi-threaded environments. 119219820Sjeff* 120219820Sjeff* SEE ALSO 121219820Sjeff* Atomic Operations, cl_atomic_inc, cl_atomic_add, cl_atomic_sub, 122219820Sjeff* cl_atomic_xchg, cl_atomic_comp_xchg 123219820Sjeff*********/ 124219820Sjeff 125219820Sjeff/****f* Component Library: Atomic Operations/cl_atomic_add 126219820Sjeff* NAME 127219820Sjeff* cl_atomic_add 128219820Sjeff* 129219820Sjeff* DESCRIPTION 130219820Sjeff* The cl_atomic_add function atomically adds a value to a 131219820Sjeff* 32-bit signed integer and returns the resulting value. 132219820Sjeff* 133219820Sjeff* SYNOPSIS 134219820Sjeff*/ 135219820Sjeffint32_t 136219820Sjeffcl_atomic_add(IN atomic32_t * const p_value, IN const int32_t increment); 137219820Sjeff/* 138219820Sjeff* PARAMETERS 139219820Sjeff* p_value 140219820Sjeff* [in] Pointer to a 32-bit integer that will be added to. 141219820Sjeff* 142219820Sjeff* increment 143219820Sjeff* [in] Value by which to increment the integer pointed to by p_value. 144219820Sjeff* 145219820Sjeff* RETURN VALUE 146219820Sjeff* Returns the value pointed to by p_value after the addition. 147219820Sjeff* 148219820Sjeff* NOTES 149219820Sjeff* The provided increment is added to the value and the result returned in 150219820Sjeff* one atomic operation. 151219820Sjeff* 152219820Sjeff* cl_atomic_add maintains data consistency without requiring additional 153219820Sjeff* synchronization mechanisms in multi-threaded environments. 154219820Sjeff* 155219820Sjeff* SEE ALSO 156219820Sjeff* Atomic Operations, cl_atomic_inc, cl_atomic_dec, cl_atomic_sub, 157219820Sjeff* cl_atomic_xchg, cl_atomic_comp_xchg 158219820Sjeff*********/ 159219820Sjeff 160219820Sjeff/****f* Component Library: Atomic Operations/cl_atomic_sub 161219820Sjeff* NAME 162219820Sjeff* cl_atomic_sub 163219820Sjeff* 164219820Sjeff* DESCRIPTION 165219820Sjeff* The cl_atomic_sub function atomically subtracts a value from a 166219820Sjeff* 32-bit signed integer and returns the resulting value. 167219820Sjeff* 168219820Sjeff* SYNOPSIS 169219820Sjeff*/ 170219820Sjeffint32_t 171219820Sjeffcl_atomic_sub(IN atomic32_t * const p_value, IN const int32_t decrement); 172219820Sjeff/* 173219820Sjeff* PARAMETERS 174219820Sjeff* p_value 175219820Sjeff* [in] Pointer to a 32-bit integer that will be subtracted from. 176219820Sjeff* 177219820Sjeff* decrement 178219820Sjeff* [in] Value by which to decrement the integer pointed to by p_value. 179219820Sjeff* 180219820Sjeff* RETURN VALUE 181219820Sjeff* Returns the value pointed to by p_value after the subtraction. 182219820Sjeff* 183219820Sjeff* NOTES 184219820Sjeff* The provided decrement is subtracted from the value and the result 185219820Sjeff* returned in one atomic operation. 186219820Sjeff* 187219820Sjeff* cl_atomic_sub maintains data consistency without requiring additional 188219820Sjeff* synchronization mechanisms in multi-threaded environments. 189219820Sjeff* 190219820Sjeff* SEE ALSO 191219820Sjeff* Atomic Operations, cl_atomic_inc, cl_atomic_dec, cl_atomic_add, 192219820Sjeff* cl_atomic_xchg, cl_atomic_comp_xchg 193219820Sjeff*********/ 194219820Sjeff 195219820SjeffEND_C_DECLS 196219820Sjeff#endif /* _CL_ATOMIC_H_ */ 197