source: gpfs_3.1_ker2.6.20/lpp/mmfs/src/ibm-kxi/cxiAtomic.h @ 195

Last change on this file since 195 was 16, checked in by rock, 17 years ago
File size: 4.3 KB
Line 
1/***************************************************************************
2 *
3 * Copyright (C) 2001 International Business Machines
4 * All rights reserved.
5 *
6 * This file is part of the GPFS mmfslinux kernel module.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 *  1. Redistributions of source code must retain the above copyright notice,
13 *     this list of conditions and the following disclaimer.
14 *  2. Redistributions in binary form must reproduce the above copyright
15 *     notice, this list of conditions and the following disclaimer in the
16 *     documentation and/or other materials provided with the distribution.
17 *  3. The name of the author may not be used to endorse or promote products
18 *     derived from this software without specific prior written
19 *     permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 *************************************************************************** */
33/* @(#)97 1.6  src/avs/fs/mmfs/ts/kernext/ibm-kxi/cxiAtomic.h, mmfs, avs_rgpfs24, rgpfs240610b 7/28/05 22:51:53 */
34
35/*
36 * Support for platform independant SMP synchronization operations
37 *
38 */
39
40#ifndef _h_cxiAtomic
41#define _h_cxiAtomic
42
43/* Include platform specific interfaces */
44#include <cxiAtomic-plat.h>
45
46/* Platform independant interface */
47
48/* 32-bit invariant atomic operations */
49#define ATOMIC_ADD(_v,_i) fetch_and_add((atomic_p)(_v), (int)(_i))
50#define ATOMIC_AND(_v,_i) fetch_and_and((atomic_p)(_v), (uint)(_i))
51#define ATOMIC_OR(_v,_i) fetch_and_or((atomic_p)(_v), (uint)(_i))
52#define ATOMIC_SWAP(_v, _p, _i) compare_and_swap((atomic_p)(_v), (int *)(_p), (int)(_i))
53#ifdef _KERNEL
54#define ATOMIC_SET(_v,_i) test_and_set((atomic_p)(_v), (int)(_i))
55#endif /* _KERNEL */
56
57/* 32-bit invariant macros with "no addresses" required for args */
58#define ATOMIC_ADD_NA(_v, _i) fetch_and_add((atomic_p)&(_v), (int)(_i))
59
60/* Variable size atomic operations (32/64-bit) */
61/* These should be used with longs and pointers, ie, the natural word width */
62#ifdef __64BIT__
63#define ATOMIC_ADDLP(_v,_i) fetch_and_addlp((atomic_l)(_v), (long)(_i))
64#define ATOMIC_ANDLP(_v,_i) fetch_and_andlp((atomic_l)(_v), (ulong)(_i))
65#define ATOMIC_ORLP(_v,_i) fetch_and_orlp((atomic_l)(_v), (ulong)(_i))
66#define ATOMIC_SWAPLP(_v, _p, _i) compare_and_swaplp((atomic_l)(_v), (long *)(_p), (long)(_i))
67#ifdef _KERNEL
68#define ATOMIC_SETLP(_v,_i) test_and_setlp((atomic_l)(_v), (long)(_i))
69#endif /* _KERNEL */
70#else /* _ILP32 */
71#define ATOMIC_ADDLP(_v,_i) ATOMIC_ADD(_v, _i)
72#define ATOMIC_ANDLP(_v,_i) ATOMIC_AND(_v, _i)
73#define ATOMIC_ORLP(_v,_i) ATOMIC_OR(_v, _i)
74#define ATOMIC_SWAPLP(_v, _p, _i) ATOMIC_SWAP(_v, _p, _i)
75#ifdef _KERNEL
76#define ATOMIC_SETLP(_v,_i) ATOMIC_SET(_v, _i)
77#endif
78#endif /* __64BIT__ */
79
80/* 64-bit invariant atomic operations */
81#ifdef __64BIT__
82#define ATOMIC_ADD64(_v,_i) ATOMIC_ADDLP(_v, _i)
83#define ATOMIC_AND64(_v,_i) ATOMIC_ANDLP(_v,_i)
84#define ATOMIC_OR64(_v,_i) ATOMIC_ORLP(_v,_i)
85#define ATOMIC_SWAP64(_v, _p, _i) ATOMIC_SWAPLP(_v, _p, _i)
86#ifdef _KERNEL
87#define ATOMIC_SET64(_v,_i) ATOMIC_SETLP(_v, _i)
88#endif /* _KERNEL */
89#endif /* __64BIT__ */
90
91/* Mutex lockword operations */
92#ifdef __64BIT__
93#define GPFS_CHECK_LOCK(_v, _i1, _i2) _check_locklp((atomic_l)(_v), (long)(_i1), (long)(_i2))
94#define LOCKWORD_SWAP  ATOMIC_SWAP64
95#define LOCKWORD_OR    ATOMIC_OR64
96#define LOCKWORD_AND   ATOMIC_AND64
97#else
98#define GPFS_CHECK_LOCK(_v, _i1, _i2) _check_lock((atomic_p)(_v), (int)(_i1), (int)(_i2))
99#define LOCKWORD_SWAP  ATOMIC_SWAP
100#define LOCKWORD_OR    ATOMIC_OR
101#define LOCKWORD_AND   ATOMIC_AND
102#endif /* 64b */
103
104#endif /* _h_cxiAtomic */
Note: See TracBrowser for help on using the repository browser.